I can now run this program:
fn main -> result/ebx: int {
result <- do-add 3 4
}
fn do-add a: int, b: int -> result/ebx: int {
result <- copy a
result <- add b
}
We still can't define local variables, but can write any programs involving
ints by passing in enough arguments for temporaries.
We haven't implemented it yet, but there's now a design for how we check
whether a function has written its output correctly. Functions must write
to each output at the top level at least once, and never overwrite an output
register in the top-level once it's been defined.
This is conservative (it can be perfectly reasonable for functions to write
the output, reuse the register for a temporary, and then write the output
again) but easy to check.
One test failing. It took enough debugging just to get to the expected
failure that it seems worth saving this snapshot.
Saw some signs that I have to remember to zero-out allocated memory. We
need a scalable solution for this.
I think parse-var-with-type needs to be rewritten. Just added a test and
a hacky fix for now.
A couple more primitives now working. In the process I ran into an issue
with some buffer filling up when running ntranslate. Isolating it to survey.subx
was straightforward, but --trace ran out of RAM, and --trace --dump ran
out of (7GB of) disk. In the end what helped was just repeatedly inserting
exits at different points, and I realized there was a magic number that
hadn't been turned into a named constant.
Support binary operations with reg/mem and reg operands.
Everything is passing. However, the self-hosting translator now generates
some discrepancies compared to the C++ translator :(