Changeset 2387


Ignore:
Timestamp:
Feb 11, 2007, 10:35:05 AM (14 years ago)
Author:
orlov
Message:
  • References to functions.
Location:
to-imperative/trunk/compiler
Files:
3 edited

Legend:

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

    r2386 r2387  
    4949$box Objects;
    5050$box Constants;
     51$box Func-Refs;
    5152
    5253$box MVbox;
     
    5960  <Store &Objects>,
    6061  <Store &Constants>,
     62  <Store &Func-Refs>,
    6163  {
    6264    <Store &Int <Lookup &RFP-Options INT>>;
     
    124126  <MVvisitEnd <MV>>,
    125127
     128//  {
     129//    <? &Func-Refs> : e (s.cl-name s.mod-name s.func-name) e,
     130//      <"visitInnerClass" s.cw s.cl-name <Null> <Null> &"ACC_STATIC">,
     131//      $fail;;
     132//  },
     133     
    126134  <"visitEnd" s.cw>,
    127   <"toByteArray" s.cw> e.java-module-name;
     135
     136  <Box (<"toByteArray" s.cw> e.java-module-name)> :: s.res,
     137  {
     138    <? &Func-Refs> : e (s.cl-name s.mod-name s.func-name s.type) e,
     139      <ClassWriter <"+" &"COMPUTE_MAXS" &"COMPUTE_FRAMES">> :: s.cw,
     140      <"visit" s.cw 46 &"ACC_FINAL" <To-Word s.class-name '$' s.cl-name> <Null> "java/lang/Object" ("org/refal/plus/Func")>,
     141      <"visitMethod" s.cw 0 "<init>" "()V" <Null> ()> :: s.mv,
     142      <MVvisitVarInsn s.mv &ALOAD 0>,
     143      <MVvisitMethodInsn s.mv &INVOKESPECIAL "java/lang/Object" "<init>" "()V">,
     144      <MVvisitInsn s.mv &RETURN>,
     145      <MVvisitMaxs s.mv 0 0>,
     146      <MVvisitEnd s.mv>,
     147      <"visitEnd" s.cw>,
     148      <"visitMethod" s.cw &"ACC_PUBLIC" "eval" "(Lorg/refal/plus/Expr;Lorg/refal/plus/Result;)Z" <Null> ("org/refal/plus/RefalException")> :: s.mv,
     149      <MVvisitVarInsn s.mv &ALOAD 1>,
     150      <MVvisitVarInsn s.mv &ALOAD 2>,
     151      s.type : {
     152        FUNC? =
     153          <MVvisitMethodInsn s.mv &INVOKESTATIC s.mod-name s.func-name "(Lorg/refal/plus/Expr;Lorg/refal/plus/Result;)Z">,
     154          <MVvisitInsn s.mv &IRETURN>;
     155        FUNC  =
     156          <MVvisitMethodInsn s.mv &INVOKESTATIC s.mod-name s.func-name "(Lorg/refal/plus/Expr;Lorg/refal/plus/Result;)V">,
     157          <MVvisitInsn s.mv &"ICONST_1"> <MVvisitInsn s.mv &IRETURN>;
     158      },
     159      <MVvisitMaxs s.mv 0 0>,
     160      <MVvisitEnd s.mv>,
     161      <"visitEnd" s.cw>,
     162      <Put s.res (<"toByteArray" s.cw>
     163        <Middle 0 1 e.java-module-name> <To-Word <R 0 e.java-module-name> '$' s.cl-name>)>,
     164      $fail;;
     165  },
     166
     167  <? s.res>;
     168
     169//  <"toByteArray" s.cw> e.java-module-name;
     170
     171
    128172
    129173$table Vars;
     
    203247
    204248
    205 $func Qualified-Module-Name s.module-name = s.qualified-module-name;
    206 
    207 Qualified-Module-Name s.module-name =
    208   <Lookup &RFP-Includes s.module-name> : {
    209     BOOT e = 'org/refal/plus/library/';
    210     LOCAL e.path,
    211       <? &RFP-Include-Path> : e (e.dir) e,
    212       e.path : \{
    213         e.dir = /*empty*/;
    214         e.dir s.dir-separator e.p = e.p;
    215       } :: e.p,
    216       <Subst (<? &Dir-Separator>) (('/')) e.p>;
    217     LOCAL = /*empty*/;
    218   } :: e.p,
    219   <To-Word e.p <Rfp2Java s.module-name>>;
     249$func Qualified-Module-Name e.module-name = s.qualified-module-name;
     250
     251Qualified-Module-Name {
     252  s.module-name =
     253    <Lookup &RFP-Includes s.module-name> : {
     254      BOOT e = 'org/refal/plus/library/';
     255      LOCAL e.path,
     256        <? &RFP-Include-Path> : e (e.dir) e,
     257        e.path : \{
     258          e.dir = /*empty*/;
     259          e.dir s.dir-separator e.p = e.p;
     260        } :: e.p,
     261        <Subst (<? &Dir-Separator>) (('/')) e.p>;
     262      LOCAL = /*empty*/;
     263    } :: e.p,
     264    <To-Word e.p <Rfp2Java s.module-name>>;
     265  /*empty*/ =
     266    <To-Word <Intersperse ('/') <? &Module-Name>>>;
     267};
    220268
    221269$func Function-Description (e.args) (e.ress) s.retType = s.desc;
     
    232280        FUNC  = 'V';
    233281        FUNC? = 'Z';
    234       } : s.retType,
     282      } : s.retType =
    235283      <Clear-Table &Vars>,
    236284      <Clear-Table &Iter-Vars>,
     
    241289      <Bind-Vars Result e.ress>,
    242290      <"+" &"ACC_STATIC" <Access-Mode t.name>> :: s.accessMode,
    243       t.name : (s s.funcName),
     291      t.name : (e s.funcName),
    244292      <To-Word <Rfp2Java s.funcName>> :: s.funcName,
    245293      <Store &Func-Name s.funcName>,
     
    427475      <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/RefalException" "<init>" "(Lorg/refal/plus/Expr;)V">,
    428476      <MVvisitInsn <MV> &ATHROW>;
    429     (s.call (s.module s.name) (e.args) (e.ress)),
     477    (s.call (e.module s.name) (e.args) (e.ress)),
    430478      s.call : \{ CALL = V; TAILCALL = V; TAILCALL? = Z; } :: s.retType =
    431       <Qualified-Module-Name s.module> :: s.module,
     479      <Qualified-Module-Name e.module> :: s.module,
    432480      <To-Word <Rfp2Java s.name>> :: s.name,
    433481      <Function-Description (e.args) (e.ress) s.retType> :: s.desc,
     
    567615
    568616Cond-To-JBC {
    569   (CALL-FAILS (CALL (s.module s.name) (e.args) (e.ress))) =
    570     <Qualified-Module-Name s.module> :: s.module,
     617  (CALL-FAILS (CALL (e.module s.name) (e.args) (e.ress))) =
     618    <Qualified-Module-Name e.module> :: s.module,
    571619    <To-Word <Rfp2Java s.name>> :: s.name,
    572620    <Function-Description (e.args) (e.ress) "Z"> :: s.desc,
     
    715763    <To-Word <Rfp2Java t.name>> :: s.name,
    716764    <MVvisitFieldInsn <MV> &GETSTATIC s.module s.name "Lorg/refal/plus/Expr;">;
    717 /*
    718   (FUNC? t.name) = () ('new Expr (new Func () {'
    719     ('public boolean eval (Expr arg, Result res) throws RefalException {'
    720       ('return '<Name-To-JBC t.name>' (arg, res);')
    721     '}') '})');
    722   (FUNC t.name) = () ('new Expr (new Func () {'
    723     ('public boolean eval (Expr arg, Result res) throws RefalException {'
    724       ((<Name-To-JBC t.name>' (arg, res);')
    725        ('return true;'))
    726     '}') '})');*/
     765  (s.func (e.module s.name)), s.func : \{ FUNC; FUNC?; } =
     766    <To-Word <Intersperse ('/') <? &Module-Name>> '$' <Length <? &Func-Refs>>> :: s.cl-name,
     767    <Put &Func-Refs (<Length <? &Func-Refs>> <Qualified-Module-Name e.module> <To-Word <Rfp2Java s.name>> s.func)>,
     768    <MVvisitTypeInsn <MV> &NEW "org/refal/plus/Expr">,
     769    <MVvisitInsn <MV> &DUP>,
     770    <MVvisitTypeInsn <MV> &NEW s.cl-name>,
     771    <MVvisitInsn <MV> &DUP>,
     772    <MVvisitMethodInsn <MV> &INVOKESPECIAL s.cl-name "<init>" "()V">,
     773    <MVvisitMethodInsn <MV> &INVOKESPECIAL "org/refal/plus/Expr" "<init>" "(Ljava/lang/Object;)V">;
    727774  s.sym, {
    728775    <Int? s.sym> =
  • to-imperative/trunk/compiler/rfp_asail_jbc.rfi

    r2338 r2387  
    11// $Id$
    22
    3 $func RFP-ASAIL-To-JBC t.module-name (e.package) (e.exports) e.module = s.bytecode e.java-module-name;
     3$func RFP-ASAIL-To-JBC t.module-name (e.package) (e.exports) e.module = e.bytecodes;
    44
  • to-imperative/trunk/compiler/rfpc.rf

    r2363 r2387  
    384384                  e.exports;
    385385              } :: e.exports,
    386               <RFP-ASAIL-To-JBC t.asail-mod-name (e.package) (e.exports) e.module> :: s.bytecode e.java-module-name,
    387               <WriteToStream <FileOutputStream
    388                   <To-Word e.dir <Intersperse (s.dir-separator) e.java-module-name> ".class">>
    389                 s.bytecode>,
     386              {
     387                <RFP-ASAIL-To-JBC t.asail-mod-name (e.package) (e.exports) e.module> :
     388                e (s.bytecode e.java-module-name) e,
     389                  <WriteToStream <FileOutputStream
     390                    <To-Word e.dir <Intersperse (s.dir-separator) e.java-module-name> ".class">>
     391                  s.bytecode>,
     392                  $fail;;
     393              },
    390394              <Verbose "compilation from as-ail to java-bytecode finished">,
    391395              $fail;
Note: See TracChangeset for help on using the changeset viewer.