public Nothing VisitSuperExpr(Expr.Super expr) { if (currentClass == ClassType.None) { Lox.Error(expr.Keyword, "Cannot use 'super' outside of a class."); } else if (currentClass != ClassType.Subclass) { Lox.Error(expr.Keyword, "Cannot use 'super' in a class with no superclass."); } ResolveLocal(expr, expr.Keyword); return(Nothing.AtAll); }
public object VisitSuperExpr(Expr.Super expr) { int distance = locals[expr]; LoxClass superclass = (LoxClass)environment.GetAt(distance, "super"); // "this" is always one level nearer than "super"'s environment. LoxInstance objekt = (LoxInstance)environment.GetAt(distance - 1, "this"); LoxFunction method = superclass.FindMethod(objekt, expr.Method.Lexeme); if (method == null) { throw new RuntimeError(expr.Method, $"Undefined property '{expr.Method.Lexeme}'."); } return(method); }
public string VisitSuperExpr(Expr.Super expr) { throw new System.NotImplementedException(); }