Ejemplo n.º 1
0
        public object Call(Interpreter interpreter, List <object> arguments)
        {
            ElizInstance instance = new ElizInstance(this);

            ElizFunction initializer = FindMethod("init");

            if (initializer != null)
            {
                initializer.Bind(instance).Call(interpreter, arguments);
            }

            return(instance);
        }
Ejemplo n.º 2
0
        public object Get(Token name)
        {
            if (fields.ContainsKey(name.Lexeme))
            {
                return(fields[name.Lexeme]);
            }

            ElizFunction method = klass.FindMethod(name.Lexeme);

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

            throw new RuntimeError(name,
                                   $"Undefined property '{name.Lexeme}'.");
        }