Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skInterpreter Class Reference

This class parses and executes Simkin script, and holds a list of global variables. More...

#include <skInterpreter.h>

Inheritance diagram for skInterpreter:

skExecutable skiExecutable List of all members.

Public Member Functions

skMethodDefNodeparseString (const skString &location, const skString &code, skExecutableContext &ctxt)
 this function parses the script in the code variable and returns a parse tree if there are no syntax errors.

skMethodDefNodeparseExternalParams (const skString &location, skStringList &paramNames, const skString &code, skExecutableContext &ctxt)
 this function parses the script in the code variable and returns a parse tree if there are no syntax errors.

void executeString (const skString &location, skiExecutable *obj, const skString &code, skRValueArray &args, skRValue &return_value, skMethodDefNode **parseTree, skExecutableContext &ctxt)
 this function parses and executes script which is assumed to belong to the object passed in.

void executeStringExternalParams (const skString &location, skiExecutable *obj, skStringList &paramNames, const skString &code, skRValueArray &args, skRValue &r, skMethodDefNode **keepParseTree, skExecutableContext &ctxt)
 this function parses and executes script with externally declared parameters which is assumed to belong to the object passed in.

void executeParseTree (const skString &location, skiExecutable *obj, skMethodDefNode *parseTree, skRValueArray &args, skRValue &return_value, skExecutableContext &ctxt)
 this function executes some script that has already been parsed into a parse tree.

void evaluateExpression (const skString &location, skiExecutable *obj, const skString &expression, skRValueTable &vars, skRValue &return_value, skExecutableContext &ctxt)
 this function parses and evaluates an expression within the given context

void evaluateExpression (const skString &location, skiExecutable *obj, skExprNode *expression, skRValueTable &vars, skRValue &return_value, skExecutableContext &ctxt)
 this function parses and evaluates an expression within the given context

void addGlobalVariable (const skString &name, const skRValue &value)
 this method adds a global variable to the list held by this interpreter.

void removeGlobalVariable (const skString &name)
 this method removes a global variable from the list held by this interpreter

bool findGlobalVariable (const skString &name, skRValue &return_value)
 this method finds the value of a global variable by name

const skRValueTablegetGlobalVariables () const
 this method returns the table of global variables

virtual bool setValue (const skString &s, const skString &attribute, const skRValue &v)
 this method is used to set the Tracing variable in the interpreter.

virtual bool getValue (const skString &s, const skString &attribute, skRValue &v)
 this method is used to retrieve the Tracing variable in the interpreter.

virtual bool method (const skString &method_name, skRValueArray &arguments, skRValue &return_value, skExecutableContext &ctxt)
 Requests that the object execute the given method.

virtual void getInstanceVariables (skRValueTable &table)
 This method returns the instance variables for this object.

void trace (const skString &msg)
 output a message to the current trace output

void trace (const Char *msg)
 output a message to the current trace output

void setTraceCallback (skTraceCallback *callback)
 this method sets an object to receive trace messages.

void setStatementStepper (skStatementStepper *stepper)
 this method sets an object to be called each time a statement is executed.

void runtimeError (skStackFrame &ctxt, const skString &msg)
 This method reports a runtime error by throwing a skRuntimeException.

void runtimeError (skStackFrame &ctxt, const Char *msg)
 This method reports a runtime error by throwing a skRuntimeException.

 skInterpreter ()
 Constructor - adds the interpreter as a global variable with the name "Interpreter".

virtual ~skInterpreter ()
 Destructor - deletes the global variable list.

void init ()
 init function


Detailed Description

This class parses and executes Simkin script, and holds a list of global variables.

There is one global Interpreter object which you should set up at the start, although others can also be created.


Constructor & Destructor Documentation

skInterpreter::skInterpreter  ) 
 

Constructor - adds the interpreter as a global variable with the name "Interpreter".

Remarks:
in Symbian version - you should call init() separately to add the interpreter global variable, as this may leave


Member Function Documentation

void skInterpreter::addGlobalVariable const skString name,
const skRValue value
 

this method adds a global variable to the list held by this interpreter.

If the variable already has a value, it is replaced with the new one

Parameters:
name - the name of the global variable
value - the value of the global variable, which can be any RValue
Exceptions:
Symbian - a leaving function

void skInterpreter::evaluateExpression const skString location,
skiExecutable obj,
skExprNode *  expression,
skRValueTable vars,
skRValue return_value,
skExecutableContext ctxt
 

this function parses and evaluates an expression within the given context

Parameters:
location - a textual description of the location of the expression (this appears in error messages)
obj - the executable object which "owns" the expression
vars - a table of local variables defined for the expression
expression - a single Simkin expression in a parse tree created by parseExpression
return_value - an RValue which receives the result of the expression
ctxt context object to receive errors
Exceptions:
skParseException - if a syntax error is encountered
skRuntimeException - if an error occurs while the expression is evaluated
Symbian - a leaving function

void skInterpreter::evaluateExpression const skString location,
skiExecutable obj,
const skString expression,
skRValueTable vars,
skRValue return_value,
skExecutableContext ctxt
 

this function parses and evaluates an expression within the given context

Parameters:
location - a textual description of the location of the expression (this appears in error messages)
obj - the executable object which "owns" the expression
vars - a table of local variables defined for the expression
expression - a single Simkin expression which must begin with "=", for example "=a+b"
return_value - an RValue which receives the result of the expression
ctxt context object to receive errors
Exceptions:
skParseException - if a syntax error is encountered
skRuntimeException - if an error occurs while the expression is evaluated
Symbian - a leaving function

void skInterpreter::executeParseTree const skString location,
skiExecutable obj,
skMethodDefNode parseTree,
skRValueArray args,
skRValue return_value,
skExecutableContext ctxt
 

this function executes some script that has already been parsed into a parse tree.

Parameters:
location - a textual description of the location of the script (this appears in error messages)
obj - the executable object which "owns" the script
parseTree - a parse tree that has been generated by one of the parse or execute functions of the Interpreter
args - an array of arguments to the function, which are passed as parameters to the script
ctxt context object to receive errors
return_value - an RValue which receives the result of the script
Exceptions:
skRuntimeException - if an error occurs while the script is running
Symbian - a leaving function

void skInterpreter::executeString const skString location,
skiExecutable obj,
const skString code,
skRValueArray args,
skRValue return_value,
skMethodDefNode **  parseTree,
skExecutableContext ctxt
 

this function parses and executes script which is assumed to belong to the object passed in.

Parameters:
location - a textual description of the location of the script (this appears in error messages)
obj - the executable object which "owns" the script
args - an array of arguments to the function, which are passed as parameters to the script
code - a string of Simkin script, including parameter declarations
return_value - an RValue which receives the result of the script
parseTree - if you supply this pointer, the parse tree is assigned to it, and you must delete it yourself. Without the parameter the parse tree will be deleted by the interpreter. The parse tree can be used in a cache and passed to executeParseTree later.
ctxt context object to receive errors
Exceptions:
skParseException - if a syntax error is encountered
skRuntimeException - if an error occurs while the script is running
Symbian - a leaving function

void skInterpreter::executeStringExternalParams const skString location,
skiExecutable obj,
skStringList paramNames,
const skString code,
skRValueArray args,
skRValue r,
skMethodDefNode **  keepParseTree,
skExecutableContext ctxt
 

this function parses and executes script with externally declared parameters which is assumed to belong to the object passed in.

Parameters:
location - a textual description of the location of the script (this appears in error messages)
obj - the executable object which "owns" the script
paramNames - a list of parameter names (hence the name "ExternalParams"
args - an array of arguments to the function, which are passed as parameters to the script
code - a string of Simkin script, which does *not* include parameter declarations
r - an RValue which receives the result of the script
keepParseTree - if you supply this pointer, the parse tree is assigned to it, and you must delete it yourself. Without the parameter the parse tree will be deleted by the interpreter. The parse tree can be used in a cache and passed to executeParseTree later.
ctxt context object to receive errors
Exceptions:
skParseException - if a syntax error is encountered
skRuntimeException - if an error occurs while the script is running
Symbian - a leaving function

bool skInterpreter::findGlobalVariable const skString name,
skRValue return_value
 

this method finds the value of a global variable by name

Parameters:
name - the name of the global variable
return_value - an RValue which receives the value of the variable
Returns:
true if the variable was found, otherwise false

const skRValueTable & skInterpreter::getGlobalVariables  )  const
 

this method returns the table of global variables

Returns:
a hashtable of global variables mapping name to object

void skInterpreter::getInstanceVariables skRValueTable table  )  [virtual]
 

This method returns the instance variables for this object.

Parameters:
table a table to filled with references to the instance variables
Exceptions:
Symbian - a leaving function

Reimplemented from skExecutable.

bool skInterpreter::getValue const skString s,
const skString attribute,
skRValue v
[virtual]
 

this method is used to retrieve the Tracing variable in the interpreter.

If true, method calls will show in the trace as the script is executed In Simkin call tracing=Interpreter.Tracing

Reimplemented from skExecutable.

void skInterpreter::init  ) 
 

init function

Remarks:
needs to be called explicitly in Symbian version
Exceptions:
Symbian - a leaving function

bool skInterpreter::method const skString method_name,
skRValueArray arguments,
skRValue return_value,
skExecutableContext ctxt
[virtual]
 

Requests that the object execute the given method.

Methods supported: breakpoint - breaks to the debugger (if present)

Parameters:
method_name - the name of the method to execute
arguments - an array of RValue objects, which are the arguments to the method
return_value - an object to receive the return value of the method
ctxt context object to receive errors
Returns:
true if the method could be executed, or false if the method is not supported
Exceptions:
skParseException - if a syntax error is encountered while the script is running
skRuntimeException - if an error occurs while the script is running

Reimplemented from skExecutable.

skMethodDefNode * skInterpreter::parseExternalParams const skString location,
skStringList paramNames,
const skString code,
skExecutableContext ctxt
 

this function parses the script in the code variable and returns a parse tree if there are no syntax errors.

It assumes that the script does *not* contain parameters and enclosing braces. If there are syntax errors the function throws an skParseException object

Parameters:
location - a string describing where this code is located, this will appear in any error messages
paramNames - a list of parameter names (hence the name "ExternalParams"
code - a string of Simkin code, which does *not* include the parameter declarations
ctxt context object to receive errors
Returns:
returns a parse tree, if the syntax was valid. The caller must free this tree.
Exceptions:
skParseException - if a syntax error is encountered
Symbian - a leaving function

skMethodDefNode * skInterpreter::parseString const skString location,
const skString code,
skExecutableContext ctxt
 

this function parses the script in the code variable and returns a parse tree if there are no syntax errors.

If there are syntax errors the function throws an skParseException object

Parameters:
location - a string describing where this code is located, this will appear in any error messages
code - a string of Simkin code, which includes the parameter declarations
ctxt context object to receive errors
Returns:
returns a parse tree, if the syntax was valid. The caller must free this tree.
Exceptions:
skParseException - if a syntax error is encountered
Symbian - a leaving function

void skInterpreter::removeGlobalVariable const skString name  ) 
 

this method removes a global variable from the list held by this interpreter

Parameters:
name - the name of the global variable

void skInterpreter::runtimeError skStackFrame ctxt,
const Char *  msg
 

This method reports a runtime error by throwing a skRuntimeException.

Parameters:
ctxt - the current source code context
msg - a message describing the error
Exceptions:
Symbian - a leaving function

void skInterpreter::runtimeError skStackFrame ctxt,
const skString msg
 

This method reports a runtime error by throwing a skRuntimeException.

Parameters:
ctxt - the current source code context
msg - a message describing the error
Exceptions:
Symbian - a leaving function

void skInterpreter::setStatementStepper skStatementStepper stepper  ) 
 

this method sets an object to be called each time a statement is executed.

Parameters:
stepper the stepper object, or 0 to clear

void skInterpreter::setTraceCallback skTraceCallback callback  ) 
 

this method sets an object to receive trace messages.

Pass 0 to fall back to standard mechanism (using skTracer)

Parameters:
callback the callback object, or 0 to fall back to using skTracer

bool skInterpreter::setValue const skString s,
const skString attribute,
const skRValue v
[virtual]
 

this method is used to set the Tracing variable in the interpreter.

This will show method calls as the script is executed In Simkin call Interpreter.Tracing=true

Reimplemented from skExecutable.

void skInterpreter::trace const Char *  msg  ) 
 

output a message to the current trace output

Parameters:
msg the message to show

void skInterpreter::trace const skString msg  ) 
 

output a message to the current trace output

Parameters:
msg the message to show


The documentation for this class was generated from the following files:
Generated on Fri Dec 17 20:27:35 2004 for Simkin by doxygen1.3