swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 1 | #+TITLE: Lisp Notes |
| 2 | #+AUTHOR: swissChili |
| 3 | |
| 4 | * Compiler |
| 5 | |
| 6 | The compiler will using DynASM to generate code at runtime. It won’t |
| 7 | be a JIT (no interpreter), strictly a dynamic compiler. |
| 8 | |
| 9 | For now I won’t even have a register allocator, all variables and |
| 10 | temporaries will be stored on the stack. This makes more or less |
| 11 | sense considering they will need to be put on the stack anyway when |
| 12 | a function is called. |
| 13 | |
| 14 | An example assembly is in =scratch.s=. |
| 15 | |
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 16 | Values will be encoded as double words, where the lowest few bits |
| 17 | indicate the type. |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 18 | |
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 19 | ** Closures and lambdas |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 20 | |
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 21 | Closures will have to be done in two passes, one pass to find the |
| 22 | free variables and one to generate the code. Free variables will be |
| 23 | accessed as an offset to =edi=, which will point to the location of |
| 24 | the lambda on the heap. =[edi]= will evaluate to the address of the |
| 25 | lambda, =[edi + 1]= for the first free variable, etc. |