示例#1
0
        public object visitSuperExpr(Expr.Super expr)
        {
            if (currentClass == ClassType.NONE)
            {
                Jingle.Error(expr.keyword, "Cannot use 'super' outside of a class.");
            }
            else if (currentClass != ClassType.SUBCLASS)
            {
                Jingle.Error(expr.keyword, "Cannot use 'super' in a class with no superclass.");
            }

            resolveLocal(expr, expr.keyword);
            return(null);
        }
示例#2
0
        public object visitSuperExpr(Expr.Super expr)
        {
            int         distance   = locals[expr];
            JingleClass superclass = (JingleClass)environment.getAt(distance, "super");

            Instance object_ = (Instance)environment.getAt(distance - 1, "this");

            JingleFunc method = superclass.findMethod(expr.method.lexeme);

            if (method == null)
            {
                throw new RuntimeError(expr.method, "Undefined property '" + expr.method.lexeme + "'.");
            }

            return(method.bind(object_));
        }
示例#3
0
 public string visitSuperExpr(Expr.Super expr)
 {
     return("");
 }