public object VisitSuperExpr(Expr.Super expr) { if (currentClass == ClassType.None) { Basil.Error(expr.Keyword, "Cannot use 'super' outside of a class."); } else if (currentClass != ClassType.Subclass) { Basil.Error(expr.Keyword, "Cannot use 'super' in a class with no superclass."); } ResolveLocal(expr, expr.Keyword); return(null); }
public object VisitSuperExpr(Expr.Super expr) { int distance = locals[expr]; BasilClass superclass = (BasilClass)environment.GetAt(distance, "super"); // "this" is always one level nearer than "super"'s environment. BasilInstance objekt = (BasilInstance)environment.GetAt(distance - 1, "this"); BasilFunction 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(); }