当前位置: 首页>>代码示例>>C#>>正文


C# EmitContext.EmitLong方法代码示例

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


在下文中一共展示了EmitContext.EmitLong方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Emit

		public override void Emit (EmitContext ec)
		{
			MethodSpec m;

			int [] words = decimal.GetBits (Value);
			int power = (words [3] >> 16) & 0xff;

			if (power == 0) {
				if (Value <= int.MaxValue && Value >= int.MinValue) {
					m = ec.Module.PredefinedMembers.DecimalCtorInt.Resolve (loc);
					if (m == null) {
						return;
					}

					ec.EmitInt ((int) Value);
					ec.Emit (OpCodes.Newobj, m);
					return;
				}

				if (Value <= long.MaxValue && Value >= long.MinValue) {
					m = ec.Module.PredefinedMembers.DecimalCtorLong.Resolve (loc);
					if (m == null) {
						return;
					}

					ec.EmitLong ((long) Value);
					ec.Emit (OpCodes.Newobj, m);
					return;
				}
			}

			ec.EmitInt (words [0]);
			ec.EmitInt (words [1]);
			ec.EmitInt (words [2]);

			// sign
			ec.EmitInt (words [3] >> 31);

			// power
			ec.EmitInt (power);

			m = ec.Module.PredefinedMembers.DecimalCtor.Resolve (loc);
			if (m != null) {
				ec.Emit (OpCodes.Newobj, m);
			}
		}
开发者ID:rabink,项目名称:mono,代码行数:46,代码来源:constant.cs

示例2: Emit

		public override void Emit (EmitContext ec)
		{
			int [] words = decimal.GetBits (Value);
			int power = (words [3] >> 16) & 0xff;

			if (power == 0) {
				if (Value <= int.MaxValue && Value >= int.MinValue) {
					if (TypeManager.void_decimal_ctor_int_arg == null) {
						TypeManager.void_decimal_ctor_int_arg = TypeManager.GetPredefinedConstructor (
							TypeManager.decimal_type, loc, TypeManager.int32_type);

						if (TypeManager.void_decimal_ctor_int_arg == null)
							return;
					}

					ec.EmitInt ((int) Value);
					ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_int_arg);
					return;
				}

				if (Value <= long.MaxValue && Value >= long.MinValue) {
					if (TypeManager.void_decimal_ctor_long_arg == null) {
						TypeManager.void_decimal_ctor_long_arg = TypeManager.GetPredefinedConstructor (
							TypeManager.decimal_type, loc, TypeManager.int64_type);

						if (TypeManager.void_decimal_ctor_long_arg == null)
							return;
					}

					ec.EmitLong ((long) Value);
					ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_long_arg);
					return;
				}
			}

			ec.EmitInt (words [0]);
			ec.EmitInt (words [1]);
			ec.EmitInt (words [2]);

			// sign
			ec.EmitInt (words [3] >> 31);

			// power
			ec.EmitInt (power);

			if (TypeManager.void_decimal_ctor_five_args == null) {
				TypeManager.void_decimal_ctor_five_args = TypeManager.GetPredefinedConstructor (
					TypeManager.decimal_type, loc, TypeManager.int32_type, TypeManager.int32_type,
					TypeManager.int32_type, TypeManager.bool_type, TypeManager.byte_type);

				if (TypeManager.void_decimal_ctor_five_args == null)
					return;
			}

			ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_five_args);
		}
开发者ID:jdecuyper,项目名称:mono,代码行数:56,代码来源:constant.cs

示例3: EmitObjectInteger

		void EmitObjectInteger (EmitContext ec, object k)
		{
			if (k is int)
				ec.EmitInt ((int) k);
			else if (k is Constant) {
				EmitObjectInteger (ec, ((Constant) k).GetValue ());
			} 
			else if (k is uint)
				ec.EmitInt (unchecked ((int) (uint) k));
			else if (k is long)
			{
				if ((long) k >= int.MinValue && (long) k <= int.MaxValue)
				{
					ec.EmitInt ((int) (long) k);
					ec.Emit (OpCodes.Conv_I8);
				}
				else
					ec.EmitLong ((long) k);
			}
			else if (k is ulong)
			{
				ulong ul = (ulong) k;
				if (ul < (1L<<32))
				{
					ec.EmitInt (unchecked ((int) ul));
					ec.Emit (OpCodes.Conv_U8);
				}
				else
				{
					ec.EmitLong (unchecked ((long) ul));
				}
			}
			else if (k is char)
				ec.EmitInt ((int) ((char) k));
			else if (k is sbyte)
				ec.EmitInt ((int) ((sbyte) k));
			else if (k is byte)
				ec.EmitInt ((int) ((byte) k));
			else if (k is short)
				ec.EmitInt ((int) ((short) k));
			else if (k is ushort)
				ec.EmitInt ((int) ((ushort) k));
			else if (k is bool)
				ec.EmitInt (((bool) k) ? 1 : 0);
			else
				throw new Exception ("Unhandled case");
		}
开发者ID:alisci01,项目名称:mono,代码行数:47,代码来源:statement.cs


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