Concrete Python  git-339c971
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions
Execution Class Reference

#include <concrete/execution.hpp>

+ Inheritance diagram for Execution:
+ Collaboration diagram for Execution:

List of all members.

Classes

struct  Data

Public Member Functions

 Execution (const Execution &other) throw ()
 Execution () throw ()
void destroy () throw ()
bool execute ()
ExecutionFrame new_frame (const CodeObject &code, const DictObject &dict)
template<typename Visitor >
void visit (Visitor &v) const

Static Public Member Functions

static Execution New (const CodeObject &code)
static Execution New (const CodeObject &code, const DictObject &dict)
static Execution NewCall (const TupleObject &args)

Protected Member Functions

 Execution (unsigned int address) throw ()
ExecutionFrame frame () const
CodeObject code () const
DictObject dict () const
void initiate_call (const Object &callable, bool not_filter=false)
void initiate_call (const Object &callable, const TupleObject &args, bool not_filter=false)
void initiate_call (const Object &callable, const TupleObject &args, const DictObject &kwargs, bool not_filter=false)
bool resume_call ()
void push (const Object &object)
Object peek () const
Object pop ()
void execute_op ()

Static Protected Member Functions

static bool Nonzero (Object object)

Private Member Functions

Datadata () const

Detailed Description

Executor for a function call stack. Implements a Python bytecode interpreter.


Constructor & Destructor Documentation

Execution ( unsigned int  address) throw () [explicit, protected]

Cast an Arena offset into a typed pointer.

Execution ( const Execution other) throw ()

Another reference.

Execution ( ) throw ()

Type-specific null pointer.


Member Function Documentation

CodeObject code ( ) const [protected]

Current function's code.

Execution::Data * data ( ) const [private]

Direct short-term access to Arena memory. Valid until the next memory allocation.

Reimplemented from ListNode< Execution >.

void destroy ( ) throw ()

Delete Data and nullify the pointer.

DictObject dict ( ) const [protected]

Current local variables.

bool execute ( )

Execute an instruction or resume a continuation.

Returns:
false if the executor finished
void execute_op ( ) [protected]

Execute the next bytecode instruction.

ExecutionFrame frame ( ) const [protected]

Current frame.

void initiate_call ( const Object callable,
bool  not_filter = false 
) [protected]

Start a Continuation.

Parameters:
callable
not_filtercauses the not-operator to be applied to the call's result before it's pushed on the stack
void initiate_call ( const Object callable,
const TupleObject args,
bool  not_filter = false 
) [protected]

Start a Continuation.

Parameters:
callable
args
not_filtercauses the not-operator to be applied to the call's result before it's pushed on the stack
void initiate_call ( const Object callable,
const TupleObject args,
const DictObject kwargs,
bool  not_filter = false 
) [protected]

Start a Continuation.

Parameters:
callable
args
kwargs
not_filtercauses the not-operator to be applied to the call's result before it's pushed on the stack
Execution New ( const CodeObject code) [static]

Create an executor for a Python module.

Returns:
new reference owned by the caller
Execution New ( const CodeObject code,
const DictObject dict 
) [static]

Create an executor for a Python function.

Returns:
new reference owned by the caller
ExecutionFrame new_frame ( const CodeObject code,
const DictObject dict 
)

Set up a nested function call. Execution keeps a reference to the new frame until it's finished, but the caller must destroy it.

Execution NewCall ( const TupleObject args) [static]

Create an executor for a Python callable.

Parameters:
argscontains a CallableObject followed by its arguments
Returns:
new reference owned by the caller
bool Nonzero ( Object  object) [static, protected]
Returns:
true if the Python object is not false
Object peek ( ) const [protected]

Refer to the object at the top of the current frame's stack.

Object pop ( ) [protected]

Remove and return the object at the top of the current frame's stack.

void push ( const Object object) [protected]

Add an object at the top of the current frame's stack.

bool resume_call ( ) [protected]

Continue the current Continuation (if any).

Returns:
false if there was no continuation
void visit ( Visitor &  v) const

Visit all object references in the call stack.