本文整理汇总了C#中EmitContext.EmitNullableHasValue方法的典型用法代码示例。如果您正苦于以下问题:C# EmitContext.EmitNullableHasValue方法的具体用法?C# EmitContext.EmitNullableHasValue怎么用?C# EmitContext.EmitNullableHasValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmitContext
的用法示例。
在下文中一共展示了EmitContext.EmitNullableHasValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: EmitLiftedUserDefinedOperator
void EmitLiftedUserDefinedOperator (EmitContext ec)
{
var ig = ec.ig;
var ret_true = ig.DefineLabel ();
var ret_false = ig.DefineLabel ();
var done = ig.DefineLabel ();
var left = ec.EmitStored (this.left);
var right = ec.EmitStored (this.right);
ec.EmitNullableHasValue (left);
ec.EmitNullableHasValue (right);
switch (NodeType) {
case ExpressionType.Equal:
ig.Emit (OpCodes.Bne_Un, ret_false);
ec.EmitNullableHasValue (left);
ig.Emit (OpCodes.Brfalse, ret_true);
break;
case ExpressionType.NotEqual:
ig.Emit (OpCodes.Bne_Un, ret_true);
ec.EmitNullableHasValue (left);
ig.Emit (OpCodes.Brfalse, ret_false);
break;
default:
ig.Emit (OpCodes.And);
ig.Emit (OpCodes.Brfalse, ret_false);
break;
}
ec.EmitNullableGetValueOrDefault (left);
ec.EmitNullableGetValueOrDefault (right);
ec.EmitCall (method);
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (ret_true);
ig.Emit (OpCodes.Ldc_I4_1);
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (ret_false);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (done);
}
示例3: 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);
}
示例4: 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);
}
示例5: EmitLiftedRelationalBinary
void EmitLiftedRelationalBinary (EmitContext ec)
{
var ig = ec.ig;
var left = ec.EmitStored (this.left);
var right = ec.EmitStored (this.right);
var ret = ig.DefineLabel ();
var done = ig.DefineLabel ();
ec.EmitNullableGetValueOrDefault (left);
ec.EmitNullableGetValueOrDefault (right);
switch (NodeType) {
case ExpressionType.Equal:
case ExpressionType.NotEqual:
ig.Emit (OpCodes.Bne_Un, ret);
break;
default:
EmitBinaryOperator (ec);
ig.Emit (OpCodes.Brfalse, ret);
break;
}
ec.EmitNullableHasValue (left);
ec.EmitNullableHasValue (right);
switch (NodeType) {
case ExpressionType.Equal:
ig.Emit (OpCodes.Ceq);
break;
case ExpressionType.NotEqual:
ig.Emit (OpCodes.Ceq);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Ceq);
break;
default:
ig.Emit (OpCodes.And);
break;
}
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (ret);
ig.Emit (NodeType == ExpressionType.NotEqual ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0);
ig.MarkLabel (done);
}
示例6: EmitCoalesce
void EmitCoalesce (EmitContext ec)
{
var ig = ec.ig;
var done = ig.DefineLabel ();
var load_right = ig.DefineLabel ();
var left = ec.EmitStored (this.left);
var left_is_nullable = left.LocalType.IsNullable ();
if (left_is_nullable)
ec.EmitNullableHasValue (left);
else
ec.EmitLoad (left);
ig.Emit (OpCodes.Brfalse, load_right);
if (left_is_nullable && !Type.IsNullable ())
ec.EmitNullableGetValue (left);
else
ec.EmitLoad (left);
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (load_right);
ec.Emit (this.right);
ig.MarkLabel (done);
}
示例7: EmitConvertedCoalesce
void EmitConvertedCoalesce (EmitContext ec)
{
var ig = ec.ig;
var done = ig.DefineLabel ();
var load_right = ig.DefineLabel ();
var left = ec.EmitStored (this.left);
if (left.LocalType.IsNullable ())
ec.EmitNullableHasValue (left);
else
ec.EmitLoad (left);
ig.Emit (OpCodes.Brfalse, load_right);
ec.Emit (conversion);
ec.EmitLoad (left);
ig.Emit (OpCodes.Callvirt, conversion.Type.GetInvokeMethod ());
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (load_right);
ec.Emit (this.right);
ig.MarkLabel (done);
}
示例8: EmitLiftedLogical
void EmitLiftedLogical (EmitContext ec)
{
var ig = ec.ig;
var and = NodeType == ExpressionType.And;
var left = ec.EmitStored (this.left);
var right = ec.EmitStored (this.right);
var ret_from_left = ig.DefineLabel ();
var ret_from_right = ig.DefineLabel ();
var done = ig.DefineLabel ();
ec.EmitNullableGetValueOrDefault (left);
ig.Emit (OpCodes.Brtrue, ret_from_left);
ec.EmitNullableGetValueOrDefault (right);
ig.Emit (OpCodes.Brtrue, ret_from_right);
ec.EmitNullableHasValue (left);
ig.Emit (OpCodes.Brfalse, ret_from_left);
ig.MarkLabel (ret_from_right);
ec.EmitLoad (and ? left : right);
ig.Emit (OpCodes.Br, done);
ig.MarkLabel (ret_from_left);
ec.EmitLoad (and ? right : left);
ig.MarkLabel (done);
}
示例9: 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);
}
示例10: 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);
}
}
示例11: 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);
}
示例12: 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);
}
示例13: EmitConvertedCoalesce
private void EmitConvertedCoalesce(EmitContext emitContext)
{
var ig = emitContext.ig;
var done = ig.DefineLabel();
var load_right = ig.DefineLabel();
var left = emitContext.EmitStored(_left);
if (left.LocalType.IsNullable())
{
emitContext.EmitNullableHasValue(left);
}
else
{
emitContext.EmitLoad(left);
}
ig.Emit(OpCodes.Brfalse, load_right);
emitContext.Emit(_conversion);
emitContext.EmitLoad(left);
ig.Emit(OpCodes.Callvirt, _conversion.Type.GetInvokeMethod());
ig.Emit(OpCodes.Br, done);
ig.MarkLabel(load_right);
emitContext.Emit(_right);
ig.MarkLabel(done);
}
示例14: EmitCoalesce
private void EmitCoalesce(EmitContext emitContext)
{
var ig = emitContext.ig;
var done = ig.DefineLabel();
var load_right = ig.DefineLabel();
var left = emitContext.EmitStored(_left);
var left_is_nullable = left.LocalType.IsNullable();
if (left_is_nullable)
{
emitContext.EmitNullableHasValue(left);
}
else
{
emitContext.EmitLoad(left);
}
ig.Emit(OpCodes.Brfalse, load_right);
if (left_is_nullable && !Type.IsNullable())
{
emitContext.EmitNullableGetValue(left);
}
else
{
emitContext.EmitLoad(left);
}
ig.Emit(OpCodes.Br, done);
ig.MarkLabel(load_right);
emitContext.Emit(_right);
ig.MarkLabel(done);
}