private ExprTypeOf CreateTypeOf(ExprTypeOrNamespace pSourceType) { ExprTypeOf rval = new ExprTypeOf(); rval.Kind = ExpressionKind.EK_TYPEOF; rval.Type = GetTypes().GetReqPredefAgg(PredefinedType.PT_TYPE).getThisType(); rval.Flags = EXPRFLAG.EXF_CANTBENULL; rval.SourceType = pSourceType; Debug.Assert(rval != null); return(rval); }
public ImplicitConversion(ExpressionBinder binder, Expr exprSrc, CType typeSrc, ExprTypeOrNamespace typeDest, bool needsExprDest, CONVERTTYPE flags) { _binder = binder; _exprSrc = exprSrc; _typeSrc = typeSrc; _typeDest = typeDest.TypeOrNamespace.AsType(); _exprTypeDest = typeDest; _needsExprDest = needsExprDest; _flags = flags; _exprDest = null; }
// ---------------------------------------------------------------------------- // BindExplicitConversion // ---------------------------------------------------------------------------- public ExplicitConversion(ExpressionBinder binder, Expr exprSrc, CType typeSrc, ExprTypeOrNamespace typeDest, CType pDestinationTypeForLambdaErrorReporting, bool needsExprDest, CONVERTTYPE flags) { _binder = binder; _exprSrc = exprSrc; _typeSrc = typeSrc; _typeDest = typeDest.TypeOrNamespace.AsType(); _pDestinationTypeForLambdaErrorReporting = pDestinationTypeForLambdaErrorReporting; _exprTypeDest = typeDest; _needsExprDest = needsExprDest; _flags = flags; _exprDest = null; }
public ExprCast CreateCast(EXPRFLAG nFlags, ExprTypeOrNamespace pType, Expr pArg) { Debug.Assert(pArg != null); Debug.Assert(pType != null); Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_CAST_ALL | EXPRFLAG.EXF_MASK_ANY))); ExprCast rval = new ExprCast(); rval.Type = pType.TypeOrNamespace as CType; rval.Kind = ExpressionKind.EK_CAST; rval.Argument = pArg; rval.Flags = nFlags; rval.DestinationType = pType; Debug.Assert(rval != null); return(rval); }
private Expr CreateZeroInit(ExprTypeOrNamespace pTypeExpr, Expr pOptionalOriginalConstructorCall, bool isConstructor) { Debug.Assert(pTypeExpr != null); CType pType = pTypeExpr.TypeOrNamespace.AsType(); bool bIsError = false; if (pType.isEnumType()) { // For enum types, we create a constant that has the default value // as an object pointer. ExprConstant expr = CreateConstant(pType, ConstVal.Get(Activator.CreateInstance(pType.AssociatedSystemType))); return(expr); } switch (pType.fundType()) { default: bIsError = true; break; case FUNDTYPE.FT_PTR: { CType nullType = GetTypes().GetNullType(); // It looks like this if is always false ... if (nullType.fundType() == pType.fundType()) { // Create a constant here. ExprConstant expr = CreateConstant(pType, ConstVal.GetDefaultValue(ConstValKind.IntPtr)); return(expr); } // Just allocate a new node and fill it in. ExprCast cast = CreateCast(0, pTypeExpr, CreateNull()); return(cast); } case FUNDTYPE.FT_REF: case FUNDTYPE.FT_I1: case FUNDTYPE.FT_U1: case FUNDTYPE.FT_I2: case FUNDTYPE.FT_U2: case FUNDTYPE.FT_I4: case FUNDTYPE.FT_U4: case FUNDTYPE.FT_I8: case FUNDTYPE.FT_U8: case FUNDTYPE.FT_R4: case FUNDTYPE.FT_R8: { ExprConstant expr = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind())); ExprConstant exprInOriginal = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind())); exprInOriginal.OptionalConstructorCall = pOptionalOriginalConstructorCall; return(expr); } case FUNDTYPE.FT_STRUCT: if (pType.isPredefType(PredefinedType.PT_DECIMAL)) { ExprConstant expr = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind())); ExprConstant exprOriginal = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind())); exprOriginal.OptionalConstructorCall = pOptionalOriginalConstructorCall; return(expr); } break; case FUNDTYPE.FT_VAR: break; } ExprZeroInit rval = new ExprZeroInit(); rval.Kind = ExpressionKind.EK_ZEROINIT; rval.Type = pType; rval.Flags = 0; rval.OptionalConstructorCall = pOptionalOriginalConstructorCall; rval.IsConstructor = isConstructor; if (bIsError) { rval.SetError(); } Debug.Assert(rval != null); return(rval); }
private Expr CreateZeroInit(ExprTypeOrNamespace pTypeExpr) { return(CreateZeroInit(pTypeExpr, null, false)); }
protected virtual Expr VisitTYPEORNAMESPACE(ExprTypeOrNamespace pExpr) { return(VisitEXPR(pExpr)); }