PikaScript
Public Member Functions | List of all members
Pika::Script< Config >::FullRoot Class Reference

FullRoot inherits from both Root and Config::Globals (which should be a descendant to Variable). More...

#include <PikaScript.h>

Inheritance diagram for Pika::Script< Config >::FullRoot:
Inheritance graph
[legend]
Collaboration diagram for Pika::Script< Config >::FullRoot:
Collaboration graph
[legend]

Public Member Functions

 FullRoot (bool includeIONatives=true)
 
 FullRoot (bool includeIONatives=true)
 
- Public Member Functions inherited from Pika::Script< Config >::Root
virtual void trace (Frame &frame, const String &source, SizeType offset, bool lvalue, const Value &value, Precedence level, bool exit)
 Overload this member function if you want to customize the tracing mechanism in PikaScript. More...
 
virtual void setTracer (Precedence traceLevel, const Value &tracerFunction) throw ()
 Called by the standard library function "trace" to assign a PikaScript tracer function and a trace level. (Also called by the standard trace() on exceptions.) More...
 
bool doTrace (Precedence level) const throw ()
 
String generateLabel ()
 Each "sub-frame" requires a unique "frame label". More...
 
virtual void trace (Frame &frame, const String &source, SizeType offset, bool lvalue, const Value &value, Precedence level, bool exit)
 Overload this member function if you want to customize the tracing mechanism in PikaScript. More...
 
virtual void setTracer (Precedence traceLevel, const Value &tracerFunction) throw ()
 Called by the standard library function "trace" to assign a PikaScript tracer function and a trace level. (Also called by the standard trace() on exceptions.) More...
 
bool doTrace (Precedence level) const throw ()
 
String generateLabel ()
 Each "sub-frame" requires a unique "frame label". More...
 
- Public Member Functions inherited from Pika::Script< Config >::Frame
 Frame (Variables &vars, Root &root, Frame *previous)
 Constructs the Frame and associates it with the variable space vars. More...
 
 Frame (Variables &vars, Root &root, Frame *previous)
 Constructs the Frame and associates it with the variable space vars. More...
 
VariablesgetVariables () const throw ()
 Returns a reference to the Variable instance associated with this Frame. Simple as that.
 
RootgetRoot () const throw ()
 Returns a reference to the "root frame" for this Frame. (No brainer.)
 
FramegetPrevious () const throw ()
 Returns a reference to the previous frame (i.e. the frame of the caller of this frame). Must not be called on the root frame (will assert).
 
VariablesgetVariables () const throw ()
 Returns a reference to the Variable instance associated with this Frame. Simple as that.
 
RootgetRoot () const throw ()
 Returns a reference to the "root frame" for this Frame. (No brainer.)
 
FramegetPrevious () const throw ()
 Returns a reference to the previous frame (i.e. the frame of the caller of this frame). Must not be called on the root frame (will assert).
 
Value get (const String &identifier, bool fallback=false) const
 Gets a variable value. More...
 
Value getOptional (const String &identifier, const Value &defaultValue=Value()) const
 Tries to get the variable value as with get() (but never "falls back"). More...
 
const Valueset (const String &identifier, const Value &v)
 Sets a variable value. More...
 
Value reference (const String &identifier) const
 Creates a reference to the variable identified by identifier by prefixing it with a "frame label". More...
 
std::pair< Frame *, StringresolveFrame (const String &identifier) const
 Resolves the frame for identifier and returns it together with identifier stripped of any prefixed "frame identifier". More...
 
Value get (const String &identifier, bool fallback=false) const
 Gets a variable value. More...
 
Value getOptional (const String &identifier, const Value &defaultValue=Value()) const
 Tries to get the variable value as with get() (but never "falls back"). More...
 
const Valueset (const String &identifier, const Value &v)
 Sets a variable value. More...
 
Value reference (const String &identifier) const
 Creates a reference to the variable identified by identifier by prefixing it with a "frame label". More...
 
std::pair< Frame *, StringresolveFrame (const String &identifier) const
 Resolves the frame for identifier and returns it together with identifier stripped of any prefixed "frame identifier". More...
 
Value call (const String &callee, const Value &body, long argc, const Value *argv=0)
 Calls a Pika function (by setting up a new "sub-frame" and executing the function body). More...
 
Value execute (const String &body)
 A low-level function that executes body directly on the Frame instance. More...
 
Value evaluate (const String source)
 Evaluates the PikaScript expression in source directly on this Frame. More...
 
StringIt parse (const StringIt &begin, const StringIt &end, bool literal)
 Parses a PikaScript expression or literal (without evaluating it) and returns an iterator pointing at the end of the expression.
 
Value call (const String &callee, const Value &body, long argc, const Value *argv=0)
 Calls a Pika function (by setting up a new "sub-frame" and executing the function body). More...
 
Value execute (const String &body)
 A low-level function that executes body directly on the Frame instance. More...
 
Value evaluate (const String source)
 Evaluates the PikaScript expression in source directly on this Frame. More...
 
StringIt parse (const StringIt &begin, const StringIt &end, bool literal)
 Parses a PikaScript expression or literal (without evaluating it) and returns an iterator pointing at the end of the expression.
 
void registerNative (const String &identifier, Native *native)
 Registers the native function (or object) native with identifier in the appropriate variable space (determined by any "frame identifier" present in identifier). More...
 
template<class A0 , class R >
void registerNative (const String &i, R(*f)(A0))
 Helper template for easily registering a unary C++ function. More...
 
template<class A0 , class A1 , class R >
void registerNative (const String &i, R(*f)(A0, A1))
 Helper template for easily registering a binary C++ function. More...
 
template<class C , class A0 , class R >
void registerNative (const String &i, C *o, R(C::*m)(A0))
 Helper template for easily registering a unary C++ member function in the C++ object pointed to by o. More...
 
void unregisterNative (const String &identifier)
 Helper function for unregistering a native function / object. More...
 
void registerNative (const String &identifier, Native *native)
 Registers the native function (or object) native with identifier in the appropriate variable space (determined by any "frame identifier" present in identifier). More...
 
template<class A0 , class R >
void registerNative (const String &i, R(*f)(A0))
 Helper template for easily registering a unary C++ function. More...
 
template<class A0 , class A1 , class R >
void registerNative (const String &i, R(*f)(A0, A1))
 Helper template for easily registering a binary C++ function. More...
 
template<class C , class A0 , class R >
void registerNative (const String &i, C *o, R(C::*m)(A0))
 Helper template for easily registering a unary C++ member function in the C++ object pointed to by o. More...
 
void unregisterNative (const String &identifier)
 Helper function for unregistering a native function / object. More...
 
virtual ~Frame ()
 The default destructor does nothing, but it is always good practice to have a virtual destructor.
 
virtual ~Frame ()
 The default destructor does nothing, but it is always good practice to have a virtual destructor.
 

Additional Inherited Members

- Protected Types inherited from Pika::Script< Config >::Frame
typedef std::pair< bool, ValueXValue
 The XValue differentiates lvalues and rvalues and is used internally in the interpreter. More...
 
typedef std::pair< bool, ValueXValue
 The XValue differentiates lvalues and rvalues and is used internally in the interpreter. More...
 
- Protected Attributes inherited from Pika::Script< Config >::Root
Precedence traceLevel
 Calls to trace() will only happen when the "precedence level" is less or equal to this. More...
 
Value tracerFunction
 Pika-script tracer function (used by the default trace() implementation).
 
bool isInsideTracer
 Set to prevent recursive calling of tracer (used by the default trace() implementation).
 
Char autoLabel [32]
 The last generated frame label (padded with leading ':').
 
CharautoLabelStart
 The first character of the last generated frame label (begins at autoLabel + 30 and slowly moves backwards when necessary).
 

Detailed Description

template<class Config>
class Pika::Script< Config >::FullRoot

FullRoot inherits from both Root and Config::Globals (which should be a descendant to Variable).

Its constructor adds the natives of the standard library. This means that by instantiating this class you will get a full execution environment for PikaScript ready to go.

Definition at line 422 of file PikaScript.h.

Constructor & Destructor Documentation

template<class Config >
Pika::Script< Config >::FullRoot::FullRoot ( bool  includeIONatives = true)
inline

< If includeIO is false, 'load', 'save', 'input', 'print' and 'system' will not be registered.

Definition at line 423 of file PikaScript.h.

template<class Config >
Pika::Script< Config >::FullRoot::FullRoot ( bool  includeIONatives = true)
inline

< If includeIO is false, 'load', 'save', 'input', 'print' and 'system' will not be registered.

Definition at line 423 of file PikaScript.h.


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