home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / type_bit_ref.e < prev    next >
Text File  |  1999-06-05  |  8KB  |  383 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 TYPE_BIT_REF
  17.  
  18. inherit TYPE;
  19.  
  20. creation make
  21.  
  22. feature
  23.  
  24.    type_bit: TYPE_BIT;
  25.  
  26.    written_mark: STRING;
  27.  
  28.    run_time_mark: STRING;
  29.  
  30. feature
  31.  
  32.    make(tb: TYPE_BIT) is
  33.       require
  34.          tb.is_run_type
  35.       do
  36.          type_bit := tb;
  37.          run_time_mark := "BIT ";
  38.          type_bit.nb.append_in(run_time_mark);
  39.          run_time_mark.append(" REF");
  40.          run_time_mark := string_aliaser.item(run_time_mark);
  41.          written_mark := run_time_mark;
  42.       ensure
  43.          type_bit = tb
  44.       end;
  45.  
  46. feature
  47.  
  48.    is_run_type: BOOLEAN is true;
  49.  
  50.    is_expanded: BOOLEAN is false;
  51.  
  52.    is_none: BOOLEAN is false;
  53.  
  54.    is_any: BOOLEAN is false;
  55.  
  56.    is_basic_eiffel_expanded: BOOLEAN is false;
  57.  
  58.    is_reference: BOOLEAN is true;
  59.  
  60.    is_user_expanded: BOOLEAN is false;
  61.  
  62.    is_dummy_expanded: BOOLEAN is false;
  63.  
  64.    is_generic: BOOLEAN is false;
  65.  
  66.    is_array: BOOLEAN is false;
  67.  
  68.    is_like_current: BOOLEAN is false;
  69.  
  70.    is_like_argument: BOOLEAN is false;
  71.  
  72.    is_like_feature: BOOLEAN is false;
  73.  
  74.    jvm_method_flags: INTEGER is 17;
  75.  
  76.    static_base_class_name: CLASS_NAME is
  77.       do
  78.          Result := base_class_name;
  79.       end;
  80.  
  81.    space_for_variable: INTEGER is
  82.       do
  83.          Result := space_for_pointer;
  84.       end;
  85.  
  86.    space_for_object: INTEGER is
  87.       do
  88.          Result := standard_space_for_object;
  89.       end;
  90.  
  91.    run_class: RUN_CLASS is
  92.       do
  93.          Result := small_eiffel.run_class(run_type);
  94.       end;
  95.  
  96.    generic_list: ARRAY[TYPE] is
  97.       do
  98.          fatal_error_generic_list;
  99.       end;
  100.  
  101.    expanded_initializer: RUN_FEATURE_3 is
  102.       do
  103.       end;
  104.  
  105.    c_header_pass1 is
  106.       do
  107.          standard_c_typedef;
  108.       end;
  109.  
  110.    c_header_pass2 is
  111.       do
  112.          tmp_string.copy(fz_struct);
  113.          tmp_string.extend('S');
  114.          id.append_in(tmp_string);
  115.          tmp_string.append("{int id;T");
  116.          type_bit.id.append_in(tmp_string);
  117.          tmp_string.append(" bit_n;};%N");
  118.          cpp.put_string(tmp_string);
  119.          -- Creation function :
  120.          tmp_string.copy("T0*toT");
  121.          id.append_in(tmp_string);
  122.          tmp_string.append("(T");
  123.          type_bit.id.append_in(tmp_string);
  124.          tmp_string.append(" bit)");
  125.          cpp.put_c_heading(tmp_string);
  126.          cpp.swap_on_c;
  127.          gc_handler.allocation(run_class);
  128.          cpp.put_string("n->bit_n=bit;%Nreturn (T0*)n;%N}%N");
  129.          cpp.swap_on_h;
  130.       end;
  131.  
  132.    c_header_pass3 is
  133.       do
  134.       end;
  135.  
  136.    c_header_pass4 is
  137.       local
  138.          mem_id: INTEGER;
  139.          rc: RUN_CLASS;
  140.       do
  141.          rc := run_class;
  142.          mem_id := rc.id;
  143.          tmp_string.copy(fz_extern);
  144.          tmp_string.extend('T');
  145.          mem_id.append_in(tmp_string);
  146.          tmp_string.extend(' ');
  147.          tmp_string.extend('M');
  148.          mem_id.append_in(tmp_string);
  149.          tmp_string.append(fz_00);
  150.          cpp.put_string(tmp_string);
  151.          cpp.swap_on_c;
  152.          tmp_string.clear;
  153.          tmp_string.extend('T');
  154.          mem_id.append_in(tmp_string);
  155.          tmp_string.extend(' ');
  156.          tmp_string.extend('M');
  157.          mem_id.append_in(tmp_string);
  158.          tmp_string.extend('=');
  159.          tmp_string.extend('{');
  160.          if rc.is_tagged then
  161.             mem_id.append_in(tmp_string);
  162.             tmp_string.extend(',');
  163.          end;
  164.          type_bit.c_initialize_in(tmp_string);
  165.          tmp_string.extend('}');
  166.          tmp_string.append(fz_00);
  167.          cpp.put_string(tmp_string);
  168.          cpp.swap_on_h;
  169.          standard_c_print_function;
  170.       end;
  171.  
  172.    c_initialize is
  173.       do
  174.          cpp.put_string(fz_null);
  175.       end;
  176.  
  177.    c_initialize_in(str: STRING) is
  178.       do
  179.          str.append(fz_null);
  180.       end;
  181.  
  182.    c_type_for_argument_in(str: STRING) is
  183.       do
  184.          str.append(fz_t0_star);
  185.       end;
  186.  
  187.    c_type_for_target_in(str: STRING) is
  188.       do
  189.          str.extend('T');
  190.          id.append_in(str);
  191.          str.extend('*');
  192.       end;
  193.  
  194.    c_type_for_result_in(str: STRING) is
  195.       do
  196.          str.append(fz_t0_star);
  197.       end;
  198.  
  199.    run_type: TYPE_BIT_REF is
  200.       do
  201.          Result := Current;
  202.       end;
  203.  
  204.    used_as_reference is
  205.       do
  206.       end;
  207.  
  208.    to_reference is
  209.       do
  210.       end;
  211.  
  212.    jvm_descriptor_in(str: STRING) is
  213.       do
  214.          str.append(jvm_root_descriptor);
  215.       end;
  216.  
  217.    jvm_target_descriptor_in(str: STRING) is
  218.       do
  219.       end;
  220.  
  221.    jvm_return_code is
  222.       do
  223.       end;
  224.  
  225.    jvm_check_class_invariant is
  226.       do
  227.       end;
  228.  
  229.    jvm_push_local(offset: INTEGER) is
  230.       do
  231.          code_attribute.opcode_aload(offset);
  232.       end;
  233.  
  234.    jvm_push_default: INTEGER is
  235.       do
  236.          code_attribute.opcode_aconst_null;
  237.          Result := 1;
  238.       end;
  239.  
  240.    jvm_write_local(offset: INTEGER) is
  241.       do
  242.          code_attribute.opcode_astore(offset);
  243.       end;
  244.  
  245.    jvm_xnewarray is
  246.       local
  247.          idx: INTEGER;
  248.       do
  249.          idx := constant_pool.idx_jvm_root_class;
  250.          code_attribute.opcode_anewarray(idx);
  251.       end;
  252.  
  253.    jvm_xastore is
  254.       do
  255.          code_attribute.opcode_aastore;
  256.       end;
  257.  
  258.    jvm_xaload is
  259.       do
  260.          code_attribute.opcode_aaload;
  261.       end;
  262.  
  263.    jvm_if_x_eq: INTEGER is
  264.       do
  265.          Result := code_attribute.opcode_if_acmpeq;
  266.       end;
  267.  
  268.    jvm_if_x_ne: INTEGER is
  269.       do
  270.          Result := code_attribute.opcode_if_acmpne;
  271.       end;
  272.  
  273.    jvm_to_reference is
  274.       do
  275.       end;
  276.  
  277.    jvm_expanded_from_reference(other: TYPE): INTEGER is
  278.       do
  279.          check
  280.             false
  281.          end;
  282.       end;
  283.  
  284.    jvm_convert_to(destination: TYPE): INTEGER is
  285.       do
  286.          if destination.is_expanded then
  287.             Result := destination.jvm_expanded_from_reference(Current);
  288.          else
  289.             Result := 1;
  290.          end;
  291.       end;
  292.  
  293.    jvm_standard_is_equal is
  294.       local
  295.          rc: RUN_CLASS;
  296.          wa: ARRAY[RUN_FEATURE_2];
  297.       do
  298.          rc := run_class;
  299.          wa := rc.writable_attributes;
  300.          jvm.std_is_equal(rc,wa);
  301.       end;
  302.  
  303.    to_runnable(rt: TYPE): like Current is
  304.       do
  305.          Result := Current;
  306.       end;
  307.  
  308.    base_class_name: CLASS_NAME is
  309.       once
  310.          !!Result.make(as_bit_n_ref,Void);
  311.       end;
  312.  
  313.    id: INTEGER is
  314.       do
  315.          Result := run_class.id;
  316.       end;
  317.  
  318.    smallest_ancestor(other: TYPE): TYPE is
  319.       do
  320.          if run_time_mark = other.run_time_mark then
  321.             Result := Current;
  322.          else
  323.             Result := type_any;
  324.          end;
  325.       end;
  326.  
  327.    is_a(other: TYPE): BOOLEAN is
  328.       do
  329.          if run_time_mark = other.run_time_mark then
  330.             Result := true;
  331.          else
  332.             Result := base_class.is_subclass_of(other.base_class);
  333.             if not Result then
  334.                eh.add_type(Current,fz_inako);
  335.                eh.add_type(other,fz_dot);
  336.             end;
  337.          end;
  338.       end;
  339.  
  340.    start_position: POSITION is do end;
  341.  
  342.    has_creation(fn: FEATURE_NAME): BOOLEAN is do end;
  343.  
  344.    need_c_struct: BOOLEAN is true;
  345.  
  346. feature {RUN_CLASS,TYPE}
  347.  
  348.    need_gc_mark_function: BOOLEAN is true;
  349.  
  350.    just_before_gc_mark_in(str: STRING) is
  351.       do
  352.          standard_just_before_gc_mark_in(str);
  353.       end;
  354.  
  355.    gc_info_in(str: STRING) is
  356.       do
  357.          standard_gc_info_in(str);
  358.       end;
  359.  
  360.    gc_define1 is
  361.       do
  362.          standard_gc_define1;
  363.       end;
  364.  
  365.    gc_define2 is
  366.       do
  367.          standard_gc_define2;
  368.       end;
  369.  
  370. feature {TYPE}
  371.  
  372.    frozen short_hook is
  373.       do
  374.          short_print.a_class_name(base_class_name);
  375.       end;
  376.  
  377. invariant
  378.  
  379.    type_bit /= Void
  380.  
  381. end -- TYPE_BIT_REF
  382.  
  383.