From 804a2fe3c90c06a22a1eed5ea50d667ff3e7b08c Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Wed, 29 Jun 2022 21:52:30 -0700 Subject: Add pattern matching for record types. I like scheme because it's possible to add any convenient language feature I can think of. --- csc/ir2.csc | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'csc/ir2.csc') 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