home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / run_feature_8.e < prev    next >
Text File  |  1999-06-05  |  9KB  |  339 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_8
  17.  
  18. inherit RUN_FEATURE redefine base_feature end;
  19.  
  20. creation make
  21.  
  22. feature
  23.  
  24.    base_feature: EXTERNAL_FUNCTION;
  25.  
  26.    static_value_mem: INTEGER;
  27.  
  28.    arguments: FORMAL_ARG_LIST;
  29.  
  30.    result_type: TYPE;
  31.  
  32.    require_assertion: RUN_REQUIRE;
  33.  
  34.    ensure_assertion: E_ENSURE;
  35.  
  36. feature
  37.  
  38.    is_pre_computable: BOOLEAN is false;
  39.  
  40.    can_be_dropped: BOOLEAN is false;
  41.  
  42.    is_once_function: BOOLEAN is false;
  43.  
  44. feature
  45.  
  46.    arg_count: INTEGER is
  47.       do
  48.          if arguments /= Void then
  49.             Result := arguments.count;
  50.          end;
  51.       end;
  52.  
  53.    local_vars: LOCAL_VAR_LIST is
  54.       do
  55.       end;
  56.  
  57.    routine_body: COMPOUND is
  58.       do
  59.       end;
  60.  
  61.    rescue_compound: COMPOUND is
  62.       do
  63.       end;
  64.  
  65.    afd_check is
  66.       do
  67.          routine_afd_check;
  68.       end;
  69.  
  70.    is_static: BOOLEAN is
  71.       local
  72.          n: STRING;
  73.          type_bit: TYPE_BIT;
  74.       do
  75.          n := name.to_string;
  76.          if as_is_expanded_type = n then
  77.             Result := true;
  78.             if current_type.is_expanded then
  79.                static_value_mem := 1;
  80.             end;
  81.          elseif as_is_basic_expanded_type = n then
  82.             Result := true;
  83.             if current_type.is_basic_eiffel_expanded then
  84.                static_value_mem := 1;
  85.             end;
  86.          elseif as_count = n and then current_type.is_bit then
  87.             Result := true;
  88.             type_bit ?= current_type;
  89.             static_value_mem := type_bit.nb;
  90.          end;
  91.       end;
  92.  
  93.    mapping_c is
  94.       local
  95.          bf: like base_feature;
  96.          native: NATIVE;
  97.          bcn: STRING;
  98.       do
  99.          bf := base_feature;
  100.          native := bf.native;
  101.          bcn := bf.base_class.name.to_string;
  102.          native.c_mapping_function(Current,bcn,bf.first_name.to_string);
  103.       end;
  104.  
  105.    c_define is
  106.       local
  107.          bf: like base_feature;
  108.          native: NATIVE;
  109.          bcn: STRING;
  110.       do
  111.          bf := base_feature;
  112.          native := bf.native;
  113.          bcn := bf.base_class.name.to_string;
  114.          native.c_define_function(Current,bcn,bf.first_name.to_string);
  115.       end;
  116.  
  117. feature {TYPE_BIT_2}
  118.  
  119.    integer_value(p: POSITION): INTEGER is
  120.       local
  121.          n: STRING;
  122.       do
  123.          n := name.to_string;
  124.          if as_integer_bits = n then
  125.             Result := Integer_bits;
  126.          elseif as_character_bits = n then
  127.             Result := Character_bits;
  128.          else
  129.             eh.add_position(p);
  130.             eh.add_position(start_position);
  131.             fatal_error(fz_iinaiv);
  132.          end;
  133.       end;
  134.  
  135. feature {RUN_CLASS}
  136.  
  137.    jvm_field_or_method is
  138.       local
  139.          bf: like base_feature;
  140.          native: NATIVE;
  141.          n, bcn: STRING;
  142.       do
  143.          bf := base_feature;
  144.          n := bf.first_name.to_string;
  145.          if as_bitn = n then
  146.             jvm.add_field(Current);
  147.          else
  148.             native := base_feature.native;
  149.             bcn := bf.base_class.name.to_string;
  150.             native.jvm_add_method_for_function(Current,bcn,n);
  151.          end;
  152.       end;
  153.  
  154. feature
  155.  
  156.    mapping_jvm is
  157.       local
  158.          bf: like base_feature;
  159.          native: NATIVE;
  160.          bcn: STRING;
  161.       do
  162.          bf := base_feature;
  163.          native := bf.native;
  164.          bcn := bf.base_class.name.to_string;
  165.          native.jvm_mapping_function(Current,bcn,bf.first_name.to_string);
  166.       end;
  167.  
  168. feature {JVM}
  169.  
  170.    jvm_define is
  171.       local
  172.          bf: like base_feature;
  173.          native: NATIVE;
  174.          n, bcn: STRING;
  175.          cp: like constant_pool;
  176.       do
  177.          bf := base_feature;
  178.          n := bf.first_name.to_string;
  179.          if as_bitn = n then
  180.             cp := constant_pool;
  181.             field_info.add(1,cp.idx_utf8(n),cp.idx_utf8(fz_a9));
  182.          else
  183.             native := bf.native;
  184.             bcn := bf.base_class.name.to_string;
  185.             native.jvm_define_function(Current,bcn,n);
  186.          end;
  187.       end;
  188.  
  189. feature {NATIVE}
  190.  
  191.    c_prototype is
  192.       do
  193.          external_prototype(base_feature);
  194.       end;
  195.  
  196. feature {NATIVE_SMALL_EIFFEL}
  197.  
  198.    c_opening is
  199.       do
  200.          define_prototype;
  201.          c_define_opening;
  202.       end;
  203.  
  204.    c_closing is
  205.       do
  206.          c_define_closing;
  207.          cpp.put_string(fz_15);
  208.          c_frame_descriptor;
  209.       end;
  210.  
  211. feature {NATIVE}
  212.  
  213.    jvm_opening is
  214.       do
  215.          method_info_start;
  216.          jvm_define_opening;
  217.       end;
  218.  
  219.    jvm_closing is
  220.       do
  221.          jvm_define_closing;
  222.          result_type.jvm_push_local(jvm_result_offset);
  223.          result_type.run_type.jvm_return_code;
  224.          method_info.finish;
  225.       end;
  226.  
  227.    jvm_closing_fast is
  228.          -- Skip ensure and assume the result is already pushed.
  229.       do
  230.          result_type.run_type.jvm_return_code;
  231.          method_info.finish;
  232.       end;
  233.  
  234. feature {NONE}
  235.  
  236.    jvm_result_store is
  237.       do
  238.          result_type.jvm_write_local(jvm_result_offset);
  239.       end;
  240.  
  241.    tmp_string: STRING is
  242.       once
  243.          !!Result.make(80);
  244.       end;
  245.  
  246. feature {CALL_PROC_CALL}
  247.  
  248.    collect_c_tmp is
  249.       do
  250.       end;
  251.  
  252. feature {ADDRESS_OF_POOL}
  253.  
  254.    address_of_c_define(caller: ADDRESS_OF) is
  255.       do
  256.       end;
  257.  
  258. feature {ADDRESS_OF}
  259.  
  260.    address_of_c_mapping is
  261.       do
  262.       end;
  263.  
  264. feature {NONE}
  265.  
  266.    initialize is
  267.       local
  268.          n: STRING;
  269.          rf: RUN_FEATURE;
  270.          type_bit_ref: TYPE_BIT_REF;
  271.       do
  272.          n := base_feature.first_name.to_string;
  273.          arguments := base_feature.arguments;
  274.          if as_bitn = n then
  275.             type_bit_ref ?= current_type;
  276.             result_type := type_bit_ref.type_bit;
  277.             if arguments /= Void then
  278.                if not arguments.is_runnable(current_type) then
  279.                   !!arguments.with(arguments,current_type);
  280.                end;
  281.             end;
  282.          else
  283.             result_type := base_feature.result_type;
  284.             if arguments = Void then
  285.                result_type := result_type.to_runnable(current_type);
  286.             elseif result_type.is_like_argument then
  287.                if not arguments.is_runnable(current_type) then
  288.                   !!arguments.with(arguments,current_type);
  289.                end;
  290.                result_type := result_type.to_runnable(current_type);
  291.             else
  292.                result_type := result_type.to_runnable(current_type);
  293.                if not arguments.is_runnable(current_type) then
  294.                   !!arguments.with(arguments,current_type);
  295.                end;
  296.             end;
  297.          end;
  298.          if run_control.require_check then
  299.             require_assertion := run_require;
  300.          end;
  301.          if run_control.ensure_check then
  302.             ensure_assertion := run_ensure;
  303.          end;
  304.          if as_twin = n then
  305.             rf := run_class.get_copy;
  306.          elseif as_se_argc = n then
  307.             type_string.set_at_run_time;
  308.          elseif as_generating_type = n then
  309.             run_control.set_generator_used;
  310.             run_control.set_generating_type_used;
  311.          elseif as_generator = n then
  312.             run_control.set_generator_used;
  313.          elseif as_exception = n then
  314.             exceptions_handler.set_used;
  315.          elseif as_signal_number = n then
  316.             exceptions_handler.set_used;
  317.          elseif n.has_prefix(fz_se_dir) then
  318.             cpp.set_basic_directory_used;
  319.          end;
  320.       end;
  321.  
  322.    compute_use_current is
  323.       do
  324.          if base_feature.use_current then
  325.             use_current_state := ucs_true;
  326.          else
  327.             std_compute_use_current;
  328.          end;
  329.       end;
  330.  
  331. feature {NONE}
  332.  
  333.    update_tmp_jvm_descriptor is
  334.       do
  335.          routine_update_tmp_jvm_descriptor;
  336.       end;
  337.  
  338. end -- RUN_FEATURE_8
  339.