diff options
| -rw-r--r-- | lopcodes.h | 5 | ||||
| -rw-r--r-- | manual/manual.of | 16 | ||||
| -rw-r--r-- | testes/heavy.lua | 18 |
3 files changed, 23 insertions, 16 deletions
| @@ -340,7 +340,7 @@ OP_VARARG,/* A C R[A], R[A+1], ..., R[A+C-2] = vararg */ | |||
| 340 | 340 | ||
| 341 | OP_GETVARG, /* A B C R[A] := R[B][R[C]], R[B] is vararg parameter */ | 341 | OP_GETVARG, /* A B C R[A] := R[B][R[C]], R[B] is vararg parameter */ |
| 342 | 342 | ||
| 343 | OP_ERRNNIL,/* A Bx raise error if R[A] ~= nil (K[Bx] is global name)*/ | 343 | OP_ERRNNIL,/* A Bx raise error if R[A] ~= nil (K[Bx - 1] is global name)*/ |
| 344 | 344 | ||
| 345 | OP_VARARGPREP,/* (adjust vararg parameters) */ | 345 | OP_VARARGPREP,/* (adjust vararg parameters) */ |
| 346 | 346 | ||
| @@ -386,6 +386,9 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
| 386 | power of 2) plus 1, or zero for size zero. If not k, the array size | 386 | power of 2) plus 1, or zero for size zero. If not k, the array size |
| 387 | is vC. Otherwise, the array size is EXTRAARG _ vC. | 387 | is vC. Otherwise, the array size is EXTRAARG _ vC. |
| 388 | 388 | ||
| 389 | (*) In OP_ERRNNIL, (Bx == 0) means index of global name doesn't | ||
| 390 | fit in Bx. (So, that name is not available for the instruction.) | ||
| 391 | |||
| 389 | (*) For comparisons, k specifies what condition the test should accept | 392 | (*) For comparisons, k specifies what condition the test should accept |
| 390 | (true or false). | 393 | (true or false). |
| 391 | 394 | ||
diff --git a/manual/manual.of b/manual/manual.of index 9b6976ca..96203d7f 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
| @@ -2402,7 +2402,7 @@ g(3, 4, 5, 8) a=3, b=4, ... -> 5 8 | |||
| 2402 | g(5, r()) a=5, b=1, ... -> 2 3 | 2402 | g(5, r()) a=5, b=1, ... -> 2 3 |
| 2403 | } | 2403 | } |
| 2404 | 2404 | ||
| 2405 | The presence of a varag table in a variadic function is indicated | 2405 | The presence of a vararg table in a variadic function is indicated |
| 2406 | by a name after the three dots. | 2406 | by a name after the three dots. |
| 2407 | When present, | 2407 | When present, |
| 2408 | a vararg table behaves like a read-only local variable | 2408 | a vararg table behaves like a read-only local variable |
| @@ -2418,8 +2418,9 @@ local <const> name = table.pack(...) | |||
| 2418 | } | 2418 | } |
| 2419 | 2419 | ||
| 2420 | As an optimization, | 2420 | As an optimization, |
| 2421 | if the vararg table is used only as a base in indexing expressions | 2421 | if the vararg table is used only as the base table |
| 2422 | (the @T{t} in @T{t[exp]} or @T{t.id}) and it is not an upvalue, | 2422 | in the syntactic constructions @T{t[exp]} or @T{t.id}) |
| 2423 | and it is not an upvalue, | ||
| 2423 | the code does not create an actual table and instead translates | 2424 | the code does not create an actual table and instead translates |
| 2424 | the indexing expressions into accesses to the internal vararg data. | 2425 | the indexing expressions into accesses to the internal vararg data. |
| 2425 | 2426 | ||
| @@ -2427,8 +2428,7 @@ the indexing expressions into accesses to the internal vararg data. | |||
| 2427 | 2428 | ||
| 2428 | } | 2429 | } |
| 2429 | 2430 | ||
| 2430 | @sect3{multires| @title{Lists of expressions, multiple results, | 2431 | @sect3{multires| @title{Lists of Expressions, Multiple Results, and Adjustment} |
| 2431 | and adjustment} | ||
| 2432 | 2432 | ||
| 2433 | Both function calls and vararg expressions can result in multiple values. | 2433 | Both function calls and vararg expressions can result in multiple values. |
| 2434 | These expressions are called @def{multires expressions}. | 2434 | These expressions are called @def{multires expressions}. |
| @@ -2686,7 +2686,7 @@ which behaves like a nil value. | |||
| 2686 | 2686 | ||
| 2687 | } | 2687 | } |
| 2688 | 2688 | ||
| 2689 | @sect3{constchar|@title{Pointers to strings} | 2689 | @sect3{constchar|@title{Pointers to Strings} |
| 2690 | 2690 | ||
| 2691 | Several functions in the API return pointers (@T{const char*}) | 2691 | Several functions in the API return pointers (@T{const char*}) |
| 2692 | to Lua strings in the stack. | 2692 | to Lua strings in the stack. |
| @@ -4126,6 +4126,8 @@ Lua still has to allocate a header for the string. | |||
| 4126 | In case of a memory-allocation error, | 4126 | In case of a memory-allocation error, |
| 4127 | Lua will call @id{falloc} before raising the error. | 4127 | Lua will call @id{falloc} before raising the error. |
| 4128 | 4128 | ||
| 4129 | The function returns a pointer to the string (that is, @id{s}). | ||
| 4130 | |||
| 4129 | } | 4131 | } |
| 4130 | 4132 | ||
| 4131 | 4133 | ||
| @@ -8413,7 +8415,7 @@ a value greater than any other numeric value. | |||
| 8413 | 8415 | ||
| 8414 | } | 8416 | } |
| 8415 | 8417 | ||
| 8416 | @LibEntry{math.ldexp(m, e)| | 8418 | @LibEntry{math.ldexp (m, e)| |
| 8417 | 8419 | ||
| 8418 | Returns @M{m2@sp{e}}, where @id{e} is an integer. | 8420 | Returns @M{m2@sp{e}}, where @id{e} is an integer. |
| 8419 | 8421 | ||
diff --git a/testes/heavy.lua b/testes/heavy.lua index 3b4e4ce3..e7219a91 100644 --- a/testes/heavy.lua +++ b/testes/heavy.lua | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | -- $Id: testes/heavy.lua,v $ | 1 | -- $Id: testes/heavy.lua,v $ |
| 2 | -- See Copyright Notice in file lua.h | 2 | -- See Copyright Notice in file lua.h |
| 3 | 3 | ||
| 4 | global <const> * | ||
| 5 | |||
| 4 | local function teststring () | 6 | local function teststring () |
| 5 | print("creating a string too long") | 7 | print("creating a string too long") |
| 6 | do | 8 | do |
| @@ -47,9 +49,9 @@ local function loadrep (x, what) | |||
| 47 | end | 49 | end |
| 48 | 50 | ||
| 49 | 51 | ||
| 50 | function controlstruct () | 52 | local function controlstruct () |
| 51 | print("control structure too long") | 53 | print("control structure too long") |
| 52 | local lim = ((1 << 24) - 2) // 3 | 54 | local lim = ((1 << 24) - 2) // 4 |
| 53 | local s = string.rep("a = a + 1\n", lim) | 55 | local s = string.rep("a = a + 1\n", lim) |
| 54 | s = "while true do " .. s .. "end" | 56 | s = "while true do " .. s .. "end" |
| 55 | assert(load(s)) | 57 | assert(load(s)) |
| @@ -63,7 +65,7 @@ function controlstruct () | |||
| 63 | end | 65 | end |
| 64 | 66 | ||
| 65 | 67 | ||
| 66 | function manylines () | 68 | local function manylines () |
| 67 | print("loading chunk with too many lines") | 69 | print("loading chunk with too many lines") |
| 68 | local st, msg = loadrep("\n", "lines") | 70 | local st, msg = loadrep("\n", "lines") |
| 69 | assert(not st and string.find(msg, "too many lines")) | 71 | assert(not st and string.find(msg, "too many lines")) |
| @@ -71,7 +73,7 @@ function manylines () | |||
| 71 | end | 73 | end |
| 72 | 74 | ||
| 73 | 75 | ||
| 74 | function hugeid () | 76 | local function hugeid () |
| 75 | print("loading chunk with huge identifier") | 77 | print("loading chunk with huge identifier") |
| 76 | local st, msg = loadrep("a", "chars") | 78 | local st, msg = loadrep("a", "chars") |
| 77 | assert(not st and | 79 | assert(not st and |
| @@ -80,7 +82,7 @@ function hugeid () | |||
| 80 | print('+') | 82 | print('+') |
| 81 | end | 83 | end |
| 82 | 84 | ||
| 83 | function toomanyinst () | 85 | local function toomanyinst () |
| 84 | print("loading chunk with too many instructions") | 86 | print("loading chunk with too many instructions") |
| 85 | local st, msg = loadrep("a = 10; ", "instructions") | 87 | local st, msg = loadrep("a = 10; ", "instructions") |
| 86 | print('+') | 88 | print('+') |
| @@ -107,7 +109,7 @@ local function loadrepfunc (prefix, f) | |||
| 107 | end | 109 | end |
| 108 | 110 | ||
| 109 | 111 | ||
| 110 | function toomanyconst () | 112 | local function toomanyconst () |
| 111 | print("loading function with too many constants") | 113 | print("loading function with too many constants") |
| 112 | loadrepfunc("function foo () return {0,", | 114 | loadrepfunc("function foo () return {0,", |
| 113 | function (n) | 115 | function (n) |
| @@ -126,7 +128,7 @@ function toomanyconst () | |||
| 126 | end | 128 | end |
| 127 | 129 | ||
| 128 | 130 | ||
| 129 | function toomanystr () | 131 | local function toomanystr () |
| 130 | local a = {} | 132 | local a = {} |
| 131 | local st, msg = pcall(function () | 133 | local st, msg = pcall(function () |
| 132 | for i = 1, math.huge do | 134 | for i = 1, math.huge do |
| @@ -144,7 +146,7 @@ function toomanystr () | |||
| 144 | end | 146 | end |
| 145 | 147 | ||
| 146 | 148 | ||
| 147 | function toomanyidx () | 149 | local function toomanyidx () |
| 148 | local a = {} | 150 | local a = {} |
| 149 | local st, msg = pcall(function () | 151 | local st, msg = pcall(function () |
| 150 | for i = 1, math.huge do | 152 | for i = 1, math.huge do |
