From a89d6c82e981fec7d6e4c975e083d2b9e04467ad Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Mon, 1 May 2023 07:56:42 -0700 Subject: Rewrite most of the compiler. This represents a major step back in terms of functionality, and amount of code. The latter I think constitutes a major win. Next steps are to reimplement syntax-rules, call/cc, and call-with-values. --- lib/csc/ir.scheme | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 lib/csc/ir.scheme (limited to 'lib/csc/ir.scheme') diff --git a/lib/csc/ir.scheme b/lib/csc/ir.scheme new file mode 100644 index 0000000..94c1d32 --- /dev/null +++ b/lib/csc/ir.scheme @@ -0,0 +1,131 @@ +(define-library (csc ir) + (export + *void* + apply-args + apply-func + apply? + call-builtin-args + call-builtin-name + call-builtin? + const-val + const? + label-var + label? + lambda-body + lambda-vars + lambda? + letrec-body + letrec-funcs + letrec? + libvar-lib + libvar-var + libvar? + make-apply + make-call-builtin + make-const + make-label + make-lambda + make-letrec + make-libvar + make-primop + make-sequence + make-set + primop-args + primop-ks + primop-name + primop-vals + primop? + sequence-head + sequence-tail + sequence? + set-body + set-var + set? + void?) + (import (scheme base)) + (begin + + + (define-record-type + (make-libvar library var) + libvar? + (library libvar-lib) + (var libvar-var)) + + + ;; ---------- IR1 + + (define-record-type + (make-lambda vars body) + lambda? + (vars lambda-vars) + (body lambda-body)) + + + (define-record-type + (make-letrec funcs body) + letrec? + (funcs letrec-funcs) + (body letrec-body)) + + + (define-record-type + (make-apply func args) + apply? + (func apply-func) + (args apply-args)) + + + (define-record-type + (make-sequence head tail) + sequence? + (head sequence-head) + (tail sequence-tail)) + + + (define-record-type + (make-set var body) + set? + (var set-var) + (body set-body)) + + + (define-record-type + (make-call-builtin name args) + call-builtin? + (name call-builtin-name) + (args call-builtin-args)) + + + (define-record-type + (make-const val) + const? + (val const-val)) + + + (define-record-type + (make-void) + void?) + + + (define *void* (make-void)) + + + ;; ------------- CPS + + ; , , , and are also IR2 forms. + + + (define-record-type