Beispiel #1
0
        public LoxFunction Bind(LoxInstance instance)
        {
            var env = new Environment(Closure);

            env.Define("this", instance);
            return(new LoxFunction(Declaration, env, IsInitializer));
        }
Beispiel #2
0
        public object Call(Interpreter interpreter, List <object> arguments)
        {
            var instance    = new LoxInstance(this);
            var initializer = FindMethod(ConstructorName);

            if (initializer is not null)
            {
                initializer.Bind(instance).Call(interpreter, arguments);
            }

            return(instance);
        }