Ignore:
Timestamp:
Jul 27, 2006, 8:40:44 AM (14 years ago)
Author:
orlov
Message:
  • Proper generation of debug info for use with Debug library (-dbg option).
  • Result expressions can contain blocks.
File:
1 edited

Legend:

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

    r1706 r2034  
    88$use "rfp_helper";
    99$use "rfp_vars";
     10$use "rfp_debug";
    1011
    1112$use Arithm Class List StdIO Table;
     
    1617// transform { A; } : Pe into { A; } :: aux, aux : Pe
    1718$func Unstick-Blocks e.Sentence = e.Sentence (e.Fe);
     19
     20// remove blocks from Re
     21$func Flatten-Result s.N (e.Re) e.items = e.assigns s.N (e.Re);
    1822
    1923$func Generate-In-Vars (e.in) e.branch = (e.in) e.branch;
     
    5054    },
    5155      t.item : (s.link s.tag t.pragma t.name (e.in) (e.out) (BRANCH t.p e.branch)) =
    52       <Unstick-Blocks e.branch> :: e.branch t,
    5356      {
    5457        <Format-Exp e.in> : e.in =
     
    5659        (e.in) e.branch;
    5760      } :: (e.in) e.branch,
     61      {
     62        <In-Table? &RFP-Options DBG> =
     63          <Add-Debug (RESULT t.p e.in) e.branch>;
     64        e.branch;
     65      } :: e.branch,
     66      <Unstick-Blocks e.branch> :: e.branch t,
    5867      <Rename-Vars 0 (<Vars e.in>) () e.branch> :: e.branch,
    5968      (s.link s.tag t.pragma t.name (e.in) (e.out) (BRANCH t.p e.branch));
     
    92101      } =
    93102        <Gener-Var-Indices 1 (<MSG e.Fes>) "aux" "block"> :: e.aux s,
    94         eL (s.block t.Pragma e.br) (FORMAT e.aux)
    95         (RESULT e.aux) <Unstick-Blocks eR>;
     103        eL (s.block t.Pragma e.br) (FORMAT (PRAGMA) e.aux)
     104        (RESULT (PRAGMA) e.aux) <Unstick-Blocks eR>;
    96105      eR : /*empty*/ =
    97106        eL (s.block t.Pragma e.br) (<MSG e.Fes>);
    98107      eL (s.block t.Pragma e.br) <Unstick-Blocks eR>;
    99108    };
    100   (RESULT t.Pragma e.Re) =
    101     eL (RESULT t.Pragma e.Re) (<Format-Exp e.Re>);
     109  (RESULT t.Pragma e.Re) eR =
     110    <Flatten-Result 1 () e.Re> :: e.assigns s (e.Re),
     111    {
     112      eR : v =
     113        eL e.assigns (RESULT t.Pragma e.Re) <Unstick-Blocks eR>;
     114      eL e.assigns (RESULT t.Pragma e.Re) (<Format-Exp e.Re>);
     115    };
    102116  (ITER (BRANCH t.p1 e.body) t.IterVars (BRANCH t.p2 e.condition)) =
    103117    <Unstick-Blocks e.body> :: e.body t,
     
    113127    eL (ERROR t.Pragma) eR (FAIL);
    114128};
     129
     130Flatten-Result s.N (e.Re) e.items, e.items : {
     131  t1 e.rest, t1 : \{ (BLOCK e); (BLOCK? e); } =
     132    <Gener-Var-Indices s.N (<Format-Exp e.Re>) "aux" "result"> :: e.aux1 s.N,
     133    <Unstick-Blocks t1> :: e1 (e.Format),
     134    <Gener-Var-Indices s.N (e.Format) "aux" "block"> :: e.aux2 s.N,
     135    (RESULT (PRAGMA) e.Re) (FORMAT (PRAGMA) e.aux1)
     136    e1 (FORMAT (PRAGMA) e.aux2)
     137    <Flatten-Result s.N (e.aux1 e.aux2) e.rest>;
     138  (PAREN e.r) e.rest =
     139    <Flatten-Result s.N () e.r> :: e.assigns s.N (e.r),
     140    e.assigns <Flatten-Result s.N (e.Re (PAREN e.r)) e.rest>;
     141  (CALL t.p t.name e.r) e.rest =
     142    <Flatten-Result s.N () e.r> :: e.assigns s.N (e.r),
     143    e.assigns <Flatten-Result s.N (e.Re (CALL t.p t.name e.r)) e.rest>;
     144  t1 e.rest = <Flatten-Result s.N (e.Re t1) e.rest>;
     145  /*empty*/ = s.N (e.Re);
     146};
     147
    115148
    116149/*
     
    301334
    302335
    303 /////////////////////////// Varibles Using Analysis /////////////////////////
     336/////////////////////////// Variables Using Analysis /////////////////////////
    304337//
    305338//$func Post-Comp (e.used-vars) e.comp-func = (e.used-vars) e.result-func;
Note: See TracChangeset for help on using the changeset viewer.