Changeset 3412


Ignore:
Timestamp:
Feb 14, 2008, 1:34:25 PM (13 years ago)
Author:
yura
Message:
  • $native for java function and fields.
Location:
to-imperative/trunk/compiler
Files:
3 edited

Legend:

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

    r3371 r3412  
    2929  };
    3030
    31 DeclarationReader s.string =
    32   <ToChars s.string> : e.head '(' e.args ')' e =
     31$func HeadReader e.head = s.isStatic s.returnType s.className s.methodName;
     32$func ArgsReader e.args = e.argTypes;
     33
     34DeclarationReader s.decl = <ToChars s.decl> :: e.string, {
     35  e.string : e.head '(' e.args ')' e = <HeadReader e.head> (<ArgsReader e.args>);
     36  <HeadReader e.string>;
     37};
     38 
     39HeadReader e.head =
    3340  <GetWhileNotWhitespace e.head> :: (e.nws1) e.head,
    3441  <GetWhileNotWhitespace e.head> :: (e.nws2) e.head,
     
    4754        e.methodname : $r e.classname '.' e.methodname1 = <ToWord e.classname> <ToWord e.methodname1>;
    4855  } :: s.className s.methodName,
     56  s.static s.resType s.className s.methodName;
     57
     58ArgsReader e.args =
    4959  () e.args $iter {
    5060    e.args : {
     
    5666      (e.argTypes <ToWord e.argType>) e.tail;
    5767  } :: (e.argTypes) e.args, <Whitespaces e.args> =
    58   s.static s.resType s.className s.methodName e.argTypes;
     68  e.argTypes;
    5969
    6070$func PrintDeclReader s = ;
     
    6676
    6777Main =
    68   <PrintDeclReader "Integer (int x, double);">,
    69   <PrintDeclReader "Integer Integer.toInteger (int x, double);">,
    70   <PrintDeclReader "static Integer java.lang.Integer.toInteger (int x, double);">,
     78  <PrintDeclReader "Integer (int x, double)">,
     79  <PrintDeclReader "Integer Integer.toInteger (int x, double)">,
     80  <PrintDeclReader "static Integer java.lang.Integer.toInteger (int x, double)">,
     81  <PrintDeclReader "Integer Integer.toInteger">,
     82  <PrintDeclReader "static Integer java.lang.Integer.toInteger">,
    7183;
  • to-imperative/trunk/compiler/NativeJava.rfi

    r3077 r3412  
    1 $func DeclarationReader s = s s s s e;
     1/* s.returnType s.methodName : empty  --  constructor */
     2/* e.argTypes : empty  --  field */
     3/* e.argTypes : (e)    --  method */
     4$func DeclarationReader s.decl = s.isStatic s.returnType s.className s.methodName e.argTypes;
  • to-imperative/trunk/compiler/rfp_asail_java.rf

    r3409 r3412  
    533533    SVAR = {
    534534      s.javaType : \{"boolean"; "char"; "byte"; "short"; "int"; "long";} =
    535         'Symbol.'s.javaType'Value('<Rfp2Java t.var>')';
    536       '(('s.javaType') Symbol.objectValue('<Rfp2Java t.var>'))';
     535        'Native.'s.javaType'Value('<Rfp2Java t.var>'.at(0))';
     536      '(('s.javaType') Native.objectValue('<Rfp2Java t.var>'.at(0)))';
    537537    };
    538538    EVAR =
     
    540540      {
    541541        s.javaElemType : \{"boolean"; "char"; "byte"; "short"; "int"; "long";} =
    542           'Symbol.arrayValue('<Rfp2Java t.var>', new 's.javaElemType'['<Rfp2Java t.var>'.length()])';
    543         '(('s.javaType') Symbol.arrayValue('<Rfp2Java t.var>', new 's.javaElemType'['<Rfp2Java t.var>'.length()]))';
     542          'Native.arrayValue('<Rfp2Java t.var>', new 's.javaElemType'['<Rfp2Java t.var>'.length()])';
     543        '(('s.javaType') Native.arrayValue('<Rfp2Java t.var>', new 's.javaElemType'['<Rfp2Java t.var>'.length()]))';
    544544      };
    545545  };
     
    554554
    555555WrapGen s.linkage FUNC t.qname (e.in) (e.out) e.native =
     556        <PrintLn>
     557        <PrintLn e.native>
    556558  <DeclarationReader <ToWord e.native>> :: s.static s.javaResType s.className s.methodName e.javaArgTypes,
    557559  { <Get &Entry> : e t.qname e = <Store &Entry_Name t.qname>;; },
    558560  { ('@RefalFormat("'<ReplaceQuotes <PrintFunctionFormat t.qname>>'")');; } :: e.refalFormat,
    559   <Del_Pragmas <Gener_Var_Indices 1 (<Vars e.in>) 'arg'>> : e.rfArgTypes s,
    560   <Del_Pragmas <Gener_Var_Indices 1 (<Vars e.out>) 'res'>> : e.rfResTypes s,
     561  <Del_Pragmas <Gener_Var_Indices 1 (<Vars e.in>) 'arg'>> : e.rfArgs s,
     562  <Del_Pragmas <Gener_Var_Indices 1 (<Vars e.out>) 'res'>> : e.rfRes s,
     563        <WriteLn s.static s.javaResType s.className s.methodName e.javaArgTypes>,
    561564  {
    562565    s.methodName : "" = 'new ' s.className 0;
    563     s.static : "" = <ConvertTo s.className <L 0 e.rfArgTypes>> '.' s.methodName 1;
     566    s.static : "" = <ConvertTo s.className <L 0 e.rfArgs>> '.' s.methodName 1;
    564567    s.className '.' s.methodName 0;
    565568  } :: e.funcHead s.shift,
    566   {
    567     s.shift : 1 = e.rfArgTypes : t e.rfArgTypes2, e.rfArgTypes2;
    568     e.rfArgTypes;
    569   } :: e.rfArgTypes2,
    570   0 $iter {
    571     {e.args : /**/ = /**/; ', ';} :: e.comma,
    572     e.args e.comma <ConvertTo <L s.num e.javaArgTypes> <L s.num e.rfArgTypes2>> <Add s.num 1>;
    573   } :: e.args s.num,
    574   <Length e.javaArgTypes> : s.num =
    575   e.funcHead '(' e.args ')' :: v.funcCall,
    576   e.rfResTypes : {
    577     /**/ = v.funcCall';';
    578     t.rfResType, (<Rfp2Java e.rfResTypes>'.assign('<ConvertFrom t.rfResType v.funcCall>');');
     569        <PrintLn e.funcHead>,
     570  {
     571                        <PrintLn "1 " e.javaArgTypes " " s.shift " " e.rfArgs>,
     572    e.javaArgTypes : (e.javaArgTypes2) =
     573      <Middle s.shift 0 e.rfArgs> :: e.rfArgs,     
     574                        <PrintLn "1 " e.rfArgs>,
     575      0 $iter {
     576        {e.args : /**/ = /**/; ', ';} :: e.comma,
     577          e.args e.comma <ConvertTo <L s.num e.javaArgTypes2> <L s.num e.rfArgs>> <Add s.num 1>;
     578      } :: e.args s.num,
     579      <Length e.javaArgTypes2> : s.num = e.funcHead '(' e.args ')';
     580    e.funcHead;
     581  } :: e.funcCall,
     582        <PrintLn e.funcCall>,
     583  e.rfRes : {
     584    /**/ = e.funcCall';';
     585    t.rfResType, (<Rfp2Java e.rfRes>'.assign('<ConvertFrom t.rfResType e.funcCall>');');
    579586  } :: e.body =
    580587  ()
    581588  e.refalFormat
    582   ('static '<Access_Mode s.linkage>' void ' <Name_To_Java t.qname>' ('<Var_Args_To_Java Expr e.rfArgTypes Result e.rfResTypes>') throws RefalException {'
    583     ('try {' (e.body) '} catch (java.lang.Exception e) {' ('throw new org.refal.plus.RefalException("'<Get &Module_Name>'", "'<Name_To_Java t.qname>'", e.toString());')'}')
     589  ('static '<Access_Mode s.linkage>' void ' <Name_To_Java t.qname>' ('<Var_Args_To_Java Expr e.rfArgs Result e.rfRes>') throws RefalException {'
     590  ('try {' (e.body) '} catch (java.lang.Exception e) {' ('throw new org.refal.plus.RefalException("'<Get &Module_Name>'", "'<Name_To_Java t.qname>'", e.toString());')'}')
    584591  '}' );
    585   /*
     592/*
    586593  {
    587594    e.javaArgTypes : e.head s.javaArgType e,
Note: See TracChangeset for help on using the changeset viewer.