indexing description: "[ Representation of a compiled multi constrained formal parameter. Wherever possible we replace the formals by its selected constraint (like in a call g.f, where g's type is a multi-constrained formal generic.) In cases where this is not possible, like in g := another_conformant_to_type_of_g we still have to provide the right answers to the questions whether it is expanded or not. For this purposes this class is intended. ]" legal: "See notice at end of class." status: "See notice at end of class." date: "$Date$" revision: "$Revision$" class MULTI_FORMAL_I inherit TYPE_I redefine is_formal, is_multi_constrained, is_valid, same_as, has_true_formal, has_formal, instantiation_in, complete_instantiation_in, generated_id, is_explicit, generate_gen_type_il, generate_cid, generate_cid_array, generate_cid_init, make_gen_type_byte_code, is_reference, is_expanded, is_standalone, is_monomorph end SHARED_BYTE_CONTEXT export {NONE} all end create make feature {NONE} -- Initialization make (is_ref: like is_reference; is_exp: like is_expanded; is_mono: like is_monomorph; i: like position; a_constraint_position: like constraint_position) is -- Assign `i' to `position'. require valid_position: i > 0 do is_expanded := is_exp is_monomorph := is_mono position := i constraint_position := a_constraint_position ensure constraint_position_set: a_constraint_position = constraint_position is_expanded_set: is_expanded = is_exp is_monomorph_set: is_monomorph = is_mono position_set: position = i end feature -- Status report constraint_position: INTEGER element_type: INTEGER_8 is -- Formal element type. do -- Before we said that we should not be called, but now there is one case -- where we are called, it is when we try to create a NATIVE_ARRAY [G] where -- G is a formal generic parameter. In this case we actually considered that -- we have for the type system a NATIVE_ARRAY [SYSTEM_OBJECT]. Result := {MD_SIGNATURE_CONSTANTS}.element_type_object end tuple_code: INTEGER_8 is -- Multi Formal tuple code. do -- Before we said that we should not be called, but now we use `tuple_code' for the -- argument passing for our new implementation of expanded conformance with generics. -- For example the eweasel test#multicon005 exercises this code. Result := {SHARED_GEN_CONF_LEVEL}.reference_tuple_code end feature -- Access position: INTEGER -- Position of the formal in declarations is_reference: BOOLEAN is -- Is the type a reference type? do Result := True end is_expanded: BOOLEAN -- Is current constrained to be always an expanded? is_valid (a_class: CLASS_C): BOOLEAN is -- Is Current consistent and valid for `a_class'? do Result := a_class.is_generic and then position <= a_class.generics.count end hash_code: INTEGER is -- Hash code for current type do Result := Other_code + position end description: GENERIC_DESC is -- Descritpion of type for skeletons. do create Result Result.set_type_i (Current) end feature -- Status report is_formal: BOOLEAN is True -- Is the type a formal type ? is_multi_constrained: BOOLEAN is True -- Is the type a formal type ? is_monomorph: BOOLEAN -- Is the type monomorph? is_explicit: BOOLEAN is False is_standalone: BOOLEAN is False -- Is type standalone, i.e. does not depend on formal generic or acnhored type? has_true_formal, has_formal: BOOLEAN is True -- Has the type formal in its structure ? instantiation_in (other: CLASS_TYPE): TYPE_I is -- Instantiation of Current in context of `other' do Result := Current end complete_instantiation_in (other: CLASS_TYPE): TYPE_I is -- Instantiation of Current in context of `other'. do Result := other.type.true_generics.item (position) end name: STRING is -- Name of current type. do create Result.make (3) Result.append ("G#") Result.append_integer (position) end il_type_name (a_prefix: STRING): STRING is -- Name of current class type. do Result := name end type_a: FORMAL_A is -- Associated FORMAL_A object. do create Result.make (is_reference, is_expanded, is_monomorph, position) end feature -- Comparison same_as (other: TYPE_I): BOOLEAN is -- Is `other' equal to Current ? local other_formal: FORMAL_I do other_formal ?= other Result := other_formal /= Void and then other_formal.position = position and then is_reference = other.is_reference and then is_expanded = other.is_expanded end feature -- Generic conformance generated_id (final_mode: BOOLEAN): INTEGER is -- Id of a generic formal parameter. do Result := Formal_type end generate_cid (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN) is do buffer.put_integer (Formal_type) buffer.put_character (',') buffer.put_integer (position) buffer.put_character (',') end make_gen_type_byte_code (ba: BYTE_ARRAY; use_info: BOOLEAN) is do ba.append_short_integer (formal_type) ba.append_short_integer (position) end generate_cid_array (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; idx_cnt: COUNTER) is local dummy: INTEGER do buffer.put_integer (Formal_type) buffer.put_character (',') buffer.put_integer (position) buffer.put_character (',') dummy := idx_cnt.next dummy := idx_cnt.next end generate_cid_init (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; idx_cnt: COUNTER) is local dummy : INTEGER do -- Increment counter dummy := idx_cnt.next dummy := idx_cnt.next end feature -- Generic conformance for IL generate_gen_type_il (il_generator: IL_CODE_GENERATOR; use_info: BOOLEAN) is -- `use_info' is true iff we generate code for a -- creation instruction. do -- We must be in a generic class otherwise having a formal creation -- does not make sense. check generic_class: context.current_type.base_class.is_generic end -- Generate call to feature, defined in every descendant of -- the current generic class, that will -- create the corresponding runtime type associated with formal -- in descendant class. il_generator.generate_type_feature_call (context.current_type.base_class.formal_at_position (position)) end feature {NONE} -- Code generation generate_cecil_value (buffer: GENERATION_BUFFER) is do ensure then False end feature {NONE} -- Not applicable c_type: TYPE_C is -- Associated C type. do -- FIXME: we should not call it, but in case we have decided that it -- will always return a reference type Result := Reference_c_type end sk_value: INTEGER is -- Generate SK value associated to the current type. do -- This is called only when the actual generic parameter is a reference -- since in that case we create a MULTI_FORMAL_I to find which constraints -- to use if needed (See {BYTE_CONTEXT}.real_type) -- This is different from FORMAL_I.sk_value which is never called because -- we always use the constraint type of the FORMAL_I to resolve types. Result := sk_ref end indexing copyright: "Copyright (c) 1984-2006, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" copying: "[ This file is part of Eiffel Software's Eiffel Development Environment. Eiffel Software's Eiffel Development Environment is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License (available at the URL listed under "license" above). Eiffel Software's Eiffel Development Environment is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Eiffel Software's Eiffel Development Environment; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ]" source: "[ Eiffel Software 356 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end