home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / native_small_eiffel.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  69.5 KB  |  2,566 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class NATIVE_SMALL_EIFFEL
  17.  
  18. inherit NATIVE;
  19.    
  20. feature
  21.    
  22.    need_prototype: BOOLEAN is false;
  23.  
  24. feature
  25.  
  26.    language_name: STRING is
  27.       do
  28.      Result := fz_se;
  29.       end;
  30.  
  31.    stupid_switch(name: STRING): BOOLEAN is
  32.       do
  33.      if us_generating_type = name then
  34.         Result := true;
  35.      elseif us_generator = name then
  36.         Result := true;
  37.      elseif us_to_pointer = name then
  38.         Result := true;
  39.      end;
  40.       end;
  41.  
  42.    c_define_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  43.       do
  44.      if us_bit_n = bcn then
  45.         c_define_procedure_bit(rf7,name);
  46.      end;
  47.       end;
  48.  
  49.    c_mapping_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  50.       local
  51.      t: TYPE;
  52.       do
  53.      if us_copy = name or else us_standard_copy = name then
  54.         t := rf7.current_type;
  55.         if t.is_reference then
  56.            cpp.put_string("*((T");
  57.            cpp.put_integer(t.id);
  58.            cpp.put_string("*)(");
  59.            cpp.put_target_as_value;
  60.            cpp.put_string("))=*((T");
  61.            cpp.put_integer(t.id);
  62.            cpp.put_string("*)(");
  63.            cpp.put_ith_argument(1);
  64.            cpp.put_string(fz_16);
  65.         elseif t.is_basic_eiffel_expanded then
  66.            cpp.put_target_as_value;
  67.            cpp.put_string(fz_00);
  68.            cpp.put_ith_argument(1);
  69.            cpp.put_string(fz_00);
  70.         else
  71.            cpp.put_string("{void* d=");
  72.            cpp.put_target_as_target;
  73.            cpp.put_string(";%NT");
  74.            cpp.put_integer(t.id);
  75.            cpp.put_string(" s;%Ns=*(");
  76.            cpp.put_ith_argument(1);
  77.            cpp.put_string(");%Nmemcpy(d,&s,sizeof(s));}%N");
  78.         end;
  79.      elseif us_flush_stream = name then
  80.         if cpp.target_cannot_be_dropped then
  81.            cpp.put_string(fz_14);
  82.         end;
  83.         cpp.put_string("fflush(");
  84.         cpp.put_ith_argument(1);
  85.         cpp.put_string(fz_14);
  86.      elseif us_write_byte = name then
  87.         cpp.put_string("putc(");
  88.         cpp.put_ith_argument(2);
  89.         cpp.put_string(",((FILE*)(");
  90.         cpp.put_ith_argument(1);
  91.         cpp.put_string(")));%N");
  92.      elseif us_print_run_time_stack = name then
  93.         cpp.put_string("rsp();%N");
  94.      elseif us_die_with_code = name then
  95.         if cpp.target_cannot_be_dropped then
  96.            cpp.put_string(fz_14);
  97.         end;
  98.         cpp.put_string("exit(");
  99.         cpp.put_ith_argument(1);
  100.         cpp.put_string(fz_14);
  101.      elseif us_se_system = name then
  102.         cpp.put_string("system(((char*)_p));");
  103.      elseif us_c_inline_c = name then
  104.         cpp.put_c_inline_c;
  105.      elseif us_c_inline_h = name then
  106.         cpp.put_c_inline_h;
  107.      elseif us_trace_switch = name then
  108.         cpp.put_trace_switch;
  109.      elseif us_native_array = bcn then
  110.         c_mapping_native_array_procedure(rf7,name);
  111.      elseif us_memory = name then
  112.         if us_free = name then
  113.            if gc_handler.is_on then
  114.           if cpp.cannot_drop_all then
  115.              cpp.put_string(fz_14);
  116.           end;
  117.            else
  118.           cpp.put_string(us_free);
  119.           cpp.put_character('(');
  120.           cpp.put_ith_argument(1);
  121.           cpp.put_string(fz_14);
  122.            end;
  123.         end;
  124.      elseif us_bit_n = bcn then
  125.         c_mapping_bit_procedure(rf7,name);
  126.      elseif us_sprintf_pointer = name then
  127.         cpp.put_string("{void*p=");
  128.         cpp.put_target_as_value;
  129.         cpp.put_string(";%Nsprintf((");
  130.         cpp.put_ith_argument(1);
  131.         cpp.put_string("),%"%%p%",p);}%N");
  132.      elseif us_sprintf_double = name then
  133.         cpp.sprintf_double_is_used;
  134.         cpp.put_string("{int i;%N%
  135.                %double d=");
  136.         cpp.put_target_as_value;
  137.         cpp.put_string(";%N%
  138.                            %sprintf(_spfd+2,%"%%d%",(");
  139.         cpp.put_ith_argument(2);
  140.         cpp.put_string("));%N%
  141.                %for(i=2;_spfd[i]!=0;i++);%N%
  142.                %_spfd[i]='f';%N%
  143.                %_spfd[++i]=0;%N%
  144.                %sprintf((");
  145.         cpp.put_ith_argument(1);
  146.         cpp.put_string("),_spfd,d);%N}%N");
  147.      elseif us_se_rename = name then
  148.         cpp.put_string("rename(((char*)");
  149.         cpp.put_ith_argument(2);
  150.         cpp.put_string("),((char*)");
  151.         cpp.put_ith_argument(4);
  152.         cpp.put_string(fz_16);
  153.      elseif us_se_remove = name then
  154.         cpp.put_string("remove(((char*)");
  155.         cpp.put_ith_argument(2);
  156.         cpp.put_string(fz_16);
  157.      end;
  158.       end;
  159.  
  160.    c_define_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  161.       local
  162.      elt_type: TYPE;
  163.      ct: TYPE;
  164.      rc: RUN_CLASS;
  165.      rf: RUN_FEATURE;
  166.      rf7: RUN_FEATURE_7;
  167.       do
  168.      if us_bit_n = bcn then
  169.         c_define_function_bit(rf8,name);
  170.      elseif us_general = bcn then
  171.         if us_is_equal = name or else us_standard_is_equal = name then
  172.            ct := rf8.current_type;
  173.            rc := ct.run_class;
  174.            if ct.is_basic_eiffel_expanded or else native_array(ct) then
  175.            elseif rc.is_tagged then
  176.           rf8.c_define_with_body(
  177.                      "R=((C->id==a1->id)?!memcmp(C,a1,sizeof(*C)):0);");
  178.                elseif rc.writable_attributes = Void then
  179.           if run_control.boost then
  180.           else
  181.              rf8.c_define_with_body("R=1;");
  182.           end;
  183.            elseif run_control.boost then
  184.                else
  185.           rf8.c_define_with_body("R=!memcmp(C,a1,sizeof(*C));");
  186.            end;
  187.         elseif us_standard_twin = name then
  188.            c_define_standard_twin(rf8,rf8.current_type);
  189.         elseif us_twin = name then
  190.            ct := rf8.current_type;
  191.            rc := ct.run_class;
  192.            rf := rc.get_copy;
  193.            rf7 ?= rf;
  194.            if rf7 /= Void then
  195.           c_define_standard_twin(rf8,ct);
  196.            else
  197.           c_define_twin(rf8,ct,rc,rf);
  198.            end;
  199.         end;
  200.      elseif us_native_array = bcn then
  201.         if us_calloc = name then
  202.            ct := rf8.current_type;
  203.            elt_type := ct.generic_list.item(1).run_type;
  204.            if elt_type.expanded_initializer /= Void then
  205.           body.copy("R=malloc(a1);%N%
  206.                 %r");
  207.           ct.id.append_in(body);
  208.           body.append("clear_all(R,a1-1);%N");
  209.           rf8.c_define_with_body(body);
  210.            end;
  211.         end
  212.          end;
  213.       end;
  214.  
  215.    c_mapping_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  216.       local
  217.      cbd: BOOLEAN;
  218.      ct: TYPE;
  219.      rc: RUN_CLASS;
  220.      rf: RUN_FEATURE;
  221.      rf7: RUN_FEATURE_7;
  222.       do
  223.      if us_stderr = name then
  224.         cpp.put_string(us_stderr);
  225.      elseif us_stdin = name then
  226.         cpp.put_string(us_stdin);
  227.      elseif us_stdout = name then
  228.         cpp.put_string(us_stdout);
  229.      elseif us_general = bcn then
  230.         if us_generating_type = name then
  231.            cpp.put_generating_type(rf8.current_type);
  232.         elseif us_generator = name then
  233.            cpp.put_generator(rf8.current_type);
  234.         elseif us_to_pointer = name then
  235.            cpp.put_to_pointer;
  236.         elseif us_object_size = name then
  237.            cpp.put_object_size(rf8.current_type);
  238.         elseif us_is_equal = name or else us_standard_is_equal = name then
  239.            ct := rf8.current_type;
  240.            rc := ct.run_class;
  241.            if ct.is_basic_eiffel_expanded or else native_array(ct) then
  242.           cpp.put_character('(');
  243.           cpp.put_target_as_value;
  244.           cpp.put_character(')');
  245.           cpp.put_string(fz_c_eq);
  246.           cpp.put_character('(');
  247.           cpp.put_ith_argument(1);
  248.           cpp.put_character(')');
  249.            elseif rc.is_tagged then
  250.           rf8.default_mapping_function;
  251.                elseif rc.writable_attributes = Void then
  252.           if run_control.boost then
  253.              cbd := cpp.cannot_drop_all;
  254.              if cbd then
  255.             cpp.put_character(',');
  256.              end;
  257.              cpp.put_character('1');
  258.              if cbd then
  259.             cpp.put_character(')');
  260.              end;
  261.           else
  262.              rf8.default_mapping_function;
  263.           end;
  264.            elseif run_control.boost then
  265.           cpp.put_string("!memcmp(");
  266.           cpp.put_target_as_target;
  267.           cpp.put_character(',');
  268.           cpp.put_ith_argument(1);
  269.           cpp.put_string(",sizeof(T");
  270.           cpp.put_integer(rc.id);
  271.           cpp.put_string(fz_13);
  272.            else 
  273.           rf8.default_mapping_function;
  274.            end;
  275.         elseif us_standard_twin = name then
  276.            c_mapping_standard_twin(rf8,rf8.current_type);
  277.         elseif us_twin = name then
  278.            ct := rf8.current_type;
  279.            rc := ct.run_class;
  280.            rf := rc.get_copy;
  281.            rf7 ?= rf;
  282.            if rf7 /= Void then
  283.           c_mapping_standard_twin(rf8,ct);
  284.            else
  285.           rf8.default_mapping_function;
  286.            end;
  287.         elseif us_is_basic_expanded_type = name then
  288.            cbd := cpp.cannot_drop_all;
  289.            if cbd then
  290.           cpp.put_character(',');
  291.            end;
  292.            if rf8.current_type.is_basic_eiffel_expanded then
  293.           cpp.put_character('1');
  294.            else
  295.           cpp.put_character('0');
  296.            end;
  297.            if cbd then
  298.           cpp.put_character(')');
  299.            end;
  300.         elseif us_is_expanded_type = name then
  301.            cbd := cpp.cannot_drop_all;
  302.            if cbd then
  303.           cpp.put_character(',');
  304.            end;
  305.            if rf8.current_type.is_expanded then
  306.           cpp.put_character('1');
  307.            else
  308.           cpp.put_character('0');
  309.            end;
  310.            if cbd then
  311.           cpp.put_character(')');
  312.            end;
  313.         elseif us_se_argc = name then
  314.            cpp.put_string(us_se_argc);
  315.         elseif us_se_argv = name then
  316.            cpp.put_string("((T0*)e2s(se_argv[_i]))");
  317.         elseif us_se_getenv = name then
  318.            cpp.put_string(
  319.                "(NULL==(_p=getenv((char*)_p)))?NULL:((T0*)e2s((char*)_p))");
  320.         end;
  321.      elseif us_native_array = bcn then
  322.         c_mapping_native_array_function(rf8,name);
  323.      elseif us_integer = bcn then
  324.         c_mapping_integer_function(rf8,name);
  325.      elseif us_real = bcn then
  326.         c_mapping_real_function(rf8,name);
  327.      elseif us_double = bcn then
  328.         c_mapping_double_function(rf8,name);
  329.      elseif us_boolean = bcn then
  330.         if us_implies = name then
  331.            cpp.put_string("(!(");
  332.            cpp.put_target_as_value;
  333.            cpp.put_string("))||(");
  334.            cpp.put_arguments;
  335.            cpp.put_character(')');
  336.         else
  337.            check
  338.           rf8.arg_count = 1;
  339.            end;
  340.            cpp.put_character('(');
  341.            cpp.put_target_as_value;
  342.            if us_or_else = name then
  343.           cpp.put_string(")||(");
  344.            else
  345.           check 
  346.              us_and_then = name;
  347.           end;
  348.           cpp.put_string(")&&(");
  349.            end;
  350.            cpp.put_arguments;
  351.            cpp.put_character(')');
  352.         end;
  353.      elseif us_character = bcn then
  354.         if us_code = name then
  355.            cpp.put_string("((unsigned char)");
  356.            cpp.put_target_as_value;
  357.            cpp.put_character(')');
  358.         else
  359.            check
  360.           us_to_bit = name or else us_to_integer = name
  361.            end;
  362.            cpp.put_target_as_value;
  363.         end;
  364.      elseif us_pointer = bcn then
  365.         check
  366.            us_is_not_void = name
  367.         end;
  368.         cpp.put_string("(NULL!=");
  369.         cpp.put_target_as_value;
  370.         cpp.put_character(')');
  371.          elseif us_platform = bcn then
  372.         cbd := cpp.target_cannot_be_dropped;
  373.         if cbd then
  374.            cpp.put_character(',');
  375.         else 
  376.            cpp.put_character(' ');
  377.         end;
  378.         if us_character_bits = name then
  379.            cpp.put_string("CHAR_BIT");
  380.         elseif us_integer_bits = name or else
  381.                us_boolean_bits = name
  382.          then
  383.            cpp.put_string("(CHAR_BIT*sizeof(int))");
  384.         elseif us_real_bits = name then
  385.            cpp.put_string("(CHAR_BIT*sizeof(float))");
  386.         elseif us_double_bits = name then
  387.            cpp.put_string("(CHAR_BIT*sizeof(double))");
  388.         elseif us_pointer_bits = name then
  389.            cpp.put_string("(CHAR_BIT*sizeof(void*))");
  390.         elseif us_minimum_character_code = name then
  391.            cpp.put_string("CHAR_MIN");
  392.         elseif us_minimum_double = name then
  393.            cpp.put_string("DBL_MIN");
  394.         elseif us_minimum_integer = name then
  395.            cpp.put_string("INT_MIN");
  396.         elseif us_minimum_real = name then
  397.            cpp.put_string("FLT_MIN");
  398.         elseif us_maximum_character_code = name then
  399.            cpp.put_string("CHAR_MAX");
  400.         elseif us_maximum_double = name then
  401.            cpp.put_string("DBL_MAX");
  402.         elseif us_maximum_integer = name then
  403.            cpp.put_string("INT_MAX");
  404.         elseif us_maximum_real = name then
  405.            cpp.put_string("FLT_MAX");
  406.         end;
  407.         if cbd then
  408.            cpp.put_character(')');
  409.         else
  410.            cpp.put_character(' ');
  411.         end;
  412.          elseif us_eof_code = name then
  413.         cbd := cpp.cannot_drop_all;
  414.         if cbd then
  415.            cpp.put_character(',');
  416.         end;
  417. --***        cpp.put_string("((unsigned char)EOF)");
  418.         cpp.put_string("(EOF)");
  419.         if cbd then
  420.            cpp.put_character(')');
  421.         end;
  422.      elseif us_feof = name then
  423.         cpp.put_string("feof((FILE*)(");
  424.         cpp.put_ith_argument(1);
  425.         cpp.put_string(fz_13);
  426.          elseif us_sfr_open = name then
  427.         cpp.put_string(fz_open);
  428.         cpp.put_character('(');
  429.         cpp.put_ith_argument(2);
  430.         cpp.put_string(",%"r%")");
  431.          elseif us_sfw_open = name then
  432.         cpp.put_string(fz_open);
  433.         cpp.put_character('(');
  434.         cpp.put_ith_argument(2);
  435.         cpp.put_string(",%"w%")");
  436.          elseif us_se_string2double = name then
  437.         cpp.put_string("(sscanf(_p,%"%%lf%",&R),R)");
  438.      elseif us_bit_n = bcn then
  439.         c_mapping_bit_function(rf8,name);
  440.          elseif us_bitn = name then
  441.             cpp.put_character('(');
  442.             cpp.put_target_as_value;
  443.             cpp.put_string(")->bit_n");
  444.      elseif us_pointer_size = name then
  445.         cpp.put_string(fz_sizeof);
  446.         cpp.put_character('(');
  447.         cpp.put_string(fz_t0_star);
  448.         cpp.put_character(')');
  449.      elseif us_read_byte = name then
  450.         cpp.put_string("getc((FILE*)(");
  451.         cpp.put_ith_argument(1);
  452.             cpp.put_string(fz_13);
  453.      end;
  454.       end;
  455.  
  456.    jvm_add_method_for_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  457.       local
  458.      ct: TYPE;
  459.      rc: RUN_CLASS;
  460.      rf: RUN_FEATURE;
  461.      rf7: RUN_FEATURE_7;
  462.       do
  463.      if us_general = bcn then
  464.         if us_twin = name then
  465.            ct := rf8.current_type;
  466.            rc := ct.run_class;
  467.            rf := rc.get_copy;
  468.            rf7 ?= rf;
  469.            if rf7 /= Void then
  470.            else
  471.           jvm.add_method(rf8);
  472.            end;
  473.         elseif us_generating_type = name then
  474.            jvm.add_method(rf8);
  475.         elseif us_generator = name then
  476.            jvm.add_method(rf8);
  477.         end;
  478.      elseif us_sfw_open = name then
  479.         jvm.add_method(rf8);
  480.      elseif us_sfr_open = name then
  481.         jvm.add_method(rf8);
  482.      elseif us_se_string2double = name then
  483.         jvm.add_method(rf8);
  484.      end;
  485.       end;
  486.  
  487.    jvm_define_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  488.       local
  489.      ct: TYPE;
  490.      rc: RUN_CLASS;
  491.      rf: RUN_FEATURE;
  492.      rf7: RUN_FEATURE_7;
  493.      rc_idx, field_idx, point1: INTEGER;
  494.      cp: like constant_pool;
  495.      ca: like code_attribute;
  496.       do
  497.      cp := constant_pool;
  498.      ca := code_attribute;
  499.      if us_general = bcn then
  500.         if us_twin = name then
  501.            ct := rf8.current_type;
  502.            rc := ct.run_class;
  503.            rf := rc.get_copy;
  504.            rf7 ?= rf;
  505.            if rf7 /= Void then
  506.            else
  507.           jvm_define_twin(rf8,rc,rf);
  508.            end;
  509.         elseif us_generating_type = name then
  510.            rf8.jvm_opening;
  511.            ct := rf8.current_type;
  512.            rc := ct.run_class;
  513.            rc_idx := rc.fully_qualified_constant_pool_index;
  514.            field_idx := cp.idx_fieldref_generating_type(rc_idx);
  515.            ca.opcode_getstatic(field_idx,1);
  516.            ca.opcode_dup;
  517.            point1 := ca.opcode_ifnonnull;
  518.            ca.opcode_pop;
  519.            ca.opcode_push_manifest_string(ct.run_time_mark);
  520.            ca.opcode_dup;
  521.            ca.opcode_putstatic(field_idx,-1);
  522.            ca.resolve_u2_branch(point1);
  523.            rf8.jvm_closing_fast;
  524.         elseif us_generator = name then
  525.            rf8.jvm_opening;
  526.            ct := rf8.current_type;
  527.            rc := ct.run_class;
  528.            rc_idx := rc.fully_qualified_constant_pool_index;
  529.            field_idx := cp.idx_fieldref_generator(rc_idx);
  530.            ca.opcode_getstatic(field_idx,1);
  531.            ca.opcode_dup;
  532.            point1 := ca.opcode_ifnonnull;
  533.            ca.opcode_pop;
  534.            ca.opcode_push_manifest_string(ct.base_class_name.to_string);
  535.            ca.opcode_dup;
  536.            ca.opcode_putstatic(field_idx,-1);
  537.            ca.resolve_u2_branch(point1);
  538.            rf8.jvm_closing_fast;
  539.         end;
  540.      elseif us_sfw_open = name then
  541.         jvm_sfw_open(rf8);
  542.      elseif us_sfr_open = name then
  543.         jvm_sfr_open(rf8);
  544.      elseif us_se_string2double = name then
  545.         jvm_se_string2double(rf8);
  546.      end;
  547.       end;
  548.  
  549.    jvm_mapping_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  550.       local
  551.      ct: TYPE;
  552.      rc: RUN_CLASS;
  553.      rf: RUN_FEATURE;
  554.      rf7: RUN_FEATURE_7;
  555.      point1, point2, space, idx: INTEGER;
  556.      cp: like constant_pool;
  557.      ca: like code_attribute;
  558.       do
  559.      ca := code_attribute;
  560.      cp := constant_pool;
  561.      if us_to_pointer = name then
  562.         jvm.push_target;
  563.      elseif us_stdin = name then
  564.         ca.opcode_system_in;
  565.          elseif us_stdout = name then
  566.         ca.opcode_system_out;
  567.          elseif us_stderr = name then
  568.         ca.opcode_system_err;
  569.      elseif us_integer = bcn then
  570.         jvm_mapping_integer_function(rf8,name);
  571.      elseif us_real = bcn then
  572.         jvm_mapping_real_function(rf8,name);
  573.      elseif us_double = bcn then
  574.         jvm_mapping_double_function(rf8,name);
  575.      elseif us_native_array = bcn then
  576.         jvm_mapping_native_array_function(rf8,name);
  577.      elseif us_character = bcn then
  578.         if us_code = name then
  579.            jvm.push_target;
  580.            ca.opcode_dup;
  581.            point1 := ca.opcode_ifge;
  582.            ca.opcode_sipush(255);
  583.            ca.opcode_iand;
  584.            ca.resolve_u2_branch(point1);
  585.         elseif us_to_integer = name then
  586.            jvm.push_target;
  587.         else
  588.            check
  589.           us_to_bit = name
  590.            end;
  591.            jvm_int_to_bit(rf8.result_type,8);
  592.         end;
  593.      elseif us_is_not_void = name then
  594.         jvm.push_target;
  595.         point1 := ca.opcode_ifnonnull;
  596.         ca.opcode_iconst_0;
  597.         point2 := ca.opcode_goto;
  598.         ca.resolve_u2_branch(point1);
  599.         ca.opcode_iconst_1;
  600.         ca.resolve_u2_branch(point2);
  601.      elseif us_implies = name then
  602.         jvm.push_target;
  603.         point1 := ca.opcode_ifeq;
  604.         space := jvm.push_ith_argument(1);
  605.         point2 := ca.opcode_goto;
  606.         ca.resolve_u2_branch(point1);
  607.         ca.opcode_iconst_1;
  608.         ca.resolve_u2_branch(point2);
  609.      elseif us_general = bcn then
  610.         if us_generating_type = name then
  611.            rf8.routine_mapping_jvm;
  612.         elseif us_generator = name then
  613.            rf8.routine_mapping_jvm;
  614.         elseif us_to_pointer = name then
  615.            fe_nyi(rf8);
  616.         elseif us_object_size = name then
  617.            jvm.drop_target;
  618.            ct := rf8.current_type;
  619.            jvm_object_size(ct);
  620.         elseif us_is_equal = name or else 
  621.            us_standard_is_equal = name 
  622.          then
  623.            jvm_standard_is_equal(rf8.current_type);
  624.         elseif us_standard_twin = name then
  625.            jvm_standard_twin(rf8.current_type);
  626.         elseif us_twin = name then
  627.            ct := rf8.current_type;
  628.            rc := ct.run_class;
  629.            rf := rc.get_copy;
  630.            rf7 ?= rf;
  631.            if rf7 /= Void then
  632.           jvm_standard_twin(ct);
  633.            else
  634.           rf8.routine_mapping_jvm;
  635.            end;
  636.         elseif us_is_basic_expanded_type = name then
  637.            jvm.drop_target;
  638.            if rf8.current_type.is_basic_eiffel_expanded then
  639.           ca.opcode_iconst_1;
  640.            else
  641.           ca.opcode_iconst_0;
  642.            end;
  643.         elseif us_is_expanded_type = name then
  644.            jvm.drop_target;
  645.            if rf8.current_type.is_expanded then
  646.           ca.opcode_iconst_1;
  647.            else
  648.           ca.opcode_iconst_0;
  649.            end;
  650.         elseif us_se_argc = name then
  651.            jvm.push_se_argc;
  652.         elseif us_se_argv = name then
  653.            jvm.push_se_argv;
  654.         elseif us_se_getenv = name then
  655.            jvm_se_getenv;
  656.         else
  657.            fe_nyi(rf8);
  658.         end;
  659.          elseif us_platform = bcn then
  660.         jvm.drop_target;
  661.         if us_character_bits = name then
  662.            ca.opcode_bipush(8);
  663.         elseif us_integer_bits = name then
  664.            ca.opcode_bipush(32);
  665.         elseif us_boolean_bits = name then
  666.            ca.opcode_bipush(32);
  667.         elseif us_real_bits = name then
  668.            ca.opcode_bipush(32);
  669.         elseif us_double_bits = name then
  670.            ca.opcode_bipush(64);
  671.         elseif us_pointer_bits = name then
  672.            ca.opcode_bipush(32);
  673.         elseif us_minimum_character_code = name then
  674.            ca.opcode_bipush(0);
  675.         elseif us_minimum_double = name then
  676.            idx := cp.idx_fieldref3(fz_62,fz_98,fz_77);
  677.            ca.opcode_getstatic(idx,2);
  678.         elseif us_minimum_integer = name then
  679.            ca.opcode_iconst_m1;
  680.            ca.opcode_iconst_1;
  681.            ca.opcode_iushr;
  682.            ca.opcode_ineg;
  683.            ca.opcode_iconst_m1;
  684.            ca.opcode_iadd;
  685.         elseif us_minimum_real = name then
  686.            idx := cp.idx_fieldref3(fz_26,fz_98,fz_78);
  687.            ca.opcode_getstatic(idx,1);
  688.         elseif us_maximum_character_code = name then
  689.            ca.opcode_sipush(255);
  690.         elseif us_maximum_double = name then
  691.            idx := cp.idx_fieldref3(fz_62,fz_95,fz_77);
  692.            ca.opcode_getstatic(idx,2);
  693.         elseif us_maximum_integer = name then
  694.            ca.opcode_iconst_m1;
  695.            ca.opcode_iconst_1;
  696.            ca.opcode_iushr;
  697.         elseif us_maximum_real = name then
  698.            idx := cp.idx_fieldref3(fz_26,fz_95,fz_78);
  699.            ca.opcode_getstatic(idx,1);
  700.         end;
  701.          elseif us_eof_code = name then
  702.         ca.opcode_iconst_m1;
  703.          elseif us_sfr_open = name then
  704.         rf8.routine_mapping_jvm;
  705.          elseif us_sfw_open = name then
  706.         rf8.routine_mapping_jvm;
  707.          elseif us_se_string2double = name then
  708.         rf8.routine_mapping_jvm;
  709.      elseif us_pointer_size = name then
  710.         ca.opcode_bipush(32);
  711.      elseif us_bit_n = bcn then
  712.         jvm_mapping_bit_function(rf8,name);
  713.          elseif us_bitn = name then
  714.         jvm.push_target;
  715.         ct := rf8.current_type;
  716.         rc := ct.run_class;
  717.         idx := rc.fully_qualified_constant_pool_index;
  718.         idx := cp.idx_fieldref4(idx,us_bitn,fz_a9);
  719.         ca.opcode_getfield(idx,0);
  720.          elseif us_read_byte = name then
  721.         space := jvm.push_ith_argument(1);
  722.         idx := cp.idx_methodref3(fz_69,fz_70,fz_71);
  723.         ca.opcode_invokevirtual(idx,0);
  724.      else
  725.         fe_nyi(rf8);
  726.      end;
  727.       end;
  728.  
  729.    jvm_add_method_for_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  730.       do
  731.      if us_sprintf_double = name then
  732.         jvm.add_method(rf7);
  733.      elseif us_se_rename = name then
  734.         jvm.add_method(rf7);
  735.      elseif us_se_remove = name then
  736.         jvm.add_method(rf7);
  737.      end;
  738.       end;
  739.  
  740.    jvm_define_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  741.       do
  742.      if us_sprintf_double = name then
  743.         jvm_define_sprintf_double(rf7);
  744.      elseif us_se_rename = name then
  745.         jvm_define_se_rename(rf7);
  746.      elseif us_se_remove = name then
  747.         jvm_define_se_remove(rf7);
  748.      end;
  749.       end;
  750.  
  751.    jvm_mapping_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  752.       local
  753.      space, idx: INTEGER;
  754.      t: TYPE;
  755.      ca: like code_attribute;
  756.       do
  757.      ca := code_attribute;
  758.      if us_copy = name or else us_standard_copy = name then
  759.         t := rf7.current_type;
  760.         if t.is_basic_eiffel_expanded then
  761.            jvm.drop_target;
  762.            jvm.drop_ith_argument(1);
  763.         else
  764.            jvm_copy(rf7.current_type);
  765.         end;
  766.      elseif us_flush_stream = name then
  767.         jvm.drop_target;
  768.         space := jvm.push_ith_argument(1);
  769.         idx := constant_pool.idx_methodref3(fz_25,"flush",fz_29);
  770.         ca.opcode_invokevirtual(idx,-1);
  771.      elseif us_write_byte = name then
  772.         space := jvm.push_ith_argument(1);
  773.         space := jvm.push_ith_argument(2);
  774.         idx := constant_pool.idx_methodref3(fz_25,"write",fz_27);
  775.         ca.opcode_invokevirtual(idx,-2);
  776.      elseif us_die_with_code = name then
  777.         jvm.drop_target;
  778.         space := jvm.push_ith_argument(1);
  779.         ca.opcode_system_exit;
  780.      elseif us_free = name then
  781.         jvm.drop_target;
  782.      elseif us_print_run_time_stack = name then
  783.         jvm.drop_target;
  784.         ca.opcode_runtime_trace_instructions(true);
  785.      elseif us_native_array = bcn then
  786.         jvm_mapping_native_array_procedure(rf7,name);
  787.      elseif us_sprintf_pointer = name then
  788.         -- *** A FAIRE ***
  789.         jvm.drop_target;
  790.         space := jvm.push_ith_argument(1);
  791.         ca.opcode_dup;
  792.         ca.opcode_iconst_0;
  793.         ca.opcode_bipush(('1').code);
  794.         ca.opcode_bastore;
  795.         ca.opcode_iconst_1;
  796.         ca.opcode_bipush(('0').code);
  797.         ca.opcode_bastore;
  798.      elseif us_sprintf_double = name then
  799.         rf7.routine_mapping_jvm;
  800.      elseif us_se_rename = name then
  801.         rf7.routine_mapping_jvm;
  802.      elseif us_se_remove = name then
  803.         rf7.routine_mapping_jvm;
  804.      elseif us_se_system = name then
  805.         jvm_se_system;
  806.      elseif us_bit_n = bcn then
  807.         jvm_mapping_bit_procedure(rf7,name);
  808.      else
  809.         fe_nyi(rf7);
  810.      end;
  811.       end;
  812.  
  813. feature
  814.  
  815.    use_current(er: EXTERNAL_ROUTINE): BOOLEAN is
  816.       local
  817.      n: STRING;
  818.       do
  819.      n := er.first_name.to_string;
  820.      if us_se_argc = n then
  821.      elseif us_read_byte = n then
  822.      elseif us_se_argv = n then
  823.      elseif us_se_rename = n then
  824.      elseif us_se_remove = n then
  825.      elseif us_se_system = n then
  826.      elseif us_write_byte = n then
  827.      else
  828.         Result := true;
  829.      end;
  830.       end;
  831.  
  832. feature {NONE}
  833.  
  834.    jvm_se_string2double(rf8: RUN_FEATURE_8) is 
  835.       local
  836.      idx: INTEGER;
  837.      cp: like constant_pool;
  838.      ca: like code_attribute;
  839.       do
  840.      cp := constant_pool;
  841.      ca := code_attribute;
  842.      rf8.jvm_opening;
  843.      -- New Java String :
  844.      idx := cp.idx_class2(fz_32);
  845.      ca.opcode_new(idx);
  846.      ca.opcode_dup;
  847.      ca.opcode_aload_2;
  848.      ca.opcode_iconst_0;
  849.      ca.opcode_aload_1;
  850.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  851.      ca.opcode_invokespecial(idx,-4);
  852.      -- Double.valueOf0(String) :
  853.      idx := cp.idx_methodref3(fz_62,fz_60,fz_61);
  854.      ca.opcode_invokestatic(idx,1);
  855.      ca.opcode_dstore(3);
  856.      rf8.jvm_closing;
  857.       end;
  858.  
  859.    jvm_se_system is
  860.       local
  861.      space, idx: INTEGER;
  862.      cp: like constant_pool;
  863.      ca: like code_attribute;
  864.       do
  865.      cp := constant_pool;
  866.      ca := code_attribute;
  867.      -- Runtime.getRuntime() :
  868.      idx := cp.idx_methodref3(fz_53,fz_55,fz_56);
  869.      ca.opcode_invokestatic(idx,1);
  870.      -- New Java String :
  871.      idx := cp.idx_class2(fz_32);
  872.      ca.opcode_new(idx);
  873.      ca.opcode_dup;
  874.      space := jvm.push_ith_argument(2);
  875.      ca.opcode_iconst_0;
  876.      space := jvm.push_ith_argument(1);
  877.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  878.      ca.opcode_invokespecial(idx,-4);
  879.      -- aProcess.exec(String);
  880.      idx := cp.idx_methodref3(fz_53,fz_89,fz_90);
  881.      ca.opcode_invokevirtual(idx,-1);
  882.      -- aProcess.waitFor();
  883.      idx := cp.idx_methodref3(fz_92,fz_91,fz_71);
  884.      ca.opcode_invokevirtual(idx,0);
  885.      ca.opcode_pop;
  886.       end;
  887.  
  888.    jvm_sfr_open(rf8: RUN_FEATURE_8) is 
  889.       local
  890.      point, idx: INTEGER;
  891.      cp: like constant_pool;
  892.      ca: like code_attribute;
  893.       do
  894.      cp := constant_pool;
  895.      ca := code_attribute;
  896.      rf8.jvm_opening;
  897.      -- New Java String :
  898.      idx := cp.idx_class2(fz_32);
  899.      ca.opcode_new(idx);
  900.      ca.opcode_dup;
  901.      ca.opcode_aload_2;
  902.      ca.opcode_iconst_0;
  903.      ca.opcode_aload_1;
  904.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  905.      ca.opcode_invokespecial(idx,-4);
  906.      ca.opcode_astore_3;
  907.      -- New java/io/File :
  908.      idx := cp.idx_class2(fz_85);
  909.      ca.opcode_new(idx);
  910.      ca.opcode_dup;
  911.      ca.opcode_aload_3;
  912.      idx := cp.idx_methodref3(fz_85,fz_35,fz_57);
  913.      ca.opcode_invokespecial(idx,0);
  914.      ca.opcode_astore_3;
  915.      -- if exists :
  916.      ca.opcode_aload_3;
  917.      idx := cp.idx_methodref3(fz_85,fz_86,fz_87);
  918.      ca.opcode_invokevirtual(idx,0);
  919.      point := ca.opcode_ifeq;
  920.      -- New java/io/FileInputstream :
  921.      idx := cp.idx_class2(fz_67);
  922.      ca.opcode_new(idx);
  923.      ca.opcode_dup;
  924.      ca.opcode_aload_3;
  925.      idx := cp.idx_methodref3(fz_67,fz_35,fz_88);
  926.      ca.opcode_invokespecial(idx,-2);
  927.      ca.opcode_areturn;
  928.      ca.resolve_u2_branch(point);
  929.      ca.opcode_aconst_null;
  930.      ca.opcode_astore_3;
  931.      rf8.jvm_closing;
  932.       end;
  933.  
  934.    jvm_sfw_open(rf8: RUN_FEATURE_8) is 
  935.       local
  936.      idx: INTEGER;
  937.      cp: like constant_pool;
  938.      ca: like code_attribute;
  939.       do
  940.      cp := constant_pool;
  941.      ca := code_attribute;
  942.      rf8.jvm_opening;
  943.      -- New java/lang/String :
  944.      idx := cp.idx_class2(fz_32);
  945.      ca.opcode_new(idx);
  946.      ca.opcode_dup;
  947.      ca.opcode_aload_2;
  948.      ca.opcode_iconst_0;
  949.      ca.opcode_aload_1;
  950.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  951.      ca.opcode_invokespecial(idx,-4);
  952.      ca.opcode_astore_3;
  953.      -- New java/io/File :
  954.      idx := cp.idx_class2(fz_85);
  955.      ca.opcode_new(idx);
  956.      ca.opcode_dup;
  957.      ca.opcode_aload_3;
  958.      idx := cp.idx_methodref3(fz_85,fz_35,fz_57);
  959.      ca.opcode_invokespecial(idx,0);
  960.      ca.opcode_astore_3;
  961.      -- New java/io/FileOutputStream :
  962.      idx := cp.idx_class2(fz_72);
  963.      ca.opcode_new(idx);
  964.      ca.opcode_dup;
  965.      ca.opcode_aload_3;
  966.      idx := cp.idx_methodref3(fz_72,fz_35,fz_88);
  967.      ca.opcode_invokespecial(idx,-2);
  968.      ca.opcode_astore_3;
  969.      rf8.jvm_closing;
  970.       end;
  971.  
  972.  
  973.    new_jvm_open(rf8: RUN_FEATURE_8; jio: STRING) is 
  974.      -- Where `jio' is a Java class name.
  975.       local
  976.      pc1, pc2, pc3: INTEGER;
  977.      idx: INTEGER;
  978.      cp: like constant_pool;
  979.      ca: like code_attribute;
  980.       do
  981.      cp := constant_pool;
  982.      ca := code_attribute;
  983.      rf8.jvm_opening;
  984.      -- New java/lang/String :
  985.      idx := cp.idx_class2(fz_32);
  986.      ca.opcode_new(idx);
  987.      ca.opcode_dup;
  988.      ca.opcode_aload_2;
  989.      ca.opcode_iconst_0;
  990.      ca.opcode_aload_1;
  991.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  992.      ca.opcode_invokespecial(idx,-4);
  993.      ca.opcode_astore_3;
  994.      -- New Input/Output Java :
  995.      pc1 := ca.program_counter;
  996.      idx := cp.idx_class2(fz_67);
  997.      ca.opcode_new(idx);
  998.      ca.opcode_dup;
  999.      ca.opcode_aload_3;
  1000.      idx := cp.idx_methodref3(jio,fz_35,fz_68);
  1001.      ca.opcode_invokespecial(idx,-2);
  1002.      ca.opcode_areturn;
  1003.      pc2 := ca.program_counter;
  1004.      pc3 := ca.program_counter;
  1005.      ca.opcode_pop;
  1006.      ca.opcode_aconst_null;
  1007.      ca.opcode_astore_3;
  1008.      idx := cp.idx_class2(fz_84);
  1009.  
  1010. --***
  1011.      pc1 := ca.program_counter;
  1012.      ca.opcode_nop;
  1013.      ca.opcode_nop;
  1014.      
  1015.      pc2 := ca.program_counter;
  1016.      ca.opcode_nop;
  1017.      ca.opcode_nop;
  1018.      
  1019.      pc3 := ca.program_counter;
  1020.      ca.opcode_nop;
  1021.      ca.opcode_nop;
  1022.      
  1023.  
  1024.      ca.add_exception(pc1,pc2,pc3,idx);
  1025.      rf8.jvm_closing;
  1026.       end;
  1027.  
  1028.    new_small_jvm_open(rf8: RUN_FEATURE_8; jio: STRING) is 
  1029.      -- Where `jio' is a Java class name.
  1030.       local
  1031.      pc1, pc2, pc3: INTEGER;
  1032.      idx: INTEGER;
  1033.      cp: like constant_pool;
  1034.      ca: like code_attribute;
  1035.       do
  1036.      cp := constant_pool;
  1037.      ca := code_attribute;
  1038.      rf8.jvm_opening;
  1039.  
  1040.      pc1 := ca.program_counter;
  1041.      ca.opcode_nop;
  1042.      ca.opcode_nop;
  1043.      
  1044.      pc2 := ca.program_counter;
  1045.      idx := ca.opcode_goto;
  1046.      ca.opcode_nop;
  1047.      
  1048.      pc3 := ca.program_counter;
  1049.      ca.opcode_pop;
  1050.      ca.opcode_nop;
  1051.      
  1052.  
  1053.      ca.add_exception(pc1,pc2,pc3,cp.idx_class2(fz_84));
  1054.      
  1055.      ca.resolve_u2_branch(idx);
  1056.      rf8.jvm_closing;
  1057.       end;
  1058.  
  1059.    jvm_se_getenv is
  1060.       local
  1061.      space, point1, idx: INTEGER;
  1062.      cp: like constant_pool;
  1063.      ca: like code_attribute;
  1064.       do
  1065.      cp := constant_pool;
  1066.      ca := code_attribute;
  1067.      -- Create a Java string from arguments :
  1068.      idx := cp.idx_class2(fz_32);
  1069.      ca.opcode_new(idx);
  1070.      ca.opcode_dup;
  1071.      space := jvm.push_ith_argument(2);
  1072.      ca.opcode_iconst_0;
  1073.      space := jvm.push_ith_argument(1);
  1074.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  1075.      ca.opcode_invokespecial(idx,-2);
  1076.      -- Call java/lang/System getProperty :
  1077.      idx := cp.idx_methodref3(fz_36,fz_79,fz_80);
  1078.      ca.opcode_invokestatic(idx,0);
  1079.      -- Create corresponding Eiffel STRING :
  1080.      ca.opcode_dup;
  1081.      point1 := ca.opcode_ifeq;
  1082.      ca.opcode_java_string2eiffel_string;
  1083.      ca.resolve_u2_branch(point1);
  1084.       end;
  1085.  
  1086.    jvm_object_size(ct: TYPE) is
  1087.       local
  1088.      t: TYPE;
  1089.      space, i: INTEGER;
  1090.      wa: ARRAY[RUN_FEATURE_2];
  1091.       do
  1092.      if ct.is_basic_eiffel_expanded then
  1093.         space := ct.jvm_stack_space;
  1094.      else
  1095.         wa := ct.run_class.writable_attributes;
  1096.         if wa /= Void then
  1097.            from
  1098.           i := wa.upper;
  1099.            until
  1100.           i = 0
  1101.            loop
  1102.           t := wa.item(i).result_type;
  1103.           space := space + t.jvm_stack_space;
  1104.           i := i - 1;
  1105.            end;
  1106.         end;
  1107.      end;
  1108.      code_attribute.opcode_push_integer(space);
  1109.       end;
  1110.  
  1111.    c_mapping_standard_twin(rf8: RUN_FEATURE_8; ct: TYPE) is
  1112.       do
  1113.      if ct.is_basic_eiffel_expanded then
  1114.         cpp.put_target_as_value;
  1115.      elseif ct.is_expanded then
  1116.         if ct.is_dummy_expanded then
  1117.            cpp.put_target_as_target;
  1118.         elseif native_array(ct) then
  1119.            cpp.put_target_as_target;
  1120.         else
  1121.            rf8.default_mapping_function;
  1122.         end;
  1123.      else
  1124.         rf8.default_mapping_function;
  1125.      end;
  1126.       end;
  1127.  
  1128.    c_define_standard_twin(rf8: RUN_FEATURE_8; ct: TYPE) is
  1129.       do
  1130.      if ct.is_basic_eiffel_expanded then
  1131.      elseif ct.is_expanded then
  1132.         if ct.is_dummy_expanded then
  1133.         elseif native_array(ct) then
  1134.         else
  1135.            rf8.c_define_with_body("memcpy(&R,C,sizeof(R));");
  1136.         end;
  1137.      else
  1138.         if gc_handler.is_on then
  1139.            body.clear;
  1140.            body.extend('R');
  1141.            body.extend('=');
  1142.            body.extend('(');
  1143.            body.append(fz_cast_void_star);
  1144.            ct.gc_call_new_in(body);
  1145.            body.extend(')');
  1146.            body.append(fz_00);
  1147.         else
  1148.            body.copy("R=malloc(sizeof(*C));%N");
  1149.         end;
  1150.         body.extend('*');
  1151.         body.extend('(');
  1152.         body.extend('(');
  1153.         body.extend('T');
  1154.         ct.id.append_in(body);
  1155.         body.extend('*');
  1156.         body.extend(')');
  1157.         body.extend('R');
  1158.         body.extend(')');
  1159.         body.extend('=');
  1160.         body.extend('*');
  1161.         body.extend('C');
  1162.         body.append(fz_00);
  1163.         rf8.c_define_with_body(body);
  1164.      end;
  1165.       end;
  1166.  
  1167.    c_define_twin(rf8: RUN_FEATURE_8; ct: TYPE; rc: RUN_CLASS;  
  1168.          cpy: RUN_FEATURE) is
  1169.       require
  1170.      rf8 /= Void;
  1171.      ct.is_reference or ct.is_user_expanded;
  1172.      rc = ct.run_class;
  1173.      cpy /= Void
  1174.       local
  1175.      id: INTEGER;
  1176.       do
  1177.      rf8.c_opening;
  1178.      if ct.is_reference then
  1179.         if gc_handler.is_on then
  1180.            body.clear;
  1181.            body.extend('R');
  1182.            body.extend('=');
  1183.            body.extend('(');
  1184.            body.append(fz_cast_void_star);
  1185.            ct.gc_call_new_in(body);
  1186.            body.extend(')');
  1187.            body.append(fz_00);
  1188.            cpp.put_string(body);
  1189.         else
  1190.            id := rc.id;
  1191.            cpp.put_string("R=malloc(sizeof(*C));%N");
  1192.            cpp.put_string("*((T");
  1193.            cpp.put_integer(id);
  1194.            cpp.put_string("*)R)=M");
  1195.            cpp.put_integer(id);
  1196.            cpp.put_string(fz_00);
  1197.         end;
  1198.      end;
  1199.      cpp.inside_twin(cpy);
  1200.      rf8.c_closing;
  1201.       end;
  1202.  
  1203.    jvm_mapping_native_array_function(rf8: RUN_FEATURE_8; name: STRING) is
  1204.       local
  1205.      elt_type: TYPE;
  1206.      space: INTEGER;
  1207.      rc: RUN_CLASS;
  1208.      loc1, point1, point2: INTEGER;
  1209.      ca: like code_attribute;
  1210.       do
  1211.      elt_type := rf8.current_type.generic_list.item(1).run_type;
  1212.      if us_element_sizeof = name then
  1213.         jvm.drop_target;
  1214.         space := elt_type.jvm_stack_space;
  1215.         code_attribute.opcode_push_integer(space);
  1216.      elseif us_item = name then
  1217.         jvm.push_target;
  1218.         space := jvm.push_ith_argument(1);
  1219.         elt_type.jvm_xaload;
  1220.      elseif us_calloc = name then
  1221.         jvm.drop_target;
  1222.         space := jvm.push_ith_argument(1);
  1223.         elt_type.jvm_xnewarray;
  1224.         if elt_type.is_user_expanded and then
  1225.            not elt_type.is_dummy_expanded 
  1226.          then
  1227.            ca := code_attribute;
  1228.            rc := elt_type.run_class;
  1229.            loc1 := ca.extra_local_size1;
  1230.            ca.opcode_dup;
  1231.            ca.opcode_arraylength;
  1232.            ca.opcode_istore(loc1);
  1233.            point1 := ca.program_counter;
  1234.            ca.opcode_iload(loc1);
  1235.            point2 := ca.opcode_ifle;
  1236.            ca.opcode_iinc(loc1,255);
  1237.            ca.opcode_dup;
  1238.            ca.opcode_iload(loc1);
  1239.            rc.jvm_expanded_push_default;
  1240.            ca.opcode_aastore;
  1241.            ca.opcode_goto_backward(point1);
  1242.            ca.resolve_u2_branch(point2);
  1243.         end;
  1244.      elseif name = us_from_pointer then
  1245.         jvm.drop_target;
  1246.         space := jvm.push_ith_argument(1);
  1247.      else
  1248.         fe_nyi(rf8);
  1249.      end;
  1250.       end;
  1251.  
  1252.    jvm_mapping_native_array_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  1253.       local
  1254.      elt_type: TYPE;
  1255.      space: INTEGER;
  1256.       do
  1257.      elt_type := rf7.current_type.generic_list.item(1).run_type;
  1258.      if us_put = name then
  1259.         jvm.push_target;
  1260.         space := jvm.push_ith_argument(2);
  1261.         space := jvm.push_ith_argument(1);
  1262.         elt_type.jvm_xastore;
  1263.      else
  1264.         check
  1265.            us_free = name
  1266.         end;
  1267.         jvm.drop_target;
  1268.      end;
  1269.       end;
  1270.  
  1271.    c_mapping_native_array_function(rf8: RUN_FEATURE_8; name: STRING) is
  1272.       local
  1273.      elt_type: TYPE;
  1274.      tcbd: BOOLEAN;
  1275.      rf: RUN_FEATURE;
  1276.       do
  1277.      elt_type := rf8.current_type.generic_list.item(1).run_type;
  1278.      if us_element_sizeof = name then
  1279.         tcbd := cpp.target_cannot_be_dropped;
  1280.         if tcbd then
  1281.            cpp.put_character(',');
  1282.         end;
  1283.         tmp_string.copy(fz_sizeof);
  1284.         tmp_string.extend('(');
  1285.         elt_type.c_type_for_argument_in(tmp_string);
  1286.         tmp_string.extend(')');
  1287.         cpp.put_string(tmp_string);
  1288.         if tcbd then
  1289.            cpp.put_character(')');
  1290.         end;
  1291.      elseif name = us_calloc then
  1292.         if elt_type.expanded_initializer = Void then
  1293.            tcbd := cpp.target_cannot_be_dropped;
  1294.            if tcbd then
  1295.           cpp.put_character(',');
  1296.            end;
  1297.            if gc_handler.is_on then
  1298.           cpp.put_string(fz_new);
  1299.           cpp.put_integer(rf8.current_type.id);
  1300.           cpp.put_character('(');
  1301.           cpp.put_ith_argument(1);
  1302.           cpp.put_character(')');
  1303.            else
  1304.           cpp.put_string(us_calloc);
  1305.           cpp.put_character('(');
  1306.           cpp.put_ith_argument(1);
  1307.           tmp_string.clear;
  1308.           tmp_string.extend(',');
  1309.           tmp_string.append(fz_sizeof);
  1310.           tmp_string.extend('(');
  1311.           elt_type.c_type_for_result_in(tmp_string);
  1312.           tmp_string.append(fz_13);
  1313.           cpp.put_string(tmp_string);
  1314.            end;
  1315.            if tcbd then
  1316.           cpp.put_character(')');
  1317.            end;
  1318.         else
  1319.            rf8.default_mapping_function;
  1320.         end;
  1321.      elseif name = us_from_pointer then
  1322.         tcbd := cpp.target_cannot_be_dropped;
  1323.         if tcbd then
  1324.            cpp.put_character(',');
  1325.         end;
  1326.         cpp.put_ith_argument(1);
  1327.         if tcbd then
  1328.            cpp.put_character(')');
  1329.         end;
  1330.      else
  1331.         check 
  1332.            us_item = name
  1333.         end;
  1334.         cpp.put_character('(');
  1335.         cpp.put_target_as_value;
  1336.         cpp.put_string(")[");
  1337.         cpp.put_ith_argument(1);
  1338.         cpp.put_character(']');
  1339.      end;
  1340.       end;
  1341.  
  1342.    c_mapping_native_array_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  1343.       local
  1344.      elt_type: TYPE;
  1345.       do
  1346.      elt_type := rf7.current_type.generic_list.item(1).run_type;
  1347.      if name = us_put then
  1348.         if elt_type.is_user_expanded then
  1349.            if elt_type.is_dummy_expanded then
  1350.           if cpp.cannot_drop_all then
  1351.              cpp.put_string(fz_14);
  1352.           end;
  1353.            else
  1354.           cpp.put_string("memcpy((");
  1355.           cpp.put_target_as_value;
  1356.           cpp.put_string(")+(");
  1357.           cpp.put_ith_argument(2);
  1358.           cpp.put_string("),");
  1359.           cpp.put_ith_argument(1);
  1360.           cpp.put_string(",sizeof(T");
  1361.           cpp.put_integer(elt_type.id);
  1362.           cpp.put_string(fz_16);
  1363.            end;
  1364.         else
  1365.            cpp.put_character('(');
  1366.            cpp.put_target_as_value;
  1367.            cpp.put_string(")[");
  1368.            cpp.put_ith_argument(2);
  1369.            cpp.put_string("]=(");
  1370.            cpp.put_ith_argument(1);
  1371.            cpp.put_string(fz_14);
  1372.         end;
  1373.      elseif name = us_free then
  1374.         cpp.put_string(us_free);
  1375.         cpp.put_character('(');
  1376.         cpp.put_target_as_value;
  1377.         cpp.put_string(fz_14);
  1378.      end;
  1379.       end;
  1380.  
  1381.    jvm_copy(t: TYPE) is
  1382.       require
  1383.      not t.is_basic_eiffel_expanded
  1384.       local
  1385.      rc: RUN_CLASS;
  1386.      wa: ARRAY[RUN_FEATURE_2];
  1387.      rf2: RUN_FEATURE_2;
  1388.      idx, space, i: INTEGER;
  1389.       do
  1390.      rc := t.run_class;
  1391.      wa := rc.writable_attributes;
  1392.      if wa = Void then
  1393.         jvm.drop_target;
  1394.         jvm.drop_ith_argument(1);
  1395.      else
  1396.         from
  1397.            jvm.push_target;
  1398.            space := jvm.push_ith_argument(1);
  1399.            i := wa.upper;
  1400.         until
  1401.            i = 0
  1402.         loop
  1403.            if i > 1 then
  1404.           code_attribute.opcode_dup2;
  1405.            end;
  1406.            rf2 := wa.item(i);
  1407.            idx := constant_pool.idx_fieldref(rf2);
  1408.            space := rf2.result_type.jvm_stack_space;
  1409.            code_attribute.opcode_getfield(idx,space - 1);
  1410.            code_attribute.opcode_putfield(idx,-(space + 1));
  1411.            i := i - 1;
  1412.         end;
  1413.      end;
  1414.       end;
  1415.  
  1416.    jvm_define_sprintf_double(rf7: RUN_FEATURE_7) is
  1417.       require
  1418.      rf7 /= Void
  1419.       local
  1420.      idx, loc1, loc2: INTEGER;
  1421.      point1, point2, point3: INTEGER;
  1422.      cp: like constant_pool;
  1423.      ca: like code_attribute;
  1424.       do
  1425.      cp := constant_pool;
  1426.      ca := code_attribute;
  1427.      rf7.jvm_opening;
  1428.      -- Double.toString(double) :
  1429.      ca.opcode_dload_0;
  1430.      idx := cp.idx_methodref3(fz_62,fz_63,fz_64);
  1431.      ca.opcode_invokestatic(idx,1);
  1432.      ca.opcode_java_string2bytes_array;
  1433.      -- loc1 is for the byte array :
  1434.      loc1 := ca.extra_local_size1;
  1435.      ca.opcode_astore(loc1);
  1436.      -- Copy of the integral part :
  1437.      loc2 := ca.extra_local_size1;
  1438.      ca.opcode_iconst_0;
  1439.      ca.opcode_istore(loc2);
  1440.      point1 := ca.program_counter;
  1441.      ca.opcode_aload(loc1);
  1442.      ca.opcode_arraylength;
  1443.      ca.opcode_iload(loc2);
  1444.      point2 := ca.opcode_if_icmple;
  1445.      ca.opcode_aload_2;
  1446.      ca.opcode_iload(loc2);
  1447.      ca.opcode_aload(loc1);
  1448.      ca.opcode_iload(loc2);
  1449.      ca.opcode_baload;
  1450.      ca.opcode_bastore;
  1451.      ca.opcode_aload(loc1);
  1452.      ca.opcode_iload(loc2);
  1453.      ca.opcode_baload;
  1454.      ca.opcode_bipush(('.').code);
  1455.      ca.opcode_iinc(loc2,1);
  1456.      point3 := ca.opcode_if_icmpeq;
  1457.      ca.opcode_goto_backward(point1);
  1458.      ca.resolve_u2_branch(point2);
  1459.      ca.resolve_u2_branch(point3);
  1460.      -- Copy of the fractional part :
  1461.      point1 := ca.program_counter;
  1462.      ca.opcode_aload(loc1);
  1463.      ca.opcode_arraylength;
  1464.      ca.opcode_iload(loc2);
  1465.      point2 := ca.opcode_if_icmple;
  1466.      ca.opcode_iload_3;
  1467.      point3 := ca.opcode_ifeq;
  1468.      ca.opcode_aload_2;
  1469.      ca.opcode_iload(loc2);
  1470.      ca.opcode_aload(loc1);
  1471.      ca.opcode_iload(loc2);
  1472.      ca.opcode_baload;
  1473.      ca.opcode_bastore;
  1474.      ca.opcode_iinc(loc2,1);
  1475.      ca.opcode_iinc(3,255);
  1476.      ca.opcode_goto_backward(point1);
  1477.      ca.resolve_u2_branch(point2);
  1478.      ca.resolve_u2_branch(point3);
  1479.      -- Add some more '0' :
  1480.      point1 := ca.program_counter;
  1481.      ca.opcode_iload_3;
  1482.      point2 := ca.opcode_ifeq;
  1483.      ca.opcode_aload_2;
  1484.      ca.opcode_iload(loc2);
  1485.      ca.opcode_bipush(('0').code);
  1486.      ca.opcode_bastore;
  1487.      ca.opcode_iinc(loc2,1);
  1488.      ca.opcode_iinc(3,255)
  1489.      ca.opcode_goto_backward(point1);
  1490.      ca.resolve_u2_branch(point2);
  1491.      -- Adding the extra '%/0' :
  1492.      ca.opcode_aload_2;
  1493.      ca.opcode_iload(loc2);
  1494.      ca.opcode_iconst_0;
  1495.      ca.opcode_bastore;
  1496.      rf7.jvm_closing;
  1497.       end;
  1498.  
  1499.    jvm_define_se_rename(rf7: RUN_FEATURE_7) is
  1500.       require
  1501.      rf7 /= Void
  1502.       local
  1503.      idx, loc1, loc2: INTEGER;
  1504.      cp: like constant_pool;
  1505.      ca: like code_attribute;
  1506.       do
  1507.      cp := constant_pool;
  1508.      ca := code_attribute;
  1509.      rf7.jvm_opening;
  1510.      -- New Java String :
  1511.      idx := cp.idx_class2(fz_32);
  1512.      ca.opcode_new(idx);
  1513.      ca.opcode_dup;
  1514.      ca.opcode_aload_2;
  1515.      ca.opcode_iconst_0;
  1516.      ca.opcode_aload_1;
  1517.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  1518.      ca.opcode_invokespecial(idx,-4);
  1519.      loc1 := ca.extra_local_size1;
  1520.      ca.opcode_istore(loc1);
  1521.      -- New java/io/File :
  1522.      idx := cp.idx_class2(fz_85);
  1523.      ca.opcode_new(idx);
  1524.      ca.opcode_dup;
  1525.      ca.opcode_aload(loc1);
  1526.      idx := cp.idx_methodref3(fz_85,fz_35,fz_57);
  1527.      ca.opcode_invokespecial(idx,0);    
  1528.      ca.opcode_istore(loc1);
  1529.      -- New Java String :
  1530.      idx := cp.idx_class2(fz_32);
  1531.      ca.opcode_new(idx);
  1532.      ca.opcode_dup;
  1533.      ca.opcode_aload(4);
  1534.      ca.opcode_iconst_0;
  1535.      ca.opcode_aload_3;
  1536.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  1537.      ca.opcode_invokespecial(idx,-4);
  1538.      loc2 := ca.extra_local_size1;
  1539.      ca.opcode_istore(loc2);
  1540.      -- New java/io/File :
  1541.      idx := cp.idx_class2(fz_85);
  1542.      ca.opcode_new(idx);
  1543.      ca.opcode_dup;
  1544.      ca.opcode_aload(loc2);
  1545.      idx := cp.idx_methodref3(fz_85,fz_35,fz_57);
  1546.      ca.opcode_invokespecial(idx,0);    
  1547.      ca.opcode_istore(loc2);
  1548.      -- java/io/File.renameTo :
  1549.      ca.opcode_aload(loc1);
  1550.      ca.opcode_aload(loc2);
  1551.      idx := cp.idx_methodref3(fz_85,fz_b3,fz_b4);
  1552.      ca.opcode_invokevirtual(idx,0);
  1553.      ca.opcode_pop;
  1554.      rf7.jvm_closing;
  1555.       end;
  1556.  
  1557.    jvm_define_se_remove(rf7: RUN_FEATURE_7) is
  1558.       require
  1559.      rf7 /= Void
  1560.       local
  1561.      idx, loc1: INTEGER;
  1562.      cp: like constant_pool;
  1563.      ca: like code_attribute;
  1564.       do
  1565.      cp := constant_pool;
  1566.      ca := code_attribute;
  1567.      rf7.jvm_opening;
  1568.      -- New Java String :
  1569.      idx := cp.idx_class2(fz_32);
  1570.      ca.opcode_new(idx);
  1571.      ca.opcode_dup;
  1572.      ca.opcode_aload_2;
  1573.      ca.opcode_iconst_0;
  1574.      ca.opcode_aload_1;
  1575.      idx := cp.idx_methodref3(fz_32,fz_35,fz_65);
  1576.      ca.opcode_invokespecial(idx,-4);
  1577.      loc1 := ca.extra_local_size1;
  1578.      ca.opcode_istore(loc1);
  1579.      -- New java/io/File :
  1580.      idx := cp.idx_class2(fz_85);
  1581.      ca.opcode_new(idx);
  1582.      ca.opcode_dup;
  1583.      ca.opcode_aload(loc1);
  1584.      idx := cp.idx_methodref3(fz_85,fz_35,fz_57);
  1585.      ca.opcode_invokespecial(idx,0);
  1586.      -- java/io/File delete :
  1587.      idx := cp.idx_methodref3(fz_85,fz_b2,fz_87);
  1588.      ca.opcode_invokevirtual(idx,0);
  1589.      ca.opcode_pop;
  1590.      rf7.jvm_closing;
  1591.       end;
  1592.  
  1593.    jvm_define_twin(rf8: RUN_FEATURE_8; rc: RUN_CLASS; cpy: RUN_FEATURE) is
  1594.       require
  1595.      rc = rf8.current_type.run_class;
  1596.      cpy /= Void
  1597.       local
  1598.      idx, space, i: INTEGER;
  1599.      wa: ARRAY[RUN_FEATURE_2];
  1600.      rf2: RUN_FEATURE_2;
  1601.       do
  1602.      rf8.jvm_opening;
  1603.      wa := rc.writable_attributes;
  1604.      idx := rc.fully_qualified_constant_pool_index;
  1605.      code_attribute.opcode_new(idx);
  1606.      code_attribute.opcode_astore_1;
  1607.      if wa /= Void then
  1608.         from
  1609.            i := wa.upper;
  1610.         until
  1611.            i = 0
  1612.         loop
  1613.            rf2 := wa.item(i);
  1614.            code_attribute.opcode_aload_1;
  1615.            idx := constant_pool.idx_fieldref(rf2);
  1616.            space := rf2.result_type.jvm_push_default;
  1617.            code_attribute.opcode_putfield(idx,-(space + 1));
  1618.            i := i - 1;
  1619.         end;
  1620.      end;
  1621.      jvm.inside_twin(cpy);
  1622.      rf8.jvm_closing;
  1623.       end;
  1624.  
  1625.    jvm_standard_is_equal(t: TYPE) is
  1626.       local
  1627.      ca: like code_attribute;
  1628.      rc: RUN_CLASS;
  1629.      wa: ARRAY[RUN_FEATURE_2];
  1630.      point1, point2, space: INTEGER;
  1631.       do
  1632.      ca := code_attribute;
  1633.      jvm.push_target;
  1634.      space := jvm.push_ith_argument(1);
  1635.      if t.is_basic_eiffel_expanded or else native_array(t) then
  1636.         point1 := t.jvm_if_x_eq;
  1637.         ca.opcode_iconst_0;
  1638.         point2 := ca.opcode_goto;
  1639.         ca.resolve_u2_branch(point1);
  1640.         ca.opcode_iconst_1;
  1641.         ca.resolve_u2_branch(point2);
  1642.      else
  1643.         rc := t.run_class;
  1644.         wa := rc.writable_attributes;
  1645.         if t.is_expanded then
  1646.            if wa = Void then
  1647.           ca.opcode_pop;
  1648.           ca.opcode_pop;
  1649.           ca.opcode_iconst_1;
  1650.            else
  1651.           jvm_standard_is_equal_aux(rc,wa);
  1652.            end;
  1653.         else
  1654.            jvm_standard_is_equal_aux(rc,wa);
  1655.         end;
  1656.      end;
  1657.       end;
  1658.  
  1659.    jvm_standard_twin(t: TYPE) is
  1660.       require
  1661.      t /= Void
  1662.       local
  1663.      rc: RUN_CLASS;
  1664.      wa: ARRAY[RUN_FEATURE_2];
  1665.       do
  1666.      if t.is_basic_eiffel_expanded or else native_array(t) then
  1667.         jvm.push_target;
  1668.      else
  1669.         rc := t.run_class;
  1670.         wa := rc.writable_attributes;
  1671.         if t.is_expanded then
  1672.            if wa = Void then
  1673.           jvm.push_target;
  1674.            else
  1675.           jvm_standard_twin_aux(rc,wa);
  1676.            end;
  1677.         else
  1678.            jvm_standard_twin_aux(rc,wa);
  1679.         end;
  1680.      end;
  1681.       end;
  1682.  
  1683.    jvm_standard_twin_aux(rc: RUN_CLASS; wa: ARRAY[RUN_FEATURE_2]) is
  1684.       require
  1685.      rc /= Void
  1686.       local
  1687.      ca: like code_attribute;
  1688.      rf2: RUN_FEATURE_2;
  1689.      idx, space, i: INTEGER;
  1690.       do
  1691.      ca := code_attribute;
  1692.      idx := rc.fully_qualified_constant_pool_index;
  1693.      ca.opcode_new(idx);
  1694.      if wa = Void then
  1695.         jvm.drop_target;
  1696.      else
  1697.         jvm.push_target;
  1698.         from
  1699.            i := wa.upper;
  1700.         until
  1701.            i = 0
  1702.         loop
  1703.            rf2 := wa.item(i);
  1704.            ca.opcode_dup2;
  1705.            idx := constant_pool.idx_fieldref(rf2);
  1706.            space := rf2.result_type.jvm_stack_space;
  1707.            ca.opcode_getfield(idx,space - 1);
  1708.            ca.opcode_putfield(idx,space + 1);
  1709.            i := i - 1;
  1710.         end;
  1711.         ca.opcode_pop;
  1712.      end;
  1713.       end;
  1714.  
  1715.    jvm_mapping_integer_function(rf8: RUN_FEATURE_8; name: STRING) is
  1716.       local
  1717.      point1, point2, space: INTEGER;
  1718.      ca: like code_attribute;
  1719.       do
  1720.      ca := code_attribute;
  1721.      if us_slash = name then
  1722.         jvm.push_target;
  1723.         ca.opcode_i2d;
  1724.         space := jvm.push_ith_argument(1);
  1725.         ca.opcode_i2d;
  1726.         ca.opcode_ddiv;
  1727.      elseif rf8.arg_count = 1 then
  1728.         jvm.push_target;
  1729.         space := jvm.push_ith_argument(1);
  1730.         if us_plus = name then
  1731.            ca.opcode_iadd;
  1732.         elseif us_minus = name then
  1733.            ca.opcode_isub;
  1734.         elseif us_muls = name then
  1735.            ca.opcode_imul;
  1736.         elseif us_slash_slash = name then
  1737.            ca.opcode_idiv;
  1738.         elseif us_backslash_backslash = name then
  1739.            ca.opcode_irem;
  1740.         else -- < > <= >= only
  1741.            if us_gt = name then
  1742.           point1 := ca.opcode_if_icmpgt;
  1743.            elseif us_lt = name then
  1744.           point1 := ca.opcode_if_icmplt;
  1745.            elseif us_le = name then
  1746.           point1 := ca.opcode_if_icmple;
  1747.            else
  1748.           point1 := ca.opcode_if_icmpge;
  1749.            end;
  1750.            ca.opcode_iconst_0;
  1751.            point2 := ca.opcode_goto;
  1752.            ca.resolve_u2_branch(point1);
  1753.            ca.opcode_iconst_1;
  1754.            ca.resolve_u2_branch(point2);
  1755.         end;
  1756.       elseif us_to_character = name then
  1757.         jvm.push_target;
  1758.         code_attribute.opcode_i2b;
  1759.      elseif us_to_bit = name then
  1760.         jvm_int_to_bit(rf8.result_type,32);
  1761.      else
  1762.         check
  1763.            us_minus = name
  1764.         end;
  1765.         jvm.push_target;
  1766.         code_attribute.opcode_ineg
  1767.      end;
  1768.       end;
  1769.  
  1770.    jvm_mapping_real_function(rf8: RUN_FEATURE_8; name: STRING) is
  1771.       local
  1772.      point1, point2, space: INTEGER;
  1773.      ca: like code_attribute;
  1774.       do
  1775.      ca := code_attribute;
  1776.      if rf8.arg_count = 1 then
  1777.         jvm.push_target;
  1778.         space := jvm.push_ith_argument(1);
  1779.         if us_plus = name then
  1780.            ca.opcode_fadd;
  1781.         elseif us_minus = name then
  1782.            ca.opcode_fsub;
  1783.         elseif us_muls = name then
  1784.            ca.opcode_fmul;
  1785.         elseif us_slash = name then
  1786.            ca.opcode_fdiv;
  1787.         else
  1788.            ca.opcode_fcmpg;
  1789.            if us_gt = name then     -- gt
  1790.           point1 := ca.opcode_ifgt;
  1791.            elseif us_lt = name then -- lt
  1792.           point1 := ca.opcode_iflt;
  1793.            elseif us_le = name then -- le
  1794.           point1 := ca.opcode_ifle;
  1795.            elseif us_ge = name then -- ge
  1796.           point1 := ca.opcode_ifge;
  1797.            end;
  1798.            ca.opcode_iconst_0;
  1799.            point2 := ca.opcode_goto;
  1800.            ca.resolve_u2_branch(point1);
  1801.            ca.opcode_iconst_1;
  1802.            ca.resolve_u2_branch(point2);
  1803.         end;
  1804.      elseif us_minus = name then
  1805.         jvm.push_target;
  1806.         ca.opcode_fneg
  1807.      elseif us_to_double = name then
  1808.         jvm.push_target;
  1809.         ca.opcode_f2d;
  1810.      end;
  1811.       end;
  1812.  
  1813.    jvm_mapping_double_function(rf8: RUN_FEATURE_8; name: STRING) is
  1814.       local
  1815.      point1, point2, space, idx: INTEGER;
  1816.      ca: like code_attribute;
  1817.       do
  1818.      ca := code_attribute;
  1819.      if rf8.arg_count = 1 then
  1820.         jvm.push_target;
  1821.         space := jvm.push_ith_argument(1);
  1822.         if us_plus = name then
  1823.            ca.opcode_dadd;
  1824.         elseif us_minus = name then
  1825.            ca.opcode_dsub;
  1826.         elseif us_muls = name then
  1827.            ca.opcode_dmul;
  1828.         elseif us_slash = name then
  1829.            ca.opcode_ddiv;
  1830.         elseif us_pow = name then
  1831.            ca.opcode_i2d;
  1832.            idx := constant_pool.idx_methodref3(fz_93,"pow",fz_99);
  1833.            ca.opcode_invokestatic(idx,-2);
  1834.         else
  1835.            ca.opcode_dcmpg;
  1836.            if us_gt = name then     -- gt
  1837.           point1 := ca.opcode_ifgt;
  1838.            elseif us_lt = name then -- lt
  1839.           point1 := ca.opcode_iflt;
  1840.            elseif us_le = name then -- le
  1841.           point1 := ca.opcode_ifle;
  1842.            elseif us_ge = name then -- ge
  1843.           point1 := ca.opcode_ifge;
  1844.            end;
  1845.            ca.opcode_iconst_0;
  1846.            point2 := ca.opcode_goto;
  1847.            ca.resolve_u2_branch(point1);
  1848.            ca.opcode_iconst_1;
  1849.            ca.resolve_u2_branch(point2);
  1850.         end;
  1851.      elseif us_minus = name then
  1852.         jvm.push_target;
  1853.         ca.opcode_dneg;
  1854.      elseif us_to_real = name then
  1855.         jvm.push_target;
  1856.         ca.opcode_d2f;
  1857.      elseif us_double_floor = name then
  1858.         jvm.push_target;
  1859.         idx := constant_pool.idx_methodref3(fz_93,us_floor,fz_94);
  1860.         ca.opcode_invokestatic(idx,0);
  1861.      elseif us_truncated_to_integer = name then
  1862.         jvm.push_target;
  1863.         idx := constant_pool.idx_methodref3(fz_93,us_floor,fz_94);
  1864.         ca.opcode_invokestatic(idx,0);
  1865.         ca.opcode_d2i;
  1866.      else -- Same name in java/lang/Math :
  1867.         jvm.push_target;
  1868.         idx := constant_pool.idx_methodref3(fz_93,name,fz_94);
  1869.         ca.opcode_invokestatic(idx,0);
  1870.      end;
  1871.       end;
  1872.  
  1873. feature {NONE}
  1874.  
  1875.    body: STRING is
  1876.       once
  1877.      !!Result.make(128);
  1878.       end;
  1879.  
  1880.    c_mapping_integer_function(rf8: RUN_FEATURE_8; name: STRING) is
  1881.       do
  1882.      if rf8.arg_count = 1 then
  1883.             if us_slash = name then
  1884.            cpp.put_character('(');
  1885.            cpp.put_character('(');
  1886.                cpp.put_string(fz_double);
  1887.            cpp.put_character(')');
  1888.            cpp.put_character('(');
  1889.         else
  1890.            cpp.put_character('(');
  1891.             end;
  1892.         cpp.put_target_as_value;
  1893.             if us_slash = name then
  1894.                cpp.put_string(fz_13);
  1895.         else
  1896.            cpp.put_character(')');
  1897.             end;
  1898.         if us_slash_slash = name then
  1899.                cpp.put_string(us_slash);
  1900.         elseif us_backslash_backslash = name then
  1901.            cpp.put_string("%%");
  1902.             else
  1903.            cpp.put_string(name);
  1904.             end;
  1905.         cpp.put_character('(');
  1906.         cpp.put_arguments;
  1907.         cpp.put_character(')');
  1908.      elseif us_to_character = name then
  1909.         cpp.put_string("((char)(");
  1910.         cpp.put_target_as_value;
  1911.         cpp.put_string(fz_13);
  1912.      elseif us_to_bit = name then
  1913.         cpp.put_target_as_value;
  1914.      else
  1915.         cpp.put_string(name);
  1916.         cpp.put_character('(');
  1917.         cpp.put_target_as_value;
  1918.         cpp.put_character(')');
  1919.      end;
  1920.       end;
  1921.    
  1922.    c_mapping_real_function(rf8: RUN_FEATURE_8; name: STRING) is
  1923.       do
  1924.      if rf8.arg_count = 1 then
  1925.         cpp.put_character('(');
  1926.         cpp.put_target_as_value;
  1927.         cpp.put_character(')');
  1928.         cpp.put_string(name);
  1929.         cpp.put_character('(');
  1930.         cpp.put_arguments;
  1931.         cpp.put_character(')');
  1932.      elseif us_to_double = name then
  1933.         cpp.put_character('(');
  1934.         cpp.put_character('(');
  1935.         cpp.put_string(fz_double)
  1936.         cpp.put_character(')');
  1937.         cpp.put_character('(');
  1938.         cpp.put_target_as_value;
  1939.         cpp.put_character(')');
  1940.         cpp.put_character(')');
  1941.      else
  1942.         cpp.put_string(name);
  1943.         cpp.put_character('(');
  1944.         cpp.put_target_as_value;
  1945.         cpp.put_character(')');
  1946.      end;
  1947.       end;
  1948.  
  1949.    c_mapping_double_function(rf8: RUN_FEATURE_8; name: STRING) is
  1950.       do
  1951.      cpp.add_c_library("-lm");
  1952.      if us_pow = name then
  1953.         cpp.put_string("pow((");
  1954.         cpp.put_target_as_value;
  1955.         cpp.put_string("),(double)(");
  1956.         cpp.put_arguments;
  1957.         cpp.put_string(fz_13);
  1958.      elseif us_double_floor = name then
  1959.         cpp.put_string(us_floor);
  1960.         cpp.put_character('(');
  1961.         cpp.put_target_as_value;
  1962.         cpp.put_character(')');
  1963.      elseif us_truncated_to_integer = name then
  1964.         cpp.put_string("((int)floor(");
  1965.         cpp.put_target_as_value;
  1966.         cpp.put_string(fz_13);
  1967.      elseif us_to_real = name then
  1968.         cpp.put_character('(');
  1969.         cpp.put_character('(');
  1970.         cpp.put_string(fz_float);
  1971.         cpp.put_character(')');
  1972.         cpp.put_character('(');
  1973.         cpp.put_target_as_value;
  1974.         cpp.put_character(')');
  1975.         cpp.put_character(')');
  1976.      elseif name.count <= 2 and then rf8.arg_count = 1 then
  1977.            cpp.put_character('(');
  1978.            cpp.put_target_as_value;
  1979.            cpp.put_character(')');
  1980.            cpp.put_string(name);
  1981.            cpp.put_character('(');
  1982.            cpp.put_arguments;
  1983.            cpp.put_character(')');
  1984.      else
  1985.         cpp.put_string(name);
  1986.         cpp.put_character('(');
  1987.         cpp.put_target_as_value;
  1988.         cpp.put_character(')');
  1989.      end;
  1990.       end;
  1991.    
  1992.    c_define_procedure_bit(rf7: RUN_FEATURE_7; n: STRING) is
  1993.       local
  1994.      type_bit: TYPE_BIT;
  1995.       do
  1996.      type_bit ?= rf7.current_type;
  1997.      if us_put_0 = n then
  1998.         if type_bit.is_c_unsigned_ptr then
  1999.            rf7.c_define_with_body(
  2000.                "{char *bp=((char*)C)+((a1-1)/CHAR_BIT);%N%
  2001.            %*bp&=(~(((unsigned char)1)<<(CHAR_BIT-1-(a1-1)%%CHAR_BIT)));}");
  2002.             end;
  2003.      elseif us_put_1 = n then
  2004.         if type_bit.is_c_unsigned_ptr then
  2005.            rf7.c_define_with_body(
  2006.                "{char *bp=((char*)C)+((a1-1)/CHAR_BIT);%N%
  2007.                %*bp|=(((unsigned char)1)<<(CHAR_BIT-1-(a1-1)%%CHAR_BIT));}");
  2008.             end;
  2009.      elseif us_put = n then
  2010.         if type_bit.is_c_unsigned_ptr then
  2011.            rf7.c_define_with_body(
  2012.                "{char *bp=((char*)C)+((a2-1)/CHAR_BIT);%N%
  2013.                %if(a1){%N%
  2014.                %*bp|=(((unsigned char)1)<<(CHAR_BIT-1-(a2-1)%%CHAR_BIT));}%N%
  2015.                %else {%N%
  2016.                %*bp&=(~(((unsigned char)1)<<(CHAR_BIT-1-(a2-1)%%CHAR_BIT)));}}");
  2017.         end;
  2018.      end;
  2019.       end;
  2020.  
  2021. feature {NONE}
  2022.  
  2023.    tmp_string: STRING is
  2024.       once
  2025.      !!Result.make(32);
  2026.       end;
  2027.  
  2028. feature {NONE}
  2029.  
  2030.    fe_nyi(rf: RUN_FEATURE) is
  2031.       do
  2032.      eh.add_position(rf.start_position);
  2033.      eh.append("Sorry, but this feature is not yet implemented for %
  2034.                    %Current type ");
  2035.      eh.append(rf.current_type.run_time_mark);
  2036.      fatal_error(" (if you cannot work around mail %"colnet@loria.fr%").");
  2037.       end;
  2038.  
  2039.    jvm_bit_to_int(size: INTEGER) is
  2040.       local
  2041.      idx: INTEGER;
  2042.      point1, point2: INTEGER;
  2043.      loc1, loc2: INTEGER;
  2044.      ca: like code_attribute;
  2045.      cp: like constant_pool;
  2046.       do
  2047.      ca := code_attribute;
  2048.      cp := constant_pool;
  2049.      jvm.push_target;
  2050.      loc1 := ca.extra_local_size1;
  2051.      ca.opcode_iconst_0;
  2052.      ca.opcode_istore(loc1);
  2053.      loc2 := ca.extra_local_size1;
  2054.      ca.opcode_iconst_0;
  2055.      ca.opcode_istore(loc2);
  2056.      ca.opcode_iconst_1;
  2057.      point1 := ca.program_counter;
  2058.      point2 := ca.opcode_ifeq;
  2059.      ca.opcode_iload(loc2);
  2060.      ca.opcode_iconst_1;
  2061.      ca.opcode_ishl;
  2062.      ca.opcode_istore(loc2);
  2063.      ca.opcode_dup;
  2064.      ca.opcode_iload(loc1);
  2065.      idx := cp.idx_methodref3(fz_a0,fz_a2,fz_a3);
  2066.      ca.opcode_invokevirtual(idx,-1);
  2067.      ca.opcode_iload(loc2);
  2068.      ca.opcode_ior;
  2069.      ca.opcode_istore(loc2);
  2070.      ca.opcode_iinc(loc1,1);
  2071. -- ***
  2072. --     ca.opcode_dup;
  2073. --     idx := cp.idx_methodref3(fz_a0,"size",fz_71);
  2074. --     ca.opcode_invokevirtual(idx,0);
  2075.          ca.opcode_push_integer(size);
  2076. -- ***
  2077.      ca.opcode_iload(loc1);
  2078.      ca.opcode_isub;
  2079.      ca.opcode_goto_backward(point1);
  2080.      ca.resolve_u2_branch(point2);
  2081.      ca.opcode_pop;
  2082.      ca.opcode_iload(loc2);
  2083.       end;
  2084.  
  2085.    jvm_int_to_bit(type_bit: TYPE; nb_bit: INTEGER) is
  2086.       local
  2087.      idx: INTEGER;
  2088.      point1, point2, point3: INTEGER;
  2089.      loc1, loc2: INTEGER;
  2090.      ca: like code_attribute;
  2091.      cp: like constant_pool;
  2092.       do
  2093.      ca := code_attribute;
  2094.      cp := constant_pool;
  2095.      jvm.push_target;
  2096.      loc1 := ca.extra_local_size1;
  2097.      ca.opcode_push_integer(nb_bit);
  2098.      ca.opcode_istore(loc1);
  2099.      loc2 := ca.extra_local_size1;
  2100.      idx := type_bit.jvm_push_default;
  2101.      ca.opcode_istore(loc2);
  2102.      ca.opcode_iconst_1;
  2103.      point1 := ca.program_counter;
  2104.      point2 := ca.opcode_ifeq;
  2105.      ca.opcode_iinc(loc1,255);
  2106.      ca.opcode_dup;
  2107.      ca.opcode_iconst_1;
  2108.      ca.opcode_iand;
  2109.      point3 := ca.opcode_ifeq;
  2110.      ca.opcode_iload(loc2);
  2111.      ca.opcode_iload(loc1);
  2112.      idx := cp.idx_methodref3(fz_a0,fz_a4,fz_27);
  2113.      ca.opcode_invokevirtual(idx,-2);
  2114.      ca.resolve_u2_branch(point3);
  2115.      ca.opcode_iconst_1;
  2116.      ca.opcode_iushr;
  2117.      ca.opcode_iload(loc1);
  2118.      ca.opcode_goto_backward(point1);
  2119.      ca.resolve_u2_branch(point2);
  2120.      ca.opcode_pop;
  2121.      ca.opcode_iload(loc2);
  2122.       end;
  2123.  
  2124.    jvm_mapping_bit_function(rf8: RUN_FEATURE_8; name: STRING) is
  2125.       local
  2126.      type_bit: TYPE_BIT;
  2127.      space, idx: INTEGER;
  2128.      point1, point2, point3: INTEGER;
  2129.      loc1, loc2: INTEGER;
  2130.      ca: like code_attribute;
  2131.      cp: like constant_pool;
  2132.       do
  2133.      ca := code_attribute;
  2134.      cp := constant_pool;
  2135.      type_bit ?= rf8.current_type;
  2136.      if us_count = name then
  2137.         jvm.drop_target;
  2138.         ca.opcode_push_integer(type_bit.nb);
  2139.      elseif us_item = name then
  2140.         jvm.push_target;
  2141.         space := jvm.push_ith_argument(1);
  2142.         ca.opcode_iconst_1;
  2143.         ca.opcode_isub;
  2144.         idx := cp.idx_methodref3(fz_a0,fz_a2,fz_a3);
  2145.         ca.opcode_invokevirtual(idx,-1);
  2146.          elseif us_shift_right = name then
  2147.         jvm.push_target;
  2148.         space := jvm.push_ith_argument(1);
  2149.         loc1 := ca.extra_local_size1;
  2150.         loc2 := ca.extra_local_size1;
  2151.         ca.opcode_istore(loc2);
  2152.         space := type_bit.jvm_push_default;
  2153.         ca.opcode_swap;
  2154.         ca.opcode_push_integer(type_bit.nb);
  2155.         ca.opcode_istore(loc1);
  2156.         ca.opcode_iload(loc1);
  2157.         ca.opcode_iload(loc2);
  2158.         ca.opcode_isub;
  2159.         ca.opcode_istore(loc2);
  2160.         ca.opcode_iload(loc2);
  2161.         point1 := ca.program_counter;
  2162.         point2 := ca.opcode_ifeq;
  2163.         ca.opcode_iinc(loc1,255);
  2164.         ca.opcode_iinc(loc2,255);
  2165.         ca.opcode_dup2;
  2166.         ca.opcode_iload(loc2);
  2167.         idx := cp.idx_methodref3(fz_a0,fz_a2,fz_a3);
  2168.         ca.opcode_invokevirtual(idx,-1);
  2169.         point3 := ca.opcode_ifne;
  2170.         ca.opcode_pop;
  2171.         ca.opcode_iload(loc2);
  2172.         ca.opcode_goto_backward(point1);
  2173.         ca.resolve_u2_branch(point3);
  2174.         ca.opcode_iload(loc1);
  2175.         idx := cp.idx_methodref3(fz_a0,fz_a4,fz_27);
  2176.         ca.opcode_invokevirtual(idx,-2);
  2177.         ca.opcode_iload(loc2);
  2178.         ca.opcode_goto_backward(point1);
  2179.         ca.resolve_u2_branch(point2);
  2180.         ca.opcode_pop;
  2181.          elseif us_shift_left = name then
  2182.         jvm.push_target;
  2183.         space := jvm.push_ith_argument(1);
  2184.         loc1 := ca.extra_local_size1;
  2185.         loc2 := ca.extra_local_size1;
  2186.         ca.opcode_istore(loc1);
  2187.         space := type_bit.jvm_push_default;
  2188.         ca.opcode_swap;
  2189.         ca.opcode_push_integer(type_bit.nb);
  2190.         ca.opcode_istore(loc2);
  2191.         ca.opcode_iload(loc2);
  2192.         ca.opcode_iload(loc1);
  2193.         ca.opcode_isub;
  2194.         ca.opcode_istore(loc1);
  2195.         ca.opcode_iload(loc1);
  2196.         point1 := ca.program_counter;
  2197.         point2 := ca.opcode_ifeq;
  2198.         ca.opcode_iinc(loc1,255);
  2199.         ca.opcode_iinc(loc2,255);
  2200.         ca.opcode_dup2;
  2201.         ca.opcode_iload(loc2);
  2202.         idx := cp.idx_methodref3(fz_a0,fz_a2,fz_a3);
  2203.         ca.opcode_invokevirtual(idx,-1);
  2204.         point3 := ca.opcode_ifne;
  2205.         ca.opcode_pop;
  2206.         ca.opcode_iload(loc1);
  2207.         ca.opcode_goto_backward(point1);
  2208.         ca.resolve_u2_branch(point3);
  2209.         ca.opcode_iload(loc1);
  2210.         idx := cp.idx_methodref3(fz_a0,fz_a4,fz_27);
  2211.         ca.opcode_invokevirtual(idx,-2);
  2212.         ca.opcode_iload(loc1);
  2213.         ca.opcode_goto_backward(point1);
  2214.         ca.resolve_u2_branch(point2);
  2215.         ca.opcode_pop;
  2216.          elseif us_xor = name then
  2217.         jvm.push_target;
  2218.         ca.opcode_dup;
  2219.         space := jvm.push_ith_argument(1);
  2220.         idx := cp.idx_methodref3(fz_a0,us_xor,fz_b1);
  2221.         ca.opcode_invokevirtual(idx,0);
  2222.          elseif us_or = name then
  2223.         jvm.push_target;
  2224.         ca.opcode_dup;
  2225.         space := jvm.push_ith_argument(1);
  2226.         idx := cp.idx_methodref3(fz_a0,us_or,fz_b1);
  2227.         ca.opcode_invokevirtual(idx,0);
  2228.          elseif us_not = name then
  2229.         jvm.push_target;
  2230.         loc1 := ca.extra_local_size1;
  2231.         ca.opcode_push_integer(type_bit.nb);
  2232.         ca.opcode_istore(loc1);
  2233.         ca.opcode_iload(loc1);
  2234.         point1 := ca.program_counter;
  2235.         point2 := ca.opcode_ifeq;
  2236.         ca.opcode_iinc(loc1,255);
  2237.         ca.opcode_dup;
  2238.         ca.opcode_iload(loc1);
  2239.         idx := cp.idx_methodref3(fz_a0,fz_a2,fz_a3);
  2240.         ca.opcode_invokevirtual(idx,-1);
  2241.         point3 := ca.opcode_ifne;
  2242.         ca.opcode_dup;
  2243.         ca.opcode_iload(loc1);
  2244.         idx := cp.idx_methodref3(fz_a0,fz_a4,fz_27);
  2245.         ca.opcode_invokevirtual(idx,-2);
  2246.         ca.opcode_iload(loc1);
  2247.         ca.opcode_goto_backward(point1);
  2248.         ca.resolve_u2_branch(point3);
  2249.         ca.opcode_dup;
  2250.         ca.opcode_iload(loc1);
  2251.         idx := cp.idx_methodref3(fz_a0,fz_a5,fz_27);
  2252.         ca.opcode_invokevirtual(idx,-2);
  2253.         ca.opcode_iload(loc1);
  2254.         ca.opcode_goto_backward(point1);
  2255.         ca.resolve_u2_branch(point2);
  2256.          elseif us_and = name then
  2257.         jvm.push_target;
  2258.         ca.opcode_dup;
  2259.         space := jvm.push_ith_argument(1);
  2260.         idx := cp.idx_methodref3(fz_a0,us_and,fz_b1);
  2261.         ca.opcode_invokevirtual(idx,0);
  2262.          elseif us_to_character = name then
  2263.         jvm_bit_to_int(8);
  2264.          elseif us_to_integer = name then
  2265.         jvm_bit_to_int(32);
  2266.      end;
  2267.       end;
  2268.  
  2269.    jvm_mapping_bit_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  2270.       local
  2271.      type_bit: TYPE_BIT;
  2272.      space, idx, point1, point2: INTEGER;
  2273.      ca: like code_attribute;
  2274.      cp: like constant_pool;
  2275.       do
  2276.      ca := code_attribute;
  2277.      cp := constant_pool;
  2278.      type_bit ?= rf7.current_type;
  2279.      if name = us_put_0 then
  2280.         jvm.push_target;
  2281.         space := jvm.push_ith_argument(1);
  2282.         ca.opcode_iconst_1;
  2283.         ca.opcode_isub;
  2284.         idx := cp.idx_methodref3(fz_a0,fz_a5,fz_27);
  2285.         ca.opcode_invokevirtual(idx,-2);
  2286.      elseif name = us_put_1 then
  2287.         jvm.push_target;
  2288.         space := jvm.push_ith_argument(1);
  2289.         ca.opcode_iconst_1;
  2290.         ca.opcode_isub;
  2291.         idx := cp.idx_methodref3(fz_a0,fz_a4,fz_27);
  2292.         ca.opcode_invokevirtual(idx,-2);
  2293.      else
  2294.             check
  2295.                name = us_put
  2296.             end;
  2297.         jvm.push_target;
  2298.         space := jvm.push_ith_argument(1);
  2299.         space := jvm.push_ith_argument(2);
  2300.         ca.opcode_iconst_1;
  2301.         ca.opcode_isub;
  2302.         ca.opcode_swap;
  2303.         point1 := ca.opcode_ifne;
  2304.         idx := cp.idx_methodref3(fz_a0,fz_a5,fz_27);
  2305.         ca.opcode_invokevirtual(idx,-2);
  2306.         point2 := ca.opcode_goto;
  2307.         ca.resolve_u2_branch(point1);
  2308.         idx := cp.idx_methodref3(fz_a0,fz_a4,fz_27);
  2309.         ca.opcode_invokevirtual(idx,-2);
  2310.         ca.resolve_u2_branch(point2);
  2311.      end;
  2312.       end;
  2313.  
  2314.    c_mapping_bit_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  2315.       local
  2316.      type_bit: TYPE_BIT;
  2317.       do
  2318.      type_bit ?= rf7.current_type;
  2319.      if name = us_put_0 then
  2320.         if type_bit.is_c_unsigned_ptr then
  2321.            rf7.default_mapping_procedure;
  2322.         else
  2323.            mapping_bit_put_0(type_bit,1);
  2324.         end;
  2325.      elseif name = us_put_1 then
  2326.         if type_bit.is_c_unsigned_ptr then
  2327.            rf7.default_mapping_procedure;
  2328.         else
  2329.            mapping_bit_put_1(type_bit,1);
  2330.         end;
  2331.      else
  2332.             check
  2333.                name = us_put
  2334.             end;
  2335.         if type_bit.is_c_unsigned_ptr then
  2336.            rf7.default_mapping_procedure;
  2337.         else
  2338.            cpp.put_string("if(");
  2339.            cpp.put_ith_argument(1);
  2340.            cpp.put_string("){%N");
  2341.            mapping_bit_put_1(type_bit,2);
  2342.            cpp.put_string("} else {%N");
  2343.            mapping_bit_put_0(type_bit,2);
  2344.            cpp.put_string(fz_12);
  2345.         end;
  2346.      end;
  2347.       end;
  2348.  
  2349.    mapping_bit_put_1(type_bit: TYPE_BIT; arg: INTEGER) is
  2350.       do
  2351.      cpp.put_target_as_value;
  2352.      cpp.put_string("|=(((unsigned ");
  2353.      if type_bit.is_c_char then
  2354.         cpp.put_string(fz_char);
  2355.          else
  2356.         cpp.put_string(fz_int);
  2357.          end;
  2358.      cpp.put_string(")1)<<((CHAR_BIT");
  2359.      if type_bit.is_c_int then
  2360.         cpp.put_string("*sizeof(unsigned)");
  2361.          end;
  2362.      cpp.put_string(")-(");
  2363.      cpp.put_ith_argument(arg);
  2364.      cpp.put_string(")));%N");
  2365.       end;
  2366.  
  2367.    mapping_bit_put_0(type_bit: TYPE_BIT; arg: INTEGER) is
  2368.       do
  2369.          cpp.put_target_as_value;
  2370.      cpp.put_string("&=(~(((unsigned ");
  2371.      if type_bit.is_c_char then
  2372.             cpp.put_string(fz_char);
  2373.          else
  2374.         cpp.put_string(fz_int);
  2375.      end;
  2376.      cpp.put_string(")1)<<((CHAR_BIT");
  2377.      if type_bit.is_c_int then
  2378.         cpp.put_string("*sizeof(unsigned)");
  2379.          end;
  2380.      cpp.put_string(")-(");
  2381.      cpp.put_ith_argument(arg);
  2382.      cpp.put_string("))));%N");
  2383.       end;
  2384.  
  2385.    c_mapping_bit_function(rf8: RUN_FEATURE_8; name: STRING) is
  2386.       local
  2387.      type_bit: TYPE_BIT;
  2388.      boost: BOOLEAN;
  2389.       do
  2390.      type_bit ?= rf8.current_type;
  2391.      boost := run_control.boost;
  2392.      if us_count = name then
  2393.         cpp.put_integer(type_bit.nb);
  2394.      elseif us_item = name then
  2395.         if type_bit.is_c_unsigned_ptr then
  2396.            rf8.default_mapping_function;
  2397.         elseif boost then
  2398.            cpp.put_string(fz_17);
  2399.            cpp.put_target_as_target;
  2400.            cpp.put_string(")>>((CHAR_BIT");
  2401.            if type_bit.is_c_int then
  2402.           cpp.put_string("*sizeof(unsigned)");
  2403.            end;
  2404.            cpp.put_string(")-(");
  2405.            cpp.put_arguments;
  2406.            cpp.put_string(")))&1");
  2407.         else
  2408.            rf8.default_mapping_function;
  2409.         end;
  2410.          elseif us_shift_right = name then
  2411.         if type_bit.is_c_unsigned_ptr then
  2412.            rf8.default_mapping_function;
  2413.         elseif boost then
  2414.            cpp.put_string(fz_17);
  2415.            cpp.put_target_as_target;
  2416.            cpp.put_string(")>>(");
  2417.            cpp.put_ith_argument(1);
  2418.            cpp.put_string(fz_13);
  2419.         else
  2420.            rf8.default_mapping_function;
  2421.         end;
  2422.          elseif us_shift_left = name then
  2423.         if type_bit.is_c_unsigned_ptr then
  2424.            rf8.default_mapping_function;
  2425.         elseif boost then
  2426.            cpp.put_string(fz_17);
  2427.            cpp.put_target_as_target;
  2428.            cpp.put_string(")<<(");
  2429.            cpp.put_ith_argument(1);
  2430.            cpp.put_string(fz_13);
  2431.         else
  2432.            rf8.default_mapping_function;
  2433.         end;
  2434.          elseif us_xor = name then
  2435.         if type_bit.is_c_unsigned_ptr then
  2436.            fe_nyi(rf8);
  2437.         else
  2438.            cpp.put_character('(');
  2439.            cpp.put_target_as_target;
  2440.            cpp.put_character(')');
  2441.            cpp.put_character('^');
  2442.            cpp.put_character('(');
  2443.            cpp.put_ith_argument(1);
  2444.            cpp.put_character(')');
  2445.         end;
  2446.          elseif us_or = name then
  2447.         if type_bit.is_c_unsigned_ptr then
  2448.            fe_nyi(rf8);
  2449.         else
  2450.            cpp.put_character('(');
  2451.            cpp.put_target_as_target;
  2452.            cpp.put_character(')');
  2453.            cpp.put_character('|');
  2454.            cpp.put_character('(');
  2455.            cpp.put_ith_argument(1);
  2456.            cpp.put_character(')');
  2457.         end;
  2458.          elseif us_not = name then
  2459.         if type_bit.is_c_unsigned_ptr then
  2460.            fe_nyi(rf8);
  2461.         else
  2462.            cpp.put_character(' ');
  2463.            cpp.put_character('~');
  2464.            cpp.put_character('(');
  2465.            cpp.put_target_as_target;
  2466.            cpp.put_character(')');
  2467.         end;
  2468.          elseif us_and = name then
  2469.         if type_bit.is_c_unsigned_ptr then
  2470.            fe_nyi(rf8);
  2471.         else
  2472.            cpp.put_character('(');
  2473.            cpp.put_target_as_target;
  2474.            cpp.put_character(')');
  2475.            cpp.put_character('&');
  2476.            cpp.put_character('(');
  2477.            cpp.put_ith_argument(1);
  2478.            cpp.put_character(')');
  2479.         end;
  2480.          elseif us_to_character = name then
  2481.         cpp.put_target_as_value;
  2482.          elseif us_to_integer = name then
  2483.         cpp.put_target_as_value;
  2484.      end;
  2485.       end;
  2486.  
  2487.    c_define_function_bit(rf8: RUN_FEATURE_8; name: STRING) is
  2488.       local
  2489.      type_bit: TYPE_BIT;
  2490.      no_check: BOOLEAN;
  2491.       do
  2492.      type_bit ?= rf8.current_type;
  2493.      no_check := run_control.no_check;
  2494.      if us_count = name then
  2495.      elseif us_item = name then
  2496.         if type_bit.is_c_unsigned_ptr then
  2497.            rf8.c_define_with_body(
  2498.            "{R=((((unsigned char*)C)[(a1-1)/CHAR_BIT])%
  2499.                %>>(CHAR_BIT-1-(a1-1)%%CHAR_BIT))&1;}")
  2500.         elseif no_check then
  2501.            if type_bit.is_c_char then
  2502.           rf8.c_define_with_body("R=((C>>(CHAR_BIT-a1))&1);");
  2503.            else
  2504.           rf8.c_define_with_body(
  2505.           "R=((C>>((CHAR_BIT*sizeof(unsigned))-a1))&1);");
  2506.            end;
  2507.         end;
  2508.      elseif us_shift_left = name then
  2509.         if type_bit.is_c_unsigned_ptr then
  2510.                body.copy( 
  2511.                "int d=a1%%(CHAR_BIT*sizeof(unsigned));%N%
  2512.                %int D=a1/(CHAR_BIT*sizeof(unsigned));%N%
  2513.                %int c=CHAR_BIT*sizeof(unsigned)-d;%N%
  2514.                %int f=(");
  2515.                type_bit.nb.append_in(body);
  2516.                body.append(
  2517.                "-1)/(CHAR_BIT*sizeof(unsigned))-D;%N%
  2518.                %int i=0;%N%
  2519.                %for(;i<f;i++) R[i]=(C[i+D]<<d)|(C[i+D+1]>>c);%N%
  2520.                %R[f]=((C[(");
  2521.                type_bit.nb.append_in(body);
  2522.                body.append(
  2523.                "-1)/(CHAR_BIT*sizeof(unsigned))])&((~0)<<(CHAR_BIT*%
  2524.                %sizeof(unsigned)-");
  2525.                type_bit.nb.append_in(body);
  2526.                body.append("%%(CHAR_BIT*sizeof(unsigned)))))<<d;");
  2527.            rf8.c_define_with_body(body);
  2528.         else
  2529.            rf8.c_define_with_body("R=(C<<a1);");
  2530.         end;
  2531.      elseif us_shift_right = name then
  2532.         if type_bit.is_c_unsigned_ptr then
  2533.            body.copy(
  2534.                "int d=a1%%(CHAR_BIT*sizeof(unsigned));%N%
  2535.                %int D=a1/(CHAR_BIT*sizeof(unsigned));%N%
  2536.                %int c=CHAR_BIT*sizeof(unsigned)-d;%N%
  2537.                %int i=(");
  2538.            type_bit.nb.append_in(body);
  2539.                body.append(
  2540.                ")/(CHAR_BIT*sizeof(unsigned));%N%
  2541.                %for(;i>D;i--) R[i]=(C[i-D]>>d)|(C[i-D-1]<<c);%N%
  2542.                %R[D]=C[0]>>d;");
  2543.            rf8.c_define_with_body(body);
  2544.         else
  2545.            rf8.c_define_with_body("R=(C>>a1);");
  2546.         end;
  2547.      end;
  2548.       end;
  2549.  
  2550. feature {NONE}
  2551.  
  2552.    native_array(t: TYPE): BOOLEAN is
  2553.       do
  2554.          Result := t.base_class_name.to_string = us_native_array;
  2555.       end;
  2556.  
  2557.    unknown_native(rf: RUN_FEATURE) is
  2558.       do
  2559.      eh.add_position(rf.start_position);
  2560.      fatal_error("Unknown native feature.");
  2561.       end;
  2562.  
  2563. end -- NATIVE_SMALL_EIFFEL
  2564.  
  2565.  
  2566.