|
PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
|
This class has got everything you need to evaluate stuff. More...
#include <Evaluator-es.h>
Public Member Functions | |
| Evaluator () | |
| Evaluator (Variant &stacktop, string scope) | |
| ~Evaluator () | |
| void | CallFunction (const OpNode *node) |
| bool | Evaluate1 () |
| bool | Evaluate1 (const PNode *node) |
| bool | Evaluate1 (const OpNode *node) |
| This method evaluates OpNodes. | |
| bool | Evaluate1 (const DataNode *node) |
| This method evaluates DataNodes. | |
| void | Push (Variant v) |
| Variant | Pop () |
| Variant | Peek () |
| void | NodeStackPush (const PNode *node) |
| int | GetNodeStackDepth () |
| int | GetStackDepth () |
| PEventLoop * | GetEventLoop () |
| bool | IsVariableName (Variant v) |
| Evaluator () | |
| Evaluator (Variant &stacktop, string scope) | |
| ~Evaluator () | |
| void | CallFunction (const OpNode *node) |
| bool | Evaluate (const PNode *node) |
| bool | Evaluate (const OpNode *node) |
| This method evaluates OpNodes. | |
| bool | Evaluate (const DataNode *node) |
| This method evaluates DataNodes. | |
| void | Push (const Variant &v) |
| Variant | Pop () |
| const Variant & | Peek () const |
| unsigned long int | GetStackDepth () |
| PEventLoop * | GetEventLoop () |
| bool | IsVariableName (Variant v) |
Static Public Attributes | |
| static FunctionMap | mFunctionMap |
| Initiate some static member data. | |
| static VariableMap | gGlobalVariableMap |
| static PEventLoop * | mEventLoop =NULL |
| static PEBLPath | gPath |
| static const PNode * | gEvalNode = NULL |
| static PCallStack | gCallStack |
Friends | |
| class | PEventLoop |
This class has got everything you need to evaluate stuff.
Definition at line 58 of file Evaluator-es.h.
| Evaluator::Evaluator | ( | ) |
Definition at line 92 of file Evaluator-es.cpp.
References gCallStack, gEvalNode, mEventLoop, PEventLoop, and PCallStack::Push().
| Evaluator::Evaluator | ( | Variant & | stacktop, |
| string | scope | ||
| ) |
Definition at line 107 of file Evaluator-es.cpp.
References gCallStack, gEvalNode, mEventLoop, PEventLoop, PCallStack::Push(), and Push().
| Evaluator::~Evaluator | ( | ) |
Definition at line 133 of file Evaluator-es.cpp.
| Evaluator::Evaluator | ( | ) |
| Evaluator::Evaluator | ( | Variant & | stacktop, |
| string | scope | ||
| ) |
| Evaluator::~Evaluator | ( | ) |
| void Evaluator::CallFunction | ( | const OpNode * | node | ) |
This method takes a PEBL_FUNCTION OpNode, which is comprised of a P_DATA_FUNCTION DataNode on the left and a parameter list on the right, Finds the function code in the FunctionMap, and Evaluates that code.
Definition at line 1982 of file Evaluator-es.cpp.
References Evaluate1(), PList::First(), counted_ptr< X >::get(), Variant::GetComplexData(), FunctionMap::GetFunction(), Variant::GetFunctionName(), OpNode::GetLeft(), PComplexData::GetObject(), PCustomObject::GetProperty(), OpNode::GetRight(), GetStackDepth(), Variant::GetString(), Variant::IsComplexData(), PComplexData::IsCustomObject(), mFunctionMap, myEval, OVE_SUCCESS, P_DATA_FUNCTION, Peek(), Pop(), Push(), PError::SignalFatalError(), and PCustomObject::ValidateProperty().
Referenced by PEBLEnvironment::CallFunction(), and Evaluate().
| void Evaluator::CallFunction | ( | const OpNode * | node | ) |
| bool Evaluator::Evaluate | ( | const DataNode * | node | ) |
This method evaluates DataNodes.
Definition at line 1271 of file Evaluator.cpp.
References Variant::GetDataType(), PNode::GetLineNumber(), DataNode::GetValue(), Variant::GetVariableBaseName(), Variant::GetVariablePropertyName(), gEvalNode, gGlobalVariableMap, P_DATA_COMPLEXDATA, P_DATA_GLOBALVARIABLE, P_DATA_LOCALVARIABLE, P_DATA_NUMBER_FLOAT, P_DATA_NUMBER_INTEGER, P_DATA_STRING, P_DATA_UNDEFINED, Push(), PEBLUtility::ResolvePropertyChain(), VariableMap::RetrieveValue(), and PError::SignalFatalError().
| bool Evaluator::Evaluate | ( | const OpNode * | node | ) |
This method evaluates OpNodes.
This switch could probably be improved with an STL Map
Definition at line 186 of file Evaluator.cpp.
References VariableMap::AddVariable(), PError::AssertType(), PList::Begin(), CallFunction(), count, PList::End(), Evaluate(), counted_ptr< X >::get(), Variant::GetComplexData(), Variant::GetDataType(), PNode::GetFunctionName(), Variant::GetFunctionPointer(), Variant::GetInteger(), OpNode::GetLeft(), PNode::GetLineNumber(), PComplexData::GetObject(), OpNode::GetOp(), OpNode::GetOpName(), OpNode::GetRight(), Variant::GetSignal(), GetStackDepth(), PNode::GetType(), DataNode::GetValue(), Variant::GetVariableBaseName(), Variant::GetVariableName(), Variant::GetVariablePropertyName(), gEvalNode, gGlobalVariableMap, Variant::IsComplexData(), Variant::IsGlobalVariable(), Variant::IsInteger(), Variant::IsLocalVariable(), Variant::IsStackSignal(), PList::Length(), NULL, P_DATA_STACK_SIGNAL, pDouble, PEAT_LIST, PEAT_VARIABLE, PEBL_OP_NODE, Peek(), Pop(), Push(), PList::PushBack(), VariableMap::RetrieveValue(), PEBLUtility::SetPropertyChain(), PError::SignalFatalError(), STACK_BREAK, STACK_LIST_HEAD, and STACK_RETURN_DUMMY.
| bool Evaluator::Evaluate | ( | const PNode * | node | ) |
This is the generic PNode evaluator
Definition at line 148 of file Evaluator.cpp.
References Evaluate(), PNode::GetLineNumber(), PNode::GetType(), gEvalNode, NULL, PEBL_DATA_NODE, PEBL_OP_NODE, and PError::SignalFatalError().
Referenced by PEBLEnvironment::CallFunction(), Evaluate(), Evaluate(), PEBLInterpret(), and PEBLInterpret().
| bool Evaluator::Evaluate1 | ( | ) |
Definition at line 199 of file Evaluator-es.cpp.
References Evaluate1().
Referenced by CallFunction(), PEBLEnvironment::CallFunction(), Eval1(), Evaluate1(), Evaluate1(), Evaluate1(), PEventLoop::Loop(), and PEBLInterpret().
| bool Evaluator::Evaluate1 | ( | const DataNode * | node | ) |
This method evaluates DataNodes.
Definition at line 1891 of file Evaluator-es.cpp.
References Variant::GetDataType(), PNode::GetLineNumber(), DataNode::GetValue(), Variant::GetVariableBaseName(), Variant::GetVariablePropertyName(), gEvalNode, gGlobalVariableMap, P_DATA_COMPLEXDATA, P_DATA_GLOBALVARIABLE, P_DATA_LOCALVARIABLE, P_DATA_NUMBER_FLOAT, P_DATA_NUMBER_INTEGER, P_DATA_STRING, P_DATA_UNDEFINED, Push(), PEBLUtility::ResolvePropertyChain(), VariableMap::RetrieveValue(), and PError::SignalFatalError().
| bool Evaluator::Evaluate1 | ( | const OpNode * | node | ) |
This method evaluates OpNodes.
Definition at line 216 of file Evaluator-es.cpp.
References VariableMap::AddVariable(), PError::AssertType(), PList::Begin(), count, PList::End(), Evaluate1(), PList::First(), gCallStack, counted_ptr< X >::get(), Variant::GetComplexData(), Variant::GetDataType(), PNode::GetFilename(), FunctionMap::GetFunction(), PNode::GetFunctionName(), Variant::GetFunctionName(), Variant::GetFunctionPointer(), Variant::GetInteger(), OpNode::GetLeft(), PNode::GetLineNumber(), PComplexData::GetObject(), OpNode::GetOp(), OpNode::GetOpName(), PCustomObject::GetProperty(), OpNode::GetRight(), Variant::GetSignal(), GetStackDepth(), Variant::GetString(), PNode::GetType(), Variant::GetVariableBaseName(), Variant::GetVariableName(), Variant::GetVariablePropertyName(), gEvalNode, gGlobalVariableMap, Variant::IsComplexData(), PComplexData::IsCustomObject(), Variant::IsGlobalVariable(), Variant::IsInteger(), Variant::IsLocalVariable(), Variant::IsStackSignal(), PList::Length(), mFunctionMap, PList::Nth(), NULL, OVE_SUCCESS, P_DATA_FUNCTION, P_DATA_STACK_SIGNAL, pDouble, PEAT_LIST, PEAT_VARIABLE, PEBL_OP_NODE, Peek(), pInt, Pop(), PCallStack::Pop(), PCallStack::Push(), Push(), PList::PushBack(), VariableMap::RetrieveValue(), PEBLUtility::SetPropertyChain(), PError::SignalFatalError(), PCallStack::Size(), STACK_BREAK, STACK_LIST_HEAD, and PCustomObject::ValidateProperty().
| bool Evaluator::Evaluate1 | ( | const PNode * | node | ) |
Definition at line 150 of file Evaluator-es.cpp.
References Evaluate1(), PError::ExitQuietly(), PNode::GetLineNumber(), PNode::GetType(), gEvalNode, NULL, PEBL_DATA_NODE, PEBL_OP_NODE, and PError::SignalFatalError().
|
inline |
|
inline |
|
inline |
Definition at line 86 of file Evaluator-es.h.
Referenced by PEBLEnvironment::CallFunction(), and PEBLInterpret().
|
inline |
Definition at line 87 of file Evaluator-es.h.
Referenced by CallFunction(), PEBLEnvironment::CallFunction(), Evaluate(), Evaluate1(), PEBLInterpret(), Pop(), Push(), and Push().
|
inline |
Definition at line 78 of file Evaluator.h.
| bool Evaluator::IsVariableName | ( | Variant | v | ) |
Definition at line 2169 of file Evaluator-es.cpp.
References VariableMap::Exists(), and gGlobalVariableMap.
Referenced by PEBLEnvironment::VariableExists().
| bool Evaluator::IsVariableName | ( | Variant | v | ) |
| void Evaluator::NodeStackPush | ( | const PNode * | node | ) |
Definition at line 2176 of file Evaluator-es.cpp.
Referenced by PEBLEnvironment::CallFunction(), and PEventLoop::Loop1().
| Variant Evaluator::Peek | ( | ) |
Definition at line 2154 of file Evaluator-es.cpp.
References PError::SignalFatalError().
Referenced by CallFunction(), Evaluate(), and Evaluate1().
| const Variant & Evaluator::Peek | ( | ) | const |
Definition at line 1525 of file Evaluator.cpp.
References PError::SignalFatalError().
| Variant Evaluator::Pop | ( | ) |
Definition at line 2134 of file Evaluator-es.cpp.
References GetStackDepth(), and PError::SignalFatalError().
Referenced by CallFunction(), PEBLEnvironment::CallFunction(), Evaluate(), Evaluate1(), and PEBLInterpret().
| Variant Evaluator::Pop | ( | ) |
| void Evaluator::Push | ( | const Variant & | v | ) |
Definition at line 1485 of file Evaluator.cpp.
References GetStackDepth(), and PError::SignalFatalError().
| void Evaluator::Push | ( | Variant | v | ) |
Definition at line 2114 of file Evaluator-es.cpp.
References GetStackDepth(), and PError::SignalFatalError().
Referenced by CallFunction(), PEBLEnvironment::CallFunction(), Evaluate(), Evaluate(), Evaluate1(), Evaluate1(), and Evaluator().
|
friend |
Definition at line 61 of file Evaluator-es.h.
Referenced by Evaluator(), and Evaluator().
|
static |
Definition at line 120 of file Evaluator-es.h.
Referenced by Evaluate1(), Evaluator(), and Evaluator().
This is used for error detection. Every time gEvalNode is updated, this is set to gEvalNode. But, it is done for all evaluators. Thus, it always points to the last node processed, and error reporting routines can look for it and find out where it came from.
Definition at line 117 of file Evaluator-es.h.
Referenced by Evaluate(), Evaluate(), Evaluate(), Evaluate1(), Evaluate1(), Evaluate1(), Evaluator(), Evaluator(), and PError::SignalWarning().
|
static |
The static keyword defines a 'Global' variable map that can be accessed\all Evaluators. It needs to be initialized somewhere outside the class, however. This is done in the main program file.
Definition at line 104 of file Evaluator-es.h.
Referenced by CaptureSignal(), Evaluate(), Evaluate(), Evaluate1(), Evaluate1(), PlatformWindow::Initialize(), IsVariableName(), PEventLoop::Loop(), PEventLoop::Loop1(), main(), PEBLObjects::MakeTextBox(), PEBLObjects::MakeWindow(), PEBLInterpret(), PlatformEventQueue::Prime(), and PlatformWindow::Resize().
|
static |
Definition at line 108 of file Evaluator-es.h.
Referenced by PEBLStream::AppendFile(), PEBLStream::CopyFile(), PEBLStream::FileReadList(), PEBLStream::FileReadTable(), PEBLStream::FileReadText(), PlatformImageBox::LoadImage(), PlatformAudioOut::LoadSoundFile(), main(), PEBLInterpret(), PlatformAudioOut::PlatformAudioOut(), PlatformFont::PlatformFont(), PlatformFont::PlatformFont(), PlatformFont::SetFontSize(), and PlatformFont::SetFontStyle().
|
static |
Definition at line 106 of file Evaluator-es.h.
Referenced by PEBLEnvironment::ClearEventLoop(), Evaluator(), Evaluator(), GetEventLoop(), PEBLEnvironment::GetInput0(), PEBLEnvironment::PlayMovie(), PEBLEnvironment::RegisterEvent(), PEBLEnvironment::StartEventLoop(), PEBLEnvironment::Wait(), PEBLEnvironment::WaitForAllKeysUp(), PEBLEnvironment::WaitForAnyKeyDown(), PEBLEnvironment::WaitForAnyKeyDownWithTimeout(), PEBLEnvironment::WaitForAnyKeyPress(), PEBLEnvironment::WaitForAnyKeyPressWithTimeout(), PEBLEnvironment::WaitForKeyDown(), PEBLEnvironment::WaitForKeyListDown(), PEBLEnvironment::WaitForKeyPress(), PEBLEnvironment::WaitForKeyRelease(), PEBLEnvironment::WaitForKeyUp(), PEBLEnvironment::WaitForListKeyPress(), PEBLEnvironment::WaitForListKeyPressWithTimeout(), PEBLEnvironment::WaitForMouseButton(), and PEBLEnvironment::WaitForMouseButtonWithTimeout().
|
static |
Initiate some static member data.
This holds a pointer to a FunctionMap, which is loaded from the initial PNode tree by the loader. It is static and public, which means that all Evaluators have access to the same one, and anything else can access it with Evaluator::mFunctionMap
Definition at line 99 of file Evaluator-es.h.
Referenced by CallFunction(), PEBLEnvironment::CallFunction(), CaptureSignal(), Evaluate1(), Loader::GetMainPEBLFunction(), Loader::LoadLibraryFunctions(), Loader::LoadUserFunctions(), and PEBLInterpret().