-
Notifications
You must be signed in to change notification settings - Fork 14
6. Compile flags
These flags can be toggled when compiling, most of the flags alter the output, but some have different uses:
Changes the way bitwise operators are compiled, cen be 3 different modes:
-
Clue
: Assumes the outputted Lua implementation uses the same operators as Clue, and leaves them as is. -
library
: Automatically addslocal bit = require("bit")
in every file that uses bitwise operators, and then converts the operators into function calls. -
vanilla
: For Lua 5.3 and 5.4 (or any implementation derived from them), works similarly toClue
mode, but converts XORs (^^
) to~
.
Short version: -b
Uses a custom file as the base for the output of the compiled directory.
This file can be any Lua file that should have:
-
local _modules = {§}
: where the output of all files will be located. -
--STATICS
: where the static variables will be located.
Note: the base file is only used when a directory is compiled.
Short version: -c
This flag has three modes to choose from:
-
Simple
: This mode uses the nativecontinue
keyword and can only be used in implementations which support it. -
goto
: Clue will usegoto continue;
and a::continue::
label when compilingcontinue
keywords instead of assuming the version of Lua you're compiling to has a propercontinue
keyword. This will work with most versions of Lua. -
Moonscript
: This approach is guaranteed to work with any version of Lua although it has a performance impact because it uses a loop. -
LuaJIT
: Deprecated, usegoto
instead,
Short version: -d
When this flag is enabled Clue will include additional debugging information to the output.
With this additional information, if an error happens the error message will include the line and the original .clue
file's name from where the error came, which can ease debugging.
Note: all the additional code added to the output will easily reduce performance, thus this flag should only used when debugging.
Short version: -D
When this flag is enabled Clue will still compile the given Clue code, but it will not save it to the output file (which won't even be created).
This flag can be used combined with --output
to quickly test Clue code without saving it to a file.
Short version: -e
When this flag is enabled Clue will execute the compiled code once it finished compiling and display any output it prints in the console.
The Lua interpreter that Clue uses is LuaJIT.
This flag can be combined with --dontsave
to test Clue code without saving it.
Short version: -E
When this flag is enabled Clue will print the given files after they have been processed by the preprocessor.
Short version: -h
When this flag is enabled Clue will not start compiling and will instead print a message with general information on how to use Clue.
Short version: -j
Note: this flag is deprecated, use --bitwise
instead.
When this flag is enabled Clue will assume the version of Lua you're compiling to is LuaJIT and will use the bit library for bitwise operations.
When enabling this flag you also have to choose the name of the variable that will store the bit library (example: --jitbit=bit
will name the variable bit
).
When this flag is enabled, after compiling a file, Clue will print the output in the console.
This flag can be used combined with --dontsave
to quickly test Clue code without saving it to a file.
Short version: -p
When this flag is enabled Clue will not treat the given path as a path but as Clue code directly.
This can be used to quickly test Clue code.
Short version: -r
When this flag is enabled Clue will use Lua's rawset
function when compiling globals
This flag can be helpful when the version of Lua you're compiling to does not allow globals without rawset.
When this flag is enabled Clue will print the syntax structure/tree after parsing the file.
When this flag is enabled Clue will print the list of tokens after scanning.
Short version: -V
When this flag is enabled Clue will not start compiling and will instead print the version of Clue you're using.
Short version: -L
When this flag is enabled Clue will not start compiling and will instead print Clue's license information.