|
PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
|
#include <Loader.h>
Public Member Functions | |
| Loader () | |
| ~Loader () | |
| void | FindFunctions (const PNode *Node) |
| void | LoadUserFunctions (OpNode *node) |
| void | LoadLibraryFunctions () |
| bool | Verify () |
| PNode * | GetMainPEBLFunction () |
| void | DumpFunctionSet () |
This class takes a parsed program and loads it into the evaluation environment. This involves following the upper levels of the parse tree (which in effect form a list of function/functions nodes) and moving functions into a FunctionMap. It also does preliminary checking, and can be a place to do other debugging stuff and perhaps optimizing.
| Loader::Loader | ( | ) |
Definition at line 69 of file Loader.cpp.
| Loader::~Loader | ( | ) |
Definition at line 74 of file Loader.cpp.
| void Loader::DumpFunctionSet | ( | ) |
Definition at line 385 of file Loader.cpp.
Referenced by PEBLInterpret().
| void Loader::FindFunctions | ( | const PNode * | node | ) |
This will perform a recursive search through a node tree and place the names of any functions it finds in the list mFunctionList, for later use by the verify routine. This probably could be done more quickly during the initial parse, or eliminated altogether for faster (riskier) loading.
This will perform a recursive search through a node tree and place the names of any functions it finds in the list mFunctionSet, for later use by the verify routine.
Definition at line 88 of file Loader.cpp.
References FindFunctions(), PNode::GetType(), P_DATA_FUNCTION, PEBL_DATA_NODE, and PEBLUtility::ToUpper().
Referenced by FindFunctions(), main(), PEBLInterpret(), and PEBLInterpret().
| PNode * Loader::GetMainPEBLFunction | ( | ) |
This looks inside the functionmap for a function titled "start", which it then retrieves.
Definition at line 372 of file Loader.cpp.
References FunctionMap::GetFunction(), and Evaluator::mFunctionMap.
Referenced by main(), PEBLInterpret(), and PEBLInterpret().
| void Loader::LoadLibraryFunctions | ( | ) |
If any functions found by FindFunctions are in libraries, this method will load them properly.
If any functions found by FindFunctions are in libraries, this method will load them properly. The method iterates through mFunctionSet, checking each item first against mFunctionMap to see if it has already been loaded (e.g., user functions), and then each of the standard function libraries
Definition at line 195 of file Loader.cpp.
References FunctionMap::AddFunction(), FunctionMap::DumpValues(), PEBLMath::FunctionTable, PEBLStream::FunctionTable, PEBLObjects::FunctionTable, PEBLEnvironment::FunctionTable, PEBLList::FunctionTable, PEBLString::FunctionTable, Evaluator::mFunctionMap, NULL, PNode::SetFunctionName(), and PError::SignalFatalError().
Referenced by main(), PEBLInterpret(), and PEBLInterpret().
| void Loader::LoadUserFunctions | ( | OpNode * | node | ) |
This will load the parsed PNode tree into mFunctionList, for use by the Evaluator.
This marches through the topmost nodes of the PNode tree and puts functions in the mFunctionMap. These nodes will all be either PEBL_FUNCTIONS or PEBL_FUNCTION.
Definition at line 147 of file Loader.cpp.
References FunctionMap::AddFunction(), OpNode::GetLeft(), OpNode::GetOp(), OpNode::GetRight(), LoadUserFunctions(), Evaluator::mFunctionMap, and PError::SignalFatalError().
Referenced by LoadUserFunctions(), main(), PEBLInterpret(), and PEBLInterpret().
| bool Loader::Verify | ( | ) |
This checks to see whether everything loaded into the environment is legal; i.e, if all functions used exist.
This method checks to see whether everything is ready for a potentially error-free run. This includes determining whether all of the used functions actually exist, and if there is an entry function, and perhaps other stuff tbd later.
Definition at line 365 of file Loader.cpp.