Exemplo n.º 1
0
 public FunctionClosure(Table env, FunctionClosure f)
     : this(env, f.f)
 {
     stack.AddRange(f.stack);
     upValues.AddRange(f.upValues);
     if ((f.f.IsVarargFlag & VirtualMachine.VARARG_ISVARARG) != 0) {
         vararg.AddRange(f.vararg);
     }
 }
Exemplo n.º 2
0
            public Closure CompileString(string str, string filename)
            {
                #if PINVOKE_ENABLED
                string luaFileName = Path.GetTempFileName();
                string luacFileName = Path.GetTempFileName();
                try {
                    File.WriteAllText(luaFileName, str);
                    var psinfo = new System.Diagnostics.ProcessStartInfo();
                    psinfo.FileName = "luac";
                    psinfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    psinfo.Arguments = string.Format("-o \"{0}\" \"{1}\"", luacFileName, luaFileName);
                    System.Diagnostics.Process.Start(psinfo).WaitForExit();
                    Function f;
                    using (FileStream fs = File.OpenRead(luacFileName)) {
                        f = vm.ReadChunk(fs, filename);
                    }
                    FunctionClosure fc = new FunctionClosure(vm.globals, f);
                    return fc;
                }
                finally {
                    File.Delete(luacFileName);
                    File.Delete(luaFileName);
                }

                #else
                throw new NotSupportedException("Cannot compile lua strings without the native luac.");
                #endif
            }
Exemplo n.º 3
0
 //Run a non-top function
 //TODO: clarify Run functions
 private object[] Run(FunctionClosure topFunction)
 {
     return Run(new LuaThread(topFunction.env, topFunction, this));
 }