示例#1
0
/*
 * feature -- Comparison
 */

        public override bool Equals(object other)
        // Is Current equal to `other'?
        {
            RT_CLASS_TYPE l_other = other as RT_CLASS_TYPE;

            return(l_other != null && (type.Value == l_other.type.Value));
        }
示例#2
0
 public virtual bool valid_generic(RT_CLASS_TYPE a_type)
 // Do the generic parameters of `type' conform to those of Current?
 // Assumes that `a_type' base class conforms to current's base class.
 {
         #if ASSERTIONS
     ASSERTIONS.REQUIRE("a_type_not_null", a_type != null);
         #endif
     return(true);
 }
示例#3
0
/*
 * feature -- Conformance
 */
        public override bool conform_to(RT_TYPE other)
        // Does `Current' conform to `other'?
        {
            RT_CLASS_TYPE l_other = other as RT_CLASS_TYPE;
            bool          Result  = l_other != null;

            if (Result)
            {
                Result = l_other.dotnet_type().IsAssignableFrom(dotnet_type()) &&
                         l_other.valid_generic(this);
            }
            return(Result);
        }
示例#4
0
/*
 * feature -- Conformance
 */
        public override bool valid_generic(RT_CLASS_TYPE a_type)
        // Do the generic parameters of `type' conform to those of Current?
        // Assumes that `a_type' base class conforms to current's base class.
        {
            bool            Result = false;
            RT_GENERIC_TYPE l_type;

            RT_TYPE [] l_generics, l_type_generics;
            int        i, nb;

                #if ASSERTIONS
            ASSERTIONS.REQUIRE("a_type_not_null", a_type != null);
                #endif

            if (type.Value == a_type.type.Value)
            {
                // Types are the same, check that their generic paramters are conformant
                Result = true;
                l_type = a_type as RT_GENERIC_TYPE;
                        #if ASSERTIONS
                ASSERTIONS.CHECK("l_type_not_void", l_type != null);
                ASSERTIONS.CHECK("same_count", count == l_type.count);
                        #endif
                l_generics      = generics;
                l_type_generics = l_type.generics;
                nb = count;
                for (i = 0; (i < nb) && Result; i++)
                {
                    Result = (l_type_generics [i]).conform_to(l_generics [i]);
                }
            }
            else
            {
                // `type' is a descendant type of Current: so we
                // have to check the current generic parameters
                // FIXME: We cannot do that because we do not have a parent table.
                //        for now we simply return True as we know that we have
                //        conformance of classes.
                Result = true;
            }
            return(Result);
        }
示例#5
0
/*
 * feature -- Status Report
 */
        public override RT_TYPE evaluated_type(RT_GENERIC_TYPE context_type)
        // Evaluate Current in context of `context_type'.
        {
            RT_GENERIC_TYPE Result;

            RT_TYPE [] l_generics, l_other_generics;
            int        i, nb;

            if (has_formal())
            {
                i  = 0;
                nb = count;

                // Duplicate current data as after the evaluation in context
                // of `context_type' it will be the same except for `generics'
                // which will only contained fully evaluated types that's why
                // `generics' is created of type `RT_CLASS_TYPE []'.
                Result           = (RT_GENERIC_TYPE)MemberwiseClone();
                l_other_generics = new RT_CLASS_TYPE [nb];
                Result.set_generics(l_other_generics);

                // Evaluate all types contained in `generics' in context of `context_type'
                l_generics = generics;
                for (; i < nb; i++)
                {
                                #if ASSERTIONS
                    ASSERTIONS.CHECK("Valid element type",
                                     l_generics [i].evaluated_type(context_type) is RT_CLASS_TYPE);
                                #endif
                    l_other_generics [i] = l_generics [i].evaluated_type(context_type);
                }
                Result.set_has_formal(false);
            }
            else
            {
                Result = this;
            }
            return(Result);
        }
示例#6
0
        // Given an Eiffel object `an_obj' extract its type information.
        public static RT_TYPE load_type_of_object(object an_obj)
        {
            RT_GENERIC_TYPE l_gen_type;
            RT_CLASS_TYPE Result;
            EIFFEL_TYPE_INFO l_obj = an_obj as EIFFEL_TYPE_INFO;

            if (l_obj != null) {
            l_gen_type = l_obj.____type ();
            } else {
            l_gen_type = null;
            }

            if (l_gen_type == null) {
                // It is not an Eiffel generic type or it is a .NET type, so we can simply
                // find its type through Reflection and then creates a RT_CLASS_TYPE object.
                // Note that .NET generic types are treated as non-generic.
            Result = new RT_CLASS_TYPE ();
            Result.set_type (an_obj.GetType ().TypeHandle);
            } else {
                // It is a generic type, so we can simply find its type through
                // its RT_GENERIC_TYPE.
            Result = l_gen_type;
            }
            return Result;
        }
示例#7
0
        // Do the generic parameters of `type' conform to those of Current?
        // Assumes that `a_type' base class conforms to current's base class.
        // Does current generic type has formals?
        /*
        feature -- Conformance
        */
        public override bool valid_generic(RT_CLASS_TYPE a_type)
        {
            bool Result = false;
            RT_GENERIC_TYPE l_type;
            RT_TYPE [] l_generics, l_type_generics;
            int i, nb;

            #if ASSERTIONS
            ASSERTIONS.REQUIRE("a_type_not_null", a_type != null);
            #endif

            if (type.Value == a_type.type.Value) {
                // Types are the same, check that their generic paramters are conformant
            Result = true;
            l_type = a_type as RT_GENERIC_TYPE;
            #if ASSERTIONS
                ASSERTIONS.CHECK("l_type_not_void", l_type != null);
                ASSERTIONS.CHECK("same_count", count == l_type.count);
            #endif
            l_generics = generics;
            l_type_generics = l_type.generics;
            nb = count;
            for (i = 0; (i < nb) && Result; i++) {
                Result = (l_type_generics [i]).conform_to (l_generics [i]);
            }
            } else {
                // `type' is a descendant type of Current: so we
                // have to check the current generic parameters
                // FIXME: We cannot do that because we do not have a parent table.
                //        for now we simply return True as we know that we have
                //        conformance of classes.
            Result = true;
            }
            return Result;
        }
示例#8
0
        // Evaluate Current in context of `context_type'.
        /*
        feature -- Status Report
        */
        public override RT_TYPE evaluated_type(RT_GENERIC_TYPE context_type)
        {
            RT_GENERIC_TYPE Result;
            RT_TYPE [] l_generics, l_other_generics;
            int i, nb;

            if (has_formal ()) {
            i = 0;
            nb = count;

                // Duplicate current data as after the evaluation in context
                // of `context_type' it will be the same except for `generics'
                // which will only contained fully evaluated types that's why
                // `generics' is created of type `RT_CLASS_TYPE []'.
            Result = (RT_GENERIC_TYPE) MemberwiseClone();
            l_other_generics = new RT_CLASS_TYPE [nb];
            Result.set_generics (l_other_generics);

                // Evaluate all types contained in `generics' in context of `context_type'
            l_generics = generics;
            for (; i < nb ; i ++) {
                #if ASSERTIONS
                    ASSERTIONS.CHECK ("Valid element type",
                        l_generics [i].evaluated_type (context_type) is RT_CLASS_TYPE);
                #endif
                l_other_generics [i] = l_generics [i].evaluated_type (context_type);
            }
            Result.set_has_formal (false);
            } else {
            Result = this;
            }
            return Result;
        }
示例#9
0
 // Do the generic parameters of `type' conform to those of Current?
 // Assumes that `a_type' base class conforms to current's base class.
 public virtual bool valid_generic(RT_CLASS_TYPE a_type)
 {
     #if ASSERTIONS
     ASSERTIONS.REQUIRE("a_type_not_null", a_type != null);
     #endif
     return true;
 }
示例#10
0
/*
feature -- Object creation
*/

	public static object create_type (RT_CLASS_TYPE a_type)
		// Create new instance of `a_type'.
	{
			// Create new object of type `a_type'.
			// Properly initializes `Result'.
		return GENERIC_CONFORMANCE.create_instance
			(Type.GetTypeFromHandle (a_type.type),
			a_type as RT_GENERIC_TYPE);
	}
示例#11
0
文件: any.cs 项目: tioui/EiffelStudio
        // Name of Current object's generating type
        // (type of which it is a direct instance)
        public static string generating_type(object Current)
        {
            string Result = null;
            RT_CLASS_TYPE l_type;
            EIFFEL_TYPE_INFO l_current = Current as EIFFEL_TYPE_INFO;

            if (Current == null) {
            generate_call_on_void_target_exception ();
            } else if (l_current != null) {
            l_type = l_current.____type ();
            if (l_type == null) {
                    // Not a generic class.
                l_type = new RT_CLASS_TYPE (Type.GetTypeHandle (Current));
            }
            Result = l_type.type_name ();
            } else {
             			Result = Current.GetType().FullName;
            }
            return Result;
        }