ImplicitConversionRequired() 공개 메소드

public ImplicitConversionRequired ( ResolveContext ec, System.TypeSpec type ) : Constant
ec ResolveContext
type System.TypeSpec
리턴 Constant
예제 #1
0
파일: enum.cs 프로젝트: raj581/Marvin
        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));
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
파일: enum.cs 프로젝트: nylen/SharpDevelop
		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);
		}
예제 #4
0
파일: field.cs 프로젝트: agallero/mono
		public override Constant ConvertInitializer (ResolveContext rc, Constant expr)
		{
			return expr.ImplicitConversionRequired (rc, rc.BuiltinTypes.Int, Location);
		}
예제 #5
0
 public override Constant ConvertInitializer(ResolveContext rc, Constant expr)
 {
     return expr.ImplicitConversionRequired (rc, TypeManager.int32_type, Location);
 }
예제 #6
0
 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));
 }