From defd1ded50dc905d055da536b799cd72058aa5b8 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 1 Feb 2018 21:55:33 -0800 Subject: [PATCH] Don't generate keyword-value-item except at top level. They aren't needed for internal environments. --- src/runtime/mit-syntax.scm | 33 ++++++++++++++++++--------------- src/runtime/runtime.pkg | 1 + src/runtime/syntax-output.scm | 5 +++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/runtime/mit-syntax.scm b/src/runtime/mit-syntax.scm index 38ad6e38e..cac5e142b 100644 --- a/src/runtime/mit-syntax.scm +++ b/src/runtime/mit-syntax.scm @@ -31,33 +31,36 @@ USA. ;;;; Macro transformers -(define (transformer-keyword name transformer->expander) - (lambda (form environment) +(define (transformer-keyword procedure-name transformer->expander) + (lambda (form senv) (syntax-check '(KEYWORD EXPRESSION) form) - (let ((item (classify/expression (cadr form) environment))) - (keyword-value-item - (transformer->expander (transformer-eval (compile-item/expression item) - environment) - environment) - (expr-item - (lambda () - (output/combination (output/runtime-reference name) - (list (compile-item/expression item) - (output/the-environment))))))))) + (let ((transformer + (compile-item/expression + (classify/expression (cadr form) senv)))) + (let ((item + (transformer->expander (transformer-eval transformer senv) + senv))) + (if (syntactic-environment/top-level? senv) + (keyword-value-item + item + (expr-item + (lambda () + (output/top-level-syntax-expander procedure-name transformer)))) + item))))) (define classifier:sc-macro-transformer ;; "Syntactic Closures" transformer - (transformer-keyword 'SC-MACRO-TRANSFORMER->EXPANDER + (transformer-keyword 'sc-macro-transformer->expander sc-macro-transformer->expander)) (define classifier:rsc-macro-transformer ;; "Reversed Syntactic Closures" transformer - (transformer-keyword 'RSC-MACRO-TRANSFORMER->EXPANDER + (transformer-keyword 'rsc-macro-transformer->expander rsc-macro-transformer->expander)) (define classifier:er-macro-transformer ;; "Explicit Renaming" transformer - (transformer-keyword 'ER-MACRO-TRANSFORMER->EXPANDER + (transformer-keyword 'er-macro-transformer->expander er-macro-transformer->expander)) ;;;; Core primitives diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 7c04ffdea..2948ab32a 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -4531,6 +4531,7 @@ USA. output/top-level-definition output/top-level-sequence output/top-level-syntax-definition + output/top-level-syntax-expander output/unassigned output/unassigned-test output/unspecific diff --git a/src/runtime/syntax-output.scm b/src/runtime/syntax-output.scm index 58446894c..e384dc2a6 100644 --- a/src/runtime/syntax-output.scm +++ b/src/runtime/syntax-output.scm @@ -59,6 +59,11 @@ USA. (define (output/top-level-syntax-definition name value) (make-scode-definition name (make-macro-reference-trap-expression value))) +(define (output/top-level-syntax-expander procedure-name transformer) + (output/combination (output/runtime-reference procedure-name) + (list transformer + (output/the-environment)))) + (define (output/conditional predicate consequent alternative) (make-scode-conditional predicate consequent alternative)) -- 2.25.1