diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-01-29 14:47:06 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-01-29 14:47:06 -0300 |
| commit | f7439112a5469078ac4f444106242cf1c1d3fe8a (patch) | |
| tree | 8d177fb83cc52fbcff4b8539f026b87d1bdd9750 | |
| parent | 39a14ea7d7b14172595c61619e8f35c2614b2606 (diff) | |
| download | lua-f7439112a5469078ac4f444106242cf1c1d3fe8a.tar.gz lua-f7439112a5469078ac4f444106242cf1c1d3fe8a.tar.bz2 lua-f7439112a5469078ac4f444106242cf1c1d3fe8a.zip | |
Details (in test library)
- Added support for negative stack indices in the "C interpreter"
- Improved format when printing values
| -rw-r--r-- | ltests.c | 21 |
1 files changed, 16 insertions, 5 deletions
| @@ -343,13 +343,19 @@ void lua_printvalue (TValue *v) { | |||
| 343 | printf("%s", (!l_isfalse(v) ? "true" : "false")); | 343 | printf("%s", (!l_isfalse(v) ? "true" : "false")); |
| 344 | break; | 344 | break; |
| 345 | } | 345 | } |
| 346 | case LUA_TLIGHTUSERDATA: { | ||
| 347 | printf("light udata: %p", pvalue(v)); | ||
| 348 | break; | ||
| 349 | } | ||
| 346 | case LUA_TNIL: { | 350 | case LUA_TNIL: { |
| 347 | printf("nil"); | 351 | printf("nil"); |
| 348 | break; | 352 | break; |
| 349 | } | 353 | } |
| 350 | default: { | 354 | default: { |
| 351 | void *p = iscollectable(v) ? gcvalue(v) : NULL; | 355 | if (ttislcf(v)) |
| 352 | printf("%s: %p", ttypename(ttype(v)), p); | 356 | printf("light C function: %p", fvalue(v)); |
| 357 | else /* must be collectable */ | ||
| 358 | printf("%s: %p", ttypename(ttype(v)), gcvalue(v)); | ||
| 353 | break; | 359 | break; |
| 354 | } | 360 | } |
| 355 | } | 361 | } |
| @@ -1499,9 +1505,14 @@ static int getindex_aux (lua_State *L, lua_State *L1, const char **pc) { | |||
| 1499 | skip(pc); | 1505 | skip(pc); |
| 1500 | switch (*(*pc)++) { | 1506 | switch (*(*pc)++) { |
| 1501 | case 'R': return LUA_REGISTRYINDEX; | 1507 | case 'R': return LUA_REGISTRYINDEX; |
| 1502 | case 'G': return luaL_error(L, "deprecated index 'G'"); | ||
| 1503 | case 'U': return lua_upvalueindex(getnum_aux(L, L1, pc)); | 1508 | case 'U': return lua_upvalueindex(getnum_aux(L, L1, pc)); |
| 1504 | default: (*pc)--; return getnum_aux(L, L1, pc); | 1509 | default: { |
| 1510 | int n; | ||
| 1511 | (*pc)--; /* to read again */ | ||
| 1512 | n = getnum_aux(L, L1, pc); | ||
| 1513 | if (n == 0) return 0; | ||
| 1514 | else return lua_absindex(L1, n); | ||
| 1515 | } | ||
| 1505 | } | 1516 | } |
| 1506 | } | 1517 | } |
| 1507 | 1518 | ||
| @@ -1550,7 +1561,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
| 1550 | const char *inst = getstring; | 1561 | const char *inst = getstring; |
| 1551 | if EQ("") return 0; | 1562 | if EQ("") return 0; |
| 1552 | else if EQ("absindex") { | 1563 | else if EQ("absindex") { |
| 1553 | lua_pushinteger(L1, lua_absindex(L1, getindex)); | 1564 | lua_pushinteger(L1, getindex); |
| 1554 | } | 1565 | } |
| 1555 | else if EQ("append") { | 1566 | else if EQ("append") { |
| 1556 | int t = getindex; | 1567 | int t = getindex; |
