Changeset 2385


Ignore:
Timestamp:
Feb 11, 2007, 6:26:03 AM (14 years ago)
Author:
orlov
Message:
  • $trap...$with and $error.
File:
1 edited

Legend:

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

    r2377 r2385  
    169169Lookup-Label t.label = <Lookup &Labels t.label> : s.l = s.l;
    170170
     171
     172$box Traps;
     173
     174$func Push-Trap s.end s.handler = ;
     175$func Get-Trap = s.handler;
     176$func Pop-Trap = s.end;
     177
     178Push-Trap s.end s.handler =
     179  <Put &Traps (s.end s.handler)>;
     180
     181Get-Trap = <R 0 <? &Traps>> : (s s.handler) = s.handler;
     182
     183Pop-Trap =
     184  <? &Traps> : e.traps (s.end s),
     185  <Store &Traps e.traps>,
     186  s.end;
     187
     188
    171189$func Qualified-Module-Name s.module-name = s.qualified-module-name;
    172190
     
    209227      t.name : (s s.funcName),
    210228      <To-Word <Rfp2Java s.funcName>> :: s.funcName,
     229      <Store &Func-Name s.funcName>,
    211230      { <? &Entry> : e t.name e = <Store &Entry-Name s.funcName>;; },
    212231      <Function-Description (e.args) (e.ress) s.retType> :: s.desc,
     
    361380    RETFAIL = <MVvisitInsn <MV> &"ICONST_0"> <MVvisitInsn <MV> &IRETURN>;
    362381    (TRY e.body) =
    363       ('try') ('{' (
    364         ('if (false)'
    365           ('throw new RefalException ("'<Intersperse ('.') <? &Module-Name>>'", "'<? &Func-Name>'", '
    366             '"This is for avoiding \'Unreachable code\' errors");'
    367         )   )
    368 //        <ASAIL-To-JBC-Temp e.body>
    369       ) '}') : e;
     382      <Label> :: s.start,
     383      <Label> :: s.end,
     384      <Label> :: s.real-end,
     385      <Label> :: s.handler,
     386      <Push-Trap s.real-end s.handler>,
     387      <MVvisitTryCatchBlock <MV> s.start s.end s.handler "org/refal/plus/RefalException">,
     388      <MVvisitLabel <MV> s.start>,
     389      <ASAIL-To-JBC e.body>,
     390      <MVvisitLabel <MV> s.end>,
     391      <MVvisitJumpInsn <MV> &GOTO s.real-end>;
    370392    (CATCH-ERROR e.body) =
    371       ('catch (RefalException error) {' (
    372         ('Expr err = error.getExpr ();')
    373 //        (<ASAIL-To-JBC-Temp e.body>)
    374       ) '}') : e;
     393      <Get-Trap> :: s.label,
     394      <MVvisitLabel <MV> s.label>,
     395      <MVvisitMethodInsn <MV> &INVOKEVIRTUAL "org/refal/plus/RefalException" "getExpr" "()Lorg/refal/plus/Expr;">,
     396      <MVvisitVarInsn <MV> &ASTORE <Bind-Var Expr s.label>>,
     397      <ASAIL-To-JBC e.body>,
     398      <MVvisitLabel <MV> <Pop-Trap>>;
    375399    FATAL =
    376       ('throw new RefalException ("'<Intersperse ('.') <? &Module-Name>>'", "'<? &Func-Name>'", "Unexpected fail");') : e;
     400      <MVvisitTypeInsn <MV> &NEW "org/refal/plus/RefalException">,
     401      <MVvisitInsn <MV> &DUP>,
     402      <MVvisitLdcInsn <MV> <WordToString <To-Word <Intersperse ('.') <? &Module-Name>>>>>,
     403      <? &Func-Name> : s.fname,
     404      <MVvisitLdcInsn <MV> <WordToString s.fname>>,
     405      <MVvisitLdcInsn <MV> <WordToString "Unexpected fail">>,
     406      <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/RefalException" "<init>" "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V">,
     407      <MVvisitInsn <MV> &ATHROW>;
    377408    (ERROR e.expr) =
    378       <Expr-Ref-To-JBC e.expr>;
    379       //('throw new RefalException ('e.j-expr');') : e;
     409      <MVvisitTypeInsn <MV> &NEW "org/refal/plus/RefalException">,
     410      <MVvisitInsn <MV> &DUP>,
     411      <Expr-Ref-To-JBC e.expr>,
     412      <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/RefalException" "<init>" "(Lorg/refal/plus/Expr;)V">,
     413      <MVvisitInsn <MV> &ATHROW>;
    380414    (s.call (s.module s.name) (e.args) (e.ress)),
    381415      s.call : \{ CALL = V; TAILCALL = V; TAILCALL? = Z; } :: s.retType =
     
    471505    <To-Word <Rfp2Java t.name>> :: s.name,
    472506    <MVvisitFieldInsn <MV> &GETSTATIC s.module s.name "Lorg/refal/plus/Expr;">;
    473   //ERROR-EXPR = 'err';
     507  ERROR-EXPR = <Var-To-JBC <Get-Trap>>;
    474508  t.term, t.term : (s.var-tag e),
    475509    s.var-tag : \{ VAR; SVAR; TVAR; EVAR; VVAR; } =
Note: See TracChangeset for help on using the changeset viewer.