mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 06:50:31 +02:00
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.
This commit is contained in:
parent
7cd61e2bf6
commit
09869e781b
4 changed files with 43 additions and 3 deletions
|
@ -153,6 +153,7 @@ CPS2_LANG_SOURCES = \
|
||||||
language/cps2.scm \
|
language/cps2.scm \
|
||||||
language/cps2/compile-cps.scm \
|
language/cps2/compile-cps.scm \
|
||||||
language/cps2/renumber.scm \
|
language/cps2/renumber.scm \
|
||||||
|
language/cps2/spec.scm \
|
||||||
language/cps2/utils.scm
|
language/cps2/utils.scm
|
||||||
|
|
||||||
BYTECODE_LANG_SOURCES = \
|
BYTECODE_LANG_SOURCES = \
|
||||||
|
|
37
module/language/cps2/spec.scm
Normal file
37
module/language/cps2/spec.scm
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
;;; Continuation-passing style (CPS) intermediate language (IL)
|
||||||
|
|
||||||
|
;; 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 cps2 spec)
|
||||||
|
#:use-module (system base language)
|
||||||
|
#:use-module (language cps2)
|
||||||
|
#:use-module (language cps2 compile-cps)
|
||||||
|
#:export (cps2))
|
||||||
|
|
||||||
|
(define* (write-cps exp #:optional (port (current-output-port)))
|
||||||
|
(write (unparse-cps exp) port))
|
||||||
|
|
||||||
|
(define-language cps2
|
||||||
|
#:title "CPS2 Intermediate Language"
|
||||||
|
#:reader (lambda (port env) (read port))
|
||||||
|
#:printer write-cps
|
||||||
|
#:parser parse-cps
|
||||||
|
#:compilers `((cps . ,compile-cps))
|
||||||
|
#:for-humans? #f
|
||||||
|
)
|
|
@ -61,7 +61,7 @@
|
||||||
#:use-module (language tree-il optimize)
|
#:use-module (language tree-il optimize)
|
||||||
#:use-module (language tree-il)
|
#:use-module (language tree-il)
|
||||||
#:use-module (language cps intmap)
|
#:use-module (language cps intmap)
|
||||||
#:export (compile-cps))
|
#:export (compile-cps2))
|
||||||
|
|
||||||
;;; Guile's semantics are that a toplevel lambda captures a reference on
|
;;; Guile's semantics are that a toplevel lambda captures a reference on
|
||||||
;;; the current module, and that all contained lambdas use that module
|
;;; the current module, and that all contained lambdas use that module
|
||||||
|
@ -878,7 +878,7 @@ integer."
|
||||||
(_ exp)))
|
(_ exp)))
|
||||||
exp))
|
exp))
|
||||||
|
|
||||||
(define (compile-cps exp env opts)
|
(define (compile-cps2 exp env opts)
|
||||||
(values (cps-convert/thunk
|
(values (cps-convert/thunk
|
||||||
(canonicalize (optimize-tree-il exp env opts)))
|
(canonicalize (optimize-tree-il exp env opts)))
|
||||||
env
|
env
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#:use-module (system base pmatch)
|
#:use-module (system base pmatch)
|
||||||
#:use-module (language tree-il)
|
#:use-module (language tree-il)
|
||||||
#:use-module (language tree-il compile-cps)
|
#:use-module (language tree-il compile-cps)
|
||||||
|
#:use-module (language tree-il compile-cps2)
|
||||||
#:export (tree-il))
|
#:export (tree-il))
|
||||||
|
|
||||||
(define (write-tree-il exp . port)
|
(define (write-tree-il exp . port)
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
#:printer write-tree-il
|
#:printer write-tree-il
|
||||||
#:parser parse-tree-il
|
#:parser parse-tree-il
|
||||||
#:joiner join
|
#:joiner join
|
||||||
#:compilers `((cps . ,compile-cps))
|
#:compilers `((cps . ,compile-cps)
|
||||||
|
(cps2 . ,compile-cps2))
|
||||||
#:for-humans? #f
|
#:for-humans? #f
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue