From 78a4efb6f15ad686efe78fc10f3216719833d8aa Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 28 Feb 2011 00:08:51 +0000 Subject: * interp/i-analy.boot (elaborateTree): New. * interp/i-special.boot (bottomUpProposition): Likewise. (upand): Use it to handle propositional formula. (upor): Likewise. --- src/ChangeLog | 7 +++++++ src/interp/i-analy.boot | 5 +++++ src/interp/i-special.boot | 19 +++++++++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 90824abc..2088c425 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2011-02-27 Gabriel Dos Reis + + * interp/i-analy.boot (elaborateTree): New. + * interp/i-special.boot (bottomUpProposition): Likewise. + (upand): Use it to handle propositional formula. + (upor): Likewise. + 2011-02-27 Gabriel Dos Reis * interp/i-analy.boot (bottomUpWithArgModesets): Split out of diff --git a/src/interp/i-analy.boot b/src/interp/i-analy.boot index 6a645bbc..fb0848b7 100644 --- a/src/interp/i-analy.boot +++ b/src/interp/i-analy.boot @@ -213,6 +213,11 @@ elaborateForm pf == bottomUp t t +++ Elaborate a VAT with specified target type. +elaborateTree(t,mode) == + putTarget(t,mode) + bottomUp t + bottomUp t == -- bottomUp takes an attributed tree, and returns the modeSet for it. -- As a side-effect it also evaluates the tree. diff --git a/src/interp/i-special.boot b/src/interp/i-special.boot index 6eb04e47..3f2b3f50 100644 --- a/src/interp/i-special.boot +++ b/src/interp/i-special.boot @@ -243,6 +243,17 @@ eq2AlgExtension eq == --% Handlers for booleans +++ `t' is a VAT that represents a propositional formula syntax. +++ Attempt to elaborate the whole tree into a `PropositionalFormula mode' +++ object. +bottomUpProposition(t,mode) == + -- FIXME: we should not hard code here the expected types of + -- FIXME: the domain. + not ofCategory(mode,$SetCategory) => nil + mode := ['PropositionalFormula,mode] + argModeSets := [elaborateTree(arg,mode) for arg in t.args] + bottomUpWithArgModesets(t,t.op,getUnname t.op,t.args,argModeSets) + upand x == -- generates code for and forms. The second argument is only -- evaluated if the first argument is true. @@ -252,7 +263,7 @@ upand x == putTarget(term2,$Boolean) putCallInfo(term2,"and",2,2) ms := bottomUp term1 - ms isnt [=$Boolean] => nil -- use general modemap + ms isnt [=$Boolean] => bottomUpProposition(x,first ms) $genValue => -- ??? we should find a way to check whether the -- ??? the type of the second operand matters or not. @@ -266,7 +277,7 @@ upand x == putModeSet(x,ms) ms := bottomUp term2 - ms isnt [=$Boolean] => nil -- use general modemap + ms isnt [=$Boolean] => bottomUpProposition(x,first ms) -- generate an IF expression and let the rest of the code handle it -- ??? In full generality, this is still incorrect. We should be -- ??? looking up modemaps to see whether the interpretation is @@ -289,7 +300,7 @@ upor x == putTarget(term2,$Boolean) putCallInfo(term2,"or",2,2) ms := bottomUp term1 - ms isnt [=$Boolean] => nil + ms isnt [=$Boolean] => bottomUpProposition(x,first ms) $genValue => objValUnwrap(getValue term1) => -- first operand is true, we are done. putValue(x,getValue term1) @@ -301,7 +312,7 @@ upor x == putModeSet(x,ms) ms := bottomUp term2 - ms isnt [=$Boolean] => nil + ms isnt [=$Boolean] => bottomUpProposition(x,first ms) -- generate an IF expression and let the rest of the code handle it cond := [mkAtreeNode "=",mkAtree "true",term1] putTarget(cond,$Boolean) -- cgit v1.2.3