Ejemplo n.º 1
0
 private static Type GetWidestType(Type Type1, Type Type2)
 {
     if ((Type1 != null) && (Type2 != null))
     {
         if (!Type1.IsEnum && !Type2.IsEnum)
         {
             TypeCode typeCode = Symbols.GetTypeCode(Type1);
             TypeCode code2    = Symbols.GetTypeCode(Type2);
             if (Symbols.IsNumericType(typeCode) && Symbols.IsNumericType(code2))
             {
                 return(Symbols.MapTypeCodeToType(ConversionResolution.ForLoopWidestTypeCode[(int)typeCode][(int)code2]));
             }
         }
         Symbols.Method operatorMethod = null;
         switch (ConversionResolution.ClassifyConversion(Type2, Type1, ref operatorMethod))
         {
         case ConversionResolution.ConversionClass.Identity:
         case ConversionResolution.ConversionClass.Widening:
             return(Type2);
         }
         operatorMethod = null;
         if (ConversionResolution.ClassifyConversion(Type1, Type2, ref operatorMethod) == ConversionResolution.ConversionClass.Widening)
         {
             return(Type1);
         }
     }
     return(null);
 }
 internal bool Lookup(Type TargetType, Type SourceType, ref ConversionResolution.ConversionClass Classification, ref Symbols.Method OperatorMethod)
 {
     int first = this.m_First;
     for (int i = 0; i < this.m_Count; i++)
     {
         if ((TargetType == this.m_List[first].TargetType) && (SourceType == this.m_List[first].SourceType))
         {
             Classification = this.m_List[first].Classification;
             OperatorMethod = this.m_List[first].OperatorMethod;
             this.MoveToFront(first);
             return true;
         }
         first = this.m_List[first].Next;
     }
     Classification = ConversionResolution.ConversionClass.Bad;
     OperatorMethod = null;
     return false;
 }
 internal void Insert(Type TargetType, Type SourceType, ConversionResolution.ConversionClass Classification, Symbols.Method OperatorMethod)
 {
     if (this.m_Count < this.m_Size)
     {
         this.m_Count++;
     }
     int last = this.m_Last;
     this.m_First = last;
     this.m_Last = this.m_List[this.m_Last].Previous;
     this.m_List[last].TargetType = TargetType;
     this.m_List[last].SourceType = SourceType;
     this.m_List[last].Classification = Classification;
     this.m_List[last].OperatorMethod = OperatorMethod;
 }