Lhogho
0.0.028
|
Go to the source code of this file.
Data Structures | |
struct | ctxnode |
Macros | |
#define | COMPILE_AS_FUNC 0 |
compile and check result to be non-unbound More... | |
#define | COMPILE_AS_PROC 1 |
compile and check result to be unbound More... | |
#define | COMPILE_AS_UNKNOWN 2 |
compile and accept any result More... | |
#define | COMPILE_AS_NON_MACRO 0 |
The COMPILE_AS_*_MACRO are independent on the other COMPILE_AS_* symbols. More... | |
#define | COMPILE_AS_MACRO 1 |
compile a function as a macro More... | |
#define | MAGIC_NUMBER 1980069381 |
code for standard standalone executables More... | |
#define | MAGIC_COMPILER_NUMBER 1761700097 |
code for custom Lhogho compilers More... | |
Typedefs | |
typedef struct ctxnode | context_t |
structure holding compilation context More... | |
Functions | |
void | init_compiler (outter_t outter, inner_t inner, inner_eof_t inner_eof) |
initializes the compiler More... | |
void | finit_compiler () |
finalizes the compiler More... | |
int | compile_from_options () |
compiles according to options More... | |
atom_t | compile_to_file () |
compiles into executable file More... | |
atom_t | compile_function (atom_t func, int mode, int is_macro) |
compiles a function More... | |
atom_t | compile_external_function (atom_t func) |
compiles an external function More... | |
atom_t | compile_internal_function (atom_t func, int static_link) |
compiles an internal function More... | |
int | run_source (chars_t source) |
compiles and runs source code More... | |
int | run_function (atom_t function) |
runs the compiled code of a function More... | |
Variables | |
int | running_compiled_code |
indicate whether generated code is currently running More... | |
int | compiling_code |
indicate whether source code is currently compiling More... | |
#define COMPILE_AS_FUNC 0 |
Definition at line 47 of file compiler.h.
#define COMPILE_AS_PROC 1 |
Definition at line 48 of file compiler.h.
#define COMPILE_AS_UNKNOWN 2 |
Definition at line 49 of file compiler.h.
#define COMPILE_AS_NON_MACRO 0 |
compile a function as a function
Definition at line 53 of file compiler.h.
#define COMPILE_AS_MACRO 1 |
Definition at line 54 of file compiler.h.
#define MAGIC_NUMBER 1980069381 |
Definition at line 60 of file compiler.h.
#define MAGIC_COMPILER_NUMBER 1761700097 |
Definition at line 61 of file compiler.h.
void init_compiler | ( | outter_t | outter, |
inner_t | inner, | ||
inner_eof_t | inner_eof | ||
) |
outter | outter function to use by dump and dumpln |
inner | inner function to use for text input |
inner_eof | inner_eof function to test eof of text input |
Initializes the compiler and all other modules
Definition at line 169 of file compiler.c.
void finit_compiler | ( | ) |
int compile_from_options | ( | ) |
Compiles according to the compiler's options. In case of error dumps the error message and returns non-zero value.
Definition at line 242 of file compiler.c.
atom_t compile_to_file | ( | ) |
Compiles current source into executable file. The name of the file is based on the name of the external source. EXE
extension is used for Windows systems. For Linux no extension is used. The generated file has read-write-execute user permisions.
If the option_make_executable_compiler is set, then the compiled file acts like a compiler in respect to its inputs.
If the option_make_executable is set, then the compiled file acts as a standalone file and does not use any of the Lhogho options.
Definition at line 341 of file compiler.c.
func | function to compile |
mode | compilation mode (COMPILE_AS_ macros) |
is_macro | macro mode |
Compiles the body of a function. If the function is not parsed or a syntax tree is not generated then parse and treeify it first.
If is_macro
is false, then the epilogue of the function releases all local variables - created at compile or at runtime.
If is_macro
is true, then the epilogue of the function calls a function to process the locals. This function would typically save the locals in the parent variable.
Definition at line 608 of file compiler.c.
func | function to compile |
Compiles the trampoline of an external function.
Definition at line 744 of file compiler.c.
func | function to compile |
static_link | static link from the current frame |
Compiles the trampoline of an internal function.
Definition at line 810 of file compiler.c.
int run_source | ( | chars_t | source) |
Compiles source code as if it is the main program. No variables are cleared before or after the compilation. Then runs the compiled code.
Definition at line 550 of file compiler.c.
int run_function | ( | atom_t | function) |
Runs the compiled code of a function. Assumes the function is already compiled without error. If error occurs during execution the error is dumped on the output stream and its code is returned.
Definition at line 480 of file compiler.c.
int running_compiled_code |
Definition at line 138 of file compiler.c.
int compiling_code |
Definition at line 139 of file compiler.c.