aboutsummaryrefslogtreecommitdiffstats
path: root/csc/cps-test.csc
AgeCommit message (Collapse)AuthorFilesLines
2022-08-01Modify the project structure.Rose Hogenson1-499/+0
Now the lib directory contains what will eventually end up on the user's /usr/lib/csc. When I write make install, it will copy all of the .csc files from lib into the destination lib directory. This means I can start working on the standard library in lib/scheme.
2022-07-29Fix test failures.Rose Hogenson1-8/+7
2022-07-26Fix a potential R7RS issue.Rose Hogenson1-429/+431
I was using the load procedure to load a program, but by a strict reading of R7RS, load can only handle expressions and definitions, not imports. So instead I'm defining each test as a library, and using the environment procedure to load them at runtime.
2022-07-24Start codegen.Rose Hogenson1-6/+6
2022-07-22Handle global variables.Rose Hogenson1-9/+12
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-50/+184
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-0/+33
2022-07-03Add a diff library.Rose Hogenson1-33/+81
I was hesitant to add a diff library, but it was surprisingly easy. A straightforward application of dynamic programming.
2022-07-02Write closure conversion.Rose Hogenson1-67/+135
I desperately need a diffing library.
2022-07-01Add update conversion.Rose Hogenson1-52/+101
Now variables can't be updated after they're created, so they can be freely copied into closures.
2022-06-28Improve CPS.Rose Hogenson1-133/+105
Goodbye soup. Thanks to "Compiling with Continuations" by Appel.
2022-06-26Finish CPS.Rose Hogenson1-0/+59
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-11/+42
I improved the abstraction in to-cps.
2022-06-25More CPS.Rose Hogenson1-0/+26
2022-06-25Continue work on continuation passing style.Rose Hogenson1-7/+64
2022-06-21More progress on CPS.Rose Hogenson1-0/+18