2 ms·
I also made a closure converting pass to my compiler (in racket also!) Here's mine: https://github.com/sinistersnare/SinScheme/blob/master/src/racket/closure-c
by sinistersnare 8y ago
I also made a closure converting pass to my compiler (in racket also!)
Here's mine: https://github.com/sinistersnare/SinScheme/blob/master/src/racket/closure-convert.rkt https://github.com/sinistersnare/SinScheme/blob/master/src/r...
- abecedarius 8y agoYet another: this is the whole compiler, but for a simpler language and target. https://github.com/darius/squeam/blob/master/eg/lambdacompiler.scm https://github.com/darius/squeam/blob/master/eg/lambdacompil... It's in my own Scheme variant, I'm afraid. I guess I should translate it to something people know. But, for example ;; Variable reference (to (var-ref<- v) (make ({.free-vars} (set<- v)) ({.compile s k} (cons (s v) k)))) turns a source-code variable access into an AST object with two methods: 1. The free-variable set of this AST has just that one variable. 2. To compile this to bytecode, given a scope s and following code k, ask the scope what instruction to emit for this variable, and prepend that to k. (In general k is passed in for the sake of tail-call optimization, on line 33.)