diff options
author | Andy Wingo <wingo@pobox.com> | 2010-02-19 15:30:34 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-02-19 15:30:34 +0100 |
commit | ea6b18e82f3ac2122d07c80bc0f320ea839a25b6 (patch) | |
tree | cd5e3c02694e73a2453b1cc9d06f160580c5c92f /module/language/tree-il/inline.scm | |
parent | f5b1f76af492f3c398527ee040e8bf09fc438a9a (diff) | |
download | guile-ea6b18e82f3ac2122d07c80bc0f320ea839a25b6.tar.gz |
prompt handlers are always inline
* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_PROMPT_INLINE_P): Remove;
prompts always have "inline" handlers now.
* libguile/control.c (scm_c_make_prompt): Remove inline_handler_p arg.
* libguile/vm-i-system.c (prompt):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
Adapt to prompt changes.
* module/language/glil.scm (make-glil-prompt, glil-prompt-inline?):
Remove inline? flag.
(parse-glil, unparse-glil):
* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
<glil-prompt> change.
* module/language/tree-il/compile-glil.scm (flatten): Require the
handler of a <prompt> to be a lambda-case.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Ensure that the handler of a <prompt> is a lambda-case.
* module/language/tree-il/inline.scm (inline!): Simplify a degenerate
case: (lambda args (apply (lambda ...) args)) => (lambda ...).
Diffstat (limited to 'module/language/tree-il/inline.scm')
-rw-r--r-- | module/language/tree-il/inline.scm | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/module/language/tree-il/inline.scm b/module/language/tree-il/inline.scm index 0653db188..905622d65 100644 --- a/module/language/tree-il/inline.scm +++ b/module/language/tree-il/inline.scm @@ -110,15 +110,29 @@ ((<fix> vars body) (if (null? vars) body x)) - ((<prompt> src tag body handler) - ;; If the handler is a simple lambda, inline it. - (if (and (lambda? handler) - (record-case (lambda-body handler) - ((<lambda-case> req opt kw rest alternate) - (and (pair? req) (not opt) (not kw) (not alternate))) - (else #f))) - (make-prompt src tag body (lambda-body handler)) - x)) - + ((<lambda-case> req opt rest kw vars body alternate) + (let () + (define (args-compatible? args vars) + (let lp ((args args) (vars vars)) + (cond + ((null? args) (null? vars)) + ((null? vars) #f) + ((and (lexical-ref? (car args)) + (eq? (lexical-ref-gensym (car args)) (car vars))) + (lp (cdr args) (cdr vars))) + (else #f)))) + + (and (not opt) (not kw) (not alternate) + (record-case body + ((<application> proc args) + ;; (lambda args (apply (lambda ...) args)) => (lambda ...) + (and (primitive-ref? proc) + (eq? (primitive-ref-name proc) '@apply) + (pair? args) + (lambda? (car args)) + (args-compatible? (cdr args) vars) + (lambda-body (car args)))) + (else #f))))) + (else #f))) (post-order! inline1 x)) |