| 53 |  |  | 
| 54 |  | namespace oopse { | 
| 55 |  |  | 
| 56 | + | class Context { | 
| 57 | + | std::string filename; | 
| 58 | + | std::tring script; | 
| 59 | + | std::vector<int> linenumbers; | 
| 60 | + | std::vector<int> lineIndices; | 
| 61 | + | std::vector<std::vector<Token> > aatoken; | 
| 62 | + | int pc; | 
| 63 | + | } | 
| 64 | + |  | 
| 65 |  | /** | 
| 66 |  | * @class SelectionEvaluator SelectionEvaluator.hpp "selection/SelectionEvaluator" | 
| 67 |  | * @brief Evalute the tokens compiled by SelectionCompiler and return a BitSet | 
| 71 |  |  | 
| 72 |  | SelectionEvaluator(SimInfo* info, const std::string& script); | 
| 73 |  |  | 
| 74 | + |  | 
| 75 |  | BitSet evaluate(); | 
| 76 |  |  | 
| 77 |  | BitSet evaluate(int frameNo); | 
| 81 |  | * @return true if the result keeps the same even the frame change, otherwise return false | 
| 82 |  | */ | 
| 83 |  | bool isStatic(); | 
| 84 | < |  | 
| 84 | > |  | 
| 85 | > | bool hadRuntimeError() const{ | 
| 86 | > | return error; | 
| 87 | > | } | 
| 88 | > |  | 
| 89 | > | std::string getErrorMessage() const { | 
| 90 | > | return errorMessage; | 
| 91 | > | } | 
| 92 | > |  | 
| 93 | > |  | 
| 94 | > | int getLinenumber() { | 
| 95 | > | return linenumbers[pc]; | 
| 96 | > | } | 
| 97 | > |  | 
| 98 | > | std::string getLine() { | 
| 99 | > | int ichBegin = lineIndices[pc]; | 
| 100 | > | int ichEnd; | 
| 101 | > | if ((ichEnd = script.find('\r', ichBegin)) == std::string:npos && | 
| 102 | > | (ichEnd = script.find('\n', ichBegin)) == std::string:npos) { | 
| 103 | > | ichEnd = script.size(); | 
| 104 | > | } | 
| 105 | > | return script.substr(ichBegin, ichEnd); | 
| 106 | > | } | 
| 107 | > |  | 
| 108 |  | private: | 
| 109 |  |  | 
| 110 | < | /** */ | 
| 111 | < | void define(); | 
| 110 | > | void clearState(); | 
| 111 | > |  | 
| 112 | > | bool loadScript(const std::string& filename, const std::string& script); | 
| 113 |  |  | 
| 114 | < | /** */ | 
| 114 | > | bool loadScriptString(const std::string& script); | 
| 115 | > |  | 
| 116 | > | bool loadScriptFileInternal(const std::string& filename); | 
| 117 | > |  | 
| 118 | > | void clearDefinitionsAndLoadPredefined(); | 
| 119 | > |  | 
| 120 | > | void define(); | 
| 121 | > |  | 
| 122 |  | void predefine(); | 
| 123 |  |  | 
| 124 | + | void instructionDispatchLoop(); | 
| 125 | + |  | 
| 126 |  | withinInstruction(Token instruction, BitSet , BitSet); | 
| 127 |  |  | 
| 128 |  | BitSet expression(std::vector<Token>& tokens, int pc); | 
| 129 | < |  | 
| 129 | > |  | 
| 130 | > | SelectionCompiler compiler; | 
| 131 | > |  | 
| 132 | > | const static int scriptLevelMax = 10; | 
| 133 | > | int scriptLevel; | 
| 134 | > |  | 
| 135 | > | Context stack[scriptLevelMax]; | 
| 136 | > |  | 
| 137 | > | std::string filename; | 
| 138 | > | std::string script; | 
| 139 | > | std::vector<int> linenumbers; | 
| 140 | > | std::vector<int> lineIndices; | 
| 141 | > | std::vector<std::vector<Token> > aatoken; | 
| 142 | > | int pc; // program counter | 
| 143 | > |  | 
| 144 | > | boolean error; | 
| 145 | > | std::string errorMessage; | 
| 146 | > |  | 
| 147 | > | std::vector<Token> statement; | 
| 148 | > | int statementLength; | 
| 149 | > |  | 
| 150 |  | SimInfo* info_; | 
| 151 |  |  | 
| 152 |  | std::map<std::string, std::vector<Token> > variables_; | 
| 153 |  | std::string script_; | 
| 154 | + |  | 
| 155 | + | Hashtable variables = new Hashtable(); | 
| 156 |  | }; | 
| 157 |  |  | 
| 158 |  | } |