diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-12 11:38:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-12 11:38:42 -0300 |
commit | f6aab3ec1f111cd8d968bdcb7ca800e93b819d24 (patch) | |
tree | 4c36c418ecc9062e6d95de73457198b38b0afce9 /manual | |
parent | be8445d7e4b6122620c428877b51a27d464253d5 (diff) | |
download | lua-github-f6aab3ec1f111cd8d968bdcb7ca800e93b819d24.tar.gz |
First implementation of constant propagation
Local constant variables initialized with compile-time constants
are optimized away from the code.
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/manual/manual.of b/manual/manual.of index 136e9022..61fcdaa3 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -223,7 +223,7 @@ In Lua, the global variable @Lid{_G} is initialized with this same value. so changing its value will affect only your own code.) When Lua loads a chunk, -the default value for its @id{_ENV} upvalue +the default value for its @id{_ENV} variable is the global environment @seeF{load}. Therefore, by default, free names in Lua code refer to entries in the global environment @@ -233,7 +233,7 @@ and some functions there operate on that environment. You can use @Lid{load} (or @Lid{loadfile}) to load a chunk with a different environment. (In C, you have to load the chunk and then change the value -of its first upvalue.) +of its first upvalue; see @See{lua_setupvalue}.) } @@ -1224,7 +1224,7 @@ As such, chunks can define local variables, receive arguments, and return values. Moreover, such anonymous function is compiled as in the scope of an external local variable called @id{_ENV} @see{globalenv}. -The resulting function always has @id{_ENV} as its only upvalue, +The resulting function always has @id{_ENV} as its only external variable, even if it does not use that variable. A chunk can be stored in a file or in a string inside the host program. @@ -2241,8 +2241,8 @@ and so the second @id{x} refers to the outside variable. Because of the @x{lexical scoping} rules, local variables can be freely accessed by functions defined inside their scope. -A local variable used by an inner function is called -an @def{upvalue}, or @emphx{external local variable}, +A local variable used by an inner function is called an @def{upvalue} +(or @emphx{external local variable}, or simply @emphx{external variable}) inside the inner function. Notice that each execution of a @Rw{local} statement @@ -4765,11 +4765,7 @@ and returns its name. Returns @id{NULL} (and pushes nothing) when the index @id{n} is greater than the number of upvalues. -For @N{C functions}, this function uses the empty string @T{""} -as a name for all upvalues. -(For Lua functions, -upvalues are the external local variables that the function uses, -and that are consequently included in its closure.) +See @Lid{debug.getupvalue} for more information about upvalues. } @@ -8485,6 +8481,8 @@ The first parameter or local variable has @N{index 1}, and so on, following the order that they are declared in the code, counting only the variables that are active in the current scope of the function. +Compile-time constants may not appear in this listing, +if they were optimized away by the compiler. Negative indices refer to vararg arguments; @num{-1} is the first vararg argument. The function returns @nil if there is no variable with the given index, @@ -8520,8 +8518,15 @@ This function returns the name and the value of the upvalue with index @id{up} of the function @id{f}. The function returns @nil if there is no upvalue with the given index. -Variable names starting with @Char{(} (open parenthesis) @C{)} -represent variables with no known names +(For Lua functions, +upvalues are the external local variables that the function uses, +and that are consequently included in its closure.) + +For @N{C functions}, this function uses the empty string @T{""} +as a name for all upvalues. + +Variable name @Char{?} (interrogation mark) +represents variables with no known names (variables from chunks saved without debug information). } @@ -8626,6 +8631,8 @@ The function returns @nil if there is no upvalue with the given index. Otherwise, it returns the name of the upvalue. +See @Lid{debug.getupvalue} for more information about upvalues. + } @LibEntry{debug.setuservalue (udata, value, n)| |