Beispiel #1
0
        //
        // Decimal constants cannot be encoded in the constant blob, and thus are marked
        // as IsInitOnly ('readonly' in C# parlance).  We get its value from the
        // DecimalConstantAttribute metadata.
        //
        public static IConstant CreateDecimal(FieldInfo fi)
        {
            if (fi is FieldBuilder)
            {
                return(null);
            }

            PredefinedAttribute pa = PredefinedAttributes.Get.DecimalConstant;

            if (!pa.IsDefined)
            {
                return(null);
            }

            object[] attrs = fi.GetCustomAttributes(pa.Type, false);
            if (attrs.Length != 1)
            {
                return(null);
            }

            IConstant ic = new ExternalConstant(fi,
                                                ((System.Runtime.CompilerServices.DecimalConstantAttribute)attrs [0]).Value);

            return(ic);
        }
Beispiel #2
0
        //
        // Decimal constants cannot be encoded in the constant blob, and thus are marked
        // as IsInitOnly ('readonly' in C# parlance).  We get its value from the
        // DecimalConstantAttribute metadata.
        //
        public static IConstant CreateDecimal(FieldInfo fi)
        {
            if (fi is FieldBuilder)
            {
                return(null);
            }

            if (TypeManager.decimal_constant_attribute_type == null)
            {
                return(null);
            }

            object[] attrs = fi.GetCustomAttributes(TypeManager.decimal_constant_attribute_type, false);
            if (attrs.Length != 1)
            {
                return(null);
            }

            IConstant ic = new ExternalConstant(fi,
                                                ((System.Runtime.CompilerServices.DecimalConstantAttribute)attrs [0]).Value);

            return(ic);
        }
Beispiel #3
0
		//
		// Decimal constants cannot be encoded in the constant blob, and thus are marked
		// as IsInitOnly ('readonly' in C# parlance).  We get its value from the 
		// DecimalConstantAttribute metadata.
		//
		public static IConstant CreateDecimal (FieldInfo fi)
		{
			if (fi is FieldBuilder)
				return null;

			if (TypeManager.decimal_constant_attribute_type == null)
				return null;

			object[] attrs = fi.GetCustomAttributes (TypeManager.decimal_constant_attribute_type, false);
			if (attrs.Length != 1)
				return null;

			IConstant ic = new ExternalConstant (fi,
				((System.Runtime.CompilerServices.DecimalConstantAttribute) attrs [0]).Value);

			return ic;
		}
Beispiel #4
0
		public override MemberExpr ResolveMemberAccess (EmitContext ec, Expression left, Location loc, SimpleName original)
		{
			constant = TypeManager.GetGenericFieldDefinition (constant);

			IConstant ic = TypeManager.GetConstant (constant);
			if (ic == null) {
				if (constant.IsLiteral) {
					ic = new ExternalConstant (constant);
				} else {
					ic = ExternalConstant.CreateDecimal (constant);
					// HACK: decimal field was not resolved as constant
					if (ic == null)
						return new FieldExpr (constant, loc).ResolveMemberAccess (ec, left, loc, original);
				}
				TypeManager.RegisterConstant (constant, ic);
			}

			return base.ResolveMemberAccess (ec, left, loc, original);
		}
		//
		// Decimal constants cannot be encoded in the constant blob, and thus are marked
		// as IsInitOnly ('readonly' in C# parlance).  We get its value from the 
		// DecimalConstantAttribute metadata.
		//
		public static IConstant CreateDecimal (FieldInfo fi)
		{
			if (fi is FieldBuilder)
				return null;

			PredefinedAttribute pa = PredefinedAttributes.Get.DecimalConstant;
			if (!pa.IsDefined)
				return null;

			object[] attrs = fi.GetCustomAttributes (pa.Type, false);
			if (attrs.Length != 1)
				return null;

			IConstant ic = new ExternalConstant (fi,
				((System.Runtime.CompilerServices.DecimalConstantAttribute) attrs [0]).Value);

			return ic;
		}