diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-04 15:23:12 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-04 15:23:12 -0200 |
commit | cde179b36979c58d9380d3c4dd29b61412d13b51 (patch) | |
tree | 804c457691024d797a7479eddf711e103966b513 /lvm.c | |
parent | 80b39d83c3512e1dd627842e64c69841638d9088 (diff) | |
download | lua-cde179b36979c58d9380d3c4dd29b61412d13b51.tar.gz lua-cde179b36979c58d9380d3c4dd29b61412d13b51.tar.bz2 lua-cde179b36979c58d9380d3c4dd29b61412d13b51.zip |
new implementation for global variable values (separated from strings)
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.63 1999/10/14 19:13:31 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.64 1999/10/14 19:46:57 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 | */ |
@@ -167,9 +167,9 @@ void luaV_rawsettable (const TObject *t) { | |||
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | void luaV_getglobal (TaggedString *ts) { | 170 | void luaV_getglobal (GlobalVar *gv) { |
171 | /* WARNING: caller must assure stack space */ | 171 | /* WARNING: caller must assure stack space */ |
172 | const TObject *value = &ts->u.s.globalval; | 172 | const TObject *value = &gv->value; |
173 | switch (ttype(value)) { | 173 | switch (ttype(value)) { |
174 | /* only userdata, tables and nil can have getglobal tag methods */ | 174 | /* only userdata, tables and nil can have getglobal tag methods */ |
175 | case LUA_T_USERDATA: case LUA_T_ARRAY: case LUA_T_NIL: { | 175 | case LUA_T_USERDATA: case LUA_T_ARRAY: case LUA_T_NIL: { |
@@ -177,7 +177,7 @@ void luaV_getglobal (TaggedString *ts) { | |||
177 | if (ttype(im) != LUA_T_NIL) { /* is there a tag method? */ | 177 | if (ttype(im) != LUA_T_NIL) { /* is there a tag method? */ |
178 | struct Stack *S = &L->stack; | 178 | struct Stack *S = &L->stack; |
179 | ttype(S->top) = LUA_T_STRING; | 179 | ttype(S->top) = LUA_T_STRING; |
180 | tsvalue(S->top) = ts; | 180 | tsvalue(S->top) = gv->name; /* global name */ |
181 | S->top++; | 181 | S->top++; |
182 | *S->top++ = *value; | 182 | *S->top++ = *value; |
183 | luaD_callTM(im, 2, 1); | 183 | luaD_callTM(im, 2, 1); |
@@ -190,18 +190,18 @@ void luaV_getglobal (TaggedString *ts) { | |||
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void luaV_setglobal (TaggedString *ts) { | 193 | void luaV_setglobal (GlobalVar *gv) { |
194 | const TObject *oldvalue = &ts->u.s.globalval; | 194 | const TObject *oldvalue = &gv->value; |
195 | const TObject *im = luaT_getimbyObj(oldvalue, IM_SETGLOBAL); | 195 | const TObject *im = luaT_getimbyObj(oldvalue, IM_SETGLOBAL); |
196 | if (ttype(im) == LUA_T_NIL) /* is there a tag method? */ | 196 | if (ttype(im) == LUA_T_NIL) /* is there a tag method? */ |
197 | luaS_rawsetglobal(ts, --L->stack.top); | 197 | gv->value = *(--L->stack.top); |
198 | else { | 198 | else { |
199 | /* WARNING: caller must assure stack space */ | 199 | /* WARNING: caller must assure stack space */ |
200 | struct Stack *S = &L->stack; | 200 | struct Stack *S = &L->stack; |
201 | TObject newvalue; | 201 | TObject newvalue; |
202 | newvalue = *(S->top-1); | 202 | newvalue = *(S->top-1); |
203 | ttype(S->top-1) = LUA_T_STRING; | 203 | ttype(S->top-1) = LUA_T_STRING; |
204 | tsvalue(S->top-1) = ts; | 204 | tsvalue(S->top-1) = gv->name; |
205 | *S->top++ = *oldvalue; | 205 | *S->top++ = *oldvalue; |
206 | *S->top++ = newvalue; | 206 | *S->top++ = newvalue; |
207 | luaD_callTM(im, 3, 0); | 207 | luaD_callTM(im, 3, 0); |
@@ -370,7 +370,7 @@ StkId luaV_execute (const Closure *cl, const TProtoFunc *tf, StkId base) { | |||
370 | 370 | ||
371 | case GETGLOBALW: aux += highbyte(*pc++); | 371 | case GETGLOBALW: aux += highbyte(*pc++); |
372 | case GETGLOBAL: aux += *pc++; | 372 | case GETGLOBAL: aux += *pc++; |
373 | luaV_getglobal(tsvalue(&consts[aux])); | 373 | luaV_getglobal(tsvalue(&consts[aux])->u.s.gv); |
374 | break; | 374 | break; |
375 | 375 | ||
376 | case GETTABLE: | 376 | case GETTABLE: |
@@ -407,7 +407,7 @@ StkId luaV_execute (const Closure *cl, const TProtoFunc *tf, StkId base) { | |||
407 | 407 | ||
408 | case SETGLOBALW: aux += highbyte(*pc++); | 408 | case SETGLOBALW: aux += highbyte(*pc++); |
409 | case SETGLOBAL: aux += *pc++; | 409 | case SETGLOBAL: aux += *pc++; |
410 | luaV_setglobal(tsvalue(&consts[aux])); | 410 | luaV_setglobal(tsvalue(&consts[aux])->u.s.gv); |
411 | break; | 411 | break; |
412 | 412 | ||
413 | case SETTABLEPOP: | 413 | case SETTABLEPOP: |