Пример #1
0
        public LoxFunction Bind(LoxInstance loxInstance)
        {
            var environment = new Environment(_closure);

            environment.Define("this", loxInstance);
            return(new LoxFunction(_name, _declaration, environment, _isInitializer));
        }
Пример #2
0
        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);
        }