summaryrefslogtreecommitdiff
path: root/module/system/base
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-01-22 09:19:39 +0100
committerAndy Wingo <wingo@pobox.com>2013-01-22 09:19:55 +0100
commit776491caa2802c990aa0c25415dbbc4b7c368c7b (patch)
treeec41de84c7ec5fb48b03acaf9d26069811fa847c /module/system/base
parent170410b607b5ea2b935dbb656c844b86720bf1ec (diff)
fix compilation of glil to assembly
* libguile/vm-i-scheme.c (VM_VALIDATE_STRUCT): Fix the error message if the value was not a struct. * module/system/base/compile.scm (find-language-joint): Default to joining at the target language. (default-language-joiner): Allow sequences of one compiled expression to pass through. Otherwise error as before. (read-and-parse): New helper; actually parses. (read-and-compile): Use read-and-parse, and fall back to default-language-joiner. Thanks to Nala Ginrut for the report.
Diffstat (limited to 'module/system/base')
-rw-r--r--module/system/base/compile.scm25
1 files changed, 21 insertions, 4 deletions
diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm
index 1c3320ad2..0e44f362c 100644
--- a/module/system/base/compile.scm
+++ b/module/system/base/compile.scm
@@ -181,12 +181,26 @@
(let lp ((in (reverse (or (lookup-compilation-order from to)
(error "no way to compile" from "to" to))))
(lang to))
- (cond ((null? in)
- (error "don't know how to join expressions" from to))
+ (cond ((null? in) to)
((language-joiner lang) lang)
(else
(lp (cdr in) (caar in))))))
+(define (default-language-joiner lang)
+ (lambda (exps env)
+ (if (and (pair? exps) (null? (cdr exps)))
+ (car exps)
+ (error
+ "Multiple expressions read and compiled, but language has no joiner"
+ lang))))
+
+(define (read-and-parse lang port cenv)
+ (let ((exp ((language-reader lang) port cenv)))
+ (cond
+ ((eof-object? exp) exp)
+ ((language-parser lang) => (lambda (parse) (parse exp)))
+ (else exp))))
+
(define* (read-and-compile port #:key
(from (current-language))
(to 'objcode)
@@ -197,11 +211,14 @@
(let ((joint (find-language-joint from to)))
(with-fluids ((*current-language* from))
(let lp ((exps '()) (env #f) (cenv env))
- (let ((x ((language-reader (current-language)) port cenv)))
+ (let ((x (read-and-parse (current-language) port cenv)))
(cond
((eof-object? x)
(close-port port)
- (compile ((language-joiner joint) (reverse exps) env)
+ (compile ((or (language-joiner joint)
+ (default-language-joiner joint))
+ (reverse exps)
+ env)
#:from joint #:to to
;; env can be false if no expressions were read.
#:env (or env (default-environment joint))