Esempio n. 1
0
/*
 * feature -- Comparison
 */
        public override bool Equals(Object other)
        // Is `other' similar to Current?
        {
            bool            Result  = false;
            RT_GENERIC_TYPE l_other = other as RT_GENERIC_TYPE;

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

            if (l_other != null)
            {
                nb = count;
                if ((type.Value == l_other.type.Value) && (nb == l_other.count))
                {
                    Result           = true;
                    l_generics       = generics;
                    l_other_generics = l_other.generics;
                    for (i = 0; (i < nb) && Result; i++)
                    {
                        Result = (l_generics [i]).Equals(l_other_generics [i]);
                    }
                }
            }
            return(Result);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 // Evaluate Current in context of `context_type'.
 public virtual RT_TYPE evaluated_type(RT_GENERIC_TYPE context_type)
 {
     return this;
 }
Esempio n. 4
0
 public virtual RT_TYPE evaluated_type(RT_GENERIC_TYPE context_type)
 // Evaluate Current in context of `context_type'.
 {
     return(this);
 }
Esempio n. 5
0
 // Evaluate Current in context of `context_type'.
 // Formal position.
 /*
 feature -- Status report
 */
 public override RT_TYPE evaluated_type(RT_GENERIC_TYPE context_type)
 {
     // Get type of formal in context of `a_current' object.
     return context_type.generics [position - 1];
 }
Esempio n. 6
0
 // Create instance of a given `type' with the type information
 // `computed_type' (if any).
 internal static object create_instance(Type type, RT_GENERIC_TYPE computed_type)
 {
     // Note: We use the `Activator' class because it is much faster than
     // creating an instance by getting the associated `ConstructorInfo'.
     if (computed_type == null ) {
         // Use argumentless constructor.
     return Activator.CreateInstance (type);
     } else {
         // Use constructor with a type parameter.
     return Activator.CreateInstance (type, new Object [] {computed_type});
     }
 }
Esempio n. 7
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;
        }
Esempio n. 8
0
        // Formal position.

/*
 * feature -- Status report
 */
        public override RT_TYPE evaluated_type(RT_GENERIC_TYPE context_type)
        // Evaluate Current in context of `context_type'.
        {
            // Get type of formal in context of `a_current' object.
            return(context_type.generics [position - 1]);
        }