prog: main test.fp
./main < test.fp > forsp.ir
llc -march=x86 -filetype=obj --relocation-model=pic forsp.ir -O1
- clang -c support.c -m32 -Os
- clang support.o forsp.ir.o -m32 -Os
+ $(CC) -c support.c -m32 -Os
+ $(CC) support.o forsp.ir.o -m32 -Os
clean:
rm -f a.out main *.ir *.o
* Lisp-style S-expression syntax
* Forth-style data stack for parameters/values
* Linking with C functions (see `support.c`)
+* Recursion: `$self` gets pointer to current function
Missing features:
+* Captured variables: Functions/lambdas are *not dynamic* and do not capture the state of previously declared variables
* Quote operator: `quote`/`'`
-* Lists and atoms or any dynamic allocations
+* Built-in dynamic allocations (implement them via platform-specific `support.c`)
## Building
void cons()
{
int32_t *st = &stack;
- int32_t *pair = malloc(2 * sizeof(int32_t));
+ int32_t *pair = (int32_t *)malloc(2 * sizeof(int32_t));
--sp;
pair[0] = st[sp];
pair[1] = st[sp - 1];