Microsoft.CSharp.RuntimeBinder.Semantics.CType.fundType C# (CSharp) Méthode

fundType() public méthode

public fundType ( ) : FUNDTYPE
Résultat FUNDTYPE
        public FUNDTYPE fundType()
        {
            switch (GetTypeKind())
            {
                case TypeKind.TK_AggregateType:
                    {
                        AggregateSymbol sym = AsAggregateType().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;
            }
        }
        public ConstValKind constValKind()

Usage Example

Exemple #1
0
        ////////////////////////////////////////////////////////////////////////////////
        //
        // Precondition:
        //
        // type - Non-null
        //
        // This returns a null for reference types and an EXPRZEROINIT for all others.

        public Expr CreateZeroInit(CType type)
        {
            Debug.Assert(type != null);

            if (type.isEnumType())
            {
                // For enum types, we create a constant that has the default value
                // as an object pointer.
                return(CreateConstant(type, ConstVal.Get(Activator.CreateInstance(type.AssociatedSystemType))));
            }

            Debug.Assert(type.fundType() > FUNDTYPE.FT_NONE);
            Debug.Assert(type.fundType() < FUNDTYPE.FT_COUNT);
            switch (type.fundType())
            {
            case FUNDTYPE.FT_PTR:
            {
                // Just allocate a new node and fill it in.
                return(CreateCast(0, type, CreateNull()));
            }

            case FUNDTYPE.FT_STRUCT:
                if (type.isPredefType(PredefinedType.PT_DECIMAL))
                {
                    goto default;
                }

                goto case FUNDTYPE.FT_VAR;

            case FUNDTYPE.FT_VAR:
                return(new ExprZeroInit(type));

            default:
                return(CreateConstant(type, ConstVal.GetDefaultValue(type.constValKind())));
            }
        }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.CType::fundType