public override Constant ConvertInitializer(ResolveContext rc, Constant expr) { if (expr is EnumConstant) { expr = ((EnumConstant)expr).Child; } var underlying = ((Enum)Parent).UnderlyingType; if (expr != null) { expr = expr.ImplicitConversionRequired(rc, underlying, Location); if (expr != null && !IsValidEnumType(expr.Type)) { Enum.Error_1008(Location, Report); expr = null; } } if (expr == null) { expr = New.Constantify(underlying, Location); } return(new EnumConstant(expr, MemberType)); }
protected override Constant DoResolveValue(EmitContext ec) { if (ValueExpr != null) { Constant c = ValueExpr.ResolveAsConstant(ec, this); if (c == null) { return(null); } if (c is EnumConstant) { c = ((EnumConstant)c).Child; } c = c.ImplicitConversionRequired(ec, ParentEnum.UnderlyingType, Location); if (c == null) { return(null); } if (!IsValidEnumType(c.Type)) { Enum.Error_1008(Location); return(null); } return(new EnumConstant(c, MemberType)); } if (prev_member == null) { return(new EnumConstant( New.Constantify(ParentEnum.UnderlyingType), MemberType)); } if (!prev_member.ResolveValue()) { return(null); } try { return((EnumConstant)prev_member.value.Increment()); } catch (OverflowException) { Report.Error(543, Location, "The enumerator value `{0}' is too " + "large to fit in its type `{1}'", GetSignatureForError(), TypeManager.CSharpName(ParentEnum.UnderlyingType)); return(null); } }
public override Constant ConvertInitializer (ResolveContext rc, Constant expr) { if (expr is EnumConstant) expr = ((EnumConstant) expr).Child; var underlying = ((Enum) Parent).UnderlyingType; if (expr != null) { expr = expr.ImplicitConversionRequired (rc, underlying, Location); if (expr != null && !IsValidEnumType (expr.Type)) { Enum.Error_1008 (Location, Report); expr = null; } } if (expr == null) expr = New.Constantify (underlying, Location); return new EnumConstant (expr, MemberType); }
public override Constant ConvertInitializer (ResolveContext rc, Constant expr) { return expr.ImplicitConversionRequired (rc, rc.BuiltinTypes.Int, Location); }
public override Constant ConvertInitializer(ResolveContext rc, Constant expr) { return expr.ImplicitConversionRequired (rc, TypeManager.int32_type, Location); }
public override Constant ConvertInitializer(ResolveContext rc, Constant expr) { return(expr.ImplicitConversionRequired(rc, rc.BuiltinTypes.Int, Location)); }
public override Constant ConvertInitializer(ResolveContext rc, Constant expr) { return(expr.ImplicitConversionRequired(rc, TypeManager.int32_type, Location)); }