本文整理汇总了C#中VList.SmartSelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# VList.SmartSelectMany方法的具体用法?C# VList.SmartSelectMany怎么用?C# VList.SmartSelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VList
的用法示例。
在下文中一共展示了VList.SmartSelectMany方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EliminateSequenceExpressions
public VList<LNode> EliminateSequenceExpressions(VList<LNode> stmts, bool isDeclContext)
{
return stmts.SmartSelectMany(stmt => {
/*
// Optimization: scan find out whether this construct has any block
// expressions. If not, skip it.
hasBlockExprs = false;
stmt.ReplaceRecursive(new Func<LNode, Maybe<LNode>>(n => {
if (!hasBlockExprs)
hasBlockExprs = n.IsCall && (
(n.Calls(S.ColonColon, 2) && n.Args[1].IsId) ||
(n.Calls(S.Var, 2) && n.AttrNamed(S.Out) != null) ||
(n.Calls(S.In, 2) && n.Args[1].Calls(S.Braces)));
return hasBlockExprs ? n : null;
}));
if (!hasBlockExprs)
return stmt;
*/
LNode result = EliminateSequenceExpressions(stmt, isDeclContext);
if (result != stmt) {
VList<LNode> results;
if (result.Calls(__numrunSequence)) {
results = MaybeRemoveNoOpFromRunSeq(result.Args);
return results;
}
}
_arrayOf1[0] = result;
return _arrayOf1;
});
}
示例2: ESEInForLoop
LNode ESEInForLoop(LNode stmt, VList<LNode> attrs, VList<LNode> init, LNode cond, VList<LNode> inc, LNode block)
{
// TODO: handle multi-int and multi-inc
var preInit = VList<LNode>.Empty;
var init_apos = init.SmartSelect(init1 => {
init1 = EliminateSequenceExpressionsInExecStmt(init1);
if (init1.CallsMin(__numrunSequence, 1)) {
preInit.AddRange(init1.Args.WithoutLast(1));
return init1.Args.Last;
}
return init1;
});
var cond_apos = BubbleUpBlocks(cond);
var inc_apos = inc.SmartSelectMany(inc1 => {
inc1 = BubbleUpBlocks(inc1);
return inc1.AsList(__numrunSequence);
});
block = EliminateSequenceExpressionsInChildStmt(block);
if (init_apos != init || cond_apos != cond || inc_apos != inc) {
init = init_apos;
if (inc_apos != inc) {
var blockStmts = block.AsList(S.Braces).AddRange(inc_apos);
block = blockStmts.AsLNode(S.Braces);
inc = LNode.List();
}
if (cond_apos.CallsMin(__numrunSequence, 1)) {
var preCond = cond_apos.Args.WithoutLast(1);
cond = cond_apos.Args.Last;
stmt = LNode.Call(CodeSymbols.For, LNode.List(LNode.Call(CodeSymbols.AltList, LNode.List(init)), LNode.Missing, LNode.Call(CodeSymbols.AltList, LNode.List(inc)), LNode.Call(CodeSymbols.Braces, LNode.List().AddRange(preCond).Add(LNode.Call(CodeSymbols.If, LNode.List(cond, block, LNode.Call(CodeSymbols.Break))))).SetStyle(NodeStyle.Statement)));
} else {
stmt = LNode.Call(LNode.List(attrs), CodeSymbols.For, LNode.List(LNode.Call(CodeSymbols.AltList, LNode.List(init)), cond, LNode.Call(CodeSymbols.AltList, LNode.List(inc)), block));
}
if (preInit.Count != 0) {
stmt = LNode.Call(CodeSymbols.Braces, LNode.List().AddRange(preInit).Add(stmt)).SetStyle(NodeStyle.Statement);
}
return stmt;
} else {
return stmt.WithArgChanged(3, block);
}
}