public static object create_array( int n, RT_TYPE a_type, EIFFEL_TYPE_INFO a_current, RuntimeTypeHandle any_type_handle ) // Create new instance of an array type whose element types are `a_type' in context of // `a_current' object. // Handles elements that are class types as well as formals. { RT_CLASS_TYPE type_to_create; // Evaluate type in context of Current object. type_to_create = (RT_CLASS_TYPE)a_type.evaluated_type(a_current.____type()); if (type_to_create.is_none() || (type_to_create.type.Value == any_type_handle.Value)) { return(new object [n]); } else { return(Array.CreateInstance( ISE_RUNTIME.interface_type(Type.GetTypeFromHandle(type_to_create.type)), n)); } }
/* * feature -- Status report */ public static bool conforms_to(object Current, object other) // Does type of current object conform to type // of `other' (as per Eiffel: The Language, chapter 13)? { bool Result = false; RT_GENERIC_TYPE l_current_type, l_other_type; EIFFEL_TYPE_INFO current_info = Current as EIFFEL_TYPE_INFO; EIFFEL_TYPE_INFO other_info = other as EIFFEL_TYPE_INFO; #if ASSERTIONS ASSERTIONS.REQUIRE("other_not_void", other != null); #endif if (Current == null) { generate_call_on_void_target_exception(); } else { if (other_info == null) { // `other' is not an Eiffel object, we simply check for .NET conformance Result = other.GetType().IsAssignableFrom(Current.GetType()); } else if (current_info == null) { // `other' is an Eiffel object, but not `Current', therefore there is // no conformance. We do nothing since `Result' is already initialized to // false. } else { l_current_type = current_info.____type(); l_other_type = other_info.____type(); if (l_other_type == null) { // Parent type represented by the `other' instance // is not generic, therefore `Current' should directly // conform to the parent type. Result = ISE_RUNTIME.interface_type(other_info.GetType()).IsAssignableFrom(Current.GetType()); } else if (l_current_type == null) { // Parent is generic, but not type represented by // `Current', so let's first check if it simply // conforms without looking at the generic parameter. Result = ISE_RUNTIME.interface_type(other_info.GetType()).IsAssignableFrom(Current.GetType()); if (Result) { // It does conform, so now we have to go through // the parents to make sure it has the same generic // derivation. // FIXME: we should use feature `conform_to' from RT_TYPE here. } } else { // Both types are generic. We first check if they // simply conforms. #if ASSERTIONS ASSERTIONS.CHECK("l_current_type_not_void", l_current_type != null); ASSERTIONS.CHECK("l_other_type_not_void", l_other_type != null); #endif Result = ISE_RUNTIME.interface_type(other_info.GetType()).IsAssignableFrom(Current.GetType()); if (Result) { Result = l_current_type.conform_to(l_other_type); } } } } return(Result); }