aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2022-07-30Fix some test cases in the compiler.Rose Hogenson3-29/+30
2022-07-30Write more tests for decode.Rose Hogenson1-15/+261
2022-07-29Fix the bytecode interpreter.Rose Hogenson9-796/+1173
I'm too scared to actually try to run it right now.
2022-07-29Insert an exit op at the end of the program.Rose Hogenson4-15/+9
2022-07-29Handle the (csc builtins) library separately.Rose Hogenson1-7/+15
2022-07-29Fix test failures.Rose Hogenson3-97/+115
2022-07-29Fig bugs in the flag library.Rose Hogenson2-11/+31
Now bool flags are handled properly. We have a compiler!!
2022-07-29Fix some compilation errors in the compiler.Rose Hogenson7-15/+72
2022-07-28Write the CLI frontend.Rose Hogenson3-5/+170
2022-07-28Improve the strings API.Rose Hogenson6-223/+264
I'm just copying the go strings library API.
2022-07-28Add the compiler frontend.Rose Hogenson2-0/+142
I haven't written any tests yet, so this code probably doesn't even compile.
2022-07-28Use a better interface for macros.Rose Hogenson2-109/+140
2022-07-28Use a better interface for linker.Rose Hogenson2-37/+53
2022-07-28Better interface for join.Rose Hogenson2-5/+5
2022-07-28Use a better hashing scheme for identifiers.Rose Hogenson1-3/+1
2022-07-26Slightly improve the hash function.Rose Hogenson1-6/+7
2022-07-26Fix a potential R7RS issue.Rose Hogenson16-1568/+1608
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-26Fix an issue with how the linker combined files.Rose Hogenson4-32/+55
I inserted jump statements into the bytecode at the beginning of each compilation unit, to jump to the init label. The point is that now the bytecode can be executed from start to finish, and assuming the libraries were ordered correctly, it will run the full program.
2022-07-25Document the plan for symbols.Rose Hogenson1-5/+5
2022-07-25Re-write the encoding library.Rose Hogenson2-93/+209
I greatly improved the library, and changed it to expect register bytecode instead of stack-based.
2022-07-25Re-write the linker.Rose Hogenson2-57/+111
2022-07-25Slightly improve loop.Rose Hogenson1-35/+28
The advantage to this approach is that the user can modify the loop variables and the variables will be stepped as expected, e.g. (loop for i from 1 to 10 do (set! i (+ 1 i)) collect i) should return '(2 4 6 8 10).
2022-07-25Fix a bug in comparing bytevectors.Rose Hogenson1-1/+3
2022-07-25Write unit tests for codegen.Rose Hogenson2-74/+169
2022-07-24Write a test for codegen.Rose Hogenson4-6/+18
I'm not sure yet how to test regalloc.
2022-07-24Fix some bugs in the compare library.Rose Hogenson3-59/+84
2022-07-24Start codegen.Rose Hogenson5-27/+300
2022-07-24Improve the match syntax for constants.Rose Hogenson4-71/+75
I guess you can pattern match using quote as a literal. That's pretty cool.
2022-07-24Fix a bug in loop with nested collect statements.Rose Hogenson2-6/+15
2022-07-24Export some common comparers from hash-map.Rose Hogenson5-48/+74
2022-07-24Improve the loop macro collect statement.Rose Hogenson2-381/+423
Now you can use multiple collect statements and they will all accumulate into the same variable. I think in common lisp you could collect into the same variable even with collect x into, but it's pretty unclear to me how to do that in Scheme. How would we know that they are the same variable?
2022-07-23Delete set.cscRose Hogenson2-334/+0
Let's not introduce dead code.
2022-07-23Add set library.Rose Hogenson2-0/+334
This will maybe be useful for live variable analysis.
2022-07-23Add a delete method to the red-black tree.Rose Hogenson5-94/+361
God damn delete is even more complicated than insert. I think it works, at least.
2022-07-22Handle global variables.Rose Hogenson3-24/+56
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-22Slightly clean up the indentation in hash-map.Rose Hogenson1-114/+110
2022-07-22Fix a bug in matching record types.Rose Hogenson2-1/+10
Running the record matcher has a side-effect (raising *no-match*), so we call it ahead of time to ensure a consistent order of evaluation.
2022-07-20Perform argument conversion.Rose Hogenson9-131/+334
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 Hogenson3-14/+80
2022-07-12Slightly improve diff formatting.Rose Hogenson2-51/+51
2022-07-12Remove redundant parentheses in the match macro.Rose Hogenson4-28/+28
I'm marginally reducing verbosity with this change, without sacrificing readability.
2022-07-03Update a comment in compare.csc.Rose Hogenson1-4/+0
2022-07-03Add a diff library.Rose Hogenson12-191/+549
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 Hogenson8-163/+356
I desperately need a diffing library.
2022-07-01Add update conversion.Rose Hogenson3-145/+345
Now variables can't be updated after they're created, so they can be freely copied into closures.
2022-06-30Remove unsafe code.Rose Hogenson1-57/+48
I'm partially doing it because I'm not sure if what I had was really safe, but also it just looks much cleaner this way.
2022-06-30Add a function for getting the gensym ID.Rose Hogenson1-2/+3
2022-06-29Add pattern matching for record types.Rose Hogenson5-152/+233
I like scheme because it's possible to add any convenient language feature I can think of.
2022-06-28Improve CPS.Rose Hogenson9-431/+357
Goodbye soup. Thanks to "Compiling with Continuations" by Appel.
2022-06-26Finish CPS.Rose Hogenson6-12/+182
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.