Beispiel #1
0
        public LoxFunction Bind(LoxInstance loxInstance)
        {
            var environment = new Environment(_closure);

            environment.Define("this", loxInstance);
            return(new LoxFunction(_name, _declaration, environment, _isInitializer));
        }
        public object Call(Interpreter interpreter, List <object> arguments)
        {
            var instance    = new LoxInstance(this);
            var initializer = FindMethod("init");

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

            return(instance);
        }