Changeset 2381


Ignore:
Timestamp:
Feb 11, 2007, 3:12:23 AM (14 years ago)
Author:
orlov
Message:
  • Fixed variables renaming after negation (#).
  • Slightly simplify conditions in ASAIL.
Location:
to-imperative/trunk/compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/compiler/rfp_as2as.rf

    r2304 r2381  
    321321        <Rename-Vars s.num (e.upper-vars) (e.res-vars) t.Catch> :: e.Catch,
    322322        () (e.new-Snt (TRY e.TryBranch e.NOFAIL e.Catch));
     323      t.Statement : (NOT t.branch) =
     324        (e.vars) (e.new-Snt (NOT <Rename-Vars s.num (e.vars) (e.res-vars) t.branch>)) e.rest;
    323325      /*
    324326       * Else proceed with the rest.
  • to-imperative/trunk/compiler/rfp_asail2asail.rf

    r2350 r2381  
    11// $Id$
    22
    3 $use Arithm Box List StdIO Table;
     3$use Apply Arithm Box Class Compare List StdIO Table;
    44$use "rfp_helper";
    55
    66$func Simplify-Infix t.asail-term = t.asail-term;
    77$func Simplify-Arithm e = e;
     8
     9$func? Simplify-Cmp s.op (expr1) (expr2) = e;
    810
    911$func Simplify e.asail = e.asail;
     
    2628Simplify {
    2729  t.first e.rest, t.first : {
    28     (IF-INT-CMP s.op (e.arg1) (e.arg2) e.body) =
    29       (IF-INT-CMP s.op (<Simplify-Arithm (e.arg1)>) (<Simplify-Arithm (e.arg2)>)
    30         <Simplify e.body>);
     30    (IF-INT-CMP s.op (e.arg1) (e.arg2) e.body) = {
     31      <Simplify-Cmp s.op (<Simplify-Arithm (e.arg1)>) (<Simplify-Arithm (e.arg2)>)> : {
     32        (e1) (e2) = (IF-INT-CMP s.op (e1) (e2) <Simplify e.body>);
     33        /*empty*/ = <Simplify e.body>;
     34      };;
     35    };
    3136    (IF t.cond e.body) = (IF t.cond <Simplify e.body>);
    3237    (INT t.var e.expr) = (INT t.var <Simplify-Arithm (e.expr)>);
     
    237242};
    238243
     244$func? Cmp s.fn (expr1) (expr2) = e;
     245
     246Simplify-Cmp s.op (expr1) (expr2) =
     247  s.op : { "!=" = &"/="; ">" = &">"; "<" = &"<"; } :: s.op,
     248  <Cmp s.op (expr1) (expr2)>;
     249
     250Cmp {
     251  s.fn (e11 tx e12) (e21 tx e22) =
     252    <Cmp s.fn (e11 e12) (e21 e22)>;
     253  s.fn (e1) (e2), <All &Int? (e1)>, <All &Int? (e2)> =
     254    <Apply s.fn (<Foldr1 &"+" (e1)>) (<Foldr1 &"+" (e2)>)>;
     255  s.fn (e1) (e2) = (e1) (e2);
     256};
     257 
    239258
    240259Free-Idx =
Note: See TracChangeset for help on using the changeset viewer.