Changeset 2355


Ignore:
Timestamp:
Feb 9, 2007, 5:40:21 PM (14 years ago)
Author:
yura
Message:
  • Advances in Java-bytecode generation (function call in condition).
File:
1 edited

Legend:

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

    r2354 r2355  
    183183  <To-Word e.p <Rfp2Java s.module-name>>;
    184184
     185$func Function-Description (e.args) (e.ress) s.retType = s.desc;
     186
     187Function-Description (e.args) (e.ress) s.retType =
     188  <To-Word '(' <Replicate <Length e.args> "Lorg/refal/plus/Expr;">
     189    <Replicate <Length e.ress> "Lorg/refal/plus/Result;">')' s.retType>;
     190
    185191Module-To-JBC s.cw e.module, {
    186192  e.module : e t.item e, t.item : {
     
    201207      <To-Word <Rfp2Java s.funcName>> :: s.funcName,
    202208      { <? &Entry> : e t.name e = <Store &Entry-Name s.funcName>;; },
    203       <To-Word '(' <Replicate <Length e.args> "Lorg/refal/plus/Expr;">
    204         <Replicate <Length e.ress> "Lorg/refal/plus/Result;">')' s.retType> :: s.desc,
     209      <Function-Description (e.args) (e.ress) s.retType> :: s.desc,
    205210      <Store &MVbox <"visitMethod" s.cw s.accessMode s.funcName s.desc <Null> ("org/refal/plus/RefalException")>>,
    206211      <ASAIL-To-JBC e.body>,
     
    374379      <Qualified-Module-Name s.module> :: s.module,
    375380      <To-Word <Rfp2Java s.name>> :: s.name,
    376       <To-Word '(' <Replicate <Length e.args> "Lorg/refal/plus/Expr;">
    377         <Replicate <Length e.ress> "Lorg/refal/plus/Result;">')' s.retType> :: s.desc,
     381      <Function-Description (e.args) (e.ress) s.retType> :: s.desc,
    378382      {
    379383        e.args : e (e.arg) e,
     
    382386      },
    383387      {
    384         e.ress : e t.var e, <Lookup-Var t.var> : Expr s,
    385           <Bind-TMP-Var t.var> :: s.j,
    386           <MVvisitTypeInsn <MV> &NEW "org/refal/plus/Result">,
    387           <MVvisitInsn <MV> &DUP>,
    388           <MVvisitInsn <MV> &DUP>,
    389           <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/Result" "<init>" "()V">,
    390           <MVvisitVarInsn <MV> &ASTORE s.j>,
    391           $fail;;
     388        e.ress : e t.var e, <Lookup-Var t.var> :
     389          {
     390            Expr s =
     391              <Bind-TMP-Var t.var> :: s.j,
     392              <MVvisitTypeInsn <MV> &NEW "org/refal/plus/Result">,
     393              <MVvisitInsn <MV> &DUP>,
     394              <MVvisitInsn <MV> &DUP>,
     395              <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/Result" "<init>" "()V">,
     396              <MVvisitVarInsn <MV> &ASTORE s.j>;
     397            Result s.i =
     398              <MVvisitVarInsn <MV> &ALOAD s.i>;
     399          }, $fail;;
    392400      },
    393401      <MVvisitMethodInsn <MV> &INVOKESTATIC s.module s.name s.desc>,
     
    410418  }, $fail; e;
    411419};
     420
    412421
    413422$func Term-Ref-To-JBC t.term = ;
     
    461470  //ERROR-EXPR = 'err';
    462471  t.term, t.term : (s.var-tag e),
    463     s.var-tag : \{ VAR; SVAR; TVAR; EVAR; VVAR; } = <Var-To-JBC t.term>;
     472    s.var-tag : \{ VAR; SVAR; TVAR; EVAR; VVAR; } =
     473    <Var-To-JBC t.term>;
    464474};
    465475
     
    505515
    506516Cond-To-JBC {
    507   (CALL-FAILS (CALL t.name (e.exprs) (e.ress))) = &IFEQ; /*
     517  (CALL-FAILS (CALL (s.module s.name) (e.args) (e.ress))) =
     518  /*
    508519    '!RF_CALL (' <Name-To-CPP t.name> ', '
    509520          <Args-To-CPP () Exprs e.exprs> ', '
    510521          <Args-To-CPP () Vars e.ress>   ')';*/
     522    <Qualified-Module-Name s.module> :: s.module,
     523    <To-Word <Rfp2Java s.name>> :: s.name,
     524    <Function-Description (e.args) (e.ress) "Z"> :: s.desc,
     525    {
     526      e.args : e (e.arg) e,
     527        <Expr-Ref-To-JBC e.arg>,
     528        $fail;;
     529    },
     530    {
     531      e.ress : e t.var e, <Lookup-Var t.var> :
     532        {
     533          Expr s =
     534            <MVvisitTypeInsn <MV> &NEW "org/refal/plus/Result">,
     535            <MVvisitInsn <MV> &DUP>,
     536            <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/Result" "<init>" "()V">;
     537          Result s.i =
     538            <MVvisitVarInsn <MV> &ALOAD s.i>;
     539        }, $fail;;
     540    },
     541    <MVvisitMethodInsn <MV> &INVOKESTATIC s.module s.name s.desc>,
     542    &IFEQ;
    511543  (SYMBOL? e.expr (e.pos)) =
    512544    <Expr-Ref-To-JBC e.expr>,
Note: See TracChangeset for help on using the changeset viewer.