diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-11-26 11:18:29 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-11-26 11:18:29 -0300 |
| commit | f33cc4ddec886ea499d7d41dd60cac5ddc5687db (patch) | |
| tree | 917dccdbb60f984b21f5f7e1c0c3aa4f4f758ddc /testes/db.lua | |
| parent | d94f7ba3040eb06895d7305014e88157d3bfd1a1 (diff) | |
| download | lua-f33cc4ddec886ea499d7d41dd60cac5ddc5687db.tar.gz lua-f33cc4ddec886ea499d7d41dd60cac5ddc5687db.tar.bz2 lua-f33cc4ddec886ea499d7d41dd60cac5ddc5687db.zip | |
New conceptual model for vararg
Conceptually, all functions get their vararg arguments in a vararg
table. The storing of vararg arguments in the stack is always treated
as an optimization.
Diffstat (limited to 'testes/db.lua')
| -rw-r--r-- | testes/db.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/testes/db.lua b/testes/db.lua index 0f174f17..4220b68b 100644 --- a/testes/db.lua +++ b/testes/db.lua | |||
| @@ -356,8 +356,8 @@ function f(a,b) | |||
| 356 | global assert, g, string | 356 | global assert, g, string |
| 357 | local _, y = debug.getlocal(1, 2) | 357 | local _, y = debug.getlocal(1, 2) |
| 358 | assert(x == a and y == b) | 358 | assert(x == a and y == b) |
| 359 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") | 359 | assert(debug.setlocal(2, 4, "pera") == "AA".."AA") |
| 360 | assert(debug.setlocal(2, 4, "manga") == "B") | 360 | assert(debug.setlocal(2, 5, "manga") == "B") |
| 361 | x = debug.getinfo(2) | 361 | x = debug.getinfo(2) |
| 362 | assert(x.func == g and x.what == "Lua" and x.name == 'g' and | 362 | assert(x.func == g and x.what == "Lua" and x.name == 'g' and |
| 363 | x.nups == 2 and string.find(x.source, "^@.*db%.lua$")) | 363 | x.nups == 2 and string.find(x.source, "^@.*db%.lua$")) |
| @@ -392,7 +392,7 @@ function g (...) | |||
| 392 | global * | 392 | global * |
| 393 | local B = 13 | 393 | local B = 13 |
| 394 | global<const> assert | 394 | global<const> assert |
| 395 | local x,y = debug.getlocal(1,5) | 395 | local x,y = debug.getlocal(1,6) |
| 396 | assert(x == 'B' and y == 13) | 396 | assert(x == 'B' and y == 13) |
| 397 | end | 397 | end |
| 398 | end | 398 | end |
| @@ -458,7 +458,8 @@ local function collectlocals (level) | |||
| 458 | local tab = {} | 458 | local tab = {} |
| 459 | for i = 1, math.huge do | 459 | for i = 1, math.huge do |
| 460 | local n, v = debug.getlocal(level + 1, i) | 460 | local n, v = debug.getlocal(level + 1, i) |
| 461 | if not (n and string.find(n, "^[a-zA-Z0-9_]+$")) then | 461 | if not (n and string.find(n, "^[a-zA-Z0-9_]+$") or |
| 462 | n == "(vararg table)") then | ||
| 462 | break -- consider only real variables | 463 | break -- consider only real variables |
| 463 | end | 464 | end |
| 464 | tab[n] = v | 465 | tab[n] = v |
