[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 02/03: Register up cps2 compiler with language tower
From: |
Andy Wingo |
Subject: |
[Guile-commits] 02/03: Register up cps2 compiler with language tower |
Date: |
Fri, 08 May 2015 12:48:58 +0000 |
wingo pushed a commit to branch master
in repository guile.
commit 09869e781b913470c6c3d83e9d8e1d8bab0611d3
Author: Andy Wingo <address@hidden>
Date: Fri May 8 13:35:08 2015 +0200
Register up cps2 compiler with language tower
* module/language/tree-il/compile-cps2.scm (compile-cps2): Rename from
compile-cps.
* module/language/cps2/spec.scm: New file.
* module/Makefile.am (CPS2_LANG_SOURCES): Add spec.scm.
* module/language/tree-il/spec.scm (tree-il): Declare compiler to cps2.
---
module/Makefile.am | 1 +
module/language/{tree-il => cps2}/spec.scm | 38 ++++++++++-----------------
module/language/tree-il/compile-cps2.scm | 4 +-
module/language/tree-il/spec.scm | 4 ++-
4 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/module/Makefile.am b/module/Makefile.am
index e4785ae..b86efc7 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -153,6 +153,7 @@ CPS2_LANG_SOURCES =
\
language/cps2.scm \
language/cps2/compile-cps.scm \
language/cps2/renumber.scm \
+ language/cps2/spec.scm \
language/cps2/utils.scm
BYTECODE_LANG_SOURCES = \
diff --git a/module/language/tree-il/spec.scm b/module/language/cps2/spec.scm
similarity index 57%
copy from module/language/tree-il/spec.scm
copy to module/language/cps2/spec.scm
index a7d1696..5ab30ff 100644
--- a/module/language/tree-il/spec.scm
+++ b/module/language/cps2/spec.scm
@@ -1,47 +1,37 @@
-;;; Tree Intermediate Language
+;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3 of the License, or (at your option) any later version.
-;;;;
+;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;; Lesser General Public License for more details.
-;;;;
+;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
;;; Code:
-(define-module (language tree-il spec)
+(define-module (language cps2 spec)
#:use-module (system base language)
- #:use-module (system base pmatch)
- #:use-module (language tree-il)
- #:use-module (language tree-il compile-cps)
- #:export (tree-il))
+ #:use-module (language cps2)
+ #:use-module (language cps2 compile-cps)
+ #:export (cps2))
-(define (write-tree-il exp . port)
- (apply write (unparse-tree-il exp) port))
+(define* (write-cps exp #:optional (port (current-output-port)))
+ (write (unparse-cps exp) port))
-(define (join exps env)
- (pmatch exps
- (() (make-void #f))
- ((,x) x)
- ((,x . ,rest)
- (make-seq #f x (join rest env)))
- (else (error "what!" exps env))))
-
-(define-language tree-il
- #:title "Tree Intermediate Language"
+(define-language cps2
+ #:title "CPS2 Intermediate Language"
#:reader (lambda (port env) (read port))
- #:printer write-tree-il
- #:parser parse-tree-il
- #:joiner join
+ #:printer write-cps
+ #:parser parse-cps
#:compilers `((cps . ,compile-cps))
#:for-humans? #f
)
diff --git a/module/language/tree-il/compile-cps2.scm
b/module/language/tree-il/compile-cps2.scm
index f8710ba..652d7ad 100644
--- a/module/language/tree-il/compile-cps2.scm
+++ b/module/language/tree-il/compile-cps2.scm
@@ -61,7 +61,7 @@
#:use-module (language tree-il optimize)
#:use-module (language tree-il)
#:use-module (language cps intmap)
- #:export (compile-cps))
+ #:export (compile-cps2))
;;; Guile's semantics are that a toplevel lambda captures a reference on
;;; the current module, and that all contained lambdas use that module
@@ -878,7 +878,7 @@ integer."
(_ exp)))
exp))
-(define (compile-cps exp env opts)
+(define (compile-cps2 exp env opts)
(values (cps-convert/thunk
(canonicalize (optimize-tree-il exp env opts)))
env
diff --git a/module/language/tree-il/spec.scm b/module/language/tree-il/spec.scm
index a7d1696..854c505 100644
--- a/module/language/tree-il/spec.scm
+++ b/module/language/tree-il/spec.scm
@@ -23,6 +23,7 @@
#:use-module (system base pmatch)
#:use-module (language tree-il)
#:use-module (language tree-il compile-cps)
+ #:use-module (language tree-il compile-cps2)
#:export (tree-il))
(define (write-tree-il exp . port)
@@ -42,6 +43,7 @@
#:printer write-tree-il
#:parser parse-tree-il
#:joiner join
- #:compilers `((cps . ,compile-cps))
+ #:compilers `((cps . ,compile-cps)
+ (cps2 . ,compile-cps2))
#:for-humans? #f
)