getExpression method

Expression getExpression(
  1. String varName
)

Returns the bound expression for the given variable. Performs recursive lookup through parentScope.

Throws a StateError, if variable is still unbound at the root scope.

Implementation

Expression getExpression(String varName) {
  if (variables.containsKey(varName)) {
    return variables[varName]!;
  }

  if (parentScope != null) {
    return parentScope!.getExpression(varName);
  } else {
    throw StateError('Variable not bound: $varName');
  }
}