예제 #1
0
파일: Lua.cs 프로젝트: lsjsoft/NetLua
        /// <summary>
        /// Parses and executes the specified string
        /// </summary>
        public LuaArguments DoString(string Chunk)
        {
            FunctionDefinition def = new FunctionDefinition();

            def.Arguments = new List <Argument>();
            def.Body      = p.ParseString(Chunk);
            var function = LuaCompiler.CompileFunction(def, Expression.Constant(ctx)).Compile();

            return(function().Call(Lua.Return()));
        }
예제 #2
0
파일: Lua.cs 프로젝트: lsjsoft/NetLua
        /// <summary>
        /// Parses and executes the specified parsed block
        /// </summary>
        public LuaArguments DoAst(Block block)
        {
            FunctionDefinition def = new FunctionDefinition();

            def.Arguments = new List <Argument>();
            def.Body      = block;
            var function = LuaCompiler.CompileFunction(def, Expression.Constant(ctx)).Compile();

            return(function().Call(Lua.Return()));
        }
예제 #3
0
        /// <summary>
        /// Parses and executes the specified file
        /// </summary>
        /// <param name="Filename">The file to execute</param>
        public LuaArguments DoFile(string Filename)
        {
            #if INTERPRETED
            LuaInterpreter.LuaReturnStatus ret;
            return(LuaInterpreter.EvalBlock(p.ParseFile(Filename), ctx, out ret));
            #endif

            #if COMPILED
            FunctionDefinition def = new FunctionDefinition();
            def.Arguments = new List <Argument>();
            def.Body      = p.ParseFile(Filename);
            var function = LuaCompiler.CompileFunction(def, Expression.Constant(ctx)).Compile();
            return(function().Call(Lua.Return()));
            #endif
        }