]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/lua/lib/contrib/src/lundump.c
update
[l4.git] / l4 / pkg / lua / lib / contrib / src / lundump.c
index 8010a45795ba095b17f17b9f742360e4818b83cb..2c68a64fe91276c4f09636e062946e9ee5be7875 100644 (file)
@@ -73,6 +73,15 @@ static lua_Number LoadNumber(LoadState* S)
  return x;
 }
 
+#ifdef LUA_TINT
+static lua_Integer LoadInteger(LoadState* S)
+{
+ lua_Integer x;
+ LoadVar(S,x);
+ return x;
+}
+#endif
+
 static TString* LoadString(LoadState* S)
 {
  size_t size;
@@ -119,6 +128,11 @@ static void LoadConstants(LoadState* S, Proto* f)
    case LUA_TNUMBER:
        setnvalue(o,LoadNumber(S));
        break;
+#ifdef LUA_TINT
+   case LUA_TINT:   /* Integer type saved in bytecode (see lcode.c) */
+       setivalue(o,LoadInteger(S));
+       break;
+#endif
    case LUA_TSTRING:
        setsvalue2n(S->L,o,LoadString(S));
        break;
@@ -223,5 +237,19 @@ void luaU_header (char* h)
  *h++=(char)sizeof(size_t);
  *h++=(char)sizeof(Instruction);
  *h++=(char)sizeof(lua_Number);
- *h++=(char)(((lua_Number)0.5)==0);            /* is lua_Number integral? */
+
+ /* 
+  * Last byte of header (0/1 in unpatched Lua 5.1.3):
+  *
+  * 0: lua_Number is float/double/ldouble (nonpatched only)
+  * 1: lua_Number is integer (nonpatched only)
+  * 4: LNUM_INT32: sizeof(lua_Integer)
+  * 8: LNUM_INT64: sizeof(lua_Integer)
+  * +0x80: LNUM_COMPLEX
+  */
+ *h++ = (char)( sizeof(lua_Integer)
+#ifdef LNUM_COMPLEX
+    | 0x80
+#endif
+    );
 }