Пример #1
0
        public EnkelFunction Bind(EnkelInstance instance)
        {
            var env = new EnkelEnvironment(_closure);

            env.Define(new DummyToken(TokenType.This, "this", null, 0), instance);
            return(new EnkelFunction(_declaration, env, _isConstructor));
        }
Пример #2
0
        public object Call(IInterpreter interpreter, IList <object> args)
        {
            var instance = new EnkelInstance(this);

            if (Methods.TryGetValue("constructor", out var constructor))
            {
                constructor.Bind(instance).Call(interpreter, args);
            }

            return(instance);
        }