resolveLocal method

int resolveLocal(
  1. Expr expr,
  2. Token name
)

Implementation

int resolveLocal(Expr.Expr expr, Token name) {
  for (int i = scopes.length - 1; i >= 0; i--) {
    if (scopes.get(i).containsKey(name.lexeme)) {
      interpreter.resolve(expr, scopes.length - 1 - i);
      return scopes.length - 1 - i;
    }
  }
  return -1;
}