Преглед изворни кода

Details

Comments, capitalization in the manual, globals in test 'heady.lua'
Roberto I пре 2 месеци
родитељ
комит
d94f7ba304
3 измењених фајлова са 23 додато и 16 уклоњено
  1. 4 1
      lopcodes.h
  2. 9 7
      manual/manual.of
  3. 10 8
      testes/heavy.lua

+ 4 - 1
lopcodes.h

@@ -340,7 +340,7 @@ OP_VARARG,/*	A C	R[A], R[A+1], ..., R[A+C-2] = vararg		*/
 
 
 OP_GETVARG, /* A B C	R[A] := R[B][R[C]], R[B] is vararg parameter    */
 OP_GETVARG, /* A B C	R[A] := R[B][R[C]], R[B] is vararg parameter    */
 
 
-OP_ERRNNIL,/*	A Bx	raise error if R[A] ~= nil (K[Bx] is global name)*/
+OP_ERRNNIL,/*	A Bx	raise error if R[A] ~= nil (K[Bx - 1] is global name)*/
 
 
 OP_VARARGPREP,/* 	(adjust vararg parameters)			*/
 OP_VARARGPREP,/* 	(adjust vararg parameters)			*/
 
 
@@ -386,6 +386,9 @@ OP_EXTRAARG/*	Ax	extra (larger) argument for previous opcode	*/
   power of 2) plus 1, or zero for size zero. If not k, the array size
   power of 2) plus 1, or zero for size zero. If not k, the array size
   is vC. Otherwise, the array size is EXTRAARG _ vC.
   is vC. Otherwise, the array size is EXTRAARG _ vC.
 
 
+  (*) In OP_ERRNNIL, (Bx == 0) means index of global name doesn't
+  fit in Bx. (So, that name is not available for the instruction.)
+
   (*) For comparisons, k specifies what condition the test should accept
   (*) For comparisons, k specifies what condition the test should accept
   (true or false).
   (true or false).
 
 

+ 9 - 7
manual/manual.of

@@ -2402,7 +2402,7 @@ g(3, 4, 5, 8)    a=3, b=4,   ... ->  5  8
 g(5, r())        a=5, b=1,   ... ->  2  3
 g(5, r())        a=5, b=1,   ... ->  2  3
 }
 }
 
 
-The presence of a varag table in a variadic function is indicated
+The presence of a vararg table in a variadic function is indicated
 by a name after the three dots.
 by a name after the three dots.
 When present,
 When present,
 a vararg table behaves like a read-only local variable
 a vararg table behaves like a read-only local variable
@@ -2418,8 +2418,9 @@ local <const> name = table.pack(...)
 }
 }
 
 
 As an optimization,
 As an optimization,
-if the vararg table is used only as a base in indexing expressions
-(the @T{t} in @T{t[exp]} or @T{t.id}) and it is not an upvalue,
+if the vararg table is used only as the base table
+in the syntactic constructions @T{t[exp]} or @T{t.id})
+and it is not an upvalue,
 the code does not create an actual table and instead translates
 the code does not create an actual table and instead translates
 the indexing expressions into accesses to the internal vararg data.
 the indexing expressions into accesses to the internal vararg data.
 
 
@@ -2427,8 +2428,7 @@ the indexing expressions into accesses to the internal vararg data.
 
 
 }
 }
 
 
-@sect3{multires| @title{Lists of expressions, multiple results,
-and adjustment}
+@sect3{multires| @title{Lists of Expressions, Multiple Results, and Adjustment}
 
 
 Both function calls and vararg expressions can result in multiple values.
 Both function calls and vararg expressions can result in multiple values.
 These expressions are called @def{multires expressions}.
 These expressions are called @def{multires expressions}.
@@ -2686,7 +2686,7 @@ which behaves like a nil value.
 
 
 }
 }
 
 
-@sect3{constchar|@title{Pointers to strings}
+@sect3{constchar|@title{Pointers to Strings}
 
 
 Several functions in the API return pointers (@T{const char*})
 Several functions in the API return pointers (@T{const char*})
 to Lua strings in the stack.
 to Lua strings in the stack.
@@ -4126,6 +4126,8 @@ Lua still has to allocate a header for the string.
 In case of a memory-allocation error,
 In case of a memory-allocation error,
 Lua will call @id{falloc} before raising the error.
 Lua will call @id{falloc} before raising the error.
 
 
+The function returns a pointer to the string (that is, @id{s}).
+
 }
 }
 
 
 
 
@@ -8413,7 +8415,7 @@ a value greater than any other numeric value.
 
 
 }
 }
 
 
-@LibEntry{math.ldexp(m, e)|
+@LibEntry{math.ldexp (m, e)|
 
 
 Returns @M{m2@sp{e}}, where @id{e} is an integer.
 Returns @M{m2@sp{e}}, where @id{e} is an integer.
 
 

+ 10 - 8
testes/heavy.lua

@@ -1,6 +1,8 @@
 -- $Id: testes/heavy.lua,v $
 -- $Id: testes/heavy.lua,v $
 -- See Copyright Notice in file lua.h
 -- See Copyright Notice in file lua.h
 
 
+global <const> *
+
 local function teststring ()
 local function teststring ()
   print("creating a string too long")
   print("creating a string too long")
   do
   do
@@ -47,9 +49,9 @@ local function loadrep (x, what)
 end
 end
 
 
 
 
-function controlstruct ()
+local function controlstruct ()
   print("control structure too long")
   print("control structure too long")
-  local lim = ((1 << 24) - 2) // 3
+  local lim = ((1 << 24) - 2) // 4
   local s = string.rep("a = a + 1\n", lim)
   local s = string.rep("a = a + 1\n", lim)
   s = "while true do " .. s .. "end"
   s = "while true do " .. s .. "end"
   assert(load(s))
   assert(load(s))
@@ -63,7 +65,7 @@ function controlstruct ()
 end
 end
 
 
 
 
-function manylines ()
+local function manylines ()
   print("loading chunk with too many lines")
   print("loading chunk with too many lines")
   local st, msg = loadrep("\n", "lines")
   local st, msg = loadrep("\n", "lines")
   assert(not st and string.find(msg, "too many lines"))
   assert(not st and string.find(msg, "too many lines"))
@@ -71,7 +73,7 @@ function manylines ()
 end
 end
 
 
 
 
-function hugeid ()
+local function hugeid ()
   print("loading chunk with huge identifier")
   print("loading chunk with huge identifier")
   local st, msg = loadrep("a", "chars")
   local st, msg = loadrep("a", "chars")
   assert(not st and 
   assert(not st and 
@@ -80,7 +82,7 @@ function hugeid ()
   print('+')
   print('+')
 end
 end
 
 
-function toomanyinst ()
+local function toomanyinst ()
   print("loading chunk with too many instructions")
   print("loading chunk with too many instructions")
   local st, msg = loadrep("a = 10; ", "instructions")
   local st, msg = loadrep("a = 10; ", "instructions")
   print('+')
   print('+')
@@ -107,7 +109,7 @@ local function loadrepfunc (prefix, f)
 end
 end
 
 
 
 
-function toomanyconst ()
+local function toomanyconst ()
   print("loading function with too many constants")
   print("loading function with too many constants")
   loadrepfunc("function foo () return {0,",
   loadrepfunc("function foo () return {0,",
       function (n)
       function (n)
@@ -126,7 +128,7 @@ function toomanyconst ()
 end
 end
 
 
 
 
-function toomanystr ()
+local function toomanystr ()
   local a = {}
   local a = {}
   local st, msg = pcall(function ()
   local st, msg = pcall(function ()
     for i = 1, math.huge do
     for i = 1, math.huge do
@@ -144,7 +146,7 @@ function toomanystr ()
 end
 end
 
 
 
 
-function toomanyidx ()
+local function toomanyidx ()
   local a = {}
   local a = {}
   local st, msg = pcall(function ()
   local st, msg = pcall(function ()
     for i = 1, math.huge do
     for i = 1, math.huge do