compile(script, @key assemble, exe, ld_options, cc_options, output, exception_handler)
Compile the Slogan source code
script file into the intermediate language or machine code.
The code in intermediate language is suitable for interpretation by the Slogan interpreter while machine code can be executed directly on hardware.
script is compiled to
produce a standalone executable.
true, a dynamically loadable file of
machine instructions is generated from
cc_options must be a string that specifies additional command-line options
for the C compiler, which is used internally by Slogan for generating machine code.
ld_options must be a string that specifies additional command-line options
for the linker.
The name of the generated file may be customized using
exception_handler must be a function that takes a single argument.
If compilation raises an exception, this function will be called with the error object
as the argument.
true on success.
// hello.sn showln("hello, world")
The above script can be compiled into intermediate language representation by the call,
.scm file can be loaded and interpreted by the Slogan interpreter.
The script can be translated into a dynamically loadable machine code module by,
compile("hello", assemble = true)
The resulting machine code (or object code) file can be linked into a Slogan program, including the interpreter (the REPL).
If the target machine do not have the Slogan interpreter or runtime installed, you can generate a standalone executable that will run directly on hardware:
compile("hello", exe = true)
Core Module Index | Contents