summaryrefslogtreecommitdiff
path: root/module/language/tree-il.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-05-15 23:44:14 +0200
committerAndy Wingo <wingo@pobox.com>2009-05-15 23:44:14 +0200
commitcf10678fe7014a67020c45ee02f2aabb44598adc (patch)
tree0051e1969fd774e50b6eea3b28a66eed3ce21c1c /module/language/tree-il.scm
parent073bb617eb7e5f76269ca6dba0fe498baff6f058 (diff)
downloadguile-cf10678fe7014a67020c45ee02f2aabb44598adc.tar.gz
tree-il -> glil compiler works now, at least in initial tests
* module/language/tree-il/analyze.scm: Break analyzer out into its own file. * module/language/tree-il/compile-glil.scm: Port the GHIL->GLIL compiler over to work on tree-il. Works, but still misses a number of important optimizations. * module/language/tree-il.scm: Add <void>. Not used quite yet. * module/language/glil.scm: Remove <glil-argument>, as it is the same as <glil-local> (minus an offset). * module/language/glil/compile-assembly.scm: * module/language/glil/decompile-assembly.scm: * module/language/ghil/compile-glil.scm: Adapt for <glil-argument> * removal. * module/Makefile.am (TREE_IL_LANG_SOURCES): Reorder, and add analyze.scm.
Diffstat (limited to 'module/language/tree-il.scm')
-rw-r--r--module/language/tree-il.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/module/language/tree-il.scm b/module/language/tree-il.scm
index 774ca2ca7..c9857ac14 100644
--- a/module/language/tree-il.scm
+++ b/module/language/tree-il.scm
@@ -24,6 +24,7 @@
<lexical> make-lexical
lexical-name lexical-gensym
+ <void> void? make-void void-src
<application> application? make-application application-src application-proc application-args
<conditional> conditional? make-conditional conditional-src conditional-test conditional-then conditional-else
<primitive-ref> primitive-ref? make-primitive-ref primitive-ref-src primitive-ref-name
@@ -48,6 +49,7 @@
pre-order!))
(define-type (<tree-il> #:common-slots (src))
+ (<void>)
(<application> proc args)
(<conditional> test then else)
(<primitive-ref> name)
@@ -85,6 +87,9 @@
(let ((loc (location exp))
(retrans (lambda (x) (parse-ghil env x))))
(pmatch exp
+ ((void)
+ (make-void loc))
+
((apply ,proc ,args)
(make-application loc (retrans proc) (retrans args)))
@@ -147,6 +152,9 @@
(define (unparse-tree-il tree-il)
(record-case tree-il
+ ((<void>)
+ '(void))
+
((<application> proc args)
`(apply ,(unparse-tree-il proc) ,(map unparse-tree-il args)))
@@ -200,6 +208,9 @@
(tree-il->scheme (cdr e))))
((record? e)
(record-case e
+ ((<void>)
+ '(if #f #f))
+
((<application> proc args)
`(,(tree-il->scheme proc) ,@(map tree-il->scheme args)))
@@ -253,6 +264,9 @@
(define (post-order! f x)
(let lp ((x x))
(record-case x
+ ((<void>)
+ (or (f x) x))
+
((<application> proc args)
(set! (application-proc x) (lp proc))
(set! (application-args x) (map lp args))