本文整理汇总了C#中LNode.WithoutAttrNamed方法的典型用法代码示例。如果您正苦于以下问题:C# LNode.WithoutAttrNamed方法的具体用法?C# LNode.WithoutAttrNamed怎么用?C# LNode.WithoutAttrNamed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LNode
的用法示例。
在下文中一共展示了LNode.WithoutAttrNamed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveLeadingNewline
LNode RemoveLeadingNewline(ref LNode node)
{
LNode newline;
node = node.WithoutAttrNamed(S.TriviaNewline, out newline);
return newline;
}
示例2: BubbleUpBlocks
// This method's main goal is to move #runSequence from child nodes to outer nodes:
// Foo(a, #runSequence(b(), c())) => #runSequence(var a_10 = a; b(); Foo(a_10, c()));
// It also converts variable declarations, e.g.
// Foo()::foo => #runSequence(var foo = Foo(), foo)
LNode BubbleUpBlocks(LNode expr, bool stmtContext = false)
{
if (!expr.IsCall)
return expr;
LNode result = null;
if (!stmtContext) {
{
LNode tmp_14, value, varName, varType;
VList<LNode> attrs;
if (expr.Calls(CodeSymbols.Braces)) {
Context.Sink.Warning(expr, "A braced block is not supported directly within an expression. Did you mean to use `#runSequence {...}`?");
result = expr;
} else if ((attrs = expr.Attrs).IsEmpty | true && attrs.NodeNamed(S.Out) != null && expr.Calls(CodeSymbols.Var, 2) && (varType = expr.Args[0]) != null && (varName = expr.Args[1]) != null && varName.IsId) {
if (varType.IsIdNamed(S.Missing))
Context.Sink.Error(expr, "#useSequenceExpressions: the data type of this variable declaration cannot be inferred and must be stated explicitly.");
result = LNode.Call(LNode.List(_trivia_pure), (Symbol) "#runSequence", LNode.List(expr.WithoutAttrNamed(S.Out), varName.PlusAttrs(LNode.List(LNode.Id(CodeSymbols.Out)))));
} else if ((attrs = expr.Attrs).IsEmpty | true && expr.Calls(CodeSymbols.Var, 2) && (varType = expr.Args[0]) != null && (tmp_14 = expr.Args[1]) != null && tmp_14.Calls(CodeSymbols.Assign, 2) && (varName = tmp_14.Args[0]) != null && (value = tmp_14.Args[1]) != null)
if (stmtContext)
result = expr; // no-op
else
result = ConvertVarDeclToRunSequence(attrs, varType, varName, value);
}
}
if (result == null) {
{
LNode args, code, value, varName;
VList<LNode> attrs;
if ((attrs = expr.Attrs).IsEmpty | true && expr.Calls(CodeSymbols.ColonColon, 2) && (value = expr.Args[0]) != null && IsQuickBindLhs(value) && (varName = expr.Args[1]) != null && varName.IsId)
result = ConvertVarDeclToRunSequence(attrs, F.Missing, varName, value);
else if ((attrs = expr.Attrs).IsEmpty | true && expr.Calls(CodeSymbols.Lambda, 2) && (args = expr.Args[0]) != null && (code = expr.Args[1]) != null)
result = expr.WithArgChanged(1, EliminateSequenceExpressionsInLambdaExpr(code, F.Missing));
else if (expr.Calls(__numrunSequence))
result = expr;
else
result = BubbleUp_GeneralCall(expr);
}
}
// #runSequences can be nested by the user or produced by BubbleUp_GeneralCall,
// so process the code inside #runSequence too
if (result.Calls(__numrunSequence))
return result.WithArgs(EliminateSequenceExpressions(result.Args, false));
else
return result;
}