1
1
/*
2
- ** $Id: lapi.c,v 2.257 2015/11/02 18:48:07 roberto Exp $
2
+ ** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp $
3
3
** Lua API
4
4
** See Copyright Notice in lua.h
5
5
*/
@@ -378,9 +378,9 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
378
378
return NULL ;
379
379
}
380
380
lua_lock (L ); /* 'luaO_tostring' may create a new string */
381
+ luaO_tostring (L , o );
381
382
luaC_checkGC (L );
382
383
o = index2addr (L , idx ); /* previous call may reallocate the stack */
383
- luaO_tostring (L , o );
384
384
lua_unlock (L );
385
385
}
386
386
if (len != NULL )
@@ -479,10 +479,10 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
479
479
LUA_API const char * lua_pushlstring (lua_State * L , const char * s , size_t len ) {
480
480
TString * ts ;
481
481
lua_lock (L );
482
- luaC_checkGC (L );
483
482
ts = (len == 0 ) ? luaS_new (L , "" ) : luaS_newlstr (L , s , len );
484
483
setsvalue2s (L , L -> top , ts );
485
484
api_incr_top (L );
485
+ luaC_checkGC (L );
486
486
lua_unlock (L );
487
487
return getstr (ts );
488
488
}
@@ -494,12 +494,12 @@ LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
494
494
setnilvalue (L -> top );
495
495
else {
496
496
TString * ts ;
497
- luaC_checkGC (L );
498
497
ts = luaS_new (L , s );
499
498
setsvalue2s (L , L -> top , ts );
500
499
s = getstr (ts ); /* internal copy's address */
501
500
}
502
501
api_incr_top (L );
502
+ luaC_checkGC (L );
503
503
lua_unlock (L );
504
504
return s ;
505
505
}
@@ -509,8 +509,8 @@ LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
509
509
va_list argp ) {
510
510
const char * ret ;
511
511
lua_lock (L );
512
- luaC_checkGC (L );
513
512
ret = luaO_pushvfstring (L , fmt , argp );
513
+ luaC_checkGC (L );
514
514
lua_unlock (L );
515
515
return ret ;
516
516
}
@@ -520,10 +520,10 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
520
520
const char * ret ;
521
521
va_list argp ;
522
522
lua_lock (L );
523
- luaC_checkGC (L );
524
523
va_start (argp , fmt );
525
524
ret = luaO_pushvfstring (L , fmt , argp );
526
525
va_end (argp );
526
+ luaC_checkGC (L );
527
527
lua_unlock (L );
528
528
return ret ;
529
529
}
@@ -538,7 +538,6 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
538
538
CClosure * cl ;
539
539
api_checknelems (L , n );
540
540
api_check (L , n <= MAXUPVAL , "upvalue index too large" );
541
- luaC_checkGC (L );
542
541
cl = luaF_newCclosure (L , n );
543
542
cl -> f = fn ;
544
543
L -> top -= n ;
@@ -549,6 +548,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
549
548
setclCvalue (L , L -> top , cl );
550
549
}
551
550
api_incr_top (L );
551
+ luaC_checkGC (L );
552
552
lua_unlock (L );
553
553
}
554
554
@@ -585,16 +585,16 @@ LUA_API int lua_pushthread (lua_State *L) {
585
585
586
586
587
587
static int auxgetstr (lua_State * L , const TValue * t , const char * k ) {
588
- const TValue * aux ;
588
+ const TValue * slot ;
589
589
TString * str = luaS_new (L , k );
590
- if (luaV_fastget (L , t , str , aux , luaH_getstr )) {
591
- setobj2s (L , L -> top , aux );
590
+ if (luaV_fastget (L , t , str , slot , luaH_getstr )) {
591
+ setobj2s (L , L -> top , slot );
592
592
api_incr_top (L );
593
593
}
594
594
else {
595
595
setsvalue2s (L , L -> top , str );
596
596
api_incr_top (L );
597
- luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , aux );
597
+ luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , slot );
598
598
}
599
599
lua_unlock (L );
600
600
return ttnov (L -> top - 1 );
@@ -626,17 +626,17 @@ LUA_API int lua_getfield (lua_State *L, int idx, const char *k) {
626
626
627
627
LUA_API int lua_geti (lua_State * L , int idx , lua_Integer n ) {
628
628
StkId t ;
629
- const TValue * aux ;
629
+ const TValue * slot ;
630
630
lua_lock (L );
631
631
t = index2addr (L , idx );
632
- if (luaV_fastget (L , t , n , aux , luaH_getint )) {
633
- setobj2s (L , L -> top , aux );
632
+ if (luaV_fastget (L , t , n , slot , luaH_getint )) {
633
+ setobj2s (L , L -> top , slot );
634
634
api_incr_top (L );
635
635
}
636
636
else {
637
637
setivalue (L -> top , n );
638
638
api_incr_top (L );
639
- luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , aux );
639
+ luaV_finishget (L , t , L -> top - 1 , L -> top - 1 , slot );
640
640
}
641
641
lua_unlock (L );
642
642
return ttnov (L -> top - 1 );
@@ -683,12 +683,12 @@ LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) {
683
683
LUA_API void lua_createtable (lua_State * L , int narray , int nrec ) {
684
684
Table * t ;
685
685
lua_lock (L );
686
- luaC_checkGC (L );
687
686
t = luaH_new (L );
688
687
sethvalue (L , L -> top , t );
689
688
api_incr_top (L );
690
689
if (narray > 0 || nrec > 0 )
691
690
luaH_resize (L , t , narray , nrec );
691
+ luaC_checkGC (L );
692
692
lua_unlock (L );
693
693
}
694
694
@@ -740,15 +740,15 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) {
740
740
** t[k] = value at the top of the stack (where 'k' is a string)
741
741
*/
742
742
static void auxsetstr (lua_State * L , const TValue * t , const char * k ) {
743
- const TValue * aux ;
743
+ const TValue * slot ;
744
744
TString * str = luaS_new (L , k );
745
745
api_checknelems (L , 1 );
746
- if (luaV_fastset (L , t , str , aux , luaH_getstr , L -> top - 1 ))
746
+ if (luaV_fastset (L , t , str , slot , luaH_getstr , L -> top - 1 ))
747
747
L -> top -- ; /* pop value */
748
748
else {
749
749
setsvalue2s (L , L -> top , str ); /* push 'str' (to make it a TValue) */
750
750
api_incr_top (L );
751
- luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , aux );
751
+ luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , slot );
752
752
L -> top -= 2 ; /* pop value and key */
753
753
}
754
754
lua_unlock (L ); /* lock done by caller */
@@ -781,16 +781,16 @@ LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
781
781
782
782
LUA_API void lua_seti (lua_State * L , int idx , lua_Integer n ) {
783
783
StkId t ;
784
- const TValue * aux ;
784
+ const TValue * slot ;
785
785
lua_lock (L );
786
786
api_checknelems (L , 1 );
787
787
t = index2addr (L , idx );
788
- if (luaV_fastset (L , t , n , aux , luaH_getint , L -> top - 1 ))
788
+ if (luaV_fastset (L , t , n , slot , luaH_getint , L -> top - 1 ))
789
789
L -> top -- ; /* pop value */
790
790
else {
791
791
setivalue (L -> top , n );
792
792
api_incr_top (L );
793
- luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , aux );
793
+ luaV_finishset (L , t , L -> top - 1 , L -> top - 2 , slot );
794
794
L -> top -= 2 ; /* pop value and key */
795
795
}
796
796
lua_unlock (L );
@@ -1140,14 +1140,14 @@ LUA_API void lua_concat (lua_State *L, int n) {
1140
1140
lua_lock (L );
1141
1141
api_checknelems (L , n );
1142
1142
if (n >= 2 ) {
1143
- luaC_checkGC (L );
1144
1143
luaV_concat (L , n );
1145
1144
}
1146
1145
else if (n == 0 ) { /* push empty string */
1147
1146
setsvalue2s (L , L -> top , luaS_newlstr (L , "" , 0 ));
1148
1147
api_incr_top (L );
1149
1148
}
1150
1149
/* else n == 1; nothing to do */
1150
+ luaC_checkGC (L );
1151
1151
lua_unlock (L );
1152
1152
}
1153
1153
@@ -1183,10 +1183,10 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
1183
1183
LUA_API void * lua_newuserdata (lua_State * L , size_t size ) {
1184
1184
Udata * u ;
1185
1185
lua_lock (L );
1186
- luaC_checkGC (L );
1187
1186
u = luaS_newudata (L , size );
1188
1187
setuvalue (L , L -> top , u );
1189
1188
api_incr_top (L );
1189
+ luaC_checkGC (L );
1190
1190
lua_unlock (L );
1191
1191
return getudatamem (u );
1192
1192
}
0 commit comments