aboutsummaryrefslogtreecommitdiffstats
path: root/csc/ir1.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-03 14:37:10 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-03 14:37:10 -0700
commitbcb098e8eb18637b6999789585a38ff9168de9d5 (patch)
treefe2bee9fcc5cac8c2f8362c836901f7a3643cb03 /csc/ir1.csc
parentWrite closure conversion. (diff)
downloadchromatopelma-bcb098e8eb18637b6999789585a38ff9168de9d5.tar.zst
Add a diff library.
I was hesitant to add a diff library, but it was surprisingly easy. A straightforward application of dynamic programming.
Diffstat (limited to 'csc/ir1.csc')
-rw-r--r--csc/ir1.csc63
1 files changed, 1 insertions, 62 deletions
diff --git a/csc/ir1.csc b/csc/ir1.csc
index 33588c9..942f8f9 100644
--- a/csc/ir1.csc
+++ b/csc/ir1.csc
@@ -23,7 +23,6 @@
if-consequent
if-test
if?
- ir1=?
lambda-arguments
lambda-body
lambda-rest
@@ -193,64 +192,4 @@
(names letrec-names)
(gensyms letrec-gensyms)
(values letrec-values)
- (expression letrec-expression))
-
-
- (define (ir1=? x y)
- (cond
- ((and (constant? x) (constant? y))
- (equal? (constant-expression x) (constant-expression y)))
- ((and (lexical-ref? x) (lexical-ref? y))
- (symbol=? (lexical-ref-name x) (lexical-ref-name y)))
- ((and (library-ref? x) (library-ref? y))
- (symbol=? (library-ref-name x) (library-ref-name y))
- (equal? (library-ref-library x) (library-ref-library y)))
- ((and (lexical-set? x) (lexical-set? y))
- (and
- (ir1=? (lexical-set-ref x) (lexical-set-ref y))
- (ir1=? (lexical-set-expression x) (lexical-set-expression y))))
- ((and (library-define? x) (library-define? y))
- (and
- (ir1=? (library-define-ref x) (library-define-ref y))
- (ir1=? (library-define-expression x) (library-define-expression y))))
- ((and (if? x) (if? y))
- (and
- (ir1=? (if-test x) (if-test y))
- (ir1=? (if-consequent x) (if-consequent y))
- (ir1=? (if-alternate x) (if-alternate y))))
- ((and (call? x) (call? y))
- (and
- (ir1=? (call-procedure x) (call-procedure y))
- (= (length (call-arguments x)) (length (call-arguments y)))
- (loop for x-arg in (call-arguments x)
- for y-arg in (call-arguments y)
- unless (ir1=? x-arg y-arg)
- return #f
- finally (return #t))))
- ((and (sequence? x) (sequence? y))
- (and
- (ir1=? (sequence-head x) (sequence-head y))
- (ir1=? (sequence-tail x) (sequence-tail y))))
- ((and (lambda? x) (lambda? y))
- (let ((x-args (lambda-arguments x))
- (x-rest (lambda-rest x))
- (y-args (lambda-arguments y))
- (y-rest (lambda-rest y)))
- (and (= (length x-args) (length y-args))
- (all ir1=? x-args y-args)
- (or (and (not x-rest) (not y-rest))
- (ir1=? x-rest y-rest))
- (ir1=? (lambda-body x) (lambda-body y)))))
- ((and (letrec? x) (letrec? y))
- (let ((x-names (letrec-names x))
- (x-values (letrec-values x))
- (y-names (letrec-names y))
- (y-values (letrec-values y)))
- (and
- (boolean=? (letrec-in-order? x) (letrec-in-order? y))
- (= (length x-names) (length y-names))
- (all symbol=? x-names y-names)
- (= (length x-values) (length y-values))
- (all ir1=? x-values y-values)
- (ir1=? (letrec-expression x) (letrec-expression y)))))
- (else #f)))))
+ (expression letrec-expression))))