#| -*-Scheme-*-
-$Id: cleanup.scm,v 1.16 1995/04/27 23:18:34 adams Exp $
+$Id: cleanup.scm,v 1.17 1995/05/06 18:04:45 adams Exp $
Copyright (c) 1994-1995 Massachusetts Institute of Technology
(else (default)))))
\f
(define-cleanup-handler BEGIN (env #!rest actions)
- (beginnify (cleanup/expr* env actions)))
+ (beginnify (cleanup/expr* env actions) #T))
(define-cleanup-handler LET (env bindings body)
(cleanup/let* cleanup/letify env bindings body))
#| -*-Scheme-*-
-$Id: utils.scm,v 1.23 1995/05/05 12:55:51 adams Exp $
+$Id: utils.scm,v 1.24 1995/05/06 18:04:53 adams Exp $
Copyright (c) 1994-1995 Massachusetts Institute of Technology
(else
`(IF ,left ,right (QUOTE #F)))))
-(define (beginnify actions)
+(define (beginnify actions #!optional incremental?)
;; Flattens the ACTIONS, discarding any in non-tail position that
;; are side-effect free or static (compile-time only). It
;; returns (BEGIN) or (BEGIN <action>+ <expression>) or <expression>
+ ;; If INCREMENTAL? is specified and true, BEGIN forms within ACTIONS are
+ ;; assumed to already satisfy the output conditions, otherwise they
+ ;; will be processed.
+ (let ((incremental? (and (not (default-object? incremental?)) incremental?)))
(let loop ((actions (reverse actions))
(actions* '()))
(cond ((null? actions)
(not (null? (cdr actions*))))
`(BEGIN ,@actions*)
(car actions*)))
- ((not (pair? (car actions)))
- (internal-warning "BEGINNIFY: Non-pair form in BEGIN:"
- (car actions))
- (loop (cdr actions)
- (cons (car actions) actions*)))
- ((eq? (caar actions) 'BEGIN)
- (loop (append (reverse (cdar actions)) (cdr actions))
- actions*))
+ ((BEGIN/? (car actions))
+ (if incremental?
+ (loop (cdr actions)
+ (append (begin/exprs (car actions)) actions*))
+ (loop (append (reverse (begin/expr (car actions)))
+ (cdr actions))
+ actions*)))
((and (not (null? actions*))
(or (form/satisfies? (car actions) '(SIDE-EFFECT-FREE))
- (and (form/satisfies? (car actions) '(STATIC))
+ (and compiler:guru?
+ (form/satisfies? (car actions) '(STATIC))
(begin
(write-line `(BEGINNIFY ELIDING ,(car actions)))
#T))))
(loop (cdr actions) actions*))
(else
(loop (cdr actions)
- (cons (car actions) actions*))))))
+ (cons (car actions) actions*)))))))
(define (simplify-actions expressions)
;; Takes a list of expressions, as in a BEGIN body, and produces a