expand changed:
- it now takes an optional environment (it was required) - it no longer returns a second value (list of libraries) - it's output is "pretty". the old expand is now called core-expand.
This commit is contained in:
		
							parent
							
								
									83d8f051fe
								
							
						
					
					
						commit
						2653cedee1
					
				
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -18,8 +18,8 @@
 | 
				
			||||||
  (export compile-core-expr-to-port 
 | 
					  (export compile-core-expr-to-port 
 | 
				
			||||||
          assembler-output optimize-cp
 | 
					          assembler-output optimize-cp
 | 
				
			||||||
          current-primitive-locations eval-core
 | 
					          current-primitive-locations eval-core
 | 
				
			||||||
          current-core-eval
 | 
					          current-core-eval compile-core-expr 
 | 
				
			||||||
          compile-core-expr expand/optimize optimizer-output
 | 
					          expand expand/optimize optimizer-output
 | 
				
			||||||
          cp0-effort-limit cp0-size-limit optimize-level 
 | 
					          cp0-effort-limit cp0-size-limit optimize-level 
 | 
				
			||||||
          perform-tag-analysis tag-analysis-output
 | 
					          perform-tag-analysis tag-analysis-output
 | 
				
			||||||
          strip-source-info generate-debug-calls)
 | 
					          strip-source-info generate-debug-calls)
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@
 | 
				
			||||||
        compile-core-expr-to-port assembler-output
 | 
					        compile-core-expr-to-port assembler-output
 | 
				
			||||||
        current-primitive-locations eval-core
 | 
					        current-primitive-locations eval-core
 | 
				
			||||||
        cp0-size-limit cp0-effort-limit 
 | 
					        cp0-size-limit cp0-effort-limit 
 | 
				
			||||||
        expand/optimize optimizer-output
 | 
					        expand/optimize expand optimizer-output
 | 
				
			||||||
        tag-analysis-output perform-tag-analysis
 | 
					        tag-analysis-output perform-tag-analysis
 | 
				
			||||||
        current-core-eval)
 | 
					        current-core-eval)
 | 
				
			||||||
    (ikarus.fasl.write)
 | 
					    (ikarus.fasl.write)
 | 
				
			||||||
| 
						 | 
					@ -2481,19 +2481,30 @@
 | 
				
			||||||
             (refresh-cached-labels!))
 | 
					             (refresh-cached-labels!))
 | 
				
			||||||
           (error 'current-primitive-locations "not a procedure" p))])))
 | 
					           (error 'current-primitive-locations "not a procedure" p))])))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(define (expand/pretty x env who . passes)
 | 
				
			||||||
 | 
					  (unless (environment? env)
 | 
				
			||||||
 | 
					    (die who "not an environment" env))
 | 
				
			||||||
 | 
					  (let-values ([(x libs) (core-expand x env)])
 | 
				
			||||||
 | 
					    (let f ([x (recordize x)] [passes passes])
 | 
				
			||||||
 | 
					      (if (null? passes)
 | 
				
			||||||
 | 
					          (unparse-pretty x)
 | 
				
			||||||
 | 
					          (f ((car passes) x) (cdr passes))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define expand/optimize
 | 
					(define expand/optimize
 | 
				
			||||||
  (case-lambda
 | 
					  (case-lambda
 | 
				
			||||||
    [(p) (expand/optimize p (interaction-environment))]
 | 
					    [(x) (expand/optimize x (interaction-environment))]
 | 
				
			||||||
    [(p env)
 | 
					    [(x env)
 | 
				
			||||||
     (unless (environment? env)
 | 
					     (expand/pretty x env 'expand/optimize
 | 
				
			||||||
       (env 'expand/optimize "not an environment" env))
 | 
					       (lambda (x) 
 | 
				
			||||||
     (let-values ([(p lib*) (expand p env)])
 | 
					         (parameterize ([open-mvcalls #f])
 | 
				
			||||||
       (let* ([p (recordize p)]
 | 
					            (optimize-direct-calls x)))
 | 
				
			||||||
              [p (parameterize ([open-mvcalls #f])
 | 
					       optimize-letrec/scc
 | 
				
			||||||
                   (optimize-direct-calls p))]
 | 
					       source-optimize)]))
 | 
				
			||||||
              [p (optimize-letrec/scc p)]
 | 
					
 | 
				
			||||||
              [p (source-optimize p)])
 | 
					(define expand
 | 
				
			||||||
         (unparse-pretty p)))]))
 | 
					  (case-lambda
 | 
				
			||||||
 | 
					    [(x) (expand x (interaction-environment))]
 | 
				
			||||||
 | 
					    [(x env) (expand/pretty x env 'expand)]))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
1797
 | 
					1798
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@
 | 
				
			||||||
(import (except (ikarus) 
 | 
					(import (except (ikarus) 
 | 
				
			||||||
          current-core-eval
 | 
					          current-core-eval
 | 
				
			||||||
          assembler-output optimize-cp optimize-level
 | 
					          assembler-output optimize-cp optimize-level
 | 
				
			||||||
          cp0-size-limit cp0-effort-limit expand/optimize
 | 
					          cp0-size-limit cp0-effort-limit expand/optimize expand
 | 
				
			||||||
          optimizer-output tag-analysis-output perform-tag-analysis))
 | 
					          optimizer-output tag-analysis-output perform-tag-analysis))
 | 
				
			||||||
(import (ikarus.compiler))
 | 
					(import (ikarus.compiler))
 | 
				
			||||||
(import (except (psyntax system $bootstrap)
 | 
					(import (except (psyntax system $bootstrap)
 | 
				
			||||||
| 
						 | 
					@ -390,6 +390,7 @@
 | 
				
			||||||
    [optimizer-output                            i]
 | 
					    [optimizer-output                            i]
 | 
				
			||||||
    [new-cafe                                    i]
 | 
					    [new-cafe                                    i]
 | 
				
			||||||
    [expand                                      i]
 | 
					    [expand                                      i]
 | 
				
			||||||
 | 
					    [core-expand                                 i]
 | 
				
			||||||
    [expand/optimize                             i]
 | 
					    [expand/optimize                             i]
 | 
				
			||||||
    [environment?                                i]
 | 
					    [environment?                                i]
 | 
				
			||||||
    [environment-symbols                         i]
 | 
					    [environment-symbols                         i]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(library (psyntax expander)
 | 
					(library (psyntax expander)
 | 
				
			||||||
  (export identifier? syntax-dispatch 
 | 
					  (export identifier? syntax-dispatch 
 | 
				
			||||||
          eval expand generate-temporaries free-identifier=?
 | 
					          eval core-expand 
 | 
				
			||||||
 | 
					          generate-temporaries free-identifier=?
 | 
				
			||||||
          bound-identifier=? datum->syntax syntax-error
 | 
					          bound-identifier=? datum->syntax syntax-error
 | 
				
			||||||
          syntax-violation
 | 
					          syntax-violation
 | 
				
			||||||
          syntax->datum 
 | 
					          syntax->datum 
 | 
				
			||||||
| 
						 | 
					@ -3752,7 +3753,7 @@
 | 
				
			||||||
  ;;; expander (chi-expr).   It takes an expression and an environment.
 | 
					  ;;; expander (chi-expr).   It takes an expression and an environment.
 | 
				
			||||||
  ;;; It returns two values: The resulting core-expression and a list of
 | 
					  ;;; It returns two values: The resulting core-expression and a list of
 | 
				
			||||||
  ;;; libraries that must be invoked before evaluating the core expr.
 | 
					  ;;; libraries that must be invoked before evaluating the core expr.
 | 
				
			||||||
  (define expand
 | 
					  (define core-expand
 | 
				
			||||||
    (lambda (x env)
 | 
					    (lambda (x env)
 | 
				
			||||||
      (cond
 | 
					      (cond
 | 
				
			||||||
        ((env? env)
 | 
					        ((env? env)
 | 
				
			||||||
| 
						 | 
					@ -3785,6 +3786,7 @@
 | 
				
			||||||
        (else
 | 
					        (else
 | 
				
			||||||
         (assertion-violation 'expand "not an environment" env)))))
 | 
					         (assertion-violation 'expand "not an environment" env)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ;;; This is R6RS's eval.  It takes an expression and an environment,
 | 
					  ;;; This is R6RS's eval.  It takes an expression and an environment,
 | 
				
			||||||
  ;;; expands the expression, invokes its invoke-required libraries and
 | 
					  ;;; expands the expression, invokes its invoke-required libraries and
 | 
				
			||||||
  ;;; evaluates its expanded core form.
 | 
					  ;;; evaluates its expanded core form.
 | 
				
			||||||
| 
						 | 
					@ -3792,7 +3794,7 @@
 | 
				
			||||||
    (lambda (x env)
 | 
					    (lambda (x env)
 | 
				
			||||||
      (unless (environment? env)
 | 
					      (unless (environment? env)
 | 
				
			||||||
        (error 'eval "not an environment" env))
 | 
					        (error 'eval "not an environment" env))
 | 
				
			||||||
      (let-values (((x invoke-req*) (expand x env)))
 | 
					      (let-values (((x invoke-req*) (core-expand x env)))
 | 
				
			||||||
        (for-each invoke-library invoke-req*)
 | 
					        (for-each invoke-library invoke-req*)
 | 
				
			||||||
        (eval-core (expanded->core x)))))
 | 
					        (eval-core (expanded->core x)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue