Exemplo n.º 1
0
        public LuxFunction Bind(LuxInstance instance)
        {
            var environment = new Environment(_closure);

            environment.Define("this", instance);
            return(new(_declaration, environment, _isInitializer));
        }
Exemplo n.º 2
0
        public object Call(Interpreter interpreter, List <object> arguments)
        {
            var instance = new LuxInstance(this);

            var initializer = FindMethod("init");

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

            return(instance);
        }