aboutsummaryrefslogtreecommitdiff
path: root/src/lua/ltable.c
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-03-03 21:31:01 +0800
committerLi Jin <dragon-fly@qq.com>2021-03-03 21:33:37 +0800
commit1df786307c1983b8ce693e3916081a8bcd4e95ae (patch)
tree6c7aeb2198d825877fd3d179c394b7a5c1f06a17 /src/lua/ltable.c
parent66168b112b707172b9035edf8c1daed469781e06 (diff)
downloadyuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.gz
yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.bz2
yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.zip
add new metatable syntax for issue #41, fix reusing local variable issue, update built-in Lua.
Diffstat (limited to 'src/lua/ltable.c')
-rw-r--r--src/lua/ltable.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lua/ltable.c b/src/lua/ltable.c
index e98bab7..b520cdf 100644
--- a/src/lua/ltable.c
+++ b/src/lua/ltable.c
@@ -307,7 +307,7 @@ static unsigned int findindex (lua_State *L, Table *t, TValue *key,
307 return i; /* yes; that's the index */ 307 return i; /* yes; that's the index */
308 else { 308 else {
309 const TValue *n = getgeneric(t, key, 1); 309 const TValue *n = getgeneric(t, key, 1);
310 if (unlikely(isabstkey(n))) 310 if (l_unlikely(isabstkey(n)))
311 luaG_runerror(L, "invalid key to 'next'"); /* key not found */ 311 luaG_runerror(L, "invalid key to 'next'"); /* key not found */
312 i = cast_int(nodefromval(n) - gnode(t, 0)); /* key index in hash table */ 312 i = cast_int(nodefromval(n) - gnode(t, 0)); /* key index in hash table */
313 /* hash elements are numbered after array ones */ 313 /* hash elements are numbered after array ones */
@@ -541,7 +541,7 @@ void luaH_resize (lua_State *L, Table *t, unsigned int newasize,
541 } 541 }
542 /* allocate new array */ 542 /* allocate new array */
543 newarray = luaM_reallocvector(L, t->array, oldasize, newasize, TValue); 543 newarray = luaM_reallocvector(L, t->array, oldasize, newasize, TValue);
544 if (unlikely(newarray == NULL && newasize > 0)) { /* allocation failed? */ 544 if (l_unlikely(newarray == NULL && newasize > 0)) { /* allocation failed? */
545 freehash(L, &newt); /* release new hash part */ 545 freehash(L, &newt); /* release new hash part */
546 luaM_error(L); /* raise error (with array unchanged) */ 546 luaM_error(L); /* raise error (with array unchanged) */
547 } 547 }
@@ -635,7 +635,7 @@ static Node *getfreepos (Table *t) {
635void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) { 635void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) {
636 Node *mp; 636 Node *mp;
637 TValue aux; 637 TValue aux;
638 if (unlikely(ttisnil(key))) 638 if (l_unlikely(ttisnil(key)))
639 luaG_runerror(L, "table index is nil"); 639 luaG_runerror(L, "table index is nil");
640 else if (ttisfloat(key)) { 640 else if (ttisfloat(key)) {
641 lua_Number f = fltvalue(key); 641 lua_Number f = fltvalue(key);
@@ -644,7 +644,7 @@ void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) {
644 setivalue(&aux, k); 644 setivalue(&aux, k);
645 key = &aux; /* insert it as an integer */ 645 key = &aux; /* insert it as an integer */
646 } 646 }
647 else if (unlikely(luai_numisnan(f))) 647 else if (l_unlikely(luai_numisnan(f)))
648 luaG_runerror(L, "table index is NaN"); 648 luaG_runerror(L, "table index is NaN");
649 } 649 }
650 if (ttisnil(value)) 650 if (ttisnil(value))