aboutsummaryrefslogtreecommitdiffstats
path: root/csc/cps.csc
AgeCommit message (Collapse)AuthorFilesLines
2022-07-24Start codegen.Rose Hogenson1-5/+3
2022-07-24Export some common comparers from hash-map.Rose Hogenson1-2/+7
2022-07-23Add a delete method to the red-black tree.Rose Hogenson1-2/+1
God damn delete is even more complicated than insert. I think it works, at least.
2022-07-22Handle global variables.Rose Hogenson1-12/+26
Global variables will be stored in an array which is kept in register 0. The linker will later translate each library-ref into an integer, which is used as an index into the globals table. This design makes implementing eval quite straightforward, the eval bytecode will accept a globals table and a bytevector of bytecode, save the current set of registers, set register 0 to the new globals table, and begin executing the given bytecode. When eval is finished, it will restore the saved registers and return to the previous instruction pointer. In this way, calling eval can create a call stack. We could think about implementing function calls with eval, and it's cool that it would work, but the CPS transformation mostly makes this irrelevant. It's interesting to think about implementing an interpreter, where a function call would simply eval the function's bytecode, and the function call stack would be handled automatically.
2022-07-20Perform argument conversion.Rose Hogenson1-61/+124
The point of argument conversion is to validate on each function call that the right number of arguments were passed, and to ensure that no function has more than 1 argument. This second condition makes CPS slightly simpler, and ensures that the arguments will all fit in locals. We take the strategy of allocating a vector for each function call. Ideally we would optimize away most of these allocations, but for now I just want it to work.
2022-07-12Add builtin operations to IR1.Rose Hogenson1-14/+28
2022-07-12Remove redundant parentheses in the match macro.Rose Hogenson1-3/+3
I'm marginally reducing verbosity with this change, without sacrificing readability.
2022-07-02Write closure conversion.Rose Hogenson1-32/+165
I desperately need a diffing library.
2022-07-01Add update conversion.Rose Hogenson1-38/+195
Now variables can't be updated after they're created, so they can be freely copied into closures.
2022-06-29Add pattern matching for record types.Rose Hogenson1-122/+115
I like scheme because it's possible to add any convenient language feature I can think of.
2022-06-28Improve CPS.Rose Hogenson1-105/+119
Goodbye soup. Thanks to "Compiling with Continuations" by Appel.
2022-06-26Finish CPS.Rose Hogenson1-0/+58
Wow we actually finished CPS. Next is closure conversion, then codegen, and then we should be able to run some end to end tests. Then we can look at garbage collection, and from there continue building features down the long road to self hosting.
2022-06-26More CPS.Rose Hogenson1-47/+69
I improved the abstraction in to-cps.
2022-06-25More CPS.Rose Hogenson1-0/+23
2022-06-25Continue work on continuation passing style.Rose Hogenson1-7/+60
2022-06-21More progress on CPS.Rose Hogenson1-2/+6
2022-06-21Start CPS :)Rose Hogenson1-0/+22