Change FREE/EXPRESSION to EXPRESSION/FREE-VARIABLES.
authorJoe Marshall <jmarshall@alum.mit.edu>
Mon, 8 Mar 2010 19:47:14 +0000 (11:47 -0800)
committerJoe Marshall <jmarshall@alum.mit.edu>
Mon, 8 Mar 2010 19:47:14 +0000 (11:47 -0800)
src/sf/analyze.scm
src/sf/object.scm
src/sf/sf.pkg

index 41a1c74c2233304ecd863d6e715306f52e7ffad1..13683f3dce54833b7e10c5687616bc03c83309c9 100644 (file)
@@ -23,107 +23,111 @@ USA.
 
 |#
 
-;;;; SCode Optimizer: Free Variable Computation
-;;; package: (scode-optimizer free)
+;;;; SCode Optimizer: Expression analysis
+;;; package: (scode-optimizer analyze)
 
 (declare (usual-integrations)
         (integrate-external "object"))
 \f
-(declare (integrate-operator free/expression))
+;;; EXPRESSION/FREE-VARIABLES
+;;
+;; Returns an EQ? LSET of the free variables in an expression.
 
-(define (free/expression expression)
-  ((expression/method dispatch-vector expression) expression))
+(declare (integrate-operator expression/free-variables))
 
-(define (free/expressions expressions)
+(define (expression/free-variables expression)
+  ((expression/method free-variables-dispatch-vector expression) expression))
+
+(define (expressions/free-variables expressions)
   (fold-left (lambda (answer expression)
-              (lset-union eq? answer (free/expression expression)))
+              (lset-union eq? answer (expression/free-variables expression)))
             (no-free-variables)
             expressions))
 
-(define dispatch-vector
+(define free-variables-dispatch-vector
   (expression/make-dispatch-vector))
 
-(define define-method/free
-  (expression/make-method-definer dispatch-vector))
+(define define-method/free-variables
+  (expression/make-method-definer free-variables-dispatch-vector))
 
-(define-method/free 'ACCESS
+(define-method/free-variables 'ACCESS
   (lambda (expression)
-    (free/expression (access/environment expression))))
+    (expression/free-variables (access/environment expression))))
 
-(define-method/free 'ASSIGNMENT
+(define-method/free-variables 'ASSIGNMENT
   (lambda (expression)
     (lset-adjoin eq?
-                (free/expression (assignment/value expression))
+                (expression/free-variables (assignment/value expression))
                 (assignment/variable expression))))
 
-(define-method/free 'COMBINATION
+(define-method/free-variables 'COMBINATION
   (lambda (expression)
     (lset-union eq?
-               (free/expression (combination/operator expression))
-               (free/expressions (combination/operands expression)))))
+               (expression/free-variables (combination/operator expression))
+               (expressions/free-variables (combination/operands expression)))))
 
-(define-method/free 'CONDITIONAL
+(define-method/free-variables 'CONDITIONAL
   (lambda (expression)
     (lset-union eq?
-               (free/expression (conditional/predicate expression))
+               (expression/free-variables (conditional/predicate expression))
                (if (expression/always-false? (conditional/predicate expression))
                    (no-free-variables)
-                   (free/expression (conditional/consequent expression)))
+                   (expression/free-variables (conditional/consequent expression)))
                (if (expression/never-false? (conditional/predicate expression))
                    (no-free-variables)
-                   (free/expression (conditional/alternative expression))))))
+                   (expression/free-variables (conditional/alternative expression))))))
 
-(define-method/free 'CONSTANT
+(define-method/free-variables 'CONSTANT
   (lambda (expression)
     expression
     (no-free-variables)))
 
-(define-method/free 'DECLARATION
+(define-method/free-variables 'DECLARATION
   (lambda (expression)
-    (free/expression (declaration/expression expression))))
+    (expression/free-variables (declaration/expression expression))))
 \f
-(define-method/free 'DELAY
+(define-method/free-variables 'DELAY
   (lambda (expression)
-    (free/expression (delay/expression expression))))
+    (expression/free-variables (delay/expression expression))))
 
-(define-method/free 'DISJUNCTION
+(define-method/free-variables 'DISJUNCTION
   (lambda (expression)
     (lset-union eq?
-               (free/expression (disjunction/predicate expression))
+               (expression/free-variables (disjunction/predicate expression))
                (if (expression/never-false? (disjunction/predicate expression))
                    (no-free-variables)
-                   (free/expression (disjunction/alternative expression))))))
+                   (expression/free-variables (disjunction/alternative expression))))))
 
-(define-method/free 'OPEN-BLOCK
+(define-method/free-variables 'OPEN-BLOCK
   (lambda (expression)
     (let ((omit (block/bound-variables (open-block/block expression))))
      (fold-left (lambda (variables action)
                  (if (eq? action open-block/value-marker)
                      variables
-                     (lset-union eq? variables (lset-difference eq? (free/expression action) omit))))
-               (lset-difference eq? (free/expressions (open-block/values expression)) omit)
+                     (lset-union eq? variables (lset-difference eq? (expression/free-variables action) omit))))
+               (lset-difference eq? (expressions/free-variables (open-block/values expression)) omit)
                (open-block/actions expression)))))
 
-(define-method/free 'PROCEDURE
+(define-method/free-variables 'PROCEDURE
   (lambda (expression)
     (lset-difference eq?
-     (free/expression (procedure/body expression))
+     (expression/free-variables (procedure/body expression))
      (block/bound-variables (procedure/block expression)))))
 
-(define-method/free 'QUOTATION
+(define-method/free-variables 'QUOTATION
   (lambda (expression)
     (declare (ignore expression))
     (no-free-variables)))
 
-(define-method/free 'REFERENCE
+(define-method/free-variables 'REFERENCE
   (lambda (expression)
     (singleton-variable (reference/variable expression))))
 
-(define-method/free 'SEQUENCE
+(define-method/free-variables 'SEQUENCE
   (lambda (expression)
-    (free/expressions (sequence/actions expression))))
+    (expressions/free-variables (sequence/actions expression))))
 
-(define-method/free 'THE-ENVIRONMENT
+(define-method/free-variables 'THE-ENVIRONMENT
   (lambda (expression)
     (declare (ignore expression))
     (no-free-variables)))
index fbeba508ea387a034e5d74edb61768bdb8978ee4..279d78c2f8993654caa88339ec77471efddee96b 100644 (file)
@@ -662,7 +662,7 @@ USA.
   (constant/make (and expression (object/scode expression)) result)))
 
 (define-integrable (partition-operands operator operands)
-  (let ((free-in-body (free/expression (procedure/body operator))))
+  (let ((free-in-body (expression/free-variables (procedure/body operator))))
     (let loop ((parameters             (append (procedure/required operator)
                                                (procedure/optional operator)))
               (operands                operands)
index 3f8899ee346c09ea517a8f4e03a4aa5a2a73651f..42fc2f5592047b42737338d2015337417a04795b 100644 (file)
@@ -144,11 +144,11 @@ USA.
          copy/expression/intern
          copy/expression/extern))
 
-(define-package (scode-optimizer free)
+(define-package (scode-optimizer analyze)
   (files "analyze")
   (parent (scode-optimizer))
   (export (scode-optimizer)
-         free/expression
+         expression/free-variables
          variable/free-in-expression?))
 
 (define-package (scode-optimizer change-type)