From abdc13977e7dd70dfc4799761fa945cebcfa532e Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 10 Aug 1989 11:49:43 +0000 Subject: [PATCH] Fix longstanding bug in compilation of predicates. Expressions like 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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/v7/src/compiler/fggen/fggen.scm b/v7/src/compiler/fggen/fggen.scm index 4298b111a..fb6e1ca00 100644 --- a/v7/src/compiler/fggen/fggen.scm +++ b/v7/src/compiler/fggen/fggen.scm @@ -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) -- 2.25.1