||1 month ago|
|runtime||1 month ago|
|slc||1 month ago|
|.gitignore||1 month ago|
|Makefile||1 month ago|
|README.md||1 month ago|
slc - slope language compiler
So, compiler is sort of a misnomer here. It is more like freezing the runtime with a linked version of the slope source code.
How it works
When you run
slc with a given slope source code file it will replace all calls to
load-mod-file with the contents of the given files (this happens recursively to ensure all needed components are included). That file will be saved and embeded into the slope runtime as, which will then be compiled by the Go compiler. The resulting binary will lex, parse, and evaluate the source code just as the interpreter would.
The resulting binary will be fairly large as it packages both the necessary components of the go runtime as well as the slope runtime on top of that. Execution should be at least as fast as the slope interpreter. So the main gain by using
slc is that you can more easily distribute your
slope programs. To combat some size issues some compiler flags are used to discard binary debugging information. You can reduce the size significantly by processing the resulting file with upx, if you have it on your system.
Example slc usage:
slc -name myprogram ./myprogram.slo
Since the Go compiler is used under the hood here, you can set environment variables to enable cross-compilation for a different OS or architecture:
GOOS=linux GOARCH=386 slc -name myprogram ./myprogram.slo
If you need to link in the gui lib use the
slc -name my-program -g ./myprogram.slo
- go >= 1.16 is required for building
slc, but must also exist on the system that is running
slopeinterpreter, however, is not required
make; it is possible BSD make will work, but GNU make was used for testing
- a slope file you want to freeze/"compile"
To install, navigate to the root of this repo, then do the following:
make # builds the slc binary sudo make install # global installs slp & runtime lib
If you do not wish to install globally or do not have sudo privleges:
make configure # locally installs the runtime lib make # builds the binary mv ./slc/slc . # moves the binary to current dir, or elsewhere if you replace the last . with a path