evaluate method
dynamic
evaluate({
- Node? node,
Implementation
evaluate({Node? node}) {
dynamic rtn;
try {
if (node != null) {
rtn = visit(node);
} else {
//first visit all the function declarations
for (int i = program.body.length - 1; i >= 0; i--) {
Statement stmt = program.body[i];
if (stmt is FunctionDeclaration) {
stmt.visitBy(this);
}
}
rtn = visit(program);
if (rtn is Name) {
rtn = getValue(rtn);
}
}
} on ControlFlowReturnException catch (e) {
rtn = e.returnValue;
} on JSException catch (e) {
rethrow;
} catch (e) {
throw JSException(1, e.toString(),
detailedError: 'Code: $code', originalError: e);
}
return rtn;
}