home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / run_feature_8.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  6.1 KB  |  273 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 RUN_FEATURE_8
  17.    
  18. inherit RUN_FEATURE redefine base_feature end;
  19.    
  20. creation {EXTERNAL_FUNCTION} make
  21.    
  22. feature 
  23.    
  24.    static_value_mem: INTEGER;
  25.  
  26.    base_feature: EXTERNAL_FUNCTION;
  27.    
  28. feature 
  29.  
  30.    is_pre_computable: BOOLEAN is false;
  31.    
  32.    can_be_dropped: BOOLEAN is false;
  33.    
  34.    local_vars: LOCAL_VAR_LIST is do end;
  35.    
  36.    afd_check is
  37.       do
  38.      routine_afd_check;
  39.       end;
  40.  
  41.    is_static: BOOLEAN is 
  42.       local
  43.      n: STRING;
  44.      type_bit: TYPE_BIT;
  45.       do 
  46.      n := name.to_string;
  47.      if us_is_expanded_type = n then
  48.         Result := true;
  49.         if current_type.is_expanded then
  50.            static_value_mem := 1;
  51.         end;
  52.      elseif us_is_basic_expanded_type = n then
  53.         Result := true;
  54.         if current_type.is_basic_eiffel_expanded then
  55.            static_value_mem := 1;
  56.         end;
  57.          elseif us_count = n and then current_type.is_bit then
  58.         Result := true;
  59.         type_bit ?= current_type;
  60.         static_value_mem := type_bit.nb;
  61.      end;
  62.       end;
  63.    
  64.    mapping_c is
  65.       local
  66.      bf: like base_feature;
  67.      native: NATIVE;
  68.      bcn: STRING;
  69.       do
  70.      bf := base_feature;
  71.      native := bf.native;
  72.      bcn := bf.base_class.base_class_name.to_string;
  73.      native.c_mapping_function(Current,bcn,bf.first_name.to_string);
  74.       end;
  75.    
  76.    c_define is 
  77.       local
  78.      bf: like base_feature;
  79.      native: NATIVE;
  80.      bcn: STRING;
  81.       do
  82.      bf := base_feature;
  83.      native := bf.native;
  84.      bcn := bf.base_class.base_class_name.to_string;
  85.      native.c_define_function(Current,bcn,bf.first_name.to_string);
  86.       end;
  87.  
  88. feature {TYPE_BIT_2}
  89.  
  90.    integer_value(p: POSITION): INTEGER is
  91.       local
  92.      n: STRING;
  93.       do
  94.      n := name.to_string;
  95.      if us_integer_bits = n then
  96.         Result := Integer_bits;
  97.      elseif us_character_bits = n then
  98.         Result := Character_bits;
  99.      else
  100.         eh.add_position(p);
  101.         eh.add_position(start_position);
  102.         fatal_error(fz_iinaiv);
  103.      end;
  104.       end;
  105.    
  106. feature {RUN_CLASS}
  107.  
  108.    jvm_field_or_method is
  109.       local
  110.      native: NATIVE;
  111.      n, bcn: STRING;
  112.       do
  113.      n := name.to_string;
  114.      if us_bitn = n then
  115.         jvm.add_field(Current);
  116.      else
  117.         native := base_feature.native;
  118.         bcn := base_feature.base_class.base_class_name.to_string;
  119.         native.jvm_add_method_for_function(Current,bcn,n);
  120.      end;
  121.       end;
  122.  
  123. feature
  124.  
  125.    mapping_jvm is
  126.       local
  127.      bf: like base_feature;
  128.      native: NATIVE;
  129.      bcn: STRING;
  130.       do
  131.      bf := base_feature;
  132.      native := bf.native;
  133.      bcn := bf.base_class.base_class_name.to_string;
  134.      native.jvm_mapping_function(Current,bcn,bf.first_name.to_string);
  135.       end;
  136.  
  137. feature {JVM}
  138.  
  139.    jvm_define is
  140.       local
  141.      bf: like base_feature;
  142.      native: NATIVE;
  143.      n, bcn: STRING;
  144.      cp: like constant_pool;
  145.       do
  146.      bf := base_feature;
  147.      n := bf.first_name.to_string;
  148.      if us_bitn = n then
  149.         cp := constant_pool;
  150.         field_info.add(1,cp.idx_uft8(n),cp.idx_uft8(fz_a9));
  151.      else
  152.         native := bf.native;
  153.         bcn := bf.base_class.base_class_name.to_string;
  154.         native.jvm_define_function(Current,bcn,n);
  155.      end;
  156.       end;
  157.    
  158. feature {NATIVE}
  159.    
  160.    c_prototype is
  161.       do
  162.      external_prototype(base_feature);
  163.       end;
  164.    
  165.    c_define_with_body(body: STRING) is
  166.       require
  167.      body /= Void
  168.       do
  169.      c_opening;
  170.      cpp.put_string(body);
  171.      c_closing;
  172.       end;
  173.  
  174.    c_opening is
  175.       do
  176.      define_prototype;
  177.      define_opening;
  178.       end;
  179.  
  180.    c_closing is
  181.       do
  182.      define_closing;
  183.      cpp.put_string(fz_15);
  184.       end;
  185.  
  186.    jvm_opening is
  187.       do
  188.      method_info_start;
  189.      jvm_define_opening;
  190.       end;
  191.  
  192.    jvm_closing is
  193.       do
  194.      jvm_define_closing;
  195.      result_type.run_type.jvm_return_code;
  196.      method_info.finish;
  197.       end;
  198.  
  199.    jvm_closing_fast is
  200.      -- Skip ensure and assume the result is already pushed.
  201.       do
  202.      result_type.run_type.jvm_return_code;
  203.      method_info.finish;
  204.       end;
  205.  
  206. feature {NONE}   
  207.    
  208.    tmp_string: STRING is
  209.       once
  210.      !!Result.make(80);
  211.       end;
  212.  
  213. feature {NONE}   
  214.    
  215.    initialize is
  216.       local
  217.      n: STRING;
  218.      rf: RUN_FEATURE;
  219.          type_bit_ref: TYPE_BIT_REF;
  220.       do
  221.      n := name.to_string;
  222.      arguments := base_feature.arguments;
  223.      if arguments /= Void and then arguments.count > 0 then
  224.         arguments := arguments.to_runnable(current_type);
  225.      end;
  226.      if us_bitn = n then
  227.             type_bit_ref ?= current_type;
  228.         result_type := type_bit_ref.type_bit;
  229.      else
  230.         result_type := base_feature.result_type.to_runnable(current_type);
  231.          end;
  232.      if run_control.require_check then
  233.         require_assertion := base_feature.run_require(Current);
  234.      end;
  235.      if run_control.ensure_check then
  236.         ensure_assertion := base_feature.run_ensure(Current);
  237.      end;
  238.      if us_twin = n then
  239.         rf := run_class.get_copy;
  240.      elseif us_se_argc = n then
  241.         type_string.run_class.set_at_run_time;
  242.      elseif us_generating_type = n then
  243.         type_string.run_class.set_at_run_time;
  244.      elseif us_generator = n then
  245.         type_string.run_class.set_at_run_time;
  246.      end;
  247.       end;
  248.    
  249.    compute_use_current is
  250.       do
  251.      if base_feature.use_current then
  252.         use_current_state := ucs_true;
  253.      else
  254.         std_compute_use_current;
  255.      end;
  256.       end;
  257.  
  258. feature {NONE}
  259.  
  260.    update_tmp_jvm_descriptor is
  261.       do
  262.      routine_update_tmp_jvm_descriptor;
  263.       end;
  264.  
  265. invariant
  266.    
  267.    result_type /= Void;
  268.    
  269.    routine_body = Void;
  270.    
  271. end -- RUN_FEATURE_8
  272.  
  273.