Fix longstanding bug in compilation of predicates. Expressions like
authorChris Hanson <org/chris-hanson/cph>
Thu, 10 Aug 1989 11:49:43 +0000 (11:49 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 10 Aug 1989 11:49:43 +0000 (11:49 +0000)
this

  (if (if (bar numerator)
  (foo denominator)
  (not (foo denominator)))
      numerator
      denominator)

would compile incorrectly by making both calls to `foo' have the same
continuation.  This should have been noticed as an error because the
continuation entry hooks for that continuation were attached to both
expressions: when they were combined with the call to `bar' the hooks
were used to attach the continuation to the enclosing expression --
but each side of the test was attached twice.  Error checking in the
node-attachment code would have caught this one at compile time.

The new code generates a new continuation for the call to `foo' whose
result is inverted, and then codes the `not' using a PCFG and two
constants -- all of which gets folded out later, resulting in the
desired code.

v7/src/compiler/fggen/fggen.scm

index 4298b111aa875315ca548bfec12d31aa3ed10c67..fb6e1ca00197f71148b4ed356eee459d5e6fd08c 100644 (file)
@@ -1,8 +1,8 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/fggen/fggen.scm,v 4.16 1989/04/21 17:10:28 markf Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/fggen/fggen.scm,v 4.17 1989/08/10 11:49:43 cph Exp $
 
-Copyright (c) 1988 Massachusetts Institute of Technology
+Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -555,8 +555,15 @@ MIT in each case. |#
                      (continuation/next-hooks continuation))))))
           (lambda ()
             (if (eq? not operator)
-                (pcfg-invert
-                 (generate/expression block continuation (car operands)))               (with-reified-continuation block
+                (pcfg*pcfg->pcfg!
+                 (generate/subproblem/predicate
+                  block
+                  continuation
+                  (car operands)
+                  (vector 'COMBINATION-OPERAND expression 1))
+                 (generate/expression block continuation false)
+                 (generate/expression block continuation true))
+                (with-reified-continuation block
                                            continuation
                                            scfg*pcfg->pcfg!
                   (lambda (push continuation)