--- trunk/OOPSE-3.0/src/selection/SelectionEvaluator.hpp 2005/02/01 06:55:00 1961 +++ trunk/OOPSE-3.0/src/selection/SelectionEvaluator.hpp 2005/02/01 22:49:23 1962 @@ -53,6 +53,15 @@ namespace oopse { namespace oopse { +class Context { + std::string filename; + std::tring script; + std::vector linenumbers; + std::vector lineIndices; + std::vector > aatoken; + int pc; +} + /** * @class SelectionEvaluator SelectionEvaluator.hpp "selection/SelectionEvaluator" * @brief Evalute the tokens compiled by SelectionCompiler and return a BitSet @@ -62,6 +71,7 @@ class SelectionEvaluator{ SelectionEvaluator(SimInfo* info, const std::string& script); + BitSet evaluate(); BitSet evaluate(int frameNo); @@ -71,23 +81,78 @@ class SelectionEvaluator{ * @return true if the result keeps the same even the frame change, otherwise return false */ bool isStatic(); - + + bool hadRuntimeError() const{ + return error; + } + + std::string getErrorMessage() const { + return errorMessage; + } + + + int getLinenumber() { + return linenumbers[pc]; + } + + std::string getLine() { + int ichBegin = lineIndices[pc]; + int ichEnd; + if ((ichEnd = script.find('\r', ichBegin)) == std::string:npos && + (ichEnd = script.find('\n', ichBegin)) == std::string:npos) { + ichEnd = script.size(); + } + return script.substr(ichBegin, ichEnd); + } + private: - /** */ - void define(); + void clearState(); + + bool loadScript(const std::string& filename, const std::string& script); - /** */ + bool loadScriptString(const std::string& script); + + bool loadScriptFileInternal(const std::string& filename); + + void clearDefinitionsAndLoadPredefined(); + + void define(); + void predefine(); + void instructionDispatchLoop(); + withinInstruction(Token instruction, BitSet , BitSet); BitSet expression(std::vector& tokens, int pc); - + + SelectionCompiler compiler; + + const static int scriptLevelMax = 10; + int scriptLevel; + + Context stack[scriptLevelMax]; + + std::string filename; + std::string script; + std::vector linenumbers; + std::vector lineIndices; + std::vector > aatoken; + int pc; // program counter + + boolean error; + std::string errorMessage; + + std::vector statement; + int statementLength; + SimInfo* info_; std::map > variables_; std::string script_; + + Hashtable variables = new Hashtable(); }; }