home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / run_feature_5.e < prev    next >
Text File  |  1999-06-05  |  5KB  |  211 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://SmallEiffel.loria.fr
  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_5
  17.  
  18. inherit RUN_FEATURE redefine base_feature end;
  19.  
  20. creation make
  21.  
  22. feature
  23.  
  24.    base_feature: ONCE_PROCEDURE;
  25.  
  26.    arguments: FORMAL_ARG_LIST;
  27.  
  28.    require_assertion: RUN_REQUIRE;
  29.  
  30.    local_vars: LOCAL_VAR_LIST;
  31.  
  32.    routine_body: COMPOUND;
  33.  
  34.    rescue_compound: COMPOUND;
  35.  
  36.    ensure_assertion: E_ENSURE;
  37.  
  38. feature
  39.  
  40.    is_static: BOOLEAN is false;
  41.  
  42.    can_be_dropped: BOOLEAN is false;
  43.  
  44.    is_pre_computable: BOOLEAN is false;
  45.  
  46.    is_once_function: BOOLEAN is false;
  47.  
  48. feature
  49.  
  50.    result_type: TYPE is
  51.       do
  52.       end;
  53.  
  54.    static_value_mem: INTEGER is
  55.       do
  56.       end;
  57.  
  58.    afd_check is
  59.       do
  60.          routine_afd_check;
  61.       end;
  62.  
  63.    mapping_c is
  64.       do
  65.          default_mapping_procedure;
  66.       end;
  67.  
  68.    c_define is
  69.       local
  70.          bfbc: BASE_CLASS;
  71.       do
  72.          bfbc := base_feature.base_class;
  73.          if not bfbc.once_flag(once_mark) then
  74.             once_boolean;
  75.          end;
  76.          define_prototype;
  77.          cpp.put_string("if (");
  78.          once_flag;
  79.          cpp.put_string("==0){%N");
  80.          c_define_opening;
  81.          once_flag;
  82.          cpp.put_string("=1;%N");
  83.          if routine_body /= Void then
  84.             routine_body.compile_to_c;
  85.          end;
  86.          c_define_closing;
  87.          cpp.put_string("}}%N");
  88.          c_frame_descriptor;
  89.       end;
  90.  
  91. feature {CALL_PROC_CALL}
  92.  
  93.    collect_c_tmp is
  94.       do
  95.       end;
  96.  
  97. feature {ADDRESS_OF_POOL}
  98.  
  99.    address_of_c_define(caller: ADDRESS_OF) is
  100.       do
  101.          if run_control.boost then
  102.             if use_current then
  103.             else
  104.                address_of_c_define_wrapper(caller);
  105.             end;
  106.          else
  107.             address_of_c_define_wrapper(caller);
  108.          end;
  109.       end;
  110.  
  111. feature {ADDRESS_OF}
  112.  
  113.    address_of_c_mapping is
  114.       do
  115.          if run_control.boost then
  116.             if use_current then
  117.                mapping_name;
  118.             else
  119.                address_of_c_mapping_wrapper;
  120.             end;
  121.          else
  122.             address_of_c_mapping_wrapper;
  123.          end;
  124.       end;
  125.  
  126. feature {NONE}
  127.  
  128.    jvm_result_store is
  129.       do
  130.       end;
  131.  
  132.    initialize is
  133.       do
  134.          arguments := base_feature.arguments;
  135.          if arguments /= Void then
  136.             if not arguments.is_runnable(current_type) then
  137.                !!arguments.with(arguments,current_type);
  138.             end;
  139.          end;
  140.          local_vars := base_feature.local_vars;
  141.          if local_vars /= Void then
  142.             local_vars := local_vars.to_runnable(current_type);
  143.          end;
  144.          routine_body := base_feature.routine_body;
  145.          if routine_body /= Void then
  146.             routine_body := routine_body.to_runnable(current_type);
  147.          end;
  148.          if run_control.require_check then
  149.             require_assertion := run_require;
  150.          end;
  151.          if run_control.ensure_check then
  152.             ensure_assertion := run_ensure;
  153.          end;
  154.          rescue_compound := base_feature.rescue_compound;
  155.          if rescue_compound /= Void then
  156.             exceptions_handler.set_used;
  157.             rescue_compound := rescue_compound.to_runnable(current_type);
  158.          end;
  159.          once_routine_pool.add_procedure(Current);
  160.       end;
  161.  
  162.    compute_use_current is
  163.       do
  164.          std_compute_use_current;
  165.       end;
  166.  
  167. feature {RUN_CLASS}
  168.  
  169.    jvm_field_or_method is
  170.       do
  171.          jvm.add_method(Current);
  172.       end;
  173.  
  174. feature
  175.  
  176.    mapping_jvm is
  177.       do
  178.          routine_mapping_jvm;
  179.       end;
  180.  
  181. feature {JVM}
  182.  
  183.    jvm_define is
  184.       local
  185.          branch, idx_flag: INTEGER;
  186.       do
  187.          idx_flag := once_routine_pool.idx_fieldref_for_flag(Current);
  188.          method_info_start;
  189.          code_attribute.opcode_getstatic(idx_flag,1);
  190.          branch := code_attribute.opcode_ifne;
  191.          code_attribute.opcode_iconst_1;
  192.          code_attribute.opcode_putstatic(idx_flag,-1);
  193.          jvm_define_opening;
  194.          if routine_body /= Void then
  195.             routine_body.compile_to_jvm;
  196.          end;
  197.          jvm_define_closing;
  198.          code_attribute.resolve_u2_branch(branch);
  199.          code_attribute.opcode_return;
  200.          method_info.finish;
  201.       end;
  202.  
  203. feature {NONE}
  204.  
  205.    update_tmp_jvm_descriptor is
  206.       do
  207.          routine_update_tmp_jvm_descriptor;
  208.       end;
  209.  
  210. end -- RUN_FEATURE_5
  211.