diff options
Diffstat (limited to 'csc/ir2.csc')
| -rw-r--r-- | csc/ir2.csc | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/csc/ir2.csc b/csc/ir2.csc index 9b9397f..40109fe 100644 --- a/csc/ir2.csc +++ b/csc/ir2.csc @@ -78,7 +78,9 @@ (only (csc list) all) (only (csc loop) loop - return)) + return) + (only (csc match) + define-match-record-type)) (begin ; This library defines the intermediate representation IR2. ; It's CPS time bitch. @@ -90,6 +92,27 @@ ; - constant, ; - lexical-ref, ; - or library-ref + ; After closure conversion, lexical refs are no longer allowed. + ; Lexical refs are converted to one of the below data types. + + + ; A variable representing the address of a function in the same compilation + ; unit. This will be a constant after linking. + (define-match-record-type <label> + (make-label gensym) + label? + %label + (gensym label-gensym)) + + + ; A local variable. This can be an argument to a function or the result of + ; a primitive. + (define-match-record-type <var> + (make-var gensym) + var? + %var + (gensym var-gensym)) + ; CPS expressions: ; CPS expressions are similar to IR1 expressions, @@ -98,9 +121,10 @@ ; Modifies a library or lexically bound variable to the given atom. - (define-record-type <update> + (define-match-record-type <update> (make-update ref atom continuation) update? + %update (ref update-ref) (atom update-atom) (continuation update-continuation)) @@ -109,9 +133,10 @@ ; Branches depending on the given atom. ; If it is true, continue with continuation true. ; If false, continue with continuation false. - (define-record-type <branch> + (define-match-record-type <branch> (make-branch atom true false) branch? + %branch (atom branch-atom) (true branch-true) (false branch-false)) @@ -120,9 +145,10 @@ ; Applies a procedure to a list of arguments. Apply does not take a ; continuation. Instead the continuation will be passed as the first ; argument to the function. - (define-record-type <apply> + (define-match-record-type <apply> (make-apply procedure arguments) apply? + %apply (procedure apply-procedure) (arguments apply-arguments)) @@ -130,9 +156,10 @@ ; A procedure. All closures are allocated in a fix expression. A closure ; does not take a continuation. Instead, the procedure will accept the ; continuation as an argument. - (define-record-type <closure> + (define-match-record-type <closure> (make-closure name arguments rest body) closure? + %closure (name closure-name) (arguments closure-arguments) (rest closure-rest) @@ -141,9 +168,10 @@ ; Defines a list of mutually recursive procedures. ; Functions is a list of closures, and body is an expression. - (define-record-type <fix> + (define-match-record-type <fix> (make-fix functions body) fix? + %fix (functions fix-functions) (body fix-body)) |
