Falcon::VMContext Class Reference

Class representing a coroutine execution context. More...

#include <vmcontext.h>

Inheritance diagram for Falcon::VMContext:

Inheritance graph
[legend]

List of all members.

Public Member Functions

void addLocals (uint32 space)
 Adds some space in the local stack for local variables.
void atomicMode (bool b)
bool atomicMode () const
bytecode () const
 Returns the current code.
void createFrame (uint32 pcount, ext_func_frame_t frameEndFunc=0)
 Creates a stack frame taking a certain number of parameters.
StackFramecurrentFrame () const
 The currently active frame in this context.
const ItemArrayglobals () const
 Returns the current module global variables vector (const version).
ItemArrayglobals ()
 Returns the current module global variables vector.
bool isWaitingForever () const
 Return true if this is waiting forever on a semaphore signal.
Itemlatch ()
 Latch item.
const Itemlatch () const
 Latch item.
Itemlatcher ()
 Latcher item.
const Itemlatcher () const
 Latcher item.
void lmodule (LiveModule *lm)
 Changes the currently active live module.
LiveModulelmodule () const
 Returns the currently active live module.
Itemlocal (uint32 itemId)
 Returns the nth local item.
const Itemlocal (uint32 itemId) const
 Returns the nth local item.
const uint32pc () const
uint32pc ()
const uint32pc_next () const
uint32pc_next ()
int32 priority () const
void priority (int32 value)
void pushParameter (const Item &item)
 Pushes a parameter for the vm callItem and callFrame functions.
const ItemregA () const
ItemregA ()
const ItemregB () const
ItemregB ()
const ItemregBind () const
ItemregBind ()
const ItemregBindP () const
ItemregBindP ()
ext_func_frame_t returnHandler () const
void returnHandler (ext_func_frame_t callbackFunc)
 Installs a post-processing return frame handler.
numeric schedule () const
void schedule (numeric value)
void scheduleAfter (numeric secs)
 Schedule this context after some time from now.
const Itemself () const
Itemself ()
void signaled ()
VMSemaphore * sleepingOn () const
void sleepOn (VMSemaphore *sl)
const ItemArraystack () const
ItemArraystack ()
const uint32stackBase () const
uint32stackBase ()
void symbol (const Symbol *s)
 Changes the currently active symbol.
const Symbolsymbol () const
 Returns the currently active symbol.
const uint32tryFrame () const
uint32tryFrame ()
 VMContext (const VMContext &other)
 VMContext ()
VMSemaphore * waitingOn () const
void waitOn (VMSemaphore *sem, numeric value=-1)
void wakeup (bool signaled=false)
 Wakes up the context after a wait.
 ~VMContext ()

Friends

class VMSemaphore


Detailed Description

Class representing a coroutine execution context.


Constructor & Destructor Documentation

Falcon::VMContext::VMContext (  ) 

Falcon::VMContext::VMContext ( const VMContext other  ) 

Falcon::VMContext::~VMContext (  ) 


Member Function Documentation

void Falcon::VMContext::addLocals ( uint32  space  )  [inline]

Adds some space in the local stack for local variables.

Referenced by Falcon::VMachine::addLocals().

void Falcon::VMContext::atomicMode ( bool  b  )  [inline]

bool Falcon::VMContext::atomicMode (  )  const [inline]

byte* Falcon::VMContext::code (  )  const [inline]

void Falcon::VMContext::createFrame ( uint32  pcount,
ext_func_frame_t  frameEndFunc = 0 
)

Creates a stack frame taking a certain number of parameters.

The frame is created directly in the stack of this context.

Parameters:
paramCount number of parameters in the stack
frameEndFunc Callback function to be executed at frame end

Referenced by Falcon::VMachine::createFrame().

StackFrame* Falcon::VMContext::currentFrame (  )  const [inline]

The currently active frame in this context.

References VM_FRAME_SPACE.

Referenced by Falcon::VMachine::currentFrame().

const ItemArray& Falcon::VMContext::globals (  )  const [inline]

Returns the current module global variables vector (const version).

ItemArray& Falcon::VMContext::globals (  )  [inline]

Returns the current module global variables vector.

Referenced by Falcon::VMachine::currentGlobals().

bool Falcon::VMContext::isWaitingForever (  )  const [inline]

Return true if this is waiting forever on a semaphore signal.

Item& Falcon::VMContext::latch (  )  [inline]

Latch item.

Generated on load property/vector instructions, it stores the accessed object.

const Item& Falcon::VMContext::latch (  )  const [inline]

Latch item.

Generated on load property/vector instructions, it stores the accessed object.

Referenced by Falcon::VMachine::latch().

Item& Falcon::VMContext::latcher (  )  [inline]

Latcher item.

Generated on load property/vector instructions, it stores the accessor item.

const Item& Falcon::VMContext::latcher (  )  const [inline]

Latcher item.

Generated on load property/vector instructions, it stores the accessor item.

Referenced by Falcon::VMachine::latcher().

void Falcon::VMContext::lmodule ( LiveModule lm  )  [inline]

Changes the currently active live module.

LiveModule* Falcon::VMContext::lmodule (  )  const [inline]

Returns the currently active live module.

Referenced by Falcon::VMachine::currentLiveModule(), and Falcon::VMachine::currentModule().

Item* Falcon::VMContext::local ( uint32  itemId  )  [inline]

Returns the nth local item.

This is just the non-const version. The first variable in the local context is numbered 0.

Parameters:
itemId the number of the local item accessed.
Returns:
a valid pointer to the (dereferenced) local variable or 0 if itemId is invalid.

const Item* Falcon::VMContext::local ( uint32  itemId  )  const [inline]

Returns the nth local item.

The first variable in the local context is numbered 0.

Note:
Fetched item pointers are valid while the stack doesn't change. Pushes, addLocal(), item calls and VM operations may alter the stack. Using this method again after such operations allows to get a valid pointer to the desired item again. Items extracted with this method can be also saved locally in an Item instance, at the cost of a a flat item copy (a few bytes).
Parameters:
itemId the number of the local item accessed.
Returns:
a valid pointer to the (dereferenced) local variable or 0 if itemId is invalid.

Referenced by Falcon::VMachine::local().

const uint32& Falcon::VMContext::pc (  )  const [inline]

uint32& Falcon::VMContext::pc (  )  [inline]

const uint32& Falcon::VMContext::pc_next (  )  const [inline]

uint32& Falcon::VMContext::pc_next (  )  [inline]

int32 Falcon::VMContext::priority (  )  const [inline]

void Falcon::VMContext::priority ( int32  value  )  [inline]

void Falcon::VMContext::pushParameter ( const Item item  )  [inline]

Pushes a parameter for the vm callItem and callFrame functions.

See also:
callItem

callFrame

Parameters:
item the item to be passes as a parameter to the next call.

Referenced by Falcon::VMachine::pushParameter().

const Item& Falcon::VMContext::regA (  )  const [inline]

Item& Falcon::VMContext::regA (  )  [inline]

const Item& Falcon::VMContext::regB (  )  const [inline]

Item& Falcon::VMContext::regB (  )  [inline]

Referenced by Falcon::VMachine::regB().

const Item& Falcon::VMContext::regBind (  )  const [inline]

Item& Falcon::VMContext::regBind (  )  [inline]

const Item& Falcon::VMContext::regBindP (  )  const [inline]

Item& Falcon::VMContext::regBindP (  )  [inline]

ext_func_frame_t Falcon::VMContext::returnHandler (  )  const [inline]

References VM_FRAME_SPACE.

void Falcon::VMContext::returnHandler ( ext_func_frame_t  callbackFunc  )  [inline]

Installs a post-processing return frame handler.

The function passed as a parmeter will receive a pointer to this VM.

The function MUST return true if it performs another frame item call. This will tell the VM that the stack cannot be freed now, as a new call stack has been prepared for immediate execution. When done, the function will be called again.

A frame handler willing to call another frame and not willing to be called anymore must first unininstall itself by calling this method with parameters set at 0, and then it MUST return true.

A frame handler not installing a new call frame MUST return false. This will terminate the current stack frame and cause the VM to complete the return stack.

Parameters:
callbackFunct the return frame handler, or 0 to disinstall a previously set handler.

Referenced by Falcon::VMachine::returnHandler().

numeric Falcon::VMContext::schedule (  )  const [inline]

void Falcon::VMContext::schedule ( numeric  value  )  [inline]

void Falcon::VMContext::scheduleAfter ( numeric  secs  ) 

Schedule this context after some time from now.

This function add the current system time to secs and prepares this context to be scheduled after that absolute time.

Parameters:
secs Number of seconds and fraction after current time.

const Item& Falcon::VMContext::self (  )  const [inline]

Item& Falcon::VMContext::self (  )  [inline]

Referenced by Falcon::VMachine::self().

void Falcon::VMContext::signaled (  ) 

VMSemaphore* Falcon::VMContext::sleepingOn (  )  const [inline]

void Falcon::VMContext::sleepOn ( VMSemaphore *  sl  )  [inline]

const ItemArray& Falcon::VMContext::stack (  )  const [inline]

ItemArray& Falcon::VMContext::stack (  )  [inline]

Referenced by Falcon::VMachine::stack().

const uint32& Falcon::VMContext::stackBase (  )  const [inline]

uint32& Falcon::VMContext::stackBase (  )  [inline]

void Falcon::VMContext::symbol ( const Symbol s  )  [inline]

Changes the currently active symbol.

const Symbol* Falcon::VMContext::symbol (  )  const [inline]

Returns the currently active symbol.

Referenced by Falcon::VMachine::currentSymbol().

const uint32& Falcon::VMContext::tryFrame (  )  const [inline]

uint32& Falcon::VMContext::tryFrame (  )  [inline]

VMSemaphore* Falcon::VMContext::waitingOn (  )  const [inline]

void Falcon::VMContext::waitOn ( VMSemaphore *  sem,
numeric  value = -1 
)

void Falcon::VMContext::wakeup ( bool  signaled = false  ) 

Wakes up the context after a wait.


Friends And Related Function Documentation

friend class VMSemaphore [friend]


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 10:11:50 2009 for Falcon_Core by  doxygen 1.5.8