aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c14
-rw-r--r--lcode.c6
-rw-r--r--ldebug.c6
-rw-r--r--lgc.c30
-rw-r--r--llex.c8
-rw-r--r--lobject.h50
-rw-r--r--lstring.c34
-rw-r--r--lstring.h16
-rw-r--r--ltable.c4
-rw-r--r--ltests.c6
-rw-r--r--ltm.c6
-rw-r--r--lvm.c15
12 files changed, 92 insertions, 103 deletions
diff --git a/lapi.c b/lapi.c
index effcc2aa..31f11702 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.144 2001/06/08 19:00:57 roberto Exp roberto $ 2** $Id: lapi.c,v 1.145 2001/06/15 19:16:41 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*/
@@ -244,11 +244,11 @@ LUA_API size_t lua_strlen (lua_State *L, int index) {
244 if (o == NULL) 244 if (o == NULL)
245 return 0; 245 return 0;
246 else if (ttype(o) == LUA_TSTRING) 246 else if (ttype(o) == LUA_TSTRING)
247 return tsvalue(o)->len; 247 return tsvalue(o)->tsv.len;
248 else { 248 else {
249 size_t l; 249 size_t l;
250 lua_lock(L); /* `luaV_tostring' may create a new string */ 250 lua_lock(L); /* `luaV_tostring' may create a new string */
251 l = (luaV_tostring(L, o) == 0) ? tsvalue(o)->len : 0; 251 l = (luaV_tostring(L, o) == 0) ? tsvalue(o)->tsv.len : 0;
252 lua_unlock(L); 252 lua_unlock(L);
253 return l; 253 return l;
254 } 254 }
@@ -263,7 +263,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
263 263
264LUA_API void *lua_touserdata (lua_State *L, int index) { 264LUA_API void *lua_touserdata (lua_State *L, int index) {
265 StkId o = luaA_indexAcceptable(L, index); 265 StkId o = luaA_indexAcceptable(L, index);
266 return (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL : uvalue(o)->value; 266 return (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL : uvalue(o)->uv.value;
267} 267}
268 268
269 269
@@ -633,7 +633,7 @@ LUA_API void lua_settag (lua_State *L, int tag) {
633 hvalue(L->top-1)->htag = tag; 633 hvalue(L->top-1)->htag = tag;
634 break; 634 break;
635 case LUA_TUSERDATA: 635 case LUA_TUSERDATA:
636 uvalue(L->top-1)->tag = tag; 636 uvalue(L->top-1)->uv.tag = tag;
637 break; 637 break;
638 default: 638 default:
639 luaO_verror(L, l_s("cannot change the tag of a %.20s"), 639 luaO_verror(L, l_s("cannot change the tag of a %.20s"),
@@ -744,7 +744,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
744 void *p; 744 void *p;
745 lua_lock(L); 745 lua_lock(L);
746 u = pushnewudata(L, size); 746 u = pushnewudata(L, size);
747 p = u->value; 747 p = u->uv.value;
748 lua_unlock(L); 748 lua_unlock(L);
749 return p; 749 return p;
750} 750}
@@ -754,7 +754,7 @@ LUA_API void lua_newuserdatabox (lua_State *L, void *p) {
754 Udata *u; 754 Udata *u;
755 lua_lock(L); 755 lua_lock(L);
756 u = pushnewudata(L, 0); 756 u = pushnewudata(L, 0);
757 u->value = p; 757 u->uv.value = p;
758 lua_unlock(L); 758 lua_unlock(L);
759} 759}
760 760
diff --git a/lcode.c b/lcode.c
index 5413058e..84052abf 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.74 2001/06/11 14:56:42 roberto Exp roberto $ 2** $Id: lcode.c,v 1.75 2001/06/12 14:36:48 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -232,12 +232,12 @@ static int addk (FuncState *fs, TObject *k) {
232 232
233int luaK_stringk (FuncState *fs, TString *s) { 233int luaK_stringk (FuncState *fs, TString *s) {
234 Proto *f = fs->f; 234 Proto *f = fs->f;
235 int c = s->constindex; 235 int c = s->tsv.constindex;
236 if (c >= fs->nk || ttype(&f->k[c]) != LUA_TSTRING || tsvalue(&f->k[c]) != s) { 236 if (c >= fs->nk || ttype(&f->k[c]) != LUA_TSTRING || tsvalue(&f->k[c]) != s) {
237 TObject o; 237 TObject o;
238 setsvalue(&o, s); 238 setsvalue(&o, s);
239 c = addk(fs, &o); 239 c = addk(fs, &o);
240 s->constindex = (unsigned short)c; /* hint for next time */ 240 s->tsv.constindex = (unsigned short)c; /* hint for next time */
241 } 241 }
242 return c; 242 return c;
243} 243}
diff --git a/ldebug.c b/ldebug.c
index 27494a4e..a0293b10 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.81 2001/06/08 19:00:57 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.82 2001/06/11 14:56:42 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*/
@@ -483,7 +483,7 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
483 switch (GET_OPCODE(i)) { 483 switch (GET_OPCODE(i)) {
484 case OP_GETGLOBAL: { 484 case OP_GETGLOBAL: {
485 lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING); 485 lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING);
486 *name = getstr(tsvalue(&p->k[GETARG_Bc(i)])); 486 *name = svalue(&p->k[GETARG_Bc(i)]);
487 return l_s("global"); 487 return l_s("global");
488 } 488 }
489 case OP_MOVE: { 489 case OP_MOVE: {
@@ -497,7 +497,7 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
497 case OP_SELF: { 497 case OP_SELF: {
498 int c = GETARG_C(i) - MAXSTACK; 498 int c = GETARG_C(i) - MAXSTACK;
499 if (c >= 0 && ttype(&p->k[c]) == LUA_TSTRING) { 499 if (c >= 0 && ttype(&p->k[c]) == LUA_TSTRING) {
500 *name = getstr(tsvalue(&p->k[c])); 500 *name = svalue(&p->k[c]);
501 return l_s("field"); 501 return l_s("field");
502 } 502 }
503 break; 503 break;
diff --git a/lgc.c b/lgc.c
index baaca9a7..de5998e3 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.104 2001/06/13 18:51:20 roberto Exp roberto $ 2** $Id: lgc.c,v 1.105 2001/06/15 19:17:33 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*/
@@ -27,7 +27,7 @@ typedef struct GCState {
27 27
28 28
29/* mark a string; marks larger than 1 cannot be changed */ 29/* mark a string; marks larger than 1 cannot be changed */
30#define strmark(s) {if ((s)->marked == 0) (s)->marked = 1;} 30#define strmark(s) {if ((s)->tsv.marked == 0) (s)->tsv.marked = 1;}
31 31
32 32
33 33
@@ -184,7 +184,7 @@ static void markall (lua_State *L) {
184static int hasmark (int tt, Value *v) { 184static int hasmark (int tt, Value *v) {
185 switch (tt) { 185 switch (tt) {
186 case LUA_TSTRING: 186 case LUA_TSTRING:
187 return v->ts->marked; 187 return v->ts->tsv.marked;
188 case LUA_TUSERDATA: 188 case LUA_TUSERDATA:
189 return ismarkedudata(v->u); 189 return ismarkedudata(v->u);
190 case LUA_TTABLE: 190 case LUA_TTABLE:
@@ -274,12 +274,12 @@ void luaC_collectudata (lua_State *L) {
274 while ((curr = *p) != NULL) { 274 while ((curr = *p) != NULL) {
275 if (ismarkedudata(curr)) { 275 if (ismarkedudata(curr)) {
276 switchudatamark(curr); /* unmark */ 276 switchudatamark(curr); /* unmark */
277 p = &curr->next; 277 p = &curr->uv.next;
278 } 278 }
279 else { /* collect */ 279 else { /* collect */
280 int tag = curr->tag; 280 int tag = curr->uv.tag;
281 *p = curr->next; 281 *p = curr->uv.next;
282 curr->next = G(L)->TMtable[tag].collected; /* chain udata */ 282 curr->uv.next = G(L)->TMtable[tag].collected; /* chain udata */
283 G(L)->TMtable[tag].collected = curr; 283 G(L)->TMtable[tag].collected = curr;
284 } 284 }
285 } 285 }
@@ -292,15 +292,15 @@ static void collectstrings (lua_State *L, int all) {
292 TString **p = &G(L)->strt.hash[i]; 292 TString **p = &G(L)->strt.hash[i];
293 TString *curr; 293 TString *curr;
294 while ((curr = *p) != NULL) { 294 while ((curr = *p) != NULL) {
295 if (curr->marked && !all) { /* preserve? */ 295 if (curr->tsv.marked && !all) { /* preserve? */
296 if (curr->marked < FIXMARK) /* does not change FIXMARKs */ 296 if (curr->tsv.marked < FIXMARK) /* does not change FIXMARKs */
297 curr->marked = 0; 297 curr->tsv.marked = 0;
298 p = &curr->nexthash; 298 p = &curr->tsv.nexthash;
299 } 299 }
300 else { /* collect */ 300 else { /* collect */
301 *p = curr->nexthash; 301 *p = curr->tsv.nexthash;
302 G(L)->strt.nuse--; 302 G(L)->strt.nuse--;
303 luaM_free(L, curr, sizestring(curr->len)); 303 luaM_free(L, curr, sizestring(curr->tsv.len));
304 } 304 }
305 } 305 }
306 } 306 }
@@ -344,10 +344,10 @@ void luaC_callgcTMudata (lua_State *L) {
344 Udata *udata; 344 Udata *udata;
345 while ((udata = G(L)->TMtable[tag].collected) != NULL) { 345 while ((udata = G(L)->TMtable[tag].collected) != NULL) {
346 TObject obj; 346 TObject obj;
347 G(L)->TMtable[tag].collected = udata->next; /* remove it from list */ 347 G(L)->TMtable[tag].collected = udata->uv.next; /* remove it from list */
348 setuvalue(&obj, udata); 348 setuvalue(&obj, udata);
349 callgcTM(L, &obj); 349 callgcTM(L, &obj);
350 luaM_free(L, udata, sizeudata(udata->len)); 350 luaM_free(L, udata, sizeudata(udata->uv.len));
351 } 351 }
352 } 352 }
353} 353}
diff --git a/llex.c b/llex.c
index bb50c276..c921b1b4 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.85 2001/06/07 15:01:21 roberto Exp roberto $ 2** $Id: llex.c,v 1.86 2001/06/13 14:25:49 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -40,7 +40,7 @@ void luaX_init (lua_State *L) {
40 for (i=0; i<NUM_RESERVED; i++) { 40 for (i=0; i<NUM_RESERVED; i++) {
41 TString *ts = luaS_new(L, token2string[i]); 41 TString *ts = luaS_new(L, token2string[i]);
42 lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); 42 lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN);
43 ts->marked = (unsigned short)(RESERVEDMARK+i); /* reserved word */ 43 ts->tsv.marked = (unsigned short)(RESERVEDMARK+i); /* reserved word */
44 } 44 }
45} 45}
46 46
@@ -370,8 +370,8 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
370 /* identifier or reserved word */ 370 /* identifier or reserved word */
371 size_t l = readname(LS); 371 size_t l = readname(LS);
372 TString *ts = luaS_newlstr(LS->L, (l_char *)G(LS->L)->Mbuffer, l); 372 TString *ts = luaS_newlstr(LS->L, (l_char *)G(LS->L)->Mbuffer, l);
373 if (ts->marked >= RESERVEDMARK) /* reserved word? */ 373 if (ts->tsv.marked >= RESERVEDMARK) /* reserved word? */
374 return ts->marked-RESERVEDMARK+FIRST_RESERVED; 374 return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED;
375 seminfo->ts = ts; 375 seminfo->ts = ts;
376 return TK_NAME; 376 return TK_NAME;
377 } 377 }
diff --git a/lobject.h b/lobject.h
index 53df58cc..2f363ec7 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.104 2001/06/06 18:00:19 roberto Exp roberto $ 2** $Id: lobject.h,v 1.105 2001/06/07 15:01:21 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*/
@@ -28,8 +28,8 @@
28 28
29 29
30typedef union { 30typedef union {
31 struct TString *ts; 31 union TString *ts;
32 struct Udata *u; 32 union Udata *u;
33 struct Closure *cl; 33 struct Closure *cl;
34 struct Hash *h; 34 struct Hash *h;
35 lua_Number n; /* LUA_TNUMBER */ 35 lua_Number n; /* LUA_TNUMBER */
@@ -80,40 +80,36 @@ typedef TObject *StkId; /* index to stack elements */
80/* 80/*
81** String headers for string table 81** String headers for string table
82*/ 82*/
83typedef struct TString { 83typedef union TString {
84 lu_hash hash;
85 size_t len;
86 unsigned short constindex; /* hint to reuse constants */
87 short marked;
88 struct TString *nexthash; /* chain for hash table */
89} TString;
90
91
92
93/*
94** type equivalent to TString, but with maximum alignment requirements
95*/
96union L_UTString {
97 TString ts;
98 union L_Umaxalign dummy; /* ensures maximum alignment for strings */ 84 union L_Umaxalign dummy; /* ensures maximum alignment for strings */
99}; 85 struct {
86 lu_hash hash;
87 size_t len;
88 unsigned short constindex; /* hint to reuse constants */
89 short marked;
90 union TString *nexthash; /* chain for hash table */
91 } tsv;
92} TString;
100 93
101 94
102#define getstr(ts) ((l_char *)((union L_UTString *)(ts) + 1)) 95#define getstr(ts) ((l_char *)((ts) + 1))
103#define svalue(o) getstr(tsvalue(o)) 96#define svalue(o) getstr(tsvalue(o))
104 97
105 98
106 99
107typedef struct Udata { 100typedef union Udata {
108 int tag; /* negative means `marked' (only during GC) */ 101 union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
109 void *value; 102 struct {
110 size_t len; 103 int tag; /* negative means `marked' (only during GC) */
111 struct Udata *next; /* chain for list of all udata */ 104 void *value;
105 size_t len;
106 union Udata *next; /* chain for list of all udata */
107 } uv;
112} Udata; 108} Udata;
113 109
114 110
115#define switchudatamark(u) ((u)->tag = (-((u)->tag+1))) 111#define switchudatamark(u) ((u)->uv.tag = (-((u)->uv.tag+1)))
116#define ismarkedudata(u) ((u)->tag < 0) 112#define ismarkedudata(u) ((u)->uv.tag < 0)
117 113
118 114
119 115
diff --git a/lstring.c b/lstring.c
index 21cad45b..a71142bb 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.63 2001/06/06 18:00:19 roberto Exp roberto $ 2** $Id: lstring.c,v 1.64 2001/06/07 15:01:21 roberto Exp roberto $
3** String table (keeps all strings handled by Lua) 3** String table (keeps all strings handled by Lua)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -32,11 +32,11 @@ void luaS_resize (lua_State *L, int newsize) {
32 for (i=0; i<tb->size; i++) { 32 for (i=0; i<tb->size; i++) {
33 TString *p = tb->hash[i]; 33 TString *p = tb->hash[i];
34 while (p) { /* for each node in the list */ 34 while (p) { /* for each node in the list */
35 TString *next = p->nexthash; /* save next */ 35 TString *next = p->tsv.nexthash; /* save next */
36 lu_hash h = p->hash; 36 lu_hash h = p->tsv.hash;
37 int h1 = lmod(h, newsize); /* new position */ 37 int h1 = lmod(h, newsize); /* new position */
38 lua_assert((int)(h%newsize) == lmod(h, newsize)); 38 lua_assert((int)(h%newsize) == lmod(h, newsize));
39 p->nexthash = newhash[h1]; /* chain it in new position */ 39 p->tsv.nexthash = newhash[h1]; /* chain it in new position */
40 newhash[h1] = p; 40 newhash[h1] = p;
41 p = next; 41 p = next;
42 } 42 }
@@ -50,16 +50,16 @@ void luaS_resize (lua_State *L, int newsize) {
50static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) { 50static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) {
51 TString *ts = (TString *)luaM_malloc(L, sizestring(l)); 51 TString *ts = (TString *)luaM_malloc(L, sizestring(l));
52 stringtable *tb; 52 stringtable *tb;
53 ts->nexthash = NULL; 53 ts->tsv.nexthash = NULL;
54 ts->len = l; 54 ts->tsv.len = l;
55 ts->hash = h; 55 ts->tsv.hash = h;
56 ts->marked = 0; 56 ts->tsv.marked = 0;
57 ts->constindex = 0; 57 ts->tsv.constindex = 0;
58 memcpy(getstr(ts), str, l*sizeof(l_char)); 58 memcpy(getstr(ts), str, l*sizeof(l_char));
59 getstr(ts)[l] = l_c('\0'); /* ending 0 */ 59 getstr(ts)[l] = l_c('\0'); /* ending 0 */
60 tb = &G(L)->strt; 60 tb = &G(L)->strt;
61 h = lmod(h, tb->size); 61 h = lmod(h, tb->size);
62 ts->nexthash = tb->hash[h]; /* chain new entry */ 62 ts->tsv.nexthash = tb->hash[h]; /* chain new entry */
63 tb->hash[h] = ts; 63 tb->hash[h] = ts;
64 tb->nuse++; 64 tb->nuse++;
65 if (tb->nuse > (ls_nstr)tb->size && tb->size <= MAX_INT/2) 65 if (tb->nuse > (ls_nstr)tb->size && tb->size <= MAX_INT/2)
@@ -75,8 +75,10 @@ TString *luaS_newlstr (lua_State *L, const l_char *str, size_t l) {
75 size_t l1; 75 size_t l1;
76 for (l1=l; l1>=step; l1-=step) /* compute hash */ 76 for (l1=l; l1>=step; l1-=step) /* compute hash */
77 h = h ^ ((h<<5)+(h>>2)+uchar(str[l1-1])); 77 h = h ^ ((h<<5)+(h>>2)+uchar(str[l1-1]));
78 for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; ts; ts = ts->nexthash) { 78 for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
79 if (ts->len == l && (memcmp(str, getstr(ts), l) == 0)) 79 ts != NULL;
80 ts = ts->tsv.nexthash) {
81 if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0))
80 return ts; 82 return ts;
81 } 83 }
82 return newlstr(L, str, l, h); /* not found */ 84 return newlstr(L, str, l, h); /* not found */
@@ -85,11 +87,11 @@ TString *luaS_newlstr (lua_State *L, const l_char *str, size_t l) {
85 87
86Udata *luaS_newudata (lua_State *L, size_t s) { 88Udata *luaS_newudata (lua_State *L, size_t s) {
87 Udata *u = (Udata *)luaM_malloc(L, sizeudata(s)); 89 Udata *u = (Udata *)luaM_malloc(L, sizeudata(s));
88 u->len = s; 90 u->uv.len = s;
89 u->tag = 0; 91 u->uv.tag = 0;
90 u->value = ((union L_UUdata *)(u) + 1); 92 u->uv.value = u + 1;
91 /* chain it on udata list */ 93 /* chain it on udata list */
92 u->next = G(L)->rootudata; 94 u->uv.next = G(L)->rootudata;
93 G(L)->rootudata = u; 95 G(L)->rootudata = u;
94 return u; 96 return u;
95} 97}
diff --git a/lstring.h b/lstring.h
index 130b3a81..02cbc1ab 100644
--- a/lstring.h
+++ b/lstring.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.h,v 1.31 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: lstring.h,v 1.32 2001/06/06 18:00:19 roberto Exp roberto $
3** String table (keep all strings handled by Lua) 3** String table (keep all strings handled by Lua)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -14,16 +14,6 @@
14 14
15 15
16/* 16/*
17** type equivalent to Udata, but with maximum alignment requirements
18*/
19union L_UUdata {
20 Udata u;
21 union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
22};
23
24
25
26/*
27** any TString with mark>=FIXMARK is never collected. 17** any TString with mark>=FIXMARK is never collected.
28** Marks>=RESERVEDMARK are used to identify reserved words. 18** Marks>=RESERVEDMARK are used to identify reserved words.
29*/ 19*/
@@ -31,10 +21,10 @@ union L_UUdata {
31#define RESERVEDMARK 3 21#define RESERVEDMARK 3
32 22
33 23
34#define sizestring(l) ((lu_mem)sizeof(union L_UTString)+ \ 24#define sizestring(l) ((lu_mem)sizeof(union TString)+ \
35 ((lu_mem)(l)+1)*sizeof(l_char)) 25 ((lu_mem)(l)+1)*sizeof(l_char))
36 26
37#define sizeudata(l) ((lu_mem)sizeof(union L_UUdata)+(l)) 27#define sizeudata(l) ((lu_mem)sizeof(union Udata)+(l))
38 28
39#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 29#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
40#define luaS_newliteral(L, s) (luaS_newlstr(L, l_s("") s, \ 30#define luaS_newliteral(L, s) (luaS_newlstr(L, l_s("") s, \
diff --git a/ltable.c b/ltable.c
index c4a2c789..4a20bb23 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.79 2001/04/11 14:42:41 roberto Exp roberto $ 2** $Id: ltable.c,v 1.80 2001/06/06 18:00:19 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*/
@@ -33,7 +33,7 @@
33 33
34 34
35#define hashnum(t,n) (&t->node[lmod((lu_hash)(ls_hash)(n), t->size)]) 35#define hashnum(t,n) (&t->node[lmod((lu_hash)(ls_hash)(n), t->size)])
36#define hashstr(t,str) (&t->node[lmod((str)->hash, t->size)]) 36#define hashstr(t,str) (&t->node[lmod((str)->tsv.hash, t->size)])
37#define hashpointer(t,p) (&t->node[lmod(IntPoint(p), t->size)]) 37#define hashpointer(t,p) (&t->node[lmod(IntPoint(p), t->size)])
38 38
39 39
diff --git a/ltests.c b/ltests.c
index b666a917..b78de996 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.81 2001/06/05 18:17:01 roberto Exp roberto $ 2** $Id: ltests.c,v 1.82 2001/06/06 18:00:19 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*/
@@ -290,7 +290,7 @@ static int mem_query (lua_State *L) {
290static int hash_query (lua_State *L) { 290static int hash_query (lua_State *L) {
291 if (lua_isnull(L, 2)) { 291 if (lua_isnull(L, 2)) {
292 luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, l_s("string expected")); 292 luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, l_s("string expected"));
293 lua_pushnumber(L, tsvalue(luaA_index(L, 1))->hash); 293 lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash);
294 } 294 }
295 else { 295 else {
296 Hash *t; 296 Hash *t;
@@ -349,7 +349,7 @@ static int string_query (lua_State *L) {
349 else if (s < tb->size) { 349 else if (s < tb->size) {
350 TString *ts; 350 TString *ts;
351 int n = 0; 351 int n = 0;
352 for (ts = tb->hash[s]; ts; ts = ts->nexthash) { 352 for (ts = tb->hash[s]; ts; ts = ts->tsv.nexthash) {
353 setsvalue(L->top, ts); 353 setsvalue(L->top, ts);
354 incr_top; 354 incr_top;
355 n++; 355 n++;
diff --git a/ltm.c b/ltm.c
index 756728cf..29419adf 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.71 2001/03/26 14:31:49 roberto Exp roberto $ 2** $Id: ltm.c,v 1.72 2001/06/06 18:00:19 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -127,7 +127,7 @@ LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
127int luaT_tag (const TObject *o) { 127int luaT_tag (const TObject *o) {
128 int t = ttype(o); 128 int t = ttype(o);
129 switch (t) { 129 switch (t) {
130 case LUA_TUSERDATA: return uvalue(o)->tag; 130 case LUA_TUSERDATA: return uvalue(o)->uv.tag;
131 case LUA_TTABLE: return hvalue(o)->htag; 131 case LUA_TTABLE: return hvalue(o)->htag;
132 default: return t; 132 default: return t;
133 } 133 }
@@ -140,7 +140,7 @@ const l_char *luaT_typename (global_State *G, const TObject *o) {
140 TString *ts; 140 TString *ts;
141 switch (t) { 141 switch (t) {
142 case LUA_TUSERDATA: 142 case LUA_TUSERDATA:
143 tag = uvalue(o)->tag; 143 tag = uvalue(o)->uv.tag;
144 break; 144 break;
145 case LUA_TTABLE: 145 case LUA_TTABLE:
146 tag = hvalue(o)->htag; 146 tag = hvalue(o)->htag;
diff --git a/lvm.c b/lvm.c
index 3b17a0ad..5df99658 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.184 2001/06/11 14:56:42 roberto Exp roberto $ 2** $Id: lvm.c,v 1.185 2001/06/15 19:17:17 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*/
@@ -249,9 +249,9 @@ static void call_arith (lua_State *L, StkId p1, TObject *p2,
249 249
250static int luaV_strlessthan (const TString *ls, const TString *rs) { 250static int luaV_strlessthan (const TString *ls, const TString *rs) {
251 const l_char *l = getstr(ls); 251 const l_char *l = getstr(ls);
252 size_t ll = ls->len; 252 size_t ll = ls->tsv.len;
253 const l_char *r = getstr(rs); 253 const l_char *r = getstr(rs);
254 size_t lr = rs->len; 254 size_t lr = rs->tsv.len;
255 for (;;) { 255 for (;;) {
256 int temp = strcoll(l, r); 256 int temp = strcoll(l, r);
257 if (temp != 0) return (temp < 0); 257 if (temp != 0) return (temp < 0);
@@ -289,20 +289,21 @@ void luaV_strconc (lua_State *L, int total, StkId top) {
289 if (tostring(L, top-2) || tostring(L, top-1)) { 289 if (tostring(L, top-2) || tostring(L, top-1)) {
290 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) 290 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
291 luaG_concaterror(L, top-2, top-1); 291 luaG_concaterror(L, top-2, top-1);
292 } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ 292 } else if (tsvalue(top-1)->tsv.len > 0) { /* if len=0, do nothing */
293 /* at least two string values; get as many as possible */ 293 /* at least two string values; get as many as possible */
294 lu_mem tl = (lu_mem)tsvalue(top-1)->len + (lu_mem)tsvalue(top-2)->len; 294 lu_mem tl = (lu_mem)tsvalue(top-1)->tsv.len +
295 (lu_mem)tsvalue(top-2)->tsv.len;
295 l_char *buffer; 296 l_char *buffer;
296 int i; 297 int i;
297 while (n < total && !tostring(L, top-n-1)) { /* collect total length */ 298 while (n < total && !tostring(L, top-n-1)) { /* collect total length */
298 tl += tsvalue(top-n-1)->len; 299 tl += tsvalue(top-n-1)->tsv.len;
299 n++; 300 n++;
300 } 301 }
301 if (tl > MAX_SIZET) luaD_error(L, l_s("string size overflow")); 302 if (tl > MAX_SIZET) luaD_error(L, l_s("string size overflow"));
302 buffer = luaO_openspace(L, tl, l_char); 303 buffer = luaO_openspace(L, tl, l_char);
303 tl = 0; 304 tl = 0;
304 for (i=n; i>0; i--) { /* concat all strings */ 305 for (i=n; i>0; i--) { /* concat all strings */
305 size_t l = tsvalue(top-i)->len; 306 size_t l = tsvalue(top-i)->tsv.len;
306 memcpy(buffer+tl, svalue(top-i), l); 307 memcpy(buffer+tl, svalue(top-i), l);
307 tl += l; 308 tl += l;
308 } 309 }