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