From 3181395bdb0a2d766af0e9df60529f7744a91542 Mon Sep 17 00:00:00 2001 From: jrm Date: Tue, 9 Feb 2010 07:56:51 -0800 Subject: [PATCH] Add SF:DISPLAY-TOP-LEVEL-PROCEDURE-NAMES? --- src/sf/sf.pkg | 2 ++ src/sf/subst.scm | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/sf/sf.pkg b/src/sf/sf.pkg index 6d1a460e3..ca1e19b50 100644 --- a/src/sf/sf.pkg +++ b/src/sf/sf.pkg @@ -76,6 +76,8 @@ USA. (define-package (scode-optimizer integrate) (files "subst") (parent (scode-optimizer)) + (export () + sf:display-top-level-procedure-names?) (export (scode-optimizer) integrate/top-level integrate/get-top-level-block diff --git a/src/sf/subst.scm b/src/sf/subst.scm index 5d018e6a6..70ff16421 100644 --- a/src/sf/subst.scm +++ b/src/sf/subst.scm @@ -341,6 +341,18 @@ USA. (simulate-unknown-application environment procedure) procedure))) +;;; If not #f, display the top-level procedure names as they are +;;; processed. Useful for debugging. +(define sf:display-top-level-procedure-names? #f) + +(define (maybe-display-name name) + (if (and sf:display-top-level-procedure-names? + (null? *current-block-names*)) + (begin + (newline) + (display ";; ") + (display name)))) + ;; Cannot optimize (lambda () (bar)) => bar (eta substitution) because ;; BAR may be a procedure with different arity than the lambda @@ -371,12 +383,12 @@ you ask for. (define (integrate/procedure operations environment procedure) (let ((block (procedure/block procedure)) + (name (procedure/name procedure)) (required (procedure/required procedure)) (optional (procedure/optional procedure)) (rest (procedure/rest procedure))) - (fluid-let ((*current-block-names* - (cons (procedure/name procedure) - *current-block-names*))) + (maybe-display-name name) + (fluid-let ((*current-block-names* (cons name *current-block-names*))) (process-block-flags (block/flags block) (lambda () (let ((body @@ -412,7 +424,7 @@ you ask for. (combination/operator body) (procedure/make (procedure/scode procedure) block - (procedure/name procedure) + name required optional rest -- 2.25.1