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);
    }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
File: Matcher.cs Progetto: sula0/Lox
 protected abstract object MatchSuperExpr(SuperExpr superExpr);
Esempio n. 6
0
 public virtual void Visit(SuperExpr expr)
 {
 }
Esempio n. 7
0
 public override void Visit(SuperExpr expr)
 {
 }
Esempio n. 8
0
 public override void Visit(SuperExpr expr)
 {
     AddStr("super." + expr.method.lexeme);
 }