示例#1
0
        private static void F_Load(ref LoadParameter param)
        {
            var L = param.L;

            LuaProto proto;
            var      c = param.LoadInfo.PeekByte();

            if (c == LuaConf.LUA_SIGNATURE[0])
            {
                L.CheckMode(param.Mode, "binary");
                proto = Undump.LoadBinary(L, param.LoadInfo, param.Name);
            }
            else
            {
                L.CheckMode(param.Mode, "text");
                proto = Parser.Parse(L, param.LoadInfo, param.Name);
            }

            var cl = new LuaLClosureValue(proto);

            Utl.Assert(cl.Upvals.Length == cl.Proto.Upvalues.Count);

            L.Top.V.SetClLValue(cl);
            L.IncrTop();
        }
示例#2
0
 public static LuaProto LoadBinary(ILuaState lua,
                                   ILoadInfo loadinfo, string name)
 {
     try
     {
         var reader = new BinaryBytesReader(loadinfo);
         var undump = new Undump(reader);
         undump.LoadHeader();
         return(undump.LoadFunction());
     }
     catch (UndumpException e)
     {
         var Lua = (LuaState)lua;
         Lua.O_PushString(string.Format(
                              "{0}: {1} precompiled chunk", name, e.Why));
         Lua.D_Throw(ThreadStatus.LUA_ERRSYNTAX);
         return(null);
     }
 }
示例#3
0
文件: Undump.cs 项目: rokyado/UniLua
        public static LuaProto LoadBinary( ILuaState lua,
			ILoadInfo loadinfo, string name )
        {
            try
            {
                var reader = new BinaryBytesReader( loadinfo );
                var undump = new Undump( reader );
                undump.LoadHeader();
                return undump.LoadFunction();
            }
            catch( UndumpException e )
            {
                var Lua = (LuaState)lua;
                Lua.O_PushString( string.Format(
                    "{0}: {1} precompiled chunk", name, e.Why ) );
                Lua.D_Throw( ThreadStatus.LUA_ERRSYNTAX );
                return null;
            }
        }