Commit Graph

5 Commits (d9edbab10c05e51aa727d147207c72ea5a9fcc1f)

Author SHA1 Message Date
James T. Martin d9edbab10c
Fix calculation of labels and jump destinations.
Previously, all calculations regarding stack depth and label depth
were broken. *All* of them. Off-by-ones, the logic was wrong, etc.
Variables are still screwed up, but I'm *almost* there, where
"there" is being able to generate functioning programs, hopefully?
2022-10-19 15:42:04 -07:00
James T. Martin 68ce32a6df
Slightly unfuck codegen for relative jumps and blocks.
Still pretty horribly broken. I was generating dispacements
backwards, failing to emit stuff like the beginning of
loops, the logic for `if` jumps was backwards, etc.
I was also completely forgetting to increment file_here
for appends. I don't remember what all I did; check the diff.
2022-10-19 12:21:46 -07:00
James T. Martin 1383484e06
No assertions fail during codegen (lang.c) for test file.
The generated executable is still incorrect
for reasons which I have not yet investigated,
but this is still a step forward.
2022-10-17 11:45:38 -07:00
James T. Martin 4c4ebeecfc
Fixed bug: use references to mutate the stack instead of values. 2022-09-10 09:07:38 -07:00
James T. Martin fcd61f6c5f
Wrote IR gen!! (Literally untested, though.)
Next stages are to wire it into the parser so I can test it,
to implement operator precedence so exprs actually exist,
and then implement operators and builtins until I can
start writing basic programs.
2022-09-08 21:07:40 -07:00