Esempio n. 1
0
        public object Call(Interpreter interpreter, List <object> arguments)
        {
            LoxInstance instance   = new LoxInstance(this);
            LoxFunction initilizer = FindMethod("init");

            if (initilizer != null)
            {
                initilizer.Bind(instance).Call(interpreter, arguments);
            }
            return(instance);
        }
Esempio n. 2
0
        internal object Get(Token name)
        {
            if (fields.ContainsKey(name.lexeme))
            {
                return(fields[name.lexeme]);
            }

            LoxFunction method = klass.FindMethod(name.lexeme);

            if (method != null)
            {
                return(method.Bind(this));
            }

            throw new RuntimeError(name, "Undefined property '" + name.lexeme + "'.");
        }