Changeset 2350


Ignore:
Timestamp:
Feb 8, 2007, 1:22:38 AM (14 years ago)
Author:
orlov
Message:
  • In ASAIL IF is changed to (IF t.cond e.body) and (IF-INT-CMP s.op (e.arg1) (e.arg2) e.body).
Location:
to-imperative/trunk/compiler
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/compiler/Makefile

    r2325 r2350  
    2727  rfp_const \
    2828  rfp_clashes \
    29   rfp_asail_optim \
    3029  rfp_asail2asail \
    3130  rfp_debug
  • to-imperative/trunk/compiler/rfp_asail2asail.rf

    r2068 r2350  
    2626Simplify {
    2727  t.first e.rest, t.first : {
    28     (IF (e.cond) e.body) =
    29       <Map &Simplify-Infix (e.cond)> : {
    30         0 = /*empty*/;
    31         1 = <Simplify e.body>;
    32         e.c = (IF (e.c) <Simplify e.body>);
    33       };
     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>);
     31    (IF t.cond e.body) = (IF t.cond <Simplify e.body>);
    3432    (INT t.var e.expr) = (INT t.var <Simplify-Arithm (e.expr)>);
    3533    (e1) = (<Simplify e1>);
     
    6361    (LABEL (t.label) e.body) =
    6462      <Put &Blocks (LABEL (t.label))>, e.body;
    65     (IF (e.cond) e.body) =
    66       <Put &Blocks (IF (e.cond))>, e.body;
     63    (IF t.cond e.body) =
     64      <Put &Blocks (IF t.cond)>, e.body;
     65    (IF-INT-CMP s.op t.arg1 t.arg2 e.body) =
     66      <Put &Blocks (IF-INT-CMP s.op t.arg1 t.arg2)>, e.body;
    6767    (TRY e.body) =
    6868      <Put &Blocks (TRY)>, e.body;
  • to-imperative/trunk/compiler/rfp_asail_cpp.rf

    r2319 r2350  
    4545$func? Name-To-CPP t.name = e.CPP-Name;
    4646
    47 $func Cond-To-CPP e.cond = e.CPP-Cond;
     47$func Cond-To-CPP t.cond = e.CPP-Cond;
    4848
    4949$func Infix-To-CPP s.func-for-converting-args-to-cpp s.op e.args = e.cpp-expr;
    50 
    51 $func Op-Arg-To-CPP s.op = s.func-for-converting-args-to-cpp;
    5250
    5351$func Trace-Enter e.name (e.args) = e.trace;
     
    128126    (TRACE t.name) =
    129127      <Bind &RFP-Trace (t.name) ()>;
    130     (IF (e.cond) e.body) =
    131       ('if (' <Cond-To-CPP e.cond> ')')
     128    (IF-INT-CMP s.op (e.arg1) (e.arg2) e.body) =
     129      ('if (' <Expr-Int-To-CPP e.arg1> ' 's.op' ' <Expr-Int-To-CPP e.arg2> ')')
     130      ('{' (<ASAIL-To-CPP e.body>) '}');
     131    (IF t.cond e.body) =
     132      ('if (' <Cond-To-CPP t.cond> ')')
    132133      ('{' (<ASAIL-To-CPP e.body>) '}');
    133134    (FOR (e.cont-label) (e.break-label) (e.cond) (e.step) e.body) =
     
    143144        e.break-label : t = (LABEL <Rfp2Cpp (LABEL e.break-label)> ': {}');;
    144145      } :: e.break,
    145       ('for ( ; ' <Cond-To-CPP e.cond> '; ' <Step-To-CPP e.step> ')') e.body e.break;
     146      ('for ( ; ; ' <Step-To-CPP e.step> ')') e.body e.break;
    146147    (LABEL (e.label) e.body) =
    147148//      {
     
    348349
    349350Cond-To-CPP {
    350   /*empty*/ = /*empty*/;
    351   (CALL t.name (e.exprs) (e.ress)) =
    352     'RF_CALL (' <Name-To-CPP t.name> ', '
     351  (CALL-FAILS (CALL t.name (e.exprs) (e.ress))) =
     352    '!RF_CALL (' <Name-To-CPP t.name> ', '
    353353          <Args-To-CPP () Exprs e.exprs> ', '
    354354          <Args-To-CPP () Vars e.ress>   ')';
     
    358358    <Expr-Ref-To-CPP e.expr> '.flat_at ('
    359359      <Expr-Int-To-CPP e.pos> ', ' <Expr-Int-To-CPP e.len> ')';
    360   (CHECK-ITER e.expr) =
    361     'RF_iter(' <Expr-Ref-To-CPP e.expr> ')';
     360  (ITER-FAILS e.expr) =
     361    '!RF_iter(' <Expr-Ref-To-CPP e.expr> ')';
    362362  (EQ e.expr1 (e.expr2) (e.pos)) =
    363363    <Expr-Ref-To-CPP e.expr1> '.eq ('
     
    366366    <Expr-Ref-To-CPP e.expr1> '.term_eq ('
    367367      <Expr-Ref-To-CPP e.expr2> ', ' <Expr-Int-To-CPP e.pos> ')';
    368   (NOT e.cond) =
    369     '!' <Cond-To-CPP e.cond>;
    370   (INFIX s.op e.args) =
    371     '(' <Infix-To-CPP <Op-Arg-To-CPP s.op> s.op e.args> ')';
    372   expr = '(' <Infix-To-CPP &Cond-To-CPP "&&" <Paren expr>> ')';
     368  (NOT t.cond) =
     369    '!' <Cond-To-CPP t.cond>;
    373370};
    374371
     
    383380};
    384381
    385 Op-Arg-To-CPP s.op, {
    386   s.op : \{ "&&"; "||"; } =
    387     &Cond-To-CPP;
    388   s.op : \{ "<"; ">"; "<="; ">="; "=="; "!="; "+"; "-"; "%"; "*"; "/"; } =
    389     &Expr-Int-To-CPP;
    390 };
    391  
    392382Step-To-CPP {
    393383  /*empty*/ = /*empty*/;
  • to-imperative/trunk/compiler/rfp_compile.rf

    r2349 r2350  
    671671Comp-Calls (e.fail) e.calls, e.calls : {
    672672  (Failable t.call) e.rest =
    673     (IF ((NOT t.call)) e.fail) <Comp-Calls (e.fail) e.rest>;
     673    (IF (CALL-FAILS t.call) e.fail) <Comp-Calls (e.fail) e.rest>;
    674674  t.call e.rest =
    675675    t.call <Comp-Calls (e.fail) e.rest>;
     
    11711171              (s.split t.var (<Get-Var Min t.l-var>) t.l-var t.r-var)
    11721172              (FOR (t.cont-label) (t.break-label) () ((s.iter-op t.var))
    1173                 (IF ((NOT (CHECK-ITER t.var))) <Concat <R 0 v.fails>>)
     1173                (IF (ITER-FAILS t.var) <Concat <R 0 v.fails>>)
    11741174                <CC s.tail?     (v.fails ((CONTINUE t.cont-label)))
    11751175                  <R 0 v.fails> e.Snt>
     
    11861186    <Put &Checked-Lengths t.idx>,
    11871187    <Lookup &Known-Lengths t.idx> : (e.len-Re) (e.len-Pe),
    1188     (IF ((INFIX "!=" (e.len-Re) (e.len-Pe))) e.fail)
     1188    (IF-INT-CMP "!=" (e.len-Re) (e.len-Pe) e.fail)
    11891189    <CC-Known-Lengths (e.fail) e.rest>;
    11901190  <RFP-Clear-Table &Known-Lengths>;
     
    11971197    t.var : (Len-Var e) =
    11981198      <Unbind &Compute-Length t.idx>,
    1199       (IF ((INFIX "<" (e.minuend)
     1199      (IF-INT-CMP "<" (e.minuend)
    12001200          ((INFIX "+" (e.subtrahend)
    12011201            ((INFIX "*" (e.min) (s.mult)))
    1202         ))      ))
     1202          ))
    12031203        e.end-cycle
    12041204      );
    12051205    <Create-Int-Var ("len") Aux e.minuend> :: t.m-var e.m-assign,
    12061206      <Create-Int-Var ("len") Aux e.subtrahend> :: t.s-var e.s-assign,
    1207       (IF ((INFIX "<" (t.m-var)
     1207      (IF-INT-CMP "<" (t.m-var)
    12081208          ((INFIX "+" (t.s-var)
    12091209            ((INFIX "*" (e.min) (s.mult)))
    1210         ))      ))
     1210          ))
    12111211        e.end-cycle
    12121212      ) :: e.min-cond,
     
    12141214        /*empty*/;
    12151215        e.max =
    1216           (IF ((INFIX ">" (t.m-var)
     1216          (IF-INT-CMP ">" (t.m-var)
    12171217              ((INFIX "+" (t.s-var)
    12181218                ((INFIX "*" (e.max) (s.mult)))
    1219             ))  ))
     1219              ))
    12201220          e.end-cycle);
    12211221      } :: e.max-cond,
     
    12311231      e.m-assign e.s-assign
    12321232      e.min-cond e.max-cond
    1233       (IF (e.div-cond) e.fail)
     1233      (IF-INT-CMP "!=" (e.div-cond) (0) e.fail)
    12341234      e.len-assign;
    12351235  };
     
    12451245      <Get-Max e.vars-Re> :: e.max =
    12461246        <Get-Min e.vars-Pe> :: e.min,
    1247         (IF ((INFIX "<" (e.len-Re e.max) (e.len-Pe e.min))) e.fail);
     1247        (IF-INT-CMP "<" (e.len-Re e.max) (e.len-Pe e.min) e.fail);
    12481248      /*empty*/;
    12491249    } :: e.cond1,
     
    12511251      <Get-Max e.vars-Pe> :: e.max =
    12521252        <Get-Min e.vars-Re> :: e.min,
    1253         (IF ((INFIX ">" (e.len-Re e.min) (e.len-Pe e.max))) e.fail);
     1253        (IF-INT-CMP ">" (e.len-Re e.min) (e.len-Pe e.max) e.fail);
    12541254      /*empty*/;
    12551255    } :: e.cond2,
     
    12841284CC-Deref (e.fail) e.actions, e.actions : {
    12851285  (SYMBOL? e.Re (s.dir e.pos)) e.rest =
    1286     (IF ((SYMBOL? e.Re (<Pos (e.Re) s.dir e.pos>))) e.fail)
     1286    (IF (SYMBOL? e.Re (<Pos (e.Re) s.dir e.pos>)) e.fail)
    12871287    <CC-Deref (e.fail) e.rest>;
    12881288  (DEREF t.var e.Re (s.dir e.pos)) e.rest =
     
    13211321        };
    13221322      } :: el (er),
    1323         (IF ((NOT (s.eq el (er) (e.pos)))) e.fail) :: t.cond,
     1323        (IF (NOT (s.eq el (er) (e.pos))) e.fail) :: t.cond,
    13241324        {
    13251325          /*
     
    13351335          t.Pt : (SVAR e) =
    13361336            (IF
    1337               ((NOT (SYMBOL? e.Re (<Pos (e.Re) s.dir e.pos>))))
     1337              (NOT (SYMBOL? e.Re (<Pos (e.Re) s.dir e.pos>)))
    13381338              e.fail
    13391339            );;
Note: See TracChangeset for help on using the changeset viewer.