GetUnderlyingType() public method

public GetUnderlyingType ( ) : AggregateType
return AggregateType
Beispiel #1
0
        ////////////////////////////////////////////////////////////////////////////////
        // Given a symbol, determine its fundamental type. This is the type that
        // indicate how the item is stored and what instructions are used to reference
        // if. The fundamental types are:
        // one of the integral/float types (includes enums with that underlying type)
        // reference type
        // struct/value type
        public FUNDTYPE fundType()
        {
            switch (GetTypeKind())
            {
            case TypeKind.TK_AggregateType:
            {
                AggregateSymbol sym = ((AggregateType)this).getAggregate();

                // Treat enums like their underlying types.
                if (sym.IsEnum())
                {
                    sym = sym.GetUnderlyingType().getAggregate();
                }

                if (sym.IsStruct())
                {
                    // Struct type could be predefined (int, long, etc.) or some other struct.
                    if (sym.IsPredefined())
                    {
                        return(PredefinedTypeFacts.GetFundType(sym.GetPredefType()));
                    }
                    return(FUNDTYPE.FT_STRUCT);
                }
                return(FUNDTYPE.FT_REF);         // Interfaces, classes, delegates are reference types.
            }

            case TypeKind.TK_TypeParameterType:
                return(FUNDTYPE.FT_VAR);

            case TypeKind.TK_ArrayType:
            case TypeKind.TK_NullType:
                return(FUNDTYPE.FT_REF);

            case TypeKind.TK_PointerType:
                return(FUNDTYPE.FT_PTR);

            case TypeKind.TK_NullableType:
                return(FUNDTYPE.FT_STRUCT);

            default:
                return(FUNDTYPE.FT_NONE);
            }
        }