aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-01 15:40:48 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-01 15:40:48 -0200
commite506b864cdc522ed7bf33e81d785fcfbd40a0368 (patch)
treec62865ee026136cd8784658110e8928127ad276c
parent9a231afa9721e87ae5f9790dedcb73cd58472a3f (diff)
downloadlua-e506b864cdc522ed7bf33e81d785fcfbd40a0368.tar.gz
lua-e506b864cdc522ed7bf33e81d785fcfbd40a0368.tar.bz2
lua-e506b864cdc522ed7bf33e81d785fcfbd40a0368.zip
no need for tags in boxed values :-(
-rw-r--r--ldo.c3
-rw-r--r--lfunc.c3
-rw-r--r--lgc.c4
-rw-r--r--lobject.h20
-rw-r--r--lstate.h9
-rw-r--r--lstring.c4
-rw-r--r--ltable.c3
7 files changed, 17 insertions, 29 deletions
diff --git a/ldo.c b/ldo.c
index 67b8f5c5..d98ab5bd 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.118 2001/01/29 15:35:17 roberto Exp roberto $ 2** $Id: ldo.c,v 1.119 2001/01/29 19:34:02 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -172,7 +172,6 @@ void luaD_call (lua_State *L, StkId func, int nResults) {
172 setclvalue(func, tm); /* tag method is the new function to be called */ 172 setclvalue(func, tm); /* tag method is the new function to be called */
173 } 173 }
174 cl = clvalue(func); 174 cl = clvalue(func);
175 ci.v.ttype = LUA_TMARK;
176 ci.func = cl; 175 ci.func = cl;
177 setivalue(func, &ci); 176 setivalue(func, &ci);
178 callhook = L->callhook; 177 callhook = L->callhook;
diff --git a/lfunc.c b/lfunc.c
index 4e7facb0..0a145c67 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.37 2001/01/19 13:20:30 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.38 2001/01/29 19:34:02 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -19,7 +19,6 @@
19 19
20Closure *luaF_newclosure (lua_State *L, int nelems) { 20Closure *luaF_newclosure (lua_State *L, int nelems) {
21 Closure *c = (Closure *)luaM_malloc(L, sizeclosure(nelems)); 21 Closure *c = (Closure *)luaM_malloc(L, sizeclosure(nelems));
22 c->v.ttype = LUA_TFUNCTION;
23 c->next = G(L)->rootcl; 22 c->next = G(L)->rootcl;
24 G(L)->rootcl = c; 23 G(L)->rootcl = c;
25 c->mark = c; 24 c->mark = c;
diff --git a/lgc.c b/lgc.c
index 182f6048..90c8165a 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.82 2001/01/29 17:16:58 roberto Exp roberto $ 2** $Id: lgc.c,v 1.83 2001/01/29 19:34:02 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*/
@@ -66,8 +66,6 @@ static void marktable (GCState *st, Hash *h) {
66 66
67 67
68static void markobject (GCState *st, TObject *o) { 68static void markobject (GCState *st, TObject *o) {
69 lua_assert(ttype(o) == LUA_TNUMBER ||
70 ttype(o) == ((TValue *)(o->value.v))->ttype);
71 switch (ttype(o)) { 69 switch (ttype(o)) {
72 case LUA_TUSERDATA: case LUA_TSTRING: 70 case LUA_TUSERDATA: case LUA_TSTRING:
73 strmark(tsvalue(o)); 71 strmark(tsvalue(o));
diff --git a/lobject.h b/lobject.h
index 78f3ba18..e1170615 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.90 2001/01/29 17:16:58 roberto Exp roberto $ 2** $Id: lobject.h,v 1.91 2001/01/29 19:34:02 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*/
@@ -41,13 +41,6 @@
41#define is_T_MARK(t) (ttype(t) == LUA_TMARK) 41#define is_T_MARK(t) (ttype(t) == LUA_TMARK)
42 42
43 43
44/*
45** tag at the start of all "boxed" Lua values
46*/
47typedef struct TValue {
48 char ttype;
49} TValue;
50
51 44
52typedef union { 45typedef union {
53 void *v; 46 void *v;
@@ -116,8 +109,6 @@ typedef struct lua_TObject {
116#define TSPACK ((int)sizeof(int)) 109#define TSPACK ((int)sizeof(int))
117 110
118typedef struct TString { 111typedef struct TString {
119 TValue v;
120 unsigned char marked;
121 union { 112 union {
122 struct { /* for strings */ 113 struct { /* for strings */
123 luint32 hash; 114 luint32 hash;
@@ -129,6 +120,7 @@ typedef struct TString {
129 } d; 120 } d;
130 } u; 121 } u;
131 size_t len; 122 size_t len;
123 int marked;
132 struct TString *nexthash; /* chain for hash table */ 124 struct TString *nexthash; /* chain for hash table */
133 char str[TSPACK]; /* variable length string!! must be the last field! */ 125 char str[TSPACK]; /* variable length string!! must be the last field! */
134} TString; 126} TString;
@@ -138,7 +130,6 @@ typedef struct TString {
138** Function Prototypes 130** Function Prototypes
139*/ 131*/
140typedef struct Proto { 132typedef struct Proto {
141 TValue v;
142 lua_Number *knum; /* numbers used by the function */ 133 lua_Number *knum; /* numbers used by the function */
143 int sizeknum; /* size of `knum' */ 134 int sizeknum; /* size of `knum' */
144 struct TString **kstr; /* strings used by the function */ 135 struct TString **kstr; /* strings used by the function */
@@ -173,15 +164,14 @@ typedef struct LocVar {
173** Closures 164** Closures
174*/ 165*/
175typedef struct Closure { 166typedef struct Closure {
176 TValue v; 167 int isC; /* 0 for Lua functions, 1 for C functions */
177 char isC; /* 0 for Lua functions, 1 for C functions */
178 short nupvalues;
179 union { 168 union {
180 lua_CFunction c; /* C functions */ 169 lua_CFunction c; /* C functions */
181 struct Proto *l; /* Lua functions */ 170 struct Proto *l; /* Lua functions */
182 } f; 171 } f;
183 struct Closure *next; 172 struct Closure *next;
184 struct Closure *mark; /* marked closures (point to itself when not marked) */ 173 struct Closure *mark; /* marked closures (point to itself when not marked) */
174 int nupvalues;
185 TObject upvalue[1]; 175 TObject upvalue[1];
186} Closure; 176} Closure;
187 177
@@ -198,7 +188,6 @@ typedef struct Node {
198 188
199 189
200typedef struct Hash { 190typedef struct Hash {
201 TValue v;
202 Node *node; 191 Node *node;
203 int htag; 192 int htag;
204 int size; 193 int size;
@@ -223,7 +212,6 @@ typedef struct Hash {
223** informations about a call (for debugging) 212** informations about a call (for debugging)
224*/ 213*/
225typedef struct CallInfo { 214typedef struct CallInfo {
226 TValue v;
227 struct Closure *func; /* function being called */ 215 struct Closure *func; /* function being called */
228 const Instruction **pc; /* current pc of called function */ 216 const Instruction **pc; /* current pc of called function */
229 int lastpc; /* last pc traced */ 217 int lastpc; /* last pc traced */
diff --git a/lstate.h b/lstate.h
index 8d25ab89..e4f52cec 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 1.47 2001/01/25 16:45:36 roberto Exp roberto $ 2** $Id: lstate.h,v 1.48 2001/01/26 11:45:51 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -32,6 +32,12 @@ extern int islocked;
32#define LUA_UNLOCK 32#define LUA_UNLOCK
33#endif 33#endif
34 34
35/*
36** macro to allow the inclusion of user information in Lua state
37*/
38#ifndef LUA_USERSTATE
39#define LUA_USERSTATE
40#endif
35 41
36typedef TObject *StkId; /* index to stack elements */ 42typedef TObject *StkId; /* index to stack elements */
37 43
@@ -90,6 +96,7 @@ typedef struct global_State {
90** "per thread" state 96** "per thread" state
91*/ 97*/
92struct lua_State { 98struct lua_State {
99 LUA_USERSTATE
93 StkId top; /* first free slot in the stack */ 100 StkId top; /* first free slot in the stack */
94 StkId stack; /* stack base */ 101 StkId stack; /* stack base */
95 StkId stack_last; /* last free slot in the stack */ 102 StkId stack_last; /* last free slot in the stack */
diff --git a/lstring.c b/lstring.c
index fbc56dd0..fe87f5c2 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.53 2001/01/29 19:34:02 roberto Exp roberto $ 2** $Id: lstring.c,v 1.54 2001/02/01 13:56:49 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*/
@@ -76,7 +76,6 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
76 } 76 }
77 /* not found */ 77 /* not found */
78 ts = (TString *)luaM_malloc(L, sizestring(l)); 78 ts = (TString *)luaM_malloc(L, sizestring(l));
79 ts->v.ttype = LUA_TSTRING;
80 ts->marked = 0; 79 ts->marked = 0;
81 ts->nexthash = NULL; 80 ts->nexthash = NULL;
82 ts->len = l; 81 ts->len = l;
@@ -92,7 +91,6 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
92TString *luaS_newudata (lua_State *L, size_t s, void *udata) { 91TString *luaS_newudata (lua_State *L, size_t s, void *udata) {
93 union L_UTString *uts = (union L_UTString *)luaM_malloc(L, sizeudata(s)); 92 union L_UTString *uts = (union L_UTString *)luaM_malloc(L, sizeudata(s));
94 TString *ts = &uts->ts; 93 TString *ts = &uts->ts;
95 ts->v.ttype = LUA_TUSERDATA;
96 ts->marked = 0; 94 ts->marked = 0;
97 ts->nexthash = NULL; 95 ts->nexthash = NULL;
98 ts->len = s; 96 ts->len = s;
diff --git a/ltable.c b/ltable.c
index 01b082e3..1e524f5f 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.73 2001/01/29 19:34:02 roberto Exp roberto $ 2** $Id: ltable.c,v 1.74 2001/01/30 19:48:37 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*/
@@ -98,7 +98,6 @@ static void setnodevector (lua_State *L, Hash *t, luint32 size) {
98 98
99Hash *luaH_new (lua_State *L, int size) { 99Hash *luaH_new (lua_State *L, int size) {
100 Hash *t = luaM_new(L, Hash); 100 Hash *t = luaM_new(L, Hash);
101 t->v.ttype = LUA_TTABLE;
102 t->htag = TagDefault; 101 t->htag = TagDefault;
103 t->next = G(L)->roottable; 102 t->next = G(L)->roottable;
104 G(L)->roottable = t; 103 G(L)->roottable = t;