aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-26 10:20:45 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-26 10:20:45 -0300
commit37f3a1c0452439bce1f5c2069ca015af148bf62f (patch)
tree0ad887fb08400103904dab1954695d28aece0500
parent9559c111a32479794acc59fba2cbeab365a567f3 (diff)
downloadlua-37f3a1c0452439bce1f5c2069ca015af148bf62f.tar.gz
lua-37f3a1c0452439bce1f5c2069ca015af148bf62f.tar.bz2
lua-37f3a1c0452439bce1f5c2069ca015af148bf62f.zip
too much optimization to "break" keys in tables; keep them as TObjects...
-rw-r--r--lapi.c10
-rw-r--r--ldebug.c6
-rw-r--r--lgc.c32
-rw-r--r--lobject.h8
-rw-r--r--ltable.c57
-rw-r--r--ltable.h10
-rw-r--r--ltests.c13
-rw-r--r--lvm.c6
8 files changed, 64 insertions, 78 deletions
diff --git a/lapi.c b/lapi.c
index 31f11702..5b6e36e3 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.145 2001/06/15 19:16:41 roberto Exp roberto $ 2** $Id: lapi.c,v 1.146 2001/06/15 20:36:57 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -672,7 +672,7 @@ LUA_API int lua_next (lua_State *L, int index) {
672 api_check(L, ttype(t) == LUA_TTABLE); 672 api_check(L, ttype(t) == LUA_TTABLE);
673 n = luaH_next(L, hvalue(t), luaA_index(L, -1)); 673 n = luaH_next(L, hvalue(t), luaA_index(L, -1));
674 if (n) { 674 if (n) {
675 setkey2obj(L->top-1, n); 675 setobj(L->top-1, key(n));
676 setobj(L->top, val(n)); 676 setobj(L->top, val(n));
677 api_incr_top(L); 677 api_incr_top(L);
678 more = 1; 678 more = 1;
@@ -701,10 +701,10 @@ LUA_API int lua_getn (lua_State *L, int index) {
701 int i = hvalue(t)->size; 701 int i = hvalue(t)->size;
702 Node *nd = hvalue(t)->node; 702 Node *nd = hvalue(t)->node;
703 while (i--) { 703 while (i--) {
704 if (ttype_key(nd) == LUA_TNUMBER && 704 if (ttype(key(nd)) == LUA_TNUMBER &&
705 ttype(val(nd)) != LUA_TNIL && 705 ttype(val(nd)) != LUA_TNIL &&
706 nvalue_key(nd) > max) 706 nvalue(key(nd)) > max)
707 max = nvalue_key(nd); 707 max = nvalue(key(nd));
708 nd++; 708 nd++;
709 } 709 }
710 n = (int)max; 710 n = (int)max;
diff --git a/ldebug.c b/ldebug.c
index a0293b10..f07e6dc3 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.82 2001/06/11 14:56:42 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.83 2001/06/15 20:36:57 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -225,8 +225,8 @@ static const l_char *travglobals (lua_State *L, const TObject *o) {
225 int i; 225 int i;
226 for (i=0; i<g->size; i++) { 226 for (i=0; i<g->size; i++) {
227 if (luaO_equalObj(o, val(node(g, i))) && 227 if (luaO_equalObj(o, val(node(g, i))) &&
228 ttype_key(node(g, i)) == LUA_TSTRING) 228 ttype(key(node(g, i))) == LUA_TSTRING)
229 return getstr(tsvalue_key(node(g, i))); 229 return getstr(tsvalue(key(node(g, i))));
230 } 230 }
231 return NULL; 231 return NULL;
232} 232}
diff --git a/lgc.c b/lgc.c
index 11119585..112d02ac 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.106 2001/06/15 20:36:57 roberto Exp roberto $ 2** $Id: lgc.c,v 1.107 2001/06/21 16:41:34 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -128,8 +128,8 @@ static void traverseclosure (GCState *st, Closure *f) {
128 128
129static void removekey (Node *n) { 129static void removekey (Node *n) {
130 lua_assert(ttype(val(n)) == LUA_TNIL); 130 lua_assert(ttype(val(n)) == LUA_TNIL);
131 if (ttype_key(n) != LUA_TNIL && ttype_key(n) != LUA_TNUMBER) 131 if (ttype(key(n)) != LUA_TNIL && ttype(key(n)) != LUA_TNUMBER)
132 ttype_key(n) = LUA_TNONE; /* dead key; remove it */ 132 setttype(key(n), LUA_TNONE); /* dead key; remove it */
133} 133}
134 134
135 135
@@ -143,14 +143,11 @@ static void traversetable (GCState *st, Hash *h) {
143 if (ttype(val(n)) == LUA_TNIL) 143 if (ttype(val(n)) == LUA_TNIL)
144 removekey(n); 144 removekey(n);
145 else { 145 else {
146 lua_assert(ttype_key(n) != LUA_TNIL); 146 lua_assert(ttype(key(n)) != LUA_TNIL);
147 if (ttype_key(n) != LUA_TNUMBER && !(mode & LUA_WEAK_KEY)) { 147 if (ttype(key(n)) != LUA_TNUMBER && !(mode & LUA_WEAK_KEY))
148 TObject k; 148 markobject(st, key(n));
149 setkey2obj(&k, n);
150 markobject(st, &k);
151 }
152 if (!(mode & LUA_WEAK_VALUE)) 149 if (!(mode & LUA_WEAK_VALUE))
153 markobject(st, &n->val); 150 markobject(st, val(n));
154 } 151 }
155 } 152 }
156} 153}
@@ -181,16 +178,16 @@ static void markall (lua_State *L) {
181} 178}
182 179
183 180
184static int hasmark (int tt, Value *v) { 181static int hasmark (const TObject *o) {
185 switch (tt) { 182 switch (ttype(o)) {
186 case LUA_TSTRING: 183 case LUA_TSTRING:
187 return v->ts->tsv.marked; 184 return tsvalue(o)->tsv.marked;
188 case LUA_TUSERDATA: 185 case LUA_TUSERDATA:
189 return ismarkedudata(v->u); 186 return ismarkedudata(uvalue(o));
190 case LUA_TTABLE: 187 case LUA_TTABLE:
191 return ismarked(v->h); 188 return ismarked(hvalue(o));
192 case LUA_TFUNCTION: 189 case LUA_TFUNCTION:
193 return ismarked(v->cl); 190 return ismarked(clvalue(o));
194 default: /* number, nil */ 191 default: /* number, nil */
195 return 1; 192 return 1;
196 } 193 }
@@ -202,8 +199,7 @@ static void cleardeadnodes (Hash *h) {
202 for (i=0; i<h->size; i++) { 199 for (i=0; i<h->size; i++) {
203 Node *n = node(h, i); 200 Node *n = node(h, i);
204 if (ttype(val(n)) == LUA_TNIL) continue; /* empty node */ 201 if (ttype(val(n)) == LUA_TNIL) continue; /* empty node */
205 if (!hasmark(ttype(val(n)), &(val(n)->value)) || 202 if (!hasmark(val(n)) || !hasmark(key(n))) {
206 !hasmark(ttype_key(n), &n->key_value)) {
207 setnilvalue(val(n)); /* remove value */ 203 setnilvalue(val(n)); /* remove value */
208 removekey(n); 204 removekey(n);
209 } 205 }
diff --git a/lobject.h b/lobject.h
index 2f363ec7..c12bc177 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.105 2001/06/07 15:01:21 roberto Exp roberto $ 2** $Id: lobject.h,v 1.106 2001/06/15 20:36:57 roberto Exp roberto $
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*/
@@ -73,6 +73,9 @@ typedef struct lua_TObject {
73 { TObject *o1=(obj1); const TObject *o2=(obj2); \ 73 { TObject *o1=(obj1); const TObject *o2=(obj2); \
74 o1->tt=o2->tt; o1->value = o2->value; } 74 o1->tt=o2->tt; o1->value = o2->value; }
75 75
76#define setttype(obj, tt) (ttype(obj) = (tt))
77
78
76 79
77typedef TObject *StkId; /* index to stack elements */ 80typedef TObject *StkId; /* index to stack elements */
78 81
@@ -167,8 +170,7 @@ typedef struct Closure {
167 170
168typedef struct Node { 171typedef struct Node {
169 struct Node *next; /* for chaining */ 172 struct Node *next; /* for chaining */
170 int key_tt; /* (break object to save padding space) */ 173 TObject key;
171 Value key_value;
172 TObject val; 174 TObject val;
173} Node; 175} Node;
174 176
diff --git a/ltable.c b/ltable.c
index 4a20bb23..c51b0a81 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.80 2001/06/06 18:00:19 roberto Exp roberto $ 2** $Id: ltable.c,v 1.81 2001/06/15 20:36:57 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -32,9 +32,9 @@
32#define TagDefault LUA_TTABLE 32#define TagDefault LUA_TTABLE
33 33
34 34
35#define hashnum(t,n) (&t->node[lmod((lu_hash)(ls_hash)(n), t->size)]) 35#define hashnum(t,n) (node(t, lmod((lu_hash)(ls_hash)(n), t->size)))
36#define hashstr(t,str) (&t->node[lmod((str)->tsv.hash, t->size)]) 36#define hashstr(t,str) (node(t, lmod((str)->tsv.hash, t->size)))
37#define hashpointer(t,p) (&t->node[lmod(IntPoint(p), t->size)]) 37#define hashpointer(t,p) (node(t, lmod(IntPoint(p), t->size)))
38 38
39 39
40/* 40/*
@@ -42,13 +42,13 @@
42** of its hash value) 42** of its hash value)
43*/ 43*/
44Node *luaH_mainposition (const Hash *t, const Node *n) { 44Node *luaH_mainposition (const Hash *t, const Node *n) {
45 switch (ttype_key(n)) { 45 switch (ttype(key(n))) {
46 case LUA_TNUMBER: 46 case LUA_TNUMBER:
47 return hashnum(t, nvalue_key(n)); 47 return hashnum(t, nvalue(key(n)));
48 case LUA_TSTRING: 48 case LUA_TSTRING:
49 return hashstr(t, tsvalue_key(n)); 49 return hashstr(t, tsvalue(key(n)));
50 default: /* all other types are hashed as (void *) */ 50 default: /* all other types are hashed as (void *) */
51 return hashpointer(t, tsvalue_key(n)); 51 return hashpointer(t, tsvalue(key(n)));
52 } 52 }
53} 53}
54 54
@@ -62,7 +62,7 @@ Node *luaH_next (lua_State *L, Hash *t, const TObject *key) {
62 if (v == &luaO_nilobject) 62 if (v == &luaO_nilobject)
63 luaD_error(L, l_s("invalid key for `next'")); 63 luaD_error(L, l_s("invalid key for `next'"));
64 i = (int)(((const l_char *)v - 64 i = (int)(((const l_char *)v -
65 (const l_char *)(&t->node[0].val)) / sizeof(Node)) + 1; 65 (const l_char *)(val(node(t, 0)))) / sizeof(Node)) + 1;
66 } 66 }
67 for (; i<t->size; i++) { 67 for (; i<t->size; i++) {
68 Node *n = node(t, i); 68 Node *n = node(t, i);
@@ -103,11 +103,11 @@ static void setnodevector (lua_State *L, Hash *t, int size) {
103 t->node = luaM_newvector(L, size, Node); 103 t->node = luaM_newvector(L, size, Node);
104 for (i=0; i<size; i++) { 104 for (i=0; i<size; i++) {
105 t->node[i].next = NULL; 105 t->node[i].next = NULL;
106 t->node[i].key_tt = LUA_TNIL; 106 setnilvalue(key(node(t, i)));
107 setnilvalue(&t->node[i].val); 107 setnilvalue(val(node(t, i)));
108 } 108 }
109 t->size = size; 109 t->size = size;
110 t->firstfree = &t->node[size-1]; /* first free position to be used */ 110 t->firstfree = node(t, size-1); /* first free position to be used */
111} 111}
112 112
113 113
@@ -161,12 +161,9 @@ static void rehash (lua_State *L, Hash *t) {
161 setnodevector(L, t, oldsize); /* just rehash; keep the same size */ 161 setnodevector(L, t, oldsize); /* just rehash; keep the same size */
162 for (i=0; i<oldsize; i++) { 162 for (i=0; i<oldsize; i++) {
163 Node *old = nold+i; 163 Node *old = nold+i;
164 if (ttype(&old->val) != LUA_TNIL) { 164 if (ttype(val(old)) != LUA_TNIL) {
165 TObject o; 165 TObject *v = luaH_set(L, t, key(old));
166 TObject *v; 166 setobj(v, val(old));
167 setkey2obj(&o, old);
168 v = luaH_set(L, t, &o);
169 setobj(v, &old->val);
170 } 167 }
171 } 168 }
172 luaM_freearray(L, nold, oldsize, Node); /* free old array */ 169 luaM_freearray(L, nold, oldsize, Node); /* free old array */
@@ -181,7 +178,7 @@ static void rehash (lua_State *L, Hash *t) {
181** position), new key goes to an empty position. 178** position), new key goes to an empty position.
182*/ 179*/
183static TObject *newkey (lua_State *L, Hash *t, Node *mp, const TObject *key) { 180static TObject *newkey (lua_State *L, Hash *t, Node *mp, const TObject *key) {
184 if (ttype(&mp->val) != LUA_TNIL) { /* main position is not free? */ 181 if (ttype(val(mp)) != LUA_TNIL) { /* main position is not free? */
185 Node *othern = luaH_mainposition(t, mp); /* `mp' of colliding node */ 182 Node *othern = luaH_mainposition(t, mp); /* `mp' of colliding node */
186 Node *n = t->firstfree; /* get a free place */ 183 Node *n = t->firstfree; /* get a free place */
187 if (othern != mp) { /* is colliding node out of its main position? */ 184 if (othern != mp) { /* is colliding node out of its main position? */
@@ -190,7 +187,7 @@ static TObject *newkey (lua_State *L, Hash *t, Node *mp, const TObject *key) {
190 othern->next = n; /* redo the chain with `n' in place of `mp' */ 187 othern->next = n; /* redo the chain with `n' in place of `mp' */
191 *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ 188 *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
192 mp->next = NULL; /* now `mp' is free */ 189 mp->next = NULL; /* now `mp' is free */
193 setnilvalue(&mp->val); 190 setnilvalue(val(mp));
194 } 191 }
195 else { /* colliding node is in its own main position */ 192 else { /* colliding node is in its own main position */
196 /* new node will go into free position */ 193 /* new node will go into free position */
@@ -199,11 +196,11 @@ static TObject *newkey (lua_State *L, Hash *t, Node *mp, const TObject *key) {
199 mp = n; 196 mp = n;
200 } 197 }
201 } 198 }
202 setobj2key(mp, key); 199 setobj(key(mp), key);
203 lua_assert(ttype(&mp->val) == LUA_TNIL); 200 lua_assert(ttype(val(mp)) == LUA_TNIL);
204 for (;;) { /* correct `firstfree' */ 201 for (;;) { /* correct `firstfree' */
205 if (ttype_key(t->firstfree) == LUA_TNIL) 202 if (ttype(key(t->firstfree)) == LUA_TNIL)
206 return &mp->val; /* OK; table still has a free place */ 203 return val(mp); /* OK; table still has a free place */
207 else if (t->firstfree == t->node) break; /* cannot decrement from here */ 204 else if (t->firstfree == t->node) break; /* cannot decrement from here */
208 else (t->firstfree)--; 205 else (t->firstfree)--;
209 } 206 }
@@ -220,8 +217,8 @@ TObject *luaH_setnum (lua_State *L, Hash *t, lua_Number key) {
220 Node *mp = hashnum(t, key); 217 Node *mp = hashnum(t, key);
221 Node *n = mp; 218 Node *n = mp;
222 do { /* check whether `key' is somewhere in the chain */ 219 do { /* check whether `key' is somewhere in the chain */
223 if (ttype_key(n) == LUA_TNUMBER && nvalue_key(n) == key) 220 if (ttype(key(n)) == LUA_TNUMBER && nvalue(key(n)) == key)
224 return &n->val; /* that's all */ 221 return val(n); /* that's all */
225 else n = n->next; 222 else n = n->next;
226 } while (n); 223 } while (n);
227 if (L == NULL) return (TObject *)&luaO_nilobject; /* get option */ 224 if (L == NULL) return (TObject *)&luaO_nilobject; /* get option */
@@ -239,8 +236,8 @@ TObject *luaH_setstr (lua_State *L, Hash *t, TString *key) {
239 Node *mp = hashstr(t, key); 236 Node *mp = hashstr(t, key);
240 Node *n = mp; 237 Node *n = mp;
241 do { /* check whether `key' is somewhere in the chain */ 238 do { /* check whether `key' is somewhere in the chain */
242 if (ttype_key(n) == LUA_TSTRING && tsvalue_key(n) == key) 239 if (ttype(key(n)) == LUA_TSTRING && tsvalue(key(n)) == key)
243 return &n->val; /* that's all */ 240 return val(n); /* that's all */
244 else n = n->next; 241 else n = n->next;
245 } while (n); 242 } while (n);
246 if (L == NULL) return (TObject *)&luaO_nilobject; /* get option */ 243 if (L == NULL) return (TObject *)&luaO_nilobject; /* get option */
@@ -258,8 +255,8 @@ static TObject *luaH_setany (lua_State *L, Hash *t, const TObject *key) {
258 Node *n = mp; 255 Node *n = mp;
259 do { /* check whether `key' is somewhere in the chain */ 256 do { /* check whether `key' is somewhere in the chain */
260 /* compare as `tsvalue', but may be other pointers (it is the same) */ 257 /* compare as `tsvalue', but may be other pointers (it is the same) */
261 if (ttype_key(n) == ttype(key) && tsvalue_key(n) == tsvalue(key)) 258 if (ttype(key(n)) == ttype(key) && tsvalue(key(n)) == tsvalue(key))
262 return &n->val; /* that's all */ 259 return val(n); /* that's all */
263 else n = n->next; 260 else n = n->next;
264 } while (n); 261 } while (n);
265 if (L == NULL) return (TObject *)&luaO_nilobject; /* get option */ 262 if (L == NULL) return (TObject *)&luaO_nilobject; /* get option */
diff --git a/ltable.h b/ltable.h
index 8de4c11b..a7c617c4 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 1.31 2001/01/29 17:17:26 roberto Exp roberto $ 2** $Id: ltable.h,v 1.32 2001/02/02 16:32:00 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,15 +11,9 @@
11 11
12 12
13#define node(_t,_i) (&(_t)->node[_i]) 13#define node(_t,_i) (&(_t)->node[_i])
14#define key(_n) (&(_n)->key)
14#define val(_n) (&(_n)->val) 15#define val(_n) (&(_n)->val)
15 16
16#define ttype_key(_n) ((_n)->key_tt)
17#define nvalue_key(_n) ((_n)->key_value.n)
18#define tsvalue_key(_n) ((_n)->key_value.ts)
19#define setkey2obj(_o,_k) \
20 ((_o)->tt = ttype_key(_k), (_o)->value = (_k)->key_value)
21#define setobj2key(_k,_o) \
22 (ttype_key(_k) = (_o)->tt, (_k)->key_value = (_o)->value)
23 17
24#define luaH_get(_t,_k) luaH_set(NULL,_t,_k) 18#define luaH_get(_t,_k) luaH_set(NULL,_t,_k)
25#define luaH_getnum(_t,_k) luaH_setnum(NULL,_t,_k) 19#define luaH_getnum(_t,_k) luaH_setnum(NULL,_t,_k)
diff --git a/ltests.c b/ltests.c
index b78de996..0093fd15 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.82 2001/06/06 18:00:19 roberto Exp roberto $ 2** $Id: ltests.c,v 1.83 2001/06/15 20:36:57 roberto Exp roberto $
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*/
@@ -298,7 +298,7 @@ static int hash_query (lua_State *L) {
298 TObject *o = luaA_index(L, 1); 298 TObject *o = luaA_index(L, 1);
299 luaL_checktype(L, 2, LUA_TTABLE); 299 luaL_checktype(L, 2, LUA_TTABLE);
300 t = hvalue(luaA_index(L, 2)); 300 t = hvalue(luaA_index(L, 2));
301 setobj2key(&n, o); 301 setobj(key(&n), o);
302 lua_pushnumber(L, luaH_mainposition(t, &n) - t->node); 302 lua_pushnumber(L, luaH_mainposition(t, &n) - t->node);
303 } 303 }
304 return 1; 304 return 1;
@@ -317,12 +317,9 @@ static int table_query (lua_State *L) {
317 } 317 }
318 else if (i < t->size) { 318 else if (i < t->size) {
319 if (ttype(val(node(t, i))) != LUA_TNIL || 319 if (ttype(val(node(t, i))) != LUA_TNIL ||
320 ttype_key(node(t, i)) == LUA_TNIL || 320 ttype(key(node(t, i))) == LUA_TNIL ||
321 ttype_key(node(t, i)) == LUA_TNUMBER || 321 ttype(key(node(t, i))) == LUA_TNUMBER) {
322 tsvalue_key(node(t, i)) != NULL) { 322 luaA_pushobject(L, key(node(t, i)));
323 TObject o;
324 setkey2obj(&o, node(t, i));
325 luaA_pushobject(L, &o);
326 } 323 }
327 else 324 else
328 lua_pushstring(L, "<undef>"); 325 lua_pushstring(L, "<undef>");
diff --git a/lvm.c b/lvm.c
index c3972b7e..7a92fab7 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.186 2001/06/15 20:36:57 roberto Exp roberto $ 2** $Id: lvm.c,v 1.187 2001/06/20 17:22:46 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -41,7 +41,7 @@ static void luaV_checkGC (lua_State *L, StkId top) {
41const TObject *luaV_tonumber (const TObject *obj, TObject *n) { 41const TObject *luaV_tonumber (const TObject *obj, TObject *n) {
42 if (ttype(obj) == LUA_TNUMBER) return obj; 42 if (ttype(obj) == LUA_TNUMBER) return obj;
43 if (ttype(obj) == LUA_TSTRING && luaO_str2d(svalue(obj), &nvalue(n))) { 43 if (ttype(obj) == LUA_TSTRING && luaO_str2d(svalue(obj), &nvalue(n))) {
44 ttype(n) = LUA_TNUMBER; 44 setttype(n, LUA_TNUMBER);
45 return n; 45 return n;
46 } 46 }
47 else 47 else
@@ -617,7 +617,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
617 if (n != -1) { /* repeat loop? */ 617 if (n != -1) { /* repeat loop? */
618 Node *node = node(t, n); 618 Node *node = node(t, n);
619 setnvalue(ra+1, n); /* index */ 619 setnvalue(ra+1, n); /* index */
620 setkey2obj(ra+2, node); 620 setobj(ra+2, key(node));
621 setobj(ra+3, val(node)); 621 setobj(ra+3, val(node));
622 dojump(pc, i); /* repeat loop */ 622 dojump(pc, i); /* repeat loop */
623 } 623 }