当前位置: 首页>>代码示例>>C#>>正文


C# LNode.With方法代码示例

本文整理汇总了C#中LNode.With方法的典型用法代码示例。如果您正苦于以下问题:C# LNode.With方法的具体用法?C# LNode.With怎么用?C# LNode.With使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LNode的用法示例。


在下文中一共展示了LNode.With方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: on_finally

		public static LNode on_finally(LNode node, IMacroContext context)
		{
			LNode firstArg, rest, on_handler = ValidateOnStmt(node, context, out rest, out firstArg);
			if (on_handler == null || firstArg != null)
				return null;
			return node.With(S.Try, rest, node.With(S.Finally, on_handler));
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:7,代码来源:OnFinallyReturnCatch.cs

示例2: TransformOnCatch

		private static LNode TransformOnCatch(LNode node, LNode firstArg, LNode rest, LNode on_handler)
		{
			if (on_handler == null)
				return null;
			if (firstArg == null)
				firstArg = LNode.Missing;
			else if (firstArg.IsId)
				firstArg = firstArg.With(S.Var, F.Id(_Exception), firstArg);
			return node.With(S.Try, rest, node.With(S.Catch, firstArg, F.Missing, on_handler));
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:10,代码来源:OnFinallyReturnCatch.cs

示例3: on_finally

		public static LNode on_finally(LNode node, IMacroContext context)
		{
			VList<LNode> rest;
			LNode firstArg, on_handler = ValidateOnStmt(node, context, out rest, out firstArg);
			if (on_handler == null || firstArg != null)
				return null;

			node.Style &= ~NodeStyle.OneLiner; // avoid collapsing output to one line
			return node.With(S.Try, F.Braces(rest), node.With(S.Finally, on_handler));
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:10,代码来源:OnFinallyThrowCatch.cs

示例4: TransformOnCatch

		private static LNode TransformOnCatch(LNode node, LNode firstArg, LNode rest, LNode on_handler)
		{
			if (on_handler == null)
				return null;
			if (firstArg == null)
				firstArg = LNode.Missing;
			else if (firstArg.IsId)
				firstArg = firstArg.With(S.Var, F.Id(_Exception), firstArg);

			node.Style &= ~NodeStyle.OneLiner; // avoid collapsing output to one line
			return node.With(S.Try, rest, node.With(S.Catch, firstArg, F.Missing, on_handler));
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:12,代码来源:OnFinallyThrowCatch.cs

示例5: _set

		public static LNode _set(LNode node, IMacroContext context)
		{
			var lhs = node.Args[0, LNode.Missing];
			var name = lhs.Name;
			bool isSnippet = name == _hash_snippet;
			if ((isSnippet || name == _hash_set) && node.ArgCount == 2 && lhs.IsId)
			{
				node = context.PreProcessChildren();

				Symbol newTarget = isSnippet ? _hash_setScopedPropertyQuote : _hash_setScopedProperty;
				var stmts = node.Args.Slice(1).Select(key =>
					{
						LNode value = [email protected];
						if (key.Calls(S.Assign, 2))
						{
							value = key.Args[1];
							key = key.Args[0];
							if (isSnippet && value.Calls(S.Braces))
								value = value.Args.AsLNode(S.Splice);
						}
						if (!key.IsId)
							context.Write(Severity.Error, key, "Invalid key; expected an identifier.");
						return node.With(newTarget, LNode.Literal(key.Name, key), value);
					});
				return F.Call(S.Splice, stmts);
			}
			return null;
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:28,代码来源:BuiltinMacros.cs

示例6: runSequence

		public static LNode runSequence(LNode node, IMacroContext context)
		{
			if (context.Parent.Calls(S.Braces))
				return node.With(S.Splice, MaybeRemoveNoOpFromRunSeq(node.Args));
			if (!context.ScopedProperties.ContainsKey(_useSequenceExpressionsIsRunning))
				Reject(context, node, "#useSequenceExpressions is required to make #runSequence work");
			return null;
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:8,代码来源:UseSequenceExpressions.out.cs

示例7: Reject

		public static LNode @unless(LNode node, IMessageSink sink)
		{
			var args = node.Args;
			LNode cond = args.TryGet(0, null), then = args.TryGet(1, null), @else = args.TryGet(3, null);
			if (node.ArgCount != 2 && (node.ArgCount != 4 || !args.TryGet(2, null).IsIdNamed(_else)))
				return Reject(sink, node, "An unless-statement must have the form «unless(Cond, expr)» or «unless(Cond, ThenClause, else, ElseClause)»");
			if (@else == null)
				return node.With(S.If, F.Call(S.Not, cond), then);
			else
				return node.With(S.If, F.Call(S.Not, cond), then, @else);
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:11,代码来源:Prelude.cs

示例8: ColonEquals

		public static LNode ColonEquals(LNode node, IMessageSink sink)
		{
			var a = node.Args;
			if (a.Count == 2) {
				LNode name = a[0], value = a[1];
				return node.With(S.Var, F._Missing, F.Call(S.Assign, name, value));
			}
			return null;
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:9,代码来源:Prelude.cs

示例9: ColonColon

		public static LNode ColonColon(LNode node, IMessageSink sink)
		{
			var a = node.Args;
			if (a.Count == 2) {
				var r = node.With(S.Var, a[1], a[0]);
				r.BaseStyle = NodeStyle.Operator;
				return r;
			}
			return null;
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:10,代码来源:Prelude.cs

示例10: throw

		public static LNode @throw(LNode node, IMessageSink sink)
		{
			if (node.ArgCount > 1) return null;
			return node.With(S.Throw, node.Args); // change throw -> #throw() and throw(x) -> #throw(x)
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:5,代码来源:Prelude.cs

示例11: GotoCase

		public static LNode GotoCase(LNode node, IMessageSink sink)
		{
			if (node.ArgCount == 2 && node.Args[0].IsIdNamed(_case))
				return node.With(S.GotoCase, node.Args[1]);
			return null;
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:6,代码来源:Prelude.cs

示例12: IfUnless

		public static LNode IfUnless(LNode node, bool isUnless, IMessageSink sink)
		{
			var args = node.Args;
			LNode cond = args.TryGet(0, null), then = args.TryGet(1, null),
				elseKW = args.TryGet(2, null), @else = args.TryGet(3, null);
			if (cond == null)
				return null;
			if (then == null)
				return Reject(sink, cond, "'{0}' statement ended early", isUnless ? "unless" : "if");
			if (isUnless)
				cond = F.Call(S.Not, cond);
			if (elseKW == null)
				return node.With(S.If, cond, then);
			if (!elseKW.IsIdNamed(_else))
				return Reject(sink, elseKW, "'{0}': expected else clause or end-of-statement marker", isUnless ? "unless" : "if");
			if (@else.IsId && args.Count > 4)
				@else = LNode.Call(@else.Name, new RVList<LNode>(args.Slice(4)), node);
			return node.With(S.If, cond, then, @else);
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:19,代码来源:Prelude.cs

示例13:

		public static LNode @foreach(LNode node, IMessageSink sink)
		{
			var args = node.Args;
			if (args.Count == 2 && args[0].Calls(_in, 2)) {
				LNode decl = args[0].Args[0], list = args[0].Args[1], body = args[1];
				if (decl.IsId)
					decl = F.Var(F._Missing, decl);
				return node.With(S.ForEach, decl, list, body);
			}
			return null;
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:11,代码来源:Prelude.cs

示例14: import_macros

		public static LNode import_macros(LNode node, IMacroContext sink)
		{
			return node.With(_importMacros, node.Args);
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:4,代码来源:BuiltinMacros.cs

示例15: EliminateSequenceExpressionsInChildStmt

			LNode EliminateSequenceExpressionsInChildStmt(LNode stmt)
			{
				stmt = EliminateSequenceExpressionsInExecStmt(stmt);
				if (stmt.Calls(__numrunSequence))
					return stmt.With(S.Braces, MaybeRemoveNoOpFromRunSeq(stmt.Args));
				return stmt;
			}
开发者ID:qwertie,项目名称:ecsharp,代码行数:7,代码来源:UseSequenceExpressions.out.cs


注:本文中的LNode.With方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。