aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lobject.c19
-rw-r--r--lobject.h4
-rw-r--r--ltests.c4
-rw-r--r--lvm.c4
4 files changed, 20 insertions, 11 deletions
diff --git a/lobject.c b/lobject.c
index df571242..666bb466 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.4 2004/07/09 16:01:38 roberto Exp roberto $ 2** $Id: lobject.c,v 2.5 2004/10/06 18:34:16 roberto Exp $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -31,12 +31,21 @@ const TValue luaO_nilobject = {{NULL}, LUA_TNIL};
31** (mmmmmxxx), where the real value is (xxx) * 2^(mmmmm) 31** (mmmmmxxx), where the real value is (xxx) * 2^(mmmmm)
32*/ 32*/
33int luaO_int2fb (unsigned int x) { 33int luaO_int2fb (unsigned int x) {
34 int m = 0; /* mantissa */ 34 int e = 0; /* expoent */
35 while (x >= (1<<3)) { 35 while (x >= 16) {
36 x = (x+1) >> 1; 36 x = (x+1) >> 1;
37 m++; 37 e++;
38 } 38 }
39 return (m << 3) | cast(int, x); 39 if (x < 8) return x;
40 else return ((e+1) << 3) | (cast(int, x) - 8);
41}
42
43
44/* converts back */
45int luaO_fb2int (int x) {
46 int e = (x >> 3) & 31;
47 if (e == 0) return x;
48 else return ((x & 7)+8) << (e - 1);
40} 49}
41 50
42 51
diff --git a/lobject.h b/lobject.h
index b407a196..fb54c3d8 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 2.5 2004/05/31 18:51:50 roberto Exp roberto $ 2** $Id: lobject.h,v 2.6 2004/10/06 18:34:16 roberto Exp $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -352,7 +352,7 @@ extern const TValue luaO_nilobject;
352 352
353int luaO_log2 (unsigned int x); 353int luaO_log2 (unsigned int x);
354int luaO_int2fb (unsigned int x); 354int luaO_int2fb (unsigned int x);
355#define fb2int(x) (((x) & 7) << ((x) >> 3)) 355int luaO_fb2int (int x);
356 356
357int luaO_rawequalObj (const TValue *t1, const TValue *t2); 357int luaO_rawequalObj (const TValue *t1, const TValue *t2);
358int luaO_str2d (const char *s, lua_Number *result); 358int luaO_str2d (const char *s, lua_Number *result);
diff --git a/ltests.c b/ltests.c
index 621acf0e..37720a26 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.13 2004/09/29 21:00:25 roberto Exp roberto $ 2** $Id: ltests.c,v 2.14 2004/10/06 18:34:16 roberto Exp $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -759,7 +759,7 @@ static int log2_aux (lua_State *L) {
759static int int2fb_aux (lua_State *L) { 759static int int2fb_aux (lua_State *L) {
760 int b = luaO_int2fb(luaL_checkint(L, 1)); 760 int b = luaO_int2fb(luaL_checkint(L, 1));
761 lua_pushinteger(L, b); 761 lua_pushinteger(L, b);
762 lua_pushinteger(L, fb2int(b)); 762 lua_pushinteger(L, luaO_fb2int(b));
763 return 2; 763 return 2;
764} 764}
765 765
diff --git a/lvm.c b/lvm.c
index e97279c3..b2845455 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.15 2004/10/04 19:01:53 roberto Exp roberto $ 2** $Id: lvm.c,v 2.16 2004/10/28 17:45:51 roberto Exp $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -461,7 +461,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
461 } 461 }
462 case OP_NEWTABLE: { 462 case OP_NEWTABLE: {
463 int b = GETARG_B(i); 463 int b = GETARG_B(i);
464 b = fb2int(b); 464 b = luaO_fb2int(b);
465 sethvalue(L, ra, luaH_new(L, b, GETARG_C(i))); 465 sethvalue(L, ra, luaH_new(L, b, GETARG_C(i)));
466 L->ci->savedpc = pc; 466 L->ci->savedpc = pc;
467 luaC_checkGC(L); /***/ 467 luaC_checkGC(L); /***/