
https://svn.lrde.epita.fr/svn/xrm/trunk Index: ChangeLog from SIGOURE Benoit <sigoure.benoit@lrde.epita.fr> Add static constant propagations in static definitions. eg: const int N = 3; const int M = N; // propagation of N in the saved definition for M const int X = M; // ditto => const int X = 3; // and not const int X = N; as it used to be. * src/str/collect-static-const-decl.str: Try to propagate static consts/formulas in the definition of static consts/formulas. * tests/prism/desugar-const.pm: New. src/str/collect-static-const-decl.str | 9 ++++++--- tests/prism/desugar-const.pm | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) Index: src/str/collect-static-const-decl.str --- src/str/collect-static-const-decl.str (revision 50) +++ src/str/collect-static-const-decl.str (working copy) @@ -10,35 +10,38 @@ collect-static-const-decl = ?ConstInt(idf, value) - ; where(!value{Type("int")} => v) ; if <ExpandStaticConsts> idf then cannot-redefine-static-const(|idf) end ; if <ExpandFormulas> idf then cannot-redefine-formula(|idf) end + ; where(<innermost(ExpandStaticConsts + ExpandFormulas)> value => v' + ; !v'{Type("int")} => v) ; rules(ExpandStaticConsts: idf -> v) collect-static-const-decl = ?ConstDouble(idf, value) - ; where(!value{Type("double")} => v) ; if <ExpandStaticConsts> idf then cannot-redefine-static-const(|idf) end ; if <ExpandFormulas> idf then cannot-redefine-formula(|idf) end + ; where(<innermost(ExpandStaticConsts + ExpandFormulas)> value => v' + ; !v'{Type("double")} => v) ; rules(ExpandStaticConsts: idf -> v) collect-static-const-decl = ?ConstBool(idf, value) - ; where(!value{Type("bool")} => v) ; if <ExpandStaticConsts> idf then cannot-redefine-static-const(|idf) end ; if <ExpandFormulas> idf then cannot-redefine-formula(|idf) end + ; where(<innermost(ExpandStaticConsts + ExpandFormulas)> value => v' + ; !v'{Type("bool")} => v) ; rules(ExpandStaticConsts: idf -> v) rules Index: tests/prism/desugar-const.pm --- tests/prism/desugar-const.pm (revision 0) +++ tests/prism/desugar-const.pm (revision 0) @@ -0,0 +1,4 @@ +const int N = 3; +const int M = N; + +const int test = M; // this should become a 3 with xrm-front -D