本文整理汇总了C#中Ref.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# Ref.Concat方法的具体用法?C# Ref.Concat怎么用?C# Ref.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref.Concat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SafeExpandOpAssign
public static Node SafeExpandOpAssign(this Node root, out Dictionary<Operator, Assign> out_roots)
{
var roots = new Dictionary<Operator, Assign>();
var x_root = root.Transform((Operator op) =>
{
var opt = op.OperatorType;
if (!opt.IsAssign()) return (Expression)op.DefaultTransform();
Func<Expression, Expression> mk_safe_lhs = lhs =>
{
var @ref = lhs as Ref;
if (@ref != null) return lhs;
var slot = lhs as Slot;
if (slot != null)
{
var @this = slot.This;
if (@this == null || @this is Ref) return lhs;
else
{
var ass_root = @this.DeepClone();
var ref_root = new Ref(new Local(null, ass_root.Type()));
var ass = new Assign(ref_root, ass_root);
roots.Add(op, ass);
var fld = slot as Fld;
if (fld != null)
{
return new Fld(fld.Field, ref_root);
}
var prop = slot as Prop;
if (prop != null)
{
return new Prop(prop.Property, ref_root, prop.InvokedAsVirtual);
}
throw AssertionHelper.Fail();
}
}
var eval = lhs as Eval;
var m = eval == null ? null : eval.InvokedMethod();
if (m != null && m.IsArrayGetter())
{
var app = eval.Callee;
var @this = eval.Callee.Args.First();
if (@this == null || @this is Ref) return lhs;
else
{
var ass_root = @this.DeepClone();
var ref_root = new Ref(new Local(null, ass_root.Type()));
var ass = new Assign(ref_root, ass_root);
roots.Add(op, ass);
return new Eval(new Apply(new Lambda(m), ref_root.Concat(app.Args.Skip(1))));
}
}
throw AssertionHelper.Fail();
};
var safe_lhs = mk_safe_lhs(op.Args.FirstOrDefault());
var rhs = op.Args.SecondOrDefault() ?? new Const(1); // hack for inc/decrements
return new Assign(safe_lhs, Operator.Create(opt.Unassign(), safe_lhs, rhs));
}).AssertCast<Node>();
out_roots = roots;
return x_root;
}