Exemple #1
0
        internal LoxFunction Bind(LoxInstance instance)
        {
            Environment environment = new Environment(closure);

            environment.Define("this", instance);
            return(new LoxFunction(declaration, environment, isInitializer));
        }
Exemple #2
0
        public object Call(Interpreter interpreter, List <object> arguments)
        {
            LoxInstance instance   = new LoxInstance(this);
            LoxFunction initilizer = FindMethod("init");

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