• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CSharp.Constant类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mono.CSharp.Constant的典型用法代码示例。如果您正苦于以下问题:C# Constant类的具体用法?C# Constant怎么用?C# Constant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Constant类属于Mono.CSharp命名空间,在下文中一共展示了Constant类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConvertPromotion

		static bool ConvertPromotion (ref Constant prim, ref Constant second, Type type)
		{
			Constant c = prim.ConvertImplicitly (type);
			if (c != null) {
				prim = c;
				return true;
			}

			if (type == TypeManager.uint32_type) {
				type = TypeManager.int64_type;
				prim = prim.ConvertImplicitly (type);
				second = second.ConvertImplicitly (type);
				return prim != null && second != null;
			}

			return false;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:17,代码来源:cfold.cs


示例2: ConvertPromotion

		static bool ConvertPromotion (ResolveContext rc, ref Constant prim, ref Constant second, TypeSpec type)
		{
			Constant c = prim.ConvertImplicitly (type);
			if (c != null) {
				prim = c;
				return true;
			}

			if (type.BuiltinType == BuiltinTypeSpec.Type.UInt) {
				type = rc.BuiltinTypes.Long;
				prim = prim.ConvertImplicitly (type);
				second = second.ConvertImplicitly (type);
				return prim != null && second != null;
			}

			return false;
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:17,代码来源:cfold.cs


示例3: DoBinaryNumericPromotions

		//
		// Performs the numeric promotions on the left and right expresions
		// and deposits the results on `lc' and `rc'.
		//
		// On success, the types of `lc' and `rc' on output will always match,
		// and the pair will be one of:
		//
		static bool DoBinaryNumericPromotions (ref Constant left, ref Constant right)
		{
			Type ltype = left.Type;
			Type rtype = right.Type;

			foreach (Type t in binary_promotions) {
				if (t == ltype)
					return t == rtype || ConvertPromotion (ref right, ref left, t);

				if (t == rtype)
					return t == ltype || ConvertPromotion (ref left, ref right, t);
			}

			left = left.ConvertImplicitly (TypeManager.int32_type);
			right = right.ConvertImplicitly (TypeManager.int32_type);
			return left != null && right != null;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:24,代码来源:cfold.cs


示例4: DoBinaryNumericPromotions

		//
		// Performs the numeric promotions on the left and right expresions
		// and deposits the results on `lc' and `rc'.
		//
		// On success, the types of `lc' and `rc' on output will always match,
		// and the pair will be one of:
		//
		// TODO: BinaryFold should be called as an optimization step only,
		// error checking here is weak
		//		
		static bool DoBinaryNumericPromotions (ResolveContext rc, ref Constant left, ref Constant right)
		{
			TypeSpec ltype = left.Type;
			TypeSpec rtype = right.Type;

			foreach (TypeSpec t in rc.BuiltinTypes.BinaryPromotionsTypes) {
				if (t == ltype)
					return t == rtype || ConvertPromotion (rc, ref right, ref left, t);

				if (t == rtype)
					return t == ltype || ConvertPromotion (rc, ref left, ref right, t);
			}

			left = left.ConvertImplicitly (rc.BuiltinTypes.Int);
			right = right.ConvertImplicitly (rc.BuiltinTypes.Int);
			return left != null && right != null;
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:27,代码来源:cfold.cs


示例5: CreateDecimalConstantAttribute

        public static CustomAttributeBuilder CreateDecimalConstantAttribute(Constant c)
        {
            PredefinedAttribute pa = PredefinedAttributes.Get.DecimalConstant;
            if (pa.Constructor == null &&
                !pa.ResolveConstructor (c.Location, TypeManager.byte_type, TypeManager.byte_type,
                    TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type))
                return null;

            Decimal d = (Decimal) c.GetValue ();
            int [] bits = Decimal.GetBits (d);
            object [] args = new object [] {
                (byte) (bits [3] >> 16),
                (byte) (bits [3] >> 31),
                (uint) bits [2], (uint) bits [1], (uint) bits [0]
            };

            return new CustomAttributeBuilder (pa.Constructor, args);
        }
开发者ID:speier,项目名称:shake,代码行数:18,代码来源:const.cs


示例6: ConvertInitializer

		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);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:19,代码来源:enum.cs


示例7: DoBinaryNumericPromotions

		//
		// Performs the numeric promotions on the left and right expresions
		// and deposits the results on `lc' and `rc'.
		//
		// On success, the types of `lc' and `rc' on output will always match,
		// and the pair will be one of:
		//
		// TODO: BinaryFold should be called as an optimization step only,
		// error checking here is weak
		//		
		static bool DoBinaryNumericPromotions (ResolveContext rc, ref Constant left, ref Constant right)
		{
			TypeSpec ltype = left.Type;
			TypeSpec rtype = right.Type;

			// PlayScript - AS has bool as an additional binary promotion type.
			TypeSpec[] binaryPromotionsTypes = (rc.FileType == SourceFileType.PlayScript ? 
			                                    rc.BuiltinTypes.AsBinaryPromotionsTypes : rc.BuiltinTypes.BinaryPromotionsTypes);

			foreach (TypeSpec t in binaryPromotionsTypes) {
				if (t == ltype)
					return t == rtype || ConvertPromotion (rc, ref right, ref left, t);

				if (t == rtype)
					return t == ltype || ConvertPromotion (rc, ref left, ref right, t);
			}

			left = left.ConvertImplicitly (rc.BuiltinTypes.Int, rc);
			right = right.ConvertImplicitly (rc.BuiltinTypes.Int, rc);
			return left != null && right != null;
		}
开发者ID:edisontung,项目名称:playscript-mono,代码行数:31,代码来源:cfold.cs


示例8: CheckUselessComparison

		private void CheckUselessComparison (ResolveContext ec, Constant c, Type type)
		{
			if (c == null || !IsTypeIntegral (type)
				|| c is StringConstant
				|| c is BoolConstant
				|| c is FloatConstant
				|| c is DoubleConstant
				|| c is DecimalConstant
				)
				return;

			long value = 0;

			if (c is ULongConstant) {
				ulong uvalue = ((ULongConstant) c).Value;
				if (uvalue > long.MaxValue) {
					if (type == TypeManager.byte_type ||
					    type == TypeManager.sbyte_type ||
					    type == TypeManager.short_type ||
					    type == TypeManager.ushort_type ||
					    type == TypeManager.int32_type ||
					    type == TypeManager.uint32_type ||
					    type == TypeManager.int64_type ||
						type == TypeManager.char_type)
						WarnUselessComparison (ec, type);
					return;
				}
				value = (long) uvalue;
			}
			else if (c is ByteConstant)
				value = ((ByteConstant) c).Value;
			else if (c is SByteConstant)
				value = ((SByteConstant) c).Value;
			else if (c is ShortConstant)
				value = ((ShortConstant) c).Value;
			else if (c is UShortConstant)
				value = ((UShortConstant) c).Value;
			else if (c is IntConstant)
				value = ((IntConstant) c).Value;
			else if (c is UIntConstant)
				value = ((UIntConstant) c).Value;
			else if (c is LongConstant)
				value = ((LongConstant) c).Value;
			else if (c is CharConstant)
				value = ((CharConstant)c).Value;

			if (value == 0)
				return;

			if (IsValueOutOfRange (value, type))
				WarnUselessComparison (ec, type);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:52,代码来源:expression.cs


示例9: EnumConstant

 public EnumConstant(Constant child, TypeSpec enum_type)
     : base(child.Location)
 {
     this.Child = child;
     this.type = enum_type;
 }
开发者ID:speier,项目名称:shake,代码行数:6,代码来源:ecore.cs


示例10: Visit

			public override object Visit (Constant constant)
			{
				if (constant.GetValue () == null) 
					return new NullReferenceExpression (Convert (constant.Location));
				string literalValue;
				if (constant is ILiteralConstant) {
					literalValue = new string (((ILiteralConstant)constant).ParsedValue);
				} else {
					literalValue = constant.GetValueAsLiteral ();
				}
				var result = new PrimitiveExpression (constant.GetValue (), Convert (constant.Location), literalValue);
				return result;
			}
开发者ID:aleksandersumowski,项目名称:monodevelop,代码行数:13,代码来源:CSharpParser.cs


示例11: Visit

		public virtual object Visit (Constant constant)
		{
			return null;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs


示例12: ConvertInitializer

		public override Constant ConvertInitializer (ResolveContext rc, Constant expr)
		{
			return expr.ImplicitConversionRequired (rc, rc.BuiltinTypes.Int, Location);
		}
开发者ID:agallero,项目名称:mono,代码行数:4,代码来源:field.cs


示例13: Visit

			public override object Visit (Constant constant)
			{
				if (constant.GetValue () == null) 
					return new NullReferenceExpression (Convert (constant.Location));
				var result = new PrimitiveExpression (constant.GetValue (), Convert (constant.Location), constant.GetValueAsLiteral ().Length);
				return result;
			}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:7,代码来源:CSharpParser.cs


示例14: Visit

			public override object Visit(Constant constant)
			{
				if (constant.GetValue() == null)
					return new NullReferenceExpression(Convert(constant.Location));
				string literalValue;
				var literalConstant = constant as ILiteralConstant;
				literalValue = literalConstant != null ? new string(literalConstant.ParsedValue) : constant.GetValueAsLiteral();
				object val = constant.GetValue();
				if (val is bool)
					literalValue = (bool)val ? "true" : "false";
				var result = new PrimitiveExpression(val, Convert(constant.Location), literalValue);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:13,代码来源:CSharpParser.cs


示例15: Visit

			public override object Visit (Constant constant)
			{
				var result = new PrimitiveExpression (constant.GetValue (), Convert (constant.Location), constant.AsString ().Length);
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:5,代码来源:CSharpParser.cs


示例16: ConvertInitializer

 public override Constant ConvertInitializer(ResolveContext rc, Constant expr)
 {
     return expr.ImplicitConversionRequired (rc, TypeManager.int32_type, Location);
 }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:4,代码来源:field.cs


示例17: EmptyConstantCast

		public EmptyConstantCast(Constant child, Type type)
			: base (child.Location)
		{
			eclass = child.eclass;
			this.child = child;
			this.type = type;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:7,代码来源:ecore.cs


示例18: EnumConstant

		public EnumConstant (Constant child, Type enum_type):
			base (child.Location)
		{
			eclass = child.eclass;
			this.Child = child;
			type = enum_type;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:7,代码来源:ecore.cs


示例19: ConvertImplicitly

		public override Constant ConvertImplicitly (Type type)
		{
			Type this_type = TypeManager.DropGenericTypeArguments (Type);
			type = TypeManager.DropGenericTypeArguments (type);

			if (this_type == type) {
				// This is workaround of mono bug. It can be removed when the latest corlib spreads enough
				if (TypeManager.IsEnumType (type.UnderlyingSystemType))
					return this;

				Type child_type = TypeManager.DropGenericTypeArguments (Child.Type);
				if (type.UnderlyingSystemType != child_type)
					Child = Child.ConvertImplicitly (type.UnderlyingSystemType);
				return this;
			}

			if (!Convert.ImplicitStandardConversionExists (this, type)){
				return null;
			}

			return Child.ConvertImplicitly(type);
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:22,代码来源:ecore.cs


示例20: Create

		public static Constant Create (Constant expr, Expression original_expr)
		{
			return new ReducedConstantExpression (expr, original_expr);
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:4,代码来源:ecore.cs



注:本文中的Mono.CSharp.Constant类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.Constructor类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.ConstInitializer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap