public object visit_super(SuperExpr super_expr) { // Get the superclass and the 'this' object PlutoClass superclass = (PlutoClass)local_scope.get(new Token(Token.Type.Super, "super")); PlutoObject obj = (PlutoObject)local_scope.get(new Token(Token.Type.This, "this")); // Get the method from the superclass PlutoFunction method = superclass.find_method(obj, (string)super_expr.identifier.value); if (method == null) { throw new RuntimeException("Undefined method of superclass '" + super_expr.identifier.value + "'"); } return(method); }
public object visit_super(SuperExpr super_expr) { // Get the superclass and the 'this' object WavyClass superclass = (WavyClass)local_scope.get("super"); WavyObject obj = (WavyObject)local_scope.get("this"); // Get the method from the superclass WavyFunction method = superclass.find_method(obj, (string)super_expr.identifier.value); if (method == null) { throw new RuntimeException("Undefined method of superclass '" + super_expr.identifier.value + "'"); } return(method); }
public object visit_super(SuperExpr super_expr) { if (class_type == ClassType.None) { throw new RuntimeException("Cannot use super outside of a class"); } else if (class_type != ClassType.SubClass) { throw new RuntimeException("Cannot use super in a class that doesn't extend another"); } // Resolve the super identifier // This may need to be changed to identifier resolve_local_position(super_expr, "super"); return(null); }
protected override object MatchSuperExpr(SuperExpr 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 supeclass."); } ResolveLocal(expr, expr.Keyword); return(null); }
protected abstract object MatchSuperExpr(SuperExpr superExpr);
public virtual void Visit(SuperExpr expr) { }
public override void Visit(SuperExpr expr) { }
public override void Visit(SuperExpr expr) { AddStr("super." + expr.method.lexeme); }