本文整理汇总了C#中EmitContext.EmitNullableGetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# EmitContext.EmitNullableGetValueOrDefault方法的具体用法?C# EmitContext.EmitNullableGetValueOrDefault怎么用?C# EmitContext.EmitNullableGetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmitContext
的用法示例。
在下文中一共展示了EmitContext.EmitNullableGetValueOrDefault方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例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);
}
示例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);
}
示例7: 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);
}
示例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);
}
示例9: 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);
}