This is a good first stab at things, but a number of improvements can be done, mostly to reduce technical debt:
[x] The deindent function can be moved from the test files into L::B::Test, avoiding making it public and avoiding some repetition.
[ ] Would like to produce a nice diff when a bytecode test fails, instead of comparing the whole strings.
[x] Split up the compiler into individual nanopass stages — the sooner we do this, the better.
[x] Have a safer way to construct the instructions (which does argument sanity checking). (I already tried this once, and it seems we still need ways to refer to the opcodes (when interpreting or serializing a bytefunc), but as long as we do that it's fine.)
[ ] Compiler has an unhealthy dependency on read_whole, which I have a nagging feeling could be replaced with something faster and narrower.
[ ] More generally, the individual nanopasses could probably be phrased more in terms of efficient one-pass tree traversal and modification. Basically, there could be a higher-level DSL that can be extracted from the nanopasses. Maybe efficient code can be generated from a high-level statement in terms of AST transformations.
[ ] The special case about treating no as a kind of expression-y primitive should be replaced with inlining it from a set of already-compiled bytefuncs.
[ ] Generalize the parameter handling (which right now supports only one parameter).
None of this needs to happen before merge, but can serve as a list of good ideas for the near future.
Oh, but there is an XXX case introduced in the code which I would like to fix before merge. Mostly because that one is easy to fix, and orthogonal to everything else. Just need an additional test file for it. Fixed!
Closes #106.
This is a good first stab at things, but a number of improvements can be done, mostly to reduce technical debt:
deindent
function can be moved from the test files intoL::B::Test
, avoiding making it public and avoiding some repetition.read_whole
, which I have a nagging feeling could be replaced with something faster and narrower.no
as a kind of expression-y primitive should be replaced with inlining it from a set of already-compiled bytefuncs.None of this needs to happen before merge, but can serve as a list of good ideas for the near future.
Oh, but there is anFixed!XXX
case introduced in the code which I would like to fix before merge. Mostly because that one is easy to fix, and orthogonal to everything else. Just need an additional test file for it.