Evaluates 'code' and returns the output, or any error, as a String. @see ij.Macro#eval
(String code)
| 123 | * @see ij.Macro#eval |
| 124 | */ |
| 125 | public String eval(String code) { |
| 126 | Interpreter saveInstance = instance; |
| 127 | if (pgm!=null) |
| 128 | reuseSymbolTable(); |
| 129 | Tokenizer tok = new Tokenizer(); |
| 130 | Program pgm = tok.tokenize(code); |
| 131 | if (pgm.hasVars && pgm.hasFunctions) |
| 132 | saveGlobals2(pgm); |
| 133 | evaluating = true; |
| 134 | evalOutput = null; |
| 135 | ignoreErrors = true; |
| 136 | calledMacro = true; |
| 137 | run(pgm); |
| 138 | instance = saveInstance; |
| 139 | if (errorMessage!=null) |
| 140 | return errorMessage; |
| 141 | else |
| 142 | return evalOutput; |
| 143 | } |
| 144 | |
| 145 | private void reuseSymbolTable() { |
| 146 | if (pgm==null) |
nothing calls this directly
no test coverage detected