visitSuperExpr method
Implementation
@override
Object? visitSuperExpr(Expr.Super expr) {
int distance = locals[expr]!;
LoxClass superclass = environment.getAt(distance, "super") as LoxClass;
LoxInstance object = environment.getAt(distance - 1, "this") as LoxInstance;
LoxFunction? method = superclass.findMethod(expr.method.lexeme);
if (method == null) {
throw RuntimeError(
expr.method, "Undefined property '${expr.method.lexeme}'.");
}
return method.bind(object);
}