Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
 public WavyFunction find_method(WavyObject obj, string identifier)
 {
     // Find method in this class
     if (this.methods.ContainsKey(identifier))
     {
         return(methods[identifier].bind(obj));
     }
     // Find method in superclass
     if (superclass != null)
     {
         return(superclass.find_method(obj, identifier));
     }
     return(null);
 }
Ejemplo n.º 3
0
    public object get(string identifier)
    {
        // Check class methods
        WavyFunction method = the_class.find_method(this, identifier);

        if (method != null)
        {
            return(method);
        }
        // Check object members
        object member = find_member(identifier);

        if (member != null)
        {
            return(member);
        }
        throw new RuntimeException("Class member/method cannot be found '" + identifier + "'");
    }