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


C# EmitContext.EmitNullableNew方法代码示例

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


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

示例1: EmitNullableConstant

		void EmitNullableConstant (EmitContext ec, Type type, object value)
		{
			if (value == null) {
				var local = ec.ig.DeclareLocal (type);
				ec.EmitNullableInitialize (local);
			} else {
				EmitConstant (ec, type.GetFirstGenericArgument (), value);
				ec.EmitNullableNew (type);
			}
		}
开发者ID:rabink,项目名称:mono,代码行数:10,代码来源:ConstantExpression.cs

示例2: EmitNullableConstant

		void EmitNullableConstant (EmitContext ec, Type type, object value)
		{
			if (value == null) {
				var ig = ec.ig;
				var local = ig.DeclareLocal (type);
				ig.Emit (OpCodes.Ldloca, local);
				ig.Emit (OpCodes.Initobj, type);
				ig.Emit (OpCodes.Ldloc, local);
			} else {
				EmitConstant (ec, type.GetFirstGenericArgument (), value);
				ec.EmitNullableNew (type);
			}
		}
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:13,代码来源:ConstantExpression.cs

示例3: EmitUserDefinedLiftedLogicalShortCircuit

		void EmitUserDefinedLiftedLogicalShortCircuit (EmitContext ec)
		{
			var ig = ec.ig;
			var and = NodeType == ExpressionType.AndAlso;

			var left_is_null = ig.DefineLabel ();
			var ret_left = ig.DefineLabel ();
			var ret_null = ig.DefineLabel ();
			var done = ig.DefineLabel ();

			var left = ec.EmitStored (this.left);

			ec.EmitNullableHasValue (left);
			ig.Emit (OpCodes.Brfalse, and ? ret_null : left_is_null);

			ec.EmitNullableGetValueOrDefault (left);
			ec.EmitCall (and ? GetFalseOperator () : GetTrueOperator ());
			ig.Emit (OpCodes.Brtrue, ret_left);

			ig.MarkLabel (left_is_null);
			var right = ec.EmitStored (this.right);
			ec.EmitNullableHasValue (right);
			ig.Emit (OpCodes.Brfalse, ret_null);

			ec.EmitNullableGetValueOrDefault (left);
			ec.EmitNullableGetValueOrDefault (right);
			ec.EmitCall (method);

			ec.EmitNullableNew (Type);
			ig.Emit (OpCodes.Br, done);

			ig.MarkLabel (ret_left);
			ec.EmitLoad (left);
			ig.Emit (OpCodes.Br, done);

			ig.MarkLabel (ret_null);
			var ret = ig.DeclareLocal (Type);
			ec.EmitNullableInitialize (ret);

			ig.MarkLabel (done);
		}
开发者ID:jskripsky,项目名称:mono,代码行数:41,代码来源:BinaryExpression.cs

示例4: EmitLiftedToNullUserDefinedOperator

		void EmitLiftedToNullUserDefinedOperator (EmitContext ec)
		{
			var ig = ec.ig;

			var ret = ig.DefineLabel ();
			var done = ig.DefineLabel ();

			var left = ec.EmitStored (this.left);
			var right = ec.EmitStored (this.right);

			ec.EmitNullableHasValue (left);
			ec.EmitNullableHasValue (right);
			ig.Emit (OpCodes.And);
			ig.Emit (OpCodes.Brfalse, ret);

			ec.EmitNullableGetValueOrDefault (left);
			ec.EmitNullableGetValueOrDefault (right);
			ec.EmitCall (method);
			ec.EmitNullableNew (Type);
			ig.Emit (OpCodes.Br, done);

			ig.MarkLabel (ret);
			var temp = ig.DeclareLocal (Type);
			ec.EmitNullableInitialize (temp);

			ig.MarkLabel (done);
		}
开发者ID:jskripsky,项目名称:mono,代码行数:27,代码来源:BinaryExpression.cs

示例5: EmitLiftedToNullBinary

		void EmitLiftedToNullBinary (EmitContext ec)
		{
			var ig = ec.ig;
			var left = ec.EmitStored (this.left);
			var right = ec.EmitStored (this.right);
			var result = ig.DeclareLocal (Type);

			var has_value = ig.DefineLabel ();
			var done = ig.DefineLabel ();

			ec.EmitNullableHasValue (left);
			ec.EmitNullableHasValue (right);
			ig.Emit (OpCodes.And);
			ig.Emit (OpCodes.Brtrue, has_value);

			ec.EmitNullableInitialize (result);

			ig.Emit (OpCodes.Br, done);

			ig.MarkLabel (has_value);

			ec.EmitNullableGetValueOrDefault (left);
			ec.EmitNullableGetValueOrDefault (right);

			EmitBinaryOperator (ec);

			ec.EmitNullableNew (result.LocalType);

			ig.MarkLabel (done);
		}
开发者ID:jskripsky,项目名称:mono,代码行数:30,代码来源:BinaryExpression.cs

示例6: EmitLiftedLogicalShortCircuit

		void EmitLiftedLogicalShortCircuit (EmitContext ec)
		{
			var ig = ec.ig;
			var and = NodeType == ExpressionType.AndAlso;
			var left_is_null = ig.DefineLabel ();
			var ret_from_left = ig.DefineLabel ();
			var ret_null = ig.DefineLabel ();
			var ret_new = ig.DefineLabel();
			var done = ig.DefineLabel();

			var left = ec.EmitStored (this.left);

			ec.EmitNullableHasValue (left);
			ig.Emit (OpCodes.Brfalse, left_is_null);

			ec.EmitNullableGetValueOrDefault (left);

			ig.Emit (OpCodes.Ldc_I4_0);
			ig.Emit (OpCodes.Ceq);
			ig.Emit (and ? OpCodes.Brtrue : OpCodes.Brfalse, ret_from_left);

			ig.MarkLabel (left_is_null);
			var right = ec.EmitStored (this.right);

			ec.EmitNullableHasValue (right);
			ig.Emit (OpCodes.Brfalse_S, ret_null);

			ec.EmitNullableGetValueOrDefault (right);

			ig.Emit (OpCodes.Ldc_I4_0);
			ig.Emit (OpCodes.Ceq);

			ig.Emit (and ? OpCodes.Brtrue : OpCodes.Brfalse, ret_from_left);

			ec.EmitNullableHasValue (left);
			ig.Emit (OpCodes.Brfalse, ret_null);

			ig.Emit (and ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0);
			ig.Emit (OpCodes.Br_S, ret_new);

			ig.MarkLabel (ret_from_left);
			ig.Emit (and ? OpCodes.Ldc_I4_0 : OpCodes.Ldc_I4_1);

			ig.MarkLabel (ret_new);
			ec.EmitNullableNew (Type);
			ig.Emit (OpCodes.Br, done);

			ig.MarkLabel (ret_null);
			var ret = ig.DeclareLocal (Type);
			ec.EmitNullableInitialize (ret);

			ig.MarkLabel (done);
		}
开发者ID:jskripsky,项目名称:mono,代码行数:53,代码来源:BinaryExpression.cs

示例7: EmitNullEquality

		void EmitNullEquality (EmitContext ec, Expression e)
		{
			var ig = ec.ig;

			if (IsLiftedToNull) {
				e.Emit (ec);
				if (e.Type != typeof (void))
					ig.Emit (OpCodes.Pop);

				ec.EmitNullableNew (typeof (bool?));
				return;
			}

			var se = ec.EmitStored (e);
			ec.EmitNullableHasValue (se);
			if (NodeType == ExpressionType.Equal) {
				ig.Emit (OpCodes.Ldc_I4_0);
				ig.Emit (OpCodes.Ceq);
			}		
		}
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:BinaryExpression.cs

示例8: EmitLiftedUnary

		void EmitLiftedUnary (EmitContext ec)
		{
			var ig = ec.ig;

			var from = ec.EmitStored (operand);
			var to = ig.DeclareLocal (Type);

			var has_value = ig.DefineLabel ();
			var done = ig.DefineLabel ();

			ec.EmitNullableHasValue (from);
			ig.Emit (OpCodes.Brtrue, has_value);

			// if not has value
			ec.EmitNullableInitialize (to);

			ig.Emit (OpCodes.Br, done);

			ig.MarkLabel (has_value);
			// if has value
			ec.EmitNullableGetValueOrDefault (from);

			EmitUnaryOperator (ec);

			ec.EmitNullableNew (Type);

			ig.MarkLabel (done);
		}
开发者ID:qwertie,项目名称:Theraot,代码行数:28,代码来源:UnaryExpression.net30.cs

示例9: EmitConvertToNullable

		void EmitConvertToNullable (EmitContext ec)
		{
			ec.Emit (operand);

			if (IsUnBoxing ()) {
				EmitUnbox (ec);
				return;
			}

			if (operand.Type != Type.GetNotNullableType ()) {
				EmitPrimitiveConversion (ec,
					operand.Type,
					Type.GetNotNullableType ());
			}

			ec.EmitNullableNew (Type);
		}
开发者ID:qwertie,项目名称:Theraot,代码行数:17,代码来源:UnaryExpression.net30.cs

示例10: EmitLeftLiftedToNullBinary

 private void EmitLeftLiftedToNullBinary(EmitContext emitContext)
 {
     var ig = emitContext.ig;
     var ret = ig.DefineLabel();
     var done = ig.DefineLabel();
     var left = emitContext.EmitStored(_left);
     emitContext.EmitNullableHasValue(left);
     ig.Emit(OpCodes.Brfalse, ret);
     emitContext.EmitNullableGetValueOrDefault(left);
     emitContext.Emit(_right);
     EmitBinaryOperator(emitContext);
     emitContext.EmitNullableNew(Type);
     ig.Emit(OpCodes.Br, done);
     ig.MarkLabel(ret);
     var temp = ig.DeclareLocal(Type);
     emitContext.EmitNullableInitialize(temp);
     ig.MarkLabel(done);
 }
开发者ID:qwertie,项目名称:Theraot,代码行数:18,代码来源:BinaryExpression.net30.cs


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