Ejemplo n.º 1
0
        public dynamic Invoke(ScriptExecutionContext context, params dynamic[] args)
        {
            if (this.defaults != null && args.Length < this.defaults.Length)
            {
                dynamic[] newArgs = new dynamic[this.defaults.Length];

                for (int i = 0; i < args.Length; i++)
                {
                    newArgs[i] = args[i];
                }

                for (int i = args.Length; i < this.defaults.Length; i++)
                {
                    newArgs[i] = this.defaults[i];
                }

                args = newArgs;
            }

            object[] invokeArgs = new object[args.Length + 2];
            invokeArgs[0] = context;
            invokeArgs[1] = this.captures;

            for (int i = 0; i < args.Length; i++)
                invokeArgs[i + 2] = args[i];

            return this.func.DynamicInvoke(invokeArgs);
        }
Ejemplo n.º 2
0
        public ScriptEngine()
        {
            this.lexer = new ScriptLexer();
            this.parser = new ScriptParser();
            this.codeGenerator = new CodeGenerator();
            this.codeCompiler = new CodeCompiler();

            this.executionContext = new ScriptExecutionContext();
        }