aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-10 10:13:36 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-10 10:13:36 -0200
commit47fc57a2529c83376883f36954082cfe80ae588f (patch)
treec2e57e2f9f7d78279144bfd9cbd04a3b1b131f12 /lapi.c
parent4d5fe1f54bc00850f77a7c42f9e95d0ff3f1ab5b (diff)
downloadlua-47fc57a2529c83376883f36954082cfe80ae588f.tar.gz
lua-47fc57a2529c83376883f36954082cfe80ae588f.tar.bz2
lua-47fc57a2529c83376883f36954082cfe80ae588f.zip
`TObject' renamed to `TValue' + other name changes and better assertions
for incremental garbage collection
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c111
1 files changed, 56 insertions, 55 deletions
diff --git a/lapi.c b/lapi.c
index d342fc94..b5bb81af 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.250 2003/12/01 18:22:56 roberto Exp roberto $ 2** $Id: lapi.c,v 1.251 2003/12/09 16:56:11 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*/
@@ -41,7 +41,7 @@ const char lua_ident[] =
41 41
42 42
43#ifndef api_check 43#ifndef api_check
44#define api_check(L, o) /*{ assert(o); }*/ 44#define api_check(L, o) lua_assert(o)
45#endif 45#endif
46 46
47#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) 47#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base))
@@ -52,11 +52,11 @@ const char lua_ident[] =
52 52
53 53
54 54
55static TObject *luaA_index (lua_State *L, int idx) { 55static TValue *luaA_index (lua_State *L, int idx) {
56 if (idx > 0) { 56 if (idx > 0) {
57 TObject *o = L->base + (idx - 1); 57 TValue *o = L->base + (idx - 1);
58 api_check(L, idx <= L->stack_last - L->base); 58 api_check(L, idx <= L->stack_last - L->base);
59 if (o >= L->top) return cast(TObject *, &luaO_nilobject); 59 if (o >= L->top) return cast(TValue *, &luaO_nilobject);
60 else return o; 60 else return o;
61 } 61 }
62 else if (idx > LUA_REGISTRYINDEX) { 62 else if (idx > LUA_REGISTRYINDEX) {
@@ -67,19 +67,19 @@ static TObject *luaA_index (lua_State *L, int idx) {
67 case LUA_REGISTRYINDEX: return registry(L); 67 case LUA_REGISTRYINDEX: return registry(L);
68 case LUA_GLOBALSINDEX: return gt(L); 68 case LUA_GLOBALSINDEX: return gt(L);
69 default: { 69 default: {
70 TObject *func = (L->base - 1); 70 TValue *func = (L->base - 1);
71 idx = LUA_GLOBALSINDEX - idx; 71 idx = LUA_GLOBALSINDEX - idx;
72 lua_assert(iscfunction(func)); 72 lua_assert(iscfunction(func));
73 return (idx <= clvalue(func)->c.nupvalues) 73 return (idx <= clvalue(func)->c.nupvalues)
74 ? &clvalue(func)->c.upvalue[idx-1] 74 ? &clvalue(func)->c.upvalue[idx-1]
75 : cast(TObject *, &luaO_nilobject); 75 : cast(TValue *, &luaO_nilobject);
76 } 76 }
77 } 77 }
78} 78}
79 79
80 80
81void luaA_pushobject (lua_State *L, const TObject *o) { 81void luaA_pushobject (lua_State *L, const TValue *o) {
82 setobj2s(L->top, o); 82 setobj2s(L, L->top, o);
83 incr_top(L); 83 incr_top(L);
84} 84}
85 85
@@ -107,7 +107,7 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
107 api_checknelems(from, n); 107 api_checknelems(from, n);
108 from->top -= n; 108 from->top -= n;
109 for (i = 0; i < n; i++) { 109 for (i = 0; i < n; i++) {
110 setobj2s(to->top, from->top + i); 110 setobj2s(to, to->top, from->top + i);
111 api_incr_top(to); 111 api_incr_top(to);
112 } 112 }
113 lua_unlock(to); 113 lua_unlock(to);
@@ -129,7 +129,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) {
129 lua_lock(L); 129 lua_lock(L);
130 luaC_checkGC(L); 130 luaC_checkGC(L);
131 L1 = luaE_newthread(L); 131 L1 = luaE_newthread(L);
132 setthvalue(L->top, L1); 132 setthvalue(L, L->top, L1);
133 api_incr_top(L); 133 api_incr_top(L);
134 lua_unlock(L); 134 lua_unlock(L);
135 lua_userstateopen(L1); 135 lua_userstateopen(L1);
@@ -169,7 +169,7 @@ LUA_API void lua_remove (lua_State *L, int idx) {
169 lua_lock(L); 169 lua_lock(L);
170 p = luaA_index(L, idx); 170 p = luaA_index(L, idx);
171 api_checkvalidindex(L, p); 171 api_checkvalidindex(L, p);
172 while (++p < L->top) setobjs2s(p-1, p); 172 while (++p < L->top) setobjs2s(L, p-1, p);
173 L->top--; 173 L->top--;
174 lua_unlock(L); 174 lua_unlock(L);
175} 175}
@@ -181,8 +181,8 @@ LUA_API void lua_insert (lua_State *L, int idx) {
181 lua_lock(L); 181 lua_lock(L);
182 p = luaA_index(L, idx); 182 p = luaA_index(L, idx);
183 api_checkvalidindex(L, p); 183 api_checkvalidindex(L, p);
184 for (q = L->top; q>p; q--) setobjs2s(q, q-1); 184 for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
185 setobjs2s(p, L->top); 185 setobjs2s(L, p, L->top);
186 lua_unlock(L); 186 lua_unlock(L);
187} 187}
188 188
@@ -193,7 +193,7 @@ LUA_API void lua_replace (lua_State *L, int idx) {
193 api_checknelems(L, 1); 193 api_checknelems(L, 1);
194 o = luaA_index(L, idx); 194 o = luaA_index(L, idx);
195 api_checkvalidindex(L, o); 195 api_checkvalidindex(L, o);
196 setobj(o, L->top - 1); /* write barrier???? */ 196 setobj(L, o, L->top - 1); /* write barrier???? */
197 L->top--; 197 L->top--;
198 lua_unlock(L); 198 lua_unlock(L);
199} 199}
@@ -201,7 +201,7 @@ LUA_API void lua_replace (lua_State *L, int idx) {
201 201
202LUA_API void lua_pushvalue (lua_State *L, int idx) { 202LUA_API void lua_pushvalue (lua_State *L, int idx) {
203 lua_lock(L); 203 lua_lock(L);
204 setobj2s(L->top, luaA_index(L, idx)); 204 setobj2s(L, L->top, luaA_index(L, idx));
205 api_incr_top(L); 205 api_incr_top(L);
206 lua_unlock(L); 206 lua_unlock(L);
207} 207}
@@ -232,8 +232,8 @@ LUA_API int lua_iscfunction (lua_State *L, int idx) {
232 232
233 233
234LUA_API int lua_isnumber (lua_State *L, int idx) { 234LUA_API int lua_isnumber (lua_State *L, int idx) {
235 TObject n; 235 TValue n;
236 const TObject *o = luaA_index(L, idx); 236 const TValue *o = luaA_index(L, idx);
237 return tonumber(o, &n); 237 return tonumber(o, &n);
238} 238}
239 239
@@ -245,7 +245,7 @@ LUA_API int lua_isstring (lua_State *L, int idx) {
245 245
246 246
247LUA_API int lua_isuserdata (lua_State *L, int idx) { 247LUA_API int lua_isuserdata (lua_State *L, int idx) {
248 const TObject *o = luaA_index(L, idx); 248 const TValue *o = luaA_index(L, idx);
249 return (ttisuserdata(o) || ttislightuserdata(o)); 249 return (ttisuserdata(o) || ttislightuserdata(o));
250} 250}
251 251
@@ -286,8 +286,8 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
286 286
287 287
288LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { 288LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
289 TObject n; 289 TValue n;
290 const TObject *o = luaA_index(L, idx); 290 const TValue *o = luaA_index(L, idx);
291 if (tonumber(o, &n)) 291 if (tonumber(o, &n))
292 return nvalue(o); 292 return nvalue(o);
293 else 293 else
@@ -296,8 +296,8 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
296 296
297 297
298LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { 298LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
299 TObject n; 299 TValue n;
300 const TObject *o = luaA_index(L, idx); 300 const TValue *o = luaA_index(L, idx);
301 if (tonumber(o, &n)) { 301 if (tonumber(o, &n)) {
302 lua_Integer res; 302 lua_Integer res;
303 lua_number2integer(res, nvalue(o)); 303 lua_number2integer(res, nvalue(o));
@@ -309,7 +309,7 @@ LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
309 309
310 310
311LUA_API int lua_toboolean (lua_State *L, int idx) { 311LUA_API int lua_toboolean (lua_State *L, int idx) {
312 const TObject *o = luaA_index(L, idx); 312 const TValue *o = luaA_index(L, idx);
313 return !l_isfalse(o); 313 return !l_isfalse(o);
314} 314}
315 315
@@ -332,11 +332,11 @@ LUA_API const char *lua_tostring (lua_State *L, int idx) {
332LUA_API size_t lua_strlen (lua_State *L, int idx) { 332LUA_API size_t lua_strlen (lua_State *L, int idx) {
333 StkId o = luaA_index(L, idx); 333 StkId o = luaA_index(L, idx);
334 if (ttisstring(o)) 334 if (ttisstring(o))
335 return tsvalue(o)->tsv.len; 335 return tsvalue(o)->len;
336 else { 336 else {
337 size_t l; 337 size_t l;
338 lua_lock(L); /* `luaV_tostring' may create a new string */ 338 lua_lock(L); /* `luaV_tostring' may create a new string */
339 l = (luaV_tostring(L, o) ? tsvalue(o)->tsv.len : 0); 339 l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
340 lua_unlock(L); 340 lua_unlock(L);
341 return l; 341 return l;
342 } 342 }
@@ -352,7 +352,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
352LUA_API void *lua_touserdata (lua_State *L, int idx) { 352LUA_API void *lua_touserdata (lua_State *L, int idx) {
353 StkId o = luaA_index(L, idx); 353 StkId o = luaA_index(L, idx);
354 switch (ttype(o)) { 354 switch (ttype(o)) {
355 case LUA_TUSERDATA: return (uvalue(o) + 1); 355 case LUA_TUSERDATA: return (rawuvalue(o) + 1);
356 case LUA_TLIGHTUSERDATA: return pvalue(o); 356 case LUA_TLIGHTUSERDATA: return pvalue(o);
357 default: return NULL; 357 default: return NULL;
358 } 358 }
@@ -412,7 +412,7 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
412LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { 412LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
413 lua_lock(L); 413 lua_lock(L);
414 luaC_checkGC(L); 414 luaC_checkGC(L);
415 setsvalue2s(L->top, luaS_newlstr(L, s, len)); 415 setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
416 api_incr_top(L); 416 api_incr_top(L);
417 lua_unlock(L); 417 lua_unlock(L);
418} 418}
@@ -459,8 +459,9 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
459 cl->c.f = fn; 459 cl->c.f = fn;
460 L->top -= n; 460 L->top -= n;
461 while (n--) 461 while (n--)
462 setobj2n(&cl->c.upvalue[n], L->top+n); 462 setobj2n(L, &cl->c.upvalue[n], L->top+n);
463 setclvalue(L->top, cl); 463 setclvalue(L, L->top, cl);
464 lua_assert(iswhite(obj2gco(cl)));
464 api_incr_top(L); 465 api_incr_top(L);
465 lua_unlock(L); 466 lua_unlock(L);
466} 467}
@@ -500,11 +501,11 @@ LUA_API void lua_gettable (lua_State *L, int idx) {
500 501
501LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { 502LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
502 StkId t; 503 StkId t;
503 TObject key; 504 TValue key;
504 lua_lock(L); 505 lua_lock(L);
505 t = luaA_index(L, idx); 506 t = luaA_index(L, idx);
506 api_checkvalidindex(L, t); 507 api_checkvalidindex(L, t);
507 setsvalue(&key, luaS_new(L, k)); 508 setsvalue(L, &key, luaS_new(L, k));
508 luaV_gettable(L, t, &key, L->top); 509 luaV_gettable(L, t, &key, L->top);
509 api_incr_top(L); 510 api_incr_top(L);
510 lua_unlock(L); 511 lua_unlock(L);
@@ -516,7 +517,7 @@ LUA_API void lua_rawget (lua_State *L, int idx) {
516 lua_lock(L); 517 lua_lock(L);
517 t = luaA_index(L, idx); 518 t = luaA_index(L, idx);
518 api_check(L, ttistable(t)); 519 api_check(L, ttistable(t));
519 setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1)); 520 setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
520 lua_unlock(L); 521 lua_unlock(L);
521} 522}
522 523
@@ -526,7 +527,7 @@ LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
526 lua_lock(L); 527 lua_lock(L);
527 o = luaA_index(L, idx); 528 o = luaA_index(L, idx);
528 api_check(L, ttistable(o)); 529 api_check(L, ttistable(o));
529 setobj2s(L->top, luaH_getnum(hvalue(o), n)); 530 setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
530 api_incr_top(L); 531 api_incr_top(L);
531 lua_unlock(L); 532 lua_unlock(L);
532} 533}
@@ -535,14 +536,14 @@ LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
535LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { 536LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
536 lua_lock(L); 537 lua_lock(L);
537 luaC_checkGC(L); 538 luaC_checkGC(L);
538 sethvalue(L->top, luaH_new(L, narray, luaO_log2(nrec) + 1)); 539 sethvalue(L, L->top, luaH_new(L, narray, luaO_log2(nrec) + 1));
539 api_incr_top(L); 540 api_incr_top(L);
540 lua_unlock(L); 541 lua_unlock(L);
541} 542}
542 543
543 544
544LUA_API int lua_getmetatable (lua_State *L, int objindex) { 545LUA_API int lua_getmetatable (lua_State *L, int objindex) {
545 const TObject *obj; 546 const TValue *obj;
546 Table *mt = NULL; 547 Table *mt = NULL;
547 int res; 548 int res;
548 lua_lock(L); 549 lua_lock(L);
@@ -552,13 +553,13 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
552 mt = hvalue(obj)->metatable; 553 mt = hvalue(obj)->metatable;
553 break; 554 break;
554 case LUA_TUSERDATA: 555 case LUA_TUSERDATA:
555 mt = uvalue(obj)->uv.metatable; 556 mt = uvalue(obj)->metatable;
556 break; 557 break;
557 } 558 }
558 if (mt == NULL) 559 if (mt == NULL)
559 res = 0; 560 res = 0;
560 else { 561 else {
561 sethvalue(L->top, mt); 562 sethvalue(L, L->top, mt);
562 api_incr_top(L); 563 api_incr_top(L);
563 res = 1; 564 res = 1;
564 } 565 }
@@ -572,7 +573,7 @@ LUA_API void lua_getfenv (lua_State *L, int idx) {
572 lua_lock(L); 573 lua_lock(L);
573 o = luaA_index(L, idx); 574 o = luaA_index(L, idx);
574 api_checkvalidindex(L, o); 575 api_checkvalidindex(L, o);
575 setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L)); 576 setobj2s(L, L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L));
576 api_incr_top(L); 577 api_incr_top(L);
577 lua_unlock(L); 578 lua_unlock(L);
578} 579}
@@ -597,12 +598,12 @@ LUA_API void lua_settable (lua_State *L, int idx) {
597 598
598LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { 599LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
599 StkId t; 600 StkId t;
600 TObject key; 601 TValue key;
601 lua_lock(L); 602 lua_lock(L);
602 api_checknelems(L, 1); 603 api_checknelems(L, 1);
603 t = luaA_index(L, idx); 604 t = luaA_index(L, idx);
604 api_checkvalidindex(L, t); 605 api_checkvalidindex(L, t);
605 setsvalue(&key, luaS_new(L, k)); 606 setsvalue(L, &key, luaS_new(L, k));
606 luaV_settable(L, t, &key, L->top - 1); 607 luaV_settable(L, t, &key, L->top - 1);
607 L->top--; /* pop value */ 608 L->top--; /* pop value */
608 lua_unlock(L); 609 lua_unlock(L);
@@ -615,7 +616,7 @@ LUA_API void lua_rawset (lua_State *L, int idx) {
615 api_checknelems(L, 2); 616 api_checknelems(L, 2);
616 t = luaA_index(L, idx); 617 t = luaA_index(L, idx);
617 api_check(L, ttistable(t)); 618 api_check(L, ttistable(t));
618 setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); 619 setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
619 luaC_barrier(L, hvalue(t), L->top-1); 620 luaC_barrier(L, hvalue(t), L->top-1);
620 L->top -= 2; 621 L->top -= 2;
621 lua_unlock(L); 622 lua_unlock(L);
@@ -628,7 +629,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
628 api_checknelems(L, 1); 629 api_checknelems(L, 1);
629 o = luaA_index(L, idx); 630 o = luaA_index(L, idx);
630 api_check(L, ttistable(o)); 631 api_check(L, ttistable(o));
631 setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); 632 setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
632 luaC_barrier(L, hvalue(o), L->top-1); 633 luaC_barrier(L, hvalue(o), L->top-1);
633 L->top--; 634 L->top--;
634 lua_unlock(L); 635 lua_unlock(L);
@@ -636,7 +637,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
636 637
637 638
638LUA_API int lua_setmetatable (lua_State *L, int objindex) { 639LUA_API int lua_setmetatable (lua_State *L, int objindex) {
639 TObject *obj; 640 TValue *obj;
640 Table *mt; 641 Table *mt;
641 int res = 1; 642 int res = 1;
642 lua_lock(L); 643 lua_lock(L);
@@ -657,9 +658,9 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
657 break; 658 break;
658 } 659 }
659 case LUA_TUSERDATA: { 660 case LUA_TUSERDATA: {
660 uvalue(obj)->uv.metatable = mt; 661 uvalue(obj)->metatable = mt;
661 if (mt) 662 if (mt)
662 luaC_objbarrier(L, uvalue(obj), mt); 663 luaC_objbarrier(L, rawuvalue(obj), mt);
663 break; 664 break;
664 } 665 }
665 default: { 666 default: {
@@ -756,7 +757,7 @@ static void f_Ccall (lua_State *L, void *ud) {
756 Closure *cl; 757 Closure *cl;
757 cl = luaF_newCclosure(L, 0); 758 cl = luaF_newCclosure(L, 0);
758 cl->c.f = c->func; 759 cl->c.f = c->func;
759 setclvalue(L->top, cl); /* push function */ 760 setclvalue(L, L->top, cl); /* push function */
760 incr_top(L); 761 incr_top(L);
761 setpvalue(L->top, c->ud); /* push only argument */ 762 setpvalue(L->top, c->ud); /* push only argument */
762 incr_top(L); 763 incr_top(L);
@@ -791,7 +792,7 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
791 792
792LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { 793LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
793 int status; 794 int status;
794 TObject *o; 795 TValue *o;
795 lua_lock(L); 796 lua_lock(L);
796 api_checknelems(L, 1); 797 api_checknelems(L, 1);
797 o = L->top - 1; 798 o = L->top - 1;
@@ -885,7 +886,7 @@ LUA_API void lua_concat (lua_State *L, int n) {
885 L->top -= (n-1); 886 L->top -= (n-1);
886 } 887 }
887 else if (n == 0) { /* push empty string */ 888 else if (n == 0) { /* push empty string */
888 setsvalue2s(L->top, luaS_newlstr(L, NULL, 0)); 889 setsvalue2s(L, L->top, luaS_newlstr(L, NULL, 0));
889 api_incr_top(L); 890 api_incr_top(L);
890 } 891 }
891 /* else n == 1; nothing to do */ 892 /* else n == 1; nothing to do */
@@ -904,7 +905,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
904 lua_lock(L); 905 lua_lock(L);
905 luaC_checkGC(L); 906 luaC_checkGC(L);
906 u = luaS_newudata(L, size); 907 u = luaS_newudata(L, size);
907 setuvalue(L->top, u); 908 setuvalue(L, L->top, u);
908 api_incr_top(L); 909 api_incr_top(L);
909 lua_unlock(L); 910 lua_unlock(L);
910 return u + 1; 911 return u + 1;
@@ -913,7 +914,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
913 914
914 915
915 916
916static const char *aux_upvalue (lua_State *L, StkId fi, int n, TObject **val) { 917static const char *aux_upvalue (lua_State *L, StkId fi, int n, TValue **val) {
917 Closure *f; 918 Closure *f;
918 if (!ttisfunction(fi)) return NULL; 919 if (!ttisfunction(fi)) return NULL;
919 f = clvalue(fi); 920 f = clvalue(fi);
@@ -933,11 +934,11 @@ static const char *aux_upvalue (lua_State *L, StkId fi, int n, TObject **val) {
933 934
934LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { 935LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
935 const char *name; 936 const char *name;
936 TObject *val; 937 TValue *val;
937 lua_lock(L); 938 lua_lock(L);
938 name = aux_upvalue(L, luaA_index(L, funcindex), n, &val); 939 name = aux_upvalue(L, luaA_index(L, funcindex), n, &val);
939 if (name) { 940 if (name) {
940 setobj2s(L->top, val); 941 setobj2s(L, L->top, val);
941 api_incr_top(L); 942 api_incr_top(L);
942 } 943 }
943 lua_unlock(L); 944 lua_unlock(L);
@@ -947,7 +948,7 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
947 948
948LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { 949LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
949 const char *name; 950 const char *name;
950 TObject *val; 951 TValue *val;
951 StkId fi; 952 StkId fi;
952 lua_lock(L); 953 lua_lock(L);
953 fi = luaA_index(L, funcindex); 954 fi = luaA_index(L, funcindex);
@@ -955,7 +956,7 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
955 name = aux_upvalue(L, fi, n, &val); 956 name = aux_upvalue(L, fi, n, &val);
956 if (name) { 957 if (name) {
957 L->top--; 958 L->top--;
958 setobj(val, L->top); 959 setobj(L, val, L->top);
959 luaC_barrier(L, clvalue(fi), L->top); 960 luaC_barrier(L, clvalue(fi), L->top);
960 } 961 }
961 lua_unlock(L); 962 lua_unlock(L);