| author | Tom Harley | 2019-11-09 19:47:29 +0000 |
|---|---|---|
| committer | Tom Harley | 2019-11-10 03:18:30 +0000 |
| commit | 58ab7191eecd6d1758356bafd40ff40b42daf3d0 (patch) | |
| tree | b9afe784416c02ca1b9d08f41db889ee68911ece /examples | |
| parent | Enable -Weverything (diff) | |
| download | sinter-58ab7191eecd6d1758356bafd40ff40b42daf3d0.tar.gz sinter-58ab7191eecd6d1758356bafd40ff40b42daf3d0.zip | |
Add basics for interpreter; add CLI options
The compiler now accepts options on the command-line, such as whether to interpret or compile, or what kind of output is desired.
Instead of mallocing (and creating a memory leak), generated code now uses the Boehm garbage collector to allocate memory for boxes. I’m not entirely sure how the GC works, but it does seem to be working (tested by setting the environment variable GC_PRINT_STATS when running a compiled program that calculates a Fibonacci number). More testing relating to the GC should be created.
The basics for an interpreted mode has been started, but getting it to work fully would be difficult: it would require figuring out how to dynamically link LLVM modules/object files into the LLVM execution engine, both for calling wrapper functions and for using the GC.
Removed -Weverything because it was finding problems in the GC code despite it being included as a system library.
The main function of an inter program has been renamed to inter_main. The GC requires GC_INIT is invoked at initialisation on some systems, so common.c now contains the real main function, which runs GC_INIT followed by inter_main. GC_INIT is a macro, so it cannot be called easily from LLVMIR.
