本文整理汇总了C#中Mono.CSharp.LocalTemporary.EmitAssign方法的典型用法代码示例。如果您正苦于以下问题:C# LocalTemporary.EmitAssign方法的具体用法?C# LocalTemporary.EmitAssign怎么用?C# LocalTemporary.EmitAssign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.LocalTemporary
的用法示例。
在下文中一共展示了LocalTemporary.EmitAssign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitConditionalAccess
protected void EmitConditionalAccess (EmitContext ec)
{
var a_expr = arguments [0].Expr;
var des = a_expr as DynamicExpressionStatement;
if (des != null) {
des.EmitConditionalAccess (ec);
}
if (HasConditionalAccess ()) {
var NullOperatorLabel = ec.DefineLabel ();
if (ExpressionAnalyzer.IsInexpensiveLoad (a_expr)) {
a_expr.Emit (ec);
} else {
var lt = new LocalTemporary (a_expr.Type);
lt.EmitAssign (ec, a_expr, true, false);
Arguments [0].Expr = lt;
}
ec.Emit (OpCodes.Brtrue_S, NullOperatorLabel);
if (!ec.ConditionalAccess.Statement) {
if (ec.ConditionalAccess.Type.IsNullableType)
Nullable.LiftedNull.Create (ec.ConditionalAccess.Type, Location.Null).Emit (ec);
else
ec.EmitNull ();
}
ec.Emit (OpCodes.Br, ec.ConditionalAccess.EndLabel);
ec.MarkLabel (NullOperatorLabel);
return;
}
if (a_expr.HasConditionalAccess ()) {
var lt = new LocalTemporary (a_expr.Type);
lt.EmitAssign (ec, a_expr, false, false);
Arguments [0].Expr = lt;
}
}
示例2: DoEmitStringSwitch
void DoEmitStringSwitch (LocalTemporary value, EmitContext ec)
{
Label l_initialized = ec.DefineLabel ();
//
// Skip initialization when value is null
//
value.EmitBranchable (ec, null_target, false);
//
// Check if string dictionary is initialized and initialize
//
switch_cache_field.EmitBranchable (ec, l_initialized, true);
string_dictionary.EmitStatement (ec);
ec.MarkLabel (l_initialized);
LocalTemporary string_switch_variable = new LocalTemporary (TypeManager.int32_type);
ResolveContext rc = new ResolveContext (ec.MemberContext);
if (TypeManager.generic_ienumerable_type != null) {
Arguments get_value_args = new Arguments (2);
get_value_args.Add (new Argument (value));
get_value_args.Add (new Argument (string_switch_variable, Argument.AType.Out));
Expression get_item = new Invocation (new MemberAccess (switch_cache_field, "TryGetValue", loc), get_value_args).Resolve (rc);
if (get_item == null)
return;
//
// A value was not found, go to default case
//
get_item.EmitBranchable (ec, default_target, false);
} else {
Arguments get_value_args = new Arguments (1);
get_value_args.Add (new Argument (value));
Expression get_item = new ElementAccess (switch_cache_field, get_value_args, loc).Resolve (rc);
if (get_item == null)
return;
LocalTemporary get_item_object = new LocalTemporary (TypeManager.object_type);
get_item_object.EmitAssign (ec, get_item, true, false);
ec.Emit (OpCodes.Brfalse, default_target);
ExpressionStatement get_item_int = (ExpressionStatement) new SimpleAssign (string_switch_variable,
new Cast (new TypeExpression (TypeManager.int32_type, loc), get_item_object, loc)).Resolve (rc);
get_item_int.EmitStatement (ec);
get_item_object.Release (ec);
}
TableSwitchEmit (ec, string_switch_variable);
string_switch_variable.Release (ec);
}