Logo Search packages:      
Sourcecode: falconpl version File versions  Download package

Falcon::VMachine Class Reference

#include <vm.h>

Inheritance diagram for Falcon::VMachine:

Falcon::ErrorHandler

List of all members.


Detailed Description

The Falcon virtual machine.

Virtual machine is in charge to execute Falcon bytecode.

The virtual machine execution model is quite flexible, and allow infinite execution, step-by-step execution, limited runs and interrupts (event rising and debug requests) from external code while running.

To run, the Virtual Machine needs to be properly setup. However, this "setup steps" are thought as customization steps so that the VM user is able to configure it on its needs, and they are both simple and effective.

Minimal configuration needed requires to add a Runtime object, which holds the lists of all non-main modules. It is then possible to execute a routine exported by any of the modules in the runtime, or to provide a "running module", or "main module" with the setup() method. Once the startup symbol, or running module (or both) are set, the it is possible to call run().

Note:
It is possible that this interface will be simplified in the future so that only one method is used to set up the runtime and the start symbol or main module.

This class implements the error handler interface because it may act as an error handler for the embedding components: compiler, assembler, module loader and runtime may all be embedded in a VM that may act as a referee for the script to be i.e. evaluating correctly a piece of falcon source code.

Definition at line 211 of file vm.h.


Public Types

enum  {
  i_pc_call_request = 0xFFFFFFFF-sizeof(int32)*4, i_pc_redo_request = 0xFFFFFFFF-sizeof(int32)*4, i_pc_call_external_ctor = 0xFFFFFFFF-sizeof(int32)*3, i_pc_call_external_ctor_return = 0xFFFFFFFF-sizeof(int32)*2,
  i_pc_call_external = 0xFFFFFFFF-sizeof(int32), i_pc_call_external_return = 0xFFFFFFFF
}
enum  e_callMode { e_callNormal, e_callFrame, e_callInst, e_callInstFrame }
enum  returnCode {
  return_ok, return_error_string, return_error_parse, return_error_internal,
  return_error_parse_fmt
}
enum  tEvent {
  eventNone, eventQuit, eventRisen, eventReturn,
  eventYield, eventWait, eventSuspend, eventSingleStep,
  eventOpLimit, eventSleep, eventInterrupt
}

Public Member Functions

void addLocals (uint32 space)
void allowYield (bool mode)
bool allowYield ()
ItembomParam (uint32 itemId)
int32 bomParamCount () const
uint32 callbackLoops () const
void callbackLoops (uint32 cl)
bool callFrame (const Item &callable, int32 paramCount)
void callFrameNow (ext_func_frame_t callbackFunc)
bool callItem (const Item &callable, int32 paramCount, e_callMode mode=e_callNormal)
bool callItemAtomic (const Item &callable, int32 paramCount, e_callMode mode=e_callNormal)
void callReturn ()
int compareItems (const Item &first, const Item &second)
uint32 contextCheckLoops () const
void contextCheckLoops (uint32 cl)
PropertyTablecreateClassTemplate (LiveModule *lmod, const Map &pt)
const ItemVector & currentGlobals () const
ItemVector & currentGlobals ()
const ModulecurrentModule () const
const ItemVector & currentStack () const
ItemVector & currentStack ()
SymbolcurrentSymbol () const
uint32 elapsedLoops () const
void electContext ()
ErrorHandlererrorHandler () const
void errorHandler (ErrorHandler *em, bool own=false)
ErrorexitError () const
returnCode expandString (const String &src, String &target)
void fillErrorContext (Error *err, bool filltb=true)
void fillErrorTraceback (Error &error)
AttributefindAttribute (const Symbol *sym) const
AttributefindAttribute (const String &name) const
ItemfindGlobalItem (const String &name) const
const SymModulefindGlobalSymbol (const String &str) const
ItemfindLocalSymbolItem (const String &symName) const
ItemfindLocalVariable (const String &name) const
LiveModulefindModule (const String &name)
ItemfindWKI (const String &name) const
bool functionalEval (const Item &itm)
uint32 gcCheckLoops () const
void gcCheckLoops (uint32 cl)
GarbageLock * gcLock (const Item &itm)
void gcUnlock (GarbageLock *itm)
bool getCaller (Symbol *&sym, const Module *&module)
const ContextList * getCtxList () const
ServicegetService (const String &name)
const ContextList * getSleepingList () const
bool hadError () const
bool hadEvent () const
bool hadSleepRequest () const
bool hadStoppingEvent () const
bool hadSuspensionEvent () const
virtual void handleError (Error *error)
void hasProcessStreams (bool b)
bool hasProcessStreams () const
void init ()
void interrupt ()
bool interrupted (bool raise=false, bool reset=false, bool dontCheck=false)
bool isParamByRef (uint32 itemId) const
void itemToString (String &target, const Item *itm)
void itemToString (String &target, const Item *itm, const String &format)
tEvent lastEvent () const
Itemlatch ()
const Itemlatch () const
Itemlatcher ()
const Itemlatcher () const
bool launch (const String &startSym, uint32 paramCount=0)
bool launch ()
uint32 limitLoops () const
void limitLoops (uint32 l)
bool limitLoopsHit () const
LiveModulelink (Module *module, bool isMainModule=true)
bool link (Runtime *rt)
CoreClasslinkClass (LiveModule *lmod, Symbol *clsym)
const LiveModuleMapliveModules () const
LiveModuleMapliveModules ()
Itemlocal (uint32 itemId)
const Itemlocal (uint32 itemId) const
LiveModulemainModule () const
MemPoolmemPool () const
const ItemmoduleItem (uint32 pos) const
ItemmoduleItem (uint32 pos)
const StringmoduleString (uint32 stringId) const
byte operandType (byte opNum) const
void operator delete (void *mem, size_t size)
void * operator new (size_t size)
Itemparam (uint32 itemId)
const Itemparam (uint32 itemId) const
int32 paramCount () const
virtual void periodicCallback ()
void popTry (bool moveTo)
bool prepare (const String &startSym, uint32 paramCount=0)
uint32 programCounter () const
bool publishService (Service *svr)
void pushParameter (const Item &item)
void pushTry (uint32 landingPC)
void raiseError (int code, const String &expl, int32 line=0)
void raiseError (int code, int32 line=0)
void raiseError (Error *err)
void raiseModError (Error *err)
void raiseRTError (Error *err)
void recallFrame ()
void referenceItem (Item &target, Item &source)
ItemregA ()
const ItemregA () const
ItemregB ()
const ItemregB () const
void requestQuit ()
void requestSuspend ()
void reset ()
void resetCounters ()
void resetEvent ()
void resume (const Item &returned)
void resume ()
void retnil ()
ext_func_frame_t returnHandler ()
void returnHandler (ext_func_frame_t callbackFunc)
bool returnOnSleep () const
void returnOnSleep (bool r)
void retval (const String &cs)
void retval (CoreClass *cc)
void retval (CoreObject *co)
void retval (CoreDict *cd)
void retval (CoreArray *ca)
void retval (GarbageString *cs)
void retval (const Item &val)
void retval (numeric val)
void retval (int64 val)
void retval (int32 val)
void run ()
Itemself ()
const Itemself () const
Itemsender ()
const Itemsender () const
bool singleStep () const
void singleStep (bool ss)
numeric sleepRequestTime () const
uint32 stackBase () const
const ItemstackItem (uint32 pos) const
ItemstackItem (uint32 pos)
void stdErr (Stream *nstream)
StreamstdErr () const
void stdIn (Stream *nstream)
StreamstdIn () const
void stdOut (Stream *nstream)
StreamstdOut () const
void step ()
void store (GarbageString *str_data)
void store (Garbageable *data)
bool suspendOnDone () const
void suspendOnDone (bool sus=true)
Sys::SystemDatasystemData ()
const Sys::SystemDatasystemData () const
bool unlink (const Module *module)
bool unlink (const Runtime *rt)
void * userData () const
void userData (void *ud)
 VMachine ()
 VMachine (bool initItems)
void yieldRequest (numeric time)
virtual ~VMachine ()

Protected Types

enum  { i_noTryFrame = 0xFFFFFFFF }

Protected Member Functions

bool callItemPass (const Item &callable)
bool callItemPassIn (const Item &callable)
void createFrame (uint32 paramCount)
int32 getNextNTD32 ()
int64 getNextNTD64 ()
ItemgetOpcodeParam (register uint32 bc_pos)
void internal_construct ()
bool linkSubClass (LiveModule *mod, const Symbol *clssym, Map &props, AttribHandler **attribs)
ItemparseSquareAccessor (const Item &accessed, String &accessor) const
void putAtSleep (VMContext *ctx, numeric secs)
void reschedule (VMContext *ctx, numeric secs)
void rotateContext ()
bool seekInRange (int64 num, byte *base, uint16 size, uint32 &landing) const
bool seekInteger (int64 num, byte *base, uint16 size, uint32 &landing) const
bool seekItem (const Item *item, byte *base, uint16 size, uint32 &landing)
bool seekItemClass (const Item *obj, byte *base, uint16 size, uint32 &landing) const
bool seekString (const String *str, byte *base, uint16 size, uint32 &landing) const
void yield (numeric seconds)

Protected Attributes

bool m_allowYield
bool m_atomicMode
AttribHandlerm_attributes
bool m_bhasStandardStreams
int32 m_bomParams
bool m_bOwnErrorHandler
bool m_bSingleStep
byte * m_code
ContextList m_contexts
VMContextm_currentContext
ItemVector * m_currentGlobals
const Modulem_currentModule
ErrorHandlerm_errhand
Errorm_error
tEvent m_event
BomMap * m_fbom
SymModuleMap m_globalSyms
Item m_imm [4]
LiveModuleMap m_liveModules
uint32 m_loopsCallback
uint32 m_loopsContext
uint32 m_loopsGC
LiveModulem_mainModule
MemPoolm_memPool
bool m_onDoneSuspend
uint32 m_opCount
tOpcodeHandler * m_opHandlers
uint32 m_opLimit
uint32 m_opNextCallback
uint32 m_opNextCheck
uint32 m_opNextContext
uint32 m_opNextGC
uint32 m_pc
uint32 m_pc_next
Item m_regA
Item m_regB
Item m_regL1
Item m_regL2
Item m_regS1
Item m_regS2
Map m_services
bool m_sleepAsRequests
ContextList m_sleepingContexts
ItemVector * m_stack
uint32 m_stackBase
Streamm_stdErr
Streamm_stdIn
Streamm_stdOut
Symbolm_symbol
Sys::SystemData m_systemData
uint32 m_tryFrame
void * m_userData
SymModuleMap m_wellKnownSyms
numeric m_yieldTime

Friends

void opcodeHandler_ADD (register VMachine *vm)
void opcodeHandler_ADDS (register VMachine *vm)
void opcodeHandler_AND (register VMachine *vm)
void opcodeHandler_ANDS (register VMachine *vm)
void opcodeHandler_BAND (register VMachine *vm)
void opcodeHandler_BNOT (register VMachine *vm)
void opcodeHandler_BOOL (register VMachine *vm)
void opcodeHandler_BOR (register VMachine *vm)
void opcodeHandler_BXOR (register VMachine *vm)
void opcodeHandler_CALL (register VMachine *vm)
void opcodeHandler_DEC (register VMachine *vm)
void opcodeHandler_DECP (register VMachine *vm)
void opcodeHandler_DIV (register VMachine *vm)
void opcodeHandler_DIVS (register VMachine *vm)
void opcodeHandler_END (register VMachine *vm)
void opcodeHandler_EQ (register VMachine *vm)
void opcodeHandler_FORK (register VMachine *vm)
void opcodeHandler_GE (register VMachine *vm)
void opcodeHandler_GENA (register VMachine *vm)
void opcodeHandler_GEND (register VMachine *vm)
void opcodeHandler_GENR (register VMachine *vm)
void opcodeHandler_GEOR (register VMachine *vm)
void opcodeHandler_GIVE (register VMachine *vm)
void opcodeHandler_GIVN (register VMachine *vm)
void opcodeHandler_GT (register VMachine *vm)
void opcodeHandler_HAS (register VMachine *vm)
void opcodeHandler_HASN (register VMachine *vm)
void opcodeHandler_IFF (register VMachine *vm)
void opcodeHandler_IFT (register VMachine *vm)
void opcodeHandler_IN (register VMachine *vm)
void opcodeHandler_INC (register VMachine *vm)
void opcodeHandler_INCP (register VMachine *vm)
void opcodeHandler_INDI (register VMachine *vm)
void opcodeHandler_INST (register VMachine *vm)
void opcodeHandler_IPOP (register VMachine *vm)
void opcodeHandler_JMP (register VMachine *vm)
void opcodeHandler_JTRY (register VMachine *vm)
void opcodeHandler_LD (register VMachine *vm)
void opcodeHandler_LDP (register VMachine *vm)
void opcodeHandler_LDPT (register VMachine *vm)
void opcodeHandler_LDRF (register VMachine *vm)
void opcodeHandler_LDV (register VMachine *vm)
void opcodeHandler_LDVT (register VMachine *vm)
void opcodeHandler_LE (register VMachine *vm)
void opcodeHandler_LNIL (register VMachine *vm)
void opcodeHandler_LSB (register VMachine *vm)
void opcodeHandler_LSTA (register VMachine *vm)
void opcodeHandler_LT (register VMachine *vm)
void opcodeHandler_LVAL (register VMachine *vm)
void opcodeHandler_MOD (register VMachine *vm)
void opcodeHandler_MODS (register VMachine *vm)
void opcodeHandler_MUL (register VMachine *vm)
void opcodeHandler_MULS (register VMachine *vm)
void opcodeHandler_NEG (register VMachine *vm)
void opcodeHandler_NEQ (register VMachine *vm)
void opcodeHandler_NOIN (register VMachine *vm)
void opcodeHandler_NOP (register VMachine *vm)
void opcodeHandler_NOT (register VMachine *vm)
void opcodeHandler_NOTS (register VMachine *vm)
void opcodeHandler_ONCE (register VMachine *vm)
void opcodeHandler_OR (register VMachine *vm)
void opcodeHandler_ORS (register VMachine *vm)
void opcodeHandler_PASS (register VMachine *vm)
void opcodeHandler_PEEK (register VMachine *vm)
void opcodeHandler_POP (register VMachine *vm)
void opcodeHandler_POW (register VMachine *vm)
void opcodeHandler_POWS (register VMachine *vm)
void opcodeHandler_PROV (register VMachine *vm)
void opcodeHandler_PSHN (register VMachine *vm)
void opcodeHandler_PSHR (register VMachine *vm)
void opcodeHandler_PSIN (register VMachine *vm)
void opcodeHandler_PTRY (register VMachine *vm)
void opcodeHandler_PUSH (register VMachine *vm)
void opcodeHandler_RET (register VMachine *vm)
void opcodeHandler_RETA (register VMachine *vm)
void opcodeHandler_RETV (register VMachine *vm)
void opcodeHandler_RIS (register VMachine *vm)
void opcodeHandler_SELE (register VMachine *vm)
void opcodeHandler_SHL (register VMachine *vm)
void opcodeHandler_SHLS (register VMachine *vm)
void opcodeHandler_SHR (register VMachine *vm)
void opcodeHandler_SHRS (register VMachine *vm)
void opcodeHandler_SSTA (register VMachine *vm)
void opcodeHandler_STEX (register VMachine *vm)
void opcodeHandler_STO (register VMachine *vm)
void opcodeHandler_STP (register VMachine *vm)
void opcodeHandler_STPR (register VMachine *vm)
void opcodeHandler_STPS (register VMachine *vm)
void opcodeHandler_STV (register VMachine *vm)
void opcodeHandler_STVR (register VMachine *vm)
void opcodeHandler_STVS (register VMachine *vm)
void opcodeHandler_SUB (register VMachine *vm)
void opcodeHandler_SUBS (register VMachine *vm)
void opcodeHandler_SVAL (register VMachine *vm)
void opcodeHandler_SWCH (register VMachine *vm)
void opcodeHandler_TRAC (register VMachine *vm)
void opcodeHandler_TRAL (register VMachine *vm)
void opcodeHandler_TRAN (register VMachine *vm)
void opcodeHandler_TRAV (register VMachine *vm)
void opcodeHandler_TRY (register VMachine *vm)
void opcodeHandler_UNPK (register VMachine *vm)
void opcodeHandler_UNPS (register VMachine *vm)
void opcodeHandler_WRT (register VMachine *vm)
void opcodeHandler_XORS (register VMachine *vm)
void opcodeHandler_XPOP (register VMachine *vm)
class VMContext
class VMSemaphore

Classes

class  VarDefMod

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

Generated by  Doxygen 1.6.0   Back to index