aboutsummaryrefslogtreecommitdiffstats
path: root/csc/ir2.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/ir2.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/ir2.csc')
-rw-r--r--csc/ir2.csc48
1 files changed, 1 insertions, 47 deletions
diff --git a/csc/ir2.csc b/csc/ir2.csc
index 462a4a4..7ab2803 100644
--- a/csc/ir2.csc
+++ b/csc/ir2.csc
@@ -27,7 +27,6 @@
fix-body
fix-functions
fix?
- ir2=?
kargs-expression
kargs-refs
kargs?
@@ -72,7 +71,6 @@
(import (scheme base)
(only (csc ir1)
constant?
- ir1=?
lexical-ref-gensym
lexical-ref-name
lexical-ref?
@@ -183,48 +181,4 @@
fix?
%fix
(functions fix-functions)
- (body fix-body))
-
-
- (define (atom=? x y)
- (if (and (variable? x) (variable? y))
- #t
- (ir1=? x y)))
-
-
- (define (closure=? x y)
- (and (closure? x) (closure? y)
- (let ((x-args (closure-arguments x))
- (x-rest (closure-rest x))
- (y-args (closure-arguments y))
- (y-rest (closure-rest y)))
- (and (atom=? (closure-name x) (closure-name y))
- (= (length x-args) (length y-args))
- (all atom=? x-args y-args)
- (or (and (not x-rest) (not y-rest))
- (and x-rest y-rest (atom=? x-rest y-rest)))
- (ir2=? (closure-body x) (closure-body y))))))
-
-
- (define (ir2=? x y)
- (match (cons x y)
- (((% %primitive x-oper x-args x-res x-cont) . (% %primitive y-oper y-args y-res y-cont))
- (and (symbol=? x-oper y-oper)
- (= (length x-args) (length y-args))
- (all atom=? x-args y-args)
- (= (length x-res) (length y-res))
- (all atom=? x-res y-res)
- (ir2=? x-cont y-cont)))
- (((% %branch x-atom x-true x-false) . (% %branch y-atom y-true y-false))
- (and (atom=? x-atom y-atom)
- (ir2=? x-true y-true)
- (ir2=? x-false y-false)))
- (((% %apply x-proc x-args) . (% %apply y-proc y-args))
- (and (atom=? x-proc y-proc)
- (= (length x-args) (length y-args))
- (all atom=? x-args y-args)))
- (((% %fix x-funs x-body) . (% %fix y-funs y-body))
- (and (= (length x-funs) (length y-funs))
- (all closure=? x-funs y-funs)
- (ir2=? x-body y-body)))
- (_ #f)))))
+ (body fix-body))))