• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Print

		public void Print(LNode node, StringBuilder target, IMessageSink sink = null, ParsingMode mode = null, ILNodePrinterOptions options = null)
		{
			if (_usePlainCsPrinter)
				EcsNodePrinter.PrintPlainCSharp(node, target, sink, mode, options);
			else
				EcsNodePrinter.PrintECSharp(node, target, sink, mode, options);
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:7,代码来源:EcsLanguageService.cs


示例2: In

		public static LNode In(LNode node, IMacroContext context)
		{
			{
				LNode range, x;
				if (node.Calls(CodeSymbols.In, 2) && (x = node.Args[0]) != null && (range = node.Args[1]) != null) {
					LNode parens;
					range = range.WithoutAttrNamed(S.TriviaInParens, out parens);
					if (parens == null) {
						{
							LNode hi, lo;
							if (range.Calls(CodeSymbols.DotDot, 2) && (lo = range.Args[0]) != null && (hi = range.Args[1]) != null)
								if (lo.IsIdNamed(__))
									return LNode.Call(CodeSymbols.LT, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
								else if (hi.IsIdNamed(__))
									return LNode.Call(CodeSymbols.GE, LNode.List(x, lo)).SetStyle(NodeStyle.Operator);
								else
									return LNode.Call(LNode.Call(CodeSymbols.Dot, LNode.List(x, LNode.Id((Symbol) "IsInRangeExcludeHi"))).SetStyle(NodeStyle.Operator), LNode.List(lo, hi));
							else if (range.Calls(CodeSymbols.DotDot, 1) && (hi = range.Args[0]) != null)
								return LNode.Call(CodeSymbols.LT, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
							else if (range.Calls(CodeSymbols.DotDotDot, 2) && (lo = range.Args[0]) != null && (hi = range.Args[1]) != null)
								if (lo.IsIdNamed(__))
									return LNode.Call(CodeSymbols.LE, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
								else if (hi.IsIdNamed(__))
									return LNode.Call(CodeSymbols.GE, LNode.List(x, lo)).SetStyle(NodeStyle.Operator);
								else
									return LNode.Call(LNode.Call(CodeSymbols.Dot, LNode.List(x, LNode.Id((Symbol) "IsInRange"))).SetStyle(NodeStyle.Operator), LNode.List(lo, hi));
							else if (range.Calls(CodeSymbols.DotDotDot, 1) && (hi = range.Args[0]) != null)
								return LNode.Call(CodeSymbols.LE, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
						}
					}
					return LNode.Call(LNode.Call(CodeSymbols.Dot, LNode.List(range, LNode.Id((Symbol) "Contains"))).SetStyle(NodeStyle.Operator), LNode.List(x));
				}
			}
			return null;
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:35,代码来源:InRange.out.cs


示例3: WithSpliced

		public static RVList<LNode> WithSpliced(this RVList<LNode> list, LNode node, Symbol listName)
		{
			if (node.Calls(listName))
				return list.AddRange(node.Args);
			else
				return list.Add(node);
		}
开发者ID:lydonchandra,项目名称:LoycCore,代码行数:7,代码来源:LNodeExt.cs


示例4: replace

		public static LNode replace(LNode node, IMacroContext context)
		{
			var args_body = context.GetArgsAndBody(true);
			var args = args_body.A;
			var body = args_body.B;
			if (args.Count >= 1)
			{
				var patterns = new Pair<LNode, LNode>[args.Count];
				for (int i = 0; i < patterns.Length; i++)
				{
					var pair = args[i];
					if (pair.Calls(S.Lambda, 2)) {
						LNode pattern = pair[0], repl = pair[1];
						if (pattern.Calls(S.Braces, 1) && repl.Calls(S.Braces)) {
							pattern = pattern.Args[0];
							repl = repl.WithTarget(S.Splice);
						}
						patterns[i] = Pair.Create(pattern, repl);
					} else {
						string msg = "Expected 'pattern => replacement'.";
						if (pair.Descendants().Any(n => n.Calls(S.Lambda, 2)))
							msg += " " + "(Using '=>' already? Put the pattern on the left-hand side in parentheses.)";
						return Reject(context, pair, msg);
					}
				}

				int replacementCount;
				var output = Replace(body, patterns, out replacementCount);
				if (replacementCount == 0)
					context.Write(Severity.Warning, node, "No patterns recognized; no replacements were made.");
				return output.AsLNode(S.Splice);
			}
			return null;
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:34,代码来源:ReplaceMacro.cs


示例5: SpliceAdd

		public static void SpliceAdd(this RWList<LNode> list, LNode node, Symbol listName)
		{
			if (node.Calls(listName))
				list.AddRange(node.Args);
			else
				list.Add(node);
		}
开发者ID:lydonchandra,项目名称:LoycCore,代码行数:7,代码来源:LNodeExt.cs


示例6: 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


示例7: AutoRemoveParens

		LNode AutoRemoveParens(LNode node)
		{
			int i = node.Attrs.IndexWithName(S.TriviaInParens);
			if ((i > -1))
				 return node.WithAttrs(node.Attrs.RemoveAt(i));
			return node;
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:7,代码来源:EcsParserGrammar.cs


示例8:

		public static LNode @nameof(LNode nameof, IMacroContext context)
		{
			if (nameof.ArgCount != 1)
				return null;
			Symbol expr = EcsValidators.KeyNameComponentOf(nameof.Args[0]);
			return F.Literal(expr.Name);
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:7,代码来源:CSharp6Macro.cs


示例9: NullDot

		public static LNode NullDot(LNode node, IMacroContext context)
		{
			if (!node.Calls(S.NullDot, 2))
				return null;

			var a = node.Args;
			LNode leftSide = a[0], rightSide = a[1];
			// So our input will be something like a.b?.c().d<x>, which is parsed
			//     (a.b) ?. (c().d<x>)
			// in EC# we would transform this to 
			//     a.b::tmp != null ? tmp.c().d<x> : null
			// but there's no EC# compiler yet, so instead use code that plain C#
			// can support:
			//     a.b != null ? (a.b).c().d<x> : null
			LNode condition, thenExpr;
			if (StandardMacros.LooksLikeSimpleValue(leftSide))
			{
				condition = F.Call(S.Neq, leftSide, [email protected]);
				thenExpr = ConvertToNormalDot(leftSide, rightSide);
			}
			else
			{
				LNode tempVar = F.Id(StandardMacros.NextTempName(context, leftSide));
				condition = F.Call(S.Neq, F.Var(F.Missing, tempVar, leftSide), [email protected]);
				thenExpr = ConvertToNormalDot(tempVar, rightSide);
			}
			return F.InParens(F.Call(S.QuestionMark, condition, thenExpr, F.Null));
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:28,代码来源:CSharp6Macro.cs


示例10: Stmt

		protected override void Stmt(string text, LNode expected, Action<EcsPrinterOptions> configure = null, Mode mode = Mode.Both)
		{
			bool exprMode = (mode & Mode.Expression) != 0;
			if ((mode & Mode.ParserTest) == 0)
				return;
			var sink = (mode & Mode.ExpectAndDropParserError) != 0 ? new MessageHolder() : (IMessageSink)ConsoleMessageSink.Value;
			// This is the easy way: 
			//LNode result = EcsLanguageService.Value.ParseSingle(text, sink, exprMode ? ParsingMode.Expressions : ParsingMode.Statements, preserveComments: true);
			// But to make debugging easier, I'll do it the long way:
			ILexer<Token> lexer = EcsLanguageService.Value.Tokenize(new UString(text), "", ConsoleMessageSink.Value);
			var preprocessed = new EcsPreprocessor(lexer, true);
			var treeified = new TokensToTree(preprocessed, false);
			var parser = new EcsParser(treeified.Buffered(), lexer.SourceFile, sink);
			VList<LNode> results = exprMode ? LNode.List(parser.ExprStart(false)) : LNode.List(parser.ParseStmtsGreedy());
			//if (!preprocessed.TriviaList.IsEmpty) 
			{
				// Inject comments
				var injector = new EcsTriviaInjector(preprocessed.TriviaList, preprocessed.SourceFile, (int)TokenType.Newline, "/*", "*"+"/", "//");
				results = LNode.List(injector.Run(results.GetEnumerator()).ToList());
			}
			LNode result = results.AsLNode(S.Splice);
			AreEqual(TokenType.EOF, parser.LT0.Type(), string.Format("Parser stopped before EOF at [{0}] in {1}", parser.LT0.StartIndex, text));

			if ((mode & Mode.IgnoreTrivia) != 0)
				result = result.ReplaceRecursive(n => n.IsTrivia ? Maybe<LNode>.NoValue : n, LNode.ReplaceOpt.ProcessAttrs).Value;
			AreEqual(expected, result);
			if (sink is MessageHolder)
				GreaterOrEqual(((MessageHolder)sink).List.Count, 1, "Expected an error but got none for "+text);
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:29,代码来源:EcsParserTests.cs


示例11: MayBeImplicitChildStatement

		/// <summary>Returns true if the specified child of the specified node 
		/// can be an implicit child statement, i.e. a child statement that is
		/// not necessarily a braced block, e.g. the second child of a while 
		/// loop.</summary>
		/// <remarks>
		/// This method helps the printer decide when a newline should be added 
		/// before an unbraced child statement when there are no attributes 
		/// dictating whether to add a newline or not.
		/// <para/>
		/// This method only cares about executable parent nodes. It returns 
		/// false for class/space and function/property bodies, which are always 
		/// braced blocks and therefore get a newline before every child statement 
		/// automatically.
		/// </remarks>
		public static bool MayBeImplicitChildStatement(LNode node, int childIndex)
		{
			CheckParam.IsNotNull("node", node);
			if (childIndex < 0) // target or attributes
				return false;
			var n = node.Name;
			if (!LNode.IsSpecialName(n.Name))
				return false;
			if (n == S.Braces)
				return true;
			if (n == S.Try)
				return childIndex == 0;
			switch (node.ArgCount) {
				case 1:
					if (n == S.Finally)
						return true;
					break;
				case 2:
					if (childIndex == 0 ? n == S.DoWhile :
						n == S.If || n == S.While || n == S.UsingStmt || n == S.Lock || n == S.Switch || n == S.Fixed)
						return true;
					break;
				case 3:
					if (childIndex != 0 && n == S.If)
						return true;
					if (childIndex == 2 && n == S.ForEach)
						return true;
					break;
				case 4:
					if (childIndex == 3 && (n == S.For || n == S.Catch))
						return true;
					break;
			}
			return false;
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:49,代码来源:EcsValidators.cs


示例12: static_matchCode

		public static LNode static_matchCode(LNode node, IMacroContext context)
		{
			if (node.AttrNamed(S.Static) == null && !node.HasSpecialName)
				return null; // handled by normal matchCode macro

			var args_body = context.GetArgsAndBody(false);
			VList<LNode> args = args_body.Item1, body = args_body.Item2;
			if (args.Count != 1)
				return Reject(context, args[1], "Expected only one expression to match");

			var expression = context.PreProcess(AutoStripBraces(args[0]));

			var cases = GetCases(body, context.Sink);
			// The `default:` case is represented by an empty list of patterns.
			if (cases.WithoutLast(1).Any(pair => pair.Key.IsEmpty))
				context.Write(Severity.Error, node, "The `default:` case must be the last one, because the cases are tested in the order they appear, so no case after `default:` can be matched.");

			MMap<Symbol, LNode> captures = new MMap<Symbol, LNode>();
			foreach (Pair<VList<LNode>, VList<LNode>> pair in cases)
			{
				var patterns = pair.Key.IsEmpty ? new VList<LNode>((LNode)null) : pair.Key;
				foreach (var pattern in patterns)
				{
					captures.Clear();
					VList<LNode> _;
					if (pattern == null || LNodeExt.MatchesPattern(expression, pattern, ref captures, out _)) {
						captures[_hash] = expression; // define $#
						captures.Remove(__);
						return ReplaceCaptures(pair.Value.AsLNode(S.Splice), captures);
					}
				}
			}
			return F.Call(S.Splice); // none of the cases matched
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:34,代码来源:StaticMatchCodeMacro.cs


示例13: In

		[LexicalMacro("x in lo..hi; x in lo...hi; x in ..hi; x in lo..._; x in range", "Converts an 'in' expression to a normal C# expression using the following rules " + "(keeping in mind that the EC# parser treats `..<` as an alias for `..`):\n" + "1. `x in _..hi` and `x in ..hi` become `x.IsInRangeExcl(hi)`\n" + "2. `x in _...hi` and `x in ...hi` become `x.IsInRangeIncl(hi)`\n" + "3. `x in lo.._` and `x in lo..._` become simply `x >= lo`\n" + "4. `x in lo..hi` becomes `x.IsInRangeExcludeHi(lo, hi)`\n" + "5. `x in lo...hi` becomes `x.IsInRange(lo, hi)`\n" + "6. `x in range` becomes `range.Contains(x)`\n" + "The first applicable rule is used.", "#in")] public static LNode In(LNode node, IMacroContext context)
		{
			{
				LNode range, x;
				if (node.Calls(CodeSymbols.In, 2) && (x = node.Args[0]) != null && (range = node.Args[1]) != null) {
					LNode parens;
					range = range.WithoutAttrNamed(S.TriviaInParens, out parens);
					if (parens == null) {
						{
							LNode hi, lo;
							if (range.Calls(CodeSymbols.DotDot, 2) && (lo = range.Args[0]) != null && (hi = range.Args[1]) != null)
								if (lo.IsIdNamed(__))
									return LNode.Call(CodeSymbols.LT, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
								else if (hi.IsIdNamed(__))
									return LNode.Call(CodeSymbols.GE, LNode.List(x, lo)).SetStyle(NodeStyle.Operator);
								else
									return LNode.Call(LNode.Call(CodeSymbols.Dot, LNode.List(x, LNode.Id((Symbol) "IsInRangeExcludeHi"))), LNode.List(lo, hi));
							else if (range.Calls(CodeSymbols.DotDot, 1) && (hi = range.Args[0]) != null)
								return LNode.Call(CodeSymbols.LT, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
							else if (range.Calls(CodeSymbols.DotDotDot, 2) && (lo = range.Args[0]) != null && (hi = range.Args[1]) != null)
								if (lo.IsIdNamed(__))
									return LNode.Call(CodeSymbols.LE, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
								else if (hi.IsIdNamed(__))
									return LNode.Call(CodeSymbols.GE, LNode.List(x, lo)).SetStyle(NodeStyle.Operator);
								else
									return LNode.Call(LNode.Call(CodeSymbols.Dot, LNode.List(x, LNode.Id((Symbol) "IsInRange"))), LNode.List(lo, hi));
							else if (range.Calls(CodeSymbols.DotDotDot, 1) && (hi = range.Args[0]) != null)
								return LNode.Call(CodeSymbols.LE, LNode.List(x, hi)).SetStyle(NodeStyle.Operator);
						}
					}
					return LNode.Call(LNode.Call(CodeSymbols.Dot, LNode.List(range, LNode.Id((Symbol) "Contains"))), LNode.List(x));
				}
			}
			return null;
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:35,代码来源:InRange.out.cs


示例14: with

			Mode = MacroMode.ProcessChildrenBefore)] // post-normal-macro-expansion
		public static LNode with(LNode fn, IMacroContext context)
		{
			LNode braces;
			if (fn.ArgCount != 2 || !(braces = fn.Args[1]).Calls(S.Braces))
				return null;

			LNode tmp = F.Id(NextTempName(context));
			WList<LNode> stmts = braces.Args.ToWList();
			stmts = stmts.SmartSelect(stmt => 
				stmt.ReplaceRecursive(expr => {
					if (expr.Calls(S.Dot, 1))
						return expr.WithArgs(new VList<LNode>(tmp, expr.Args.Last));
					else if (expr.IsIdNamed("#"))
						return tmp;
					return null;
				}));

			stmts.Insert(0, F.Var(null, tmp.Name, fn.Args[0]));
			if (IsExpressionContext(context)) {
				stmts.Add(tmp);
				return F.Call("#runSequence", stmts.ToVList());
			} else {
				return F.Braces(stmts.ToVList());
			}
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:26,代码来源:WithMacro.cs


示例15: CodeToTerminalPred

		public override Pred CodeToTerminalPred(LNode expr, ref string errorMsg)
		{
			bool isInt = false;
			PGIntSet set;

			if (expr.IsIdNamed(_underscore)) {
				set = PGIntSet.AllExceptEOF;
			} else if (expr.IsIdNamed(_EOF)) {
				set = PGIntSet.EOF;
			} else if (expr.Calls(S.DotDot, 2)) {
				int? from = ConstValue(expr.Args[0], ref isInt);
				int? to   = ConstValue(expr.Args[1], ref isInt);
				if (from == null || to == null) {
					errorMsg = "Expected int32 or character literal on each side of «..»";
					return null;
				}
				set = PGIntSet.WithRanges(from.Value, to.Value);
			} else if (expr.Value is string) {
				return Pred.Seq((string)expr.Value);
			} else {
				int? num = ConstValue(expr, ref isInt);
				if (num == null) {
					errorMsg = "Unrecognized expression. Expected int32 or character literal instead of: " + expr.ToString(); // warning
					return null;
				}
				set = PGIntSet.With(num.Value);
			}
			set.IsCharSet = !isInt;
			return new TerminalPred(expr, set, true);
		}
开发者ID:BingjieGao,项目名称:Loyc,代码行数:30,代码来源:IntStreamCodeGenHelper.cs


示例16: MakeBltRoundTrip

        private RoundTripPerformance MakeBltRoundTrip(LNode[] Nodes)
        {
            using (var memStream = new MemoryStream())
            {
                var timer = new Stopwatch();
                timer.Start();

                var writer = new LoycBinaryWriter(memStream);

                for (int i = 0; i < TimedRoundTripCount; i++)
                {
                    writer.WriteFile(Nodes);
                    memStream.Seek(0, SeekOrigin.Begin);
                }

                timer.Stop();
                var writePerf = timer.Elapsed;
                long size = memStream.Length;
                timer.Restart();

                for (int i = 0; i < TimedRoundTripCount; i++)
                {
                    var reader = new LoycBinaryReader(memStream);
                    reader.ReadFile("test.blt");
                    memStream.Seek(0, SeekOrigin.Begin);
                }

                timer.Stop();
                var readPerf = timer.Elapsed;

                return new RoundTripPerformance(readPerf, writePerf, size);
            }
        }
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:33,代码来源:LesComparisonBenchmark.cs


示例17: ForwardMethod

		public static LNode ForwardMethod(LNode fn, IMessageSink sink)
		{
			LNode args, fwd, body;
			if (fn.ArgCount != 4 || !(fwd = fn.Args[3]).Calls(S.Forward, 1) || !(args = fn.Args[2]).Calls(S.List))
				return null;
			
			RVList<LNode> formalArgs = args.Args;
			RVList<LNode> argList =	RVList<LNode>.Empty;
			foreach (var formalArg in formalArgs)
			{
				if (!formalArg.Calls(S.Var, 2))
					return Reject(sink, formalArg, "'==>' expected a variable declaration here");
				LNode argName = formalArg.Args[1];
				if (argName.Calls(S.Assign, 2))
					argName = argName.Args[0];
				LNode @ref = formalArg.AttrNamed(S.Ref) ?? formalArg.AttrNamed(S.Out);
				if (@ref != null)
					argName = argName.PlusAttr(@ref);
				argList.Add(argName);
			}

			LNode target = GetForwardingTarget(fwd, fn.Args[1]);
			LNode call = F.Call(target, argList);
			
			bool isVoidFn = fn.Args[0].IsIdNamed(S.Void);
			body = F.Braces(isVoidFn ? call : F.Call(S.Return, call));
			return fn.WithArgChanged(3, body);
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:28,代码来源:ForwardingMacro.cs


示例18: ForwardProperty

		public static LNode ForwardProperty(LNode prop, IMessageSink sink)
		{
			LNode name, fwd, body;
			if (prop.ArgCount != 3)
				return null;
			LNode target = GetForwardingTarget(fwd = prop.Args[2], name = prop.Args[1]);
			if (target != null)
			{
				body = F.Braces(new RVList<LNode>(
					F.Call(S.get, F.Braces(F.Call(S.Return, target))),
					F.Call(S.set, F.Braces(F.Call(S.Assign, target, F.Id(S.value))))));

				return prop.WithArgChanged(2, body);
			}
			else if ((body = fwd).Calls(S.Braces))
			{
				var body2 = body.WithArgs(stmt => {
					if (stmt.Calls(S.get, 1) && (target = GetForwardingTarget(stmt.Args[0], name)) != null)
						return stmt.WithArgs(new RVList<LNode>(F.Braces(F.Call(S.Return, target))));
					if (stmt.Calls(S.set, 1) && (target = GetForwardingTarget(stmt.Args[0], name)) != null)
						return stmt.WithArgs(new RVList<LNode>(F.Braces(F.Call(S.Assign, target, F.Id(S.value)))));
					return stmt;
				});
				if (body2 != body)
					return prop.WithArgChanged(2, body2);
			}
			return null;
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:28,代码来源:ForwardingMacro.cs


示例19: saveAndRestore

		public static LNode saveAndRestore(LNode node, IMacroContext context)
		{
			var tmp_0 = context.GetArgsAndBody(true);
			var args = tmp_0.Item1;
			var body = tmp_0.Item2;
			if (args.Count == 1) {
				LNode newValue = null;
				{
					var tmp_1 = args[0];
					LNode property;
					if (tmp_1.Calls(CodeSymbols.Assign, 2) && (property = tmp_1.Args[0]) != null && (newValue = tmp_1.Args[1]) != null || (property = tmp_1) != null) {
						string mainProp = KeyNameComponentOf(property).Name;
						string varPrefix = "old" + mainProp + "_";
						LNode varName, varDecl = TempVarDecl(property, out varName, varPrefix);
						LNode tryFinally = LNode.Call(CodeSymbols.Try, LNode.List(LNode.Call(CodeSymbols.Braces, LNode.List(body)).SetStyle(NodeStyle.Statement), LNode.Call(CodeSymbols.Finally, LNode.List(LNode.Call(CodeSymbols.Braces, LNode.List(LNode.Call(CodeSymbols.Assign, LNode.List(property, varName)).SetStyle(NodeStyle.Operator))).SetStyle(NodeStyle.Statement)))));
						if (newValue != null) {
							return LNode.Call(CodeSymbols.Splice, LNode.List(varDecl, LNode.Call(CodeSymbols.Assign, LNode.List(property, newValue)).SetStyle(NodeStyle.Operator), tryFinally));
						} else {
							return LNode.Call(CodeSymbols.Splice, LNode.List(varDecl, tryFinally));
						}
					}
				}
			}
			return null;
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:25,代码来源:SaveAndRestoreMacro.out.cs


示例20: ForwardProperty

		public static LNode ForwardProperty(LNode prop, IMacroContext context)
		{
			LNode name, fwd, body;
			if (prop.ArgCount != 4)
				return null;
			LNode target = GetForwardingTarget(name = prop.Args[1], fwd = prop.Args[3]);
			if (target != null)
			{
				body = F.Braces(F.Call(S.get, F.Braces(F.Call(S.Return, target))).SetBaseStyle(NodeStyle.Special));
				return prop.WithArgChanged(3, body);
			}
			else if ((body = fwd).Calls(S.Braces))
			{
				var body2 = body.WithArgs(stmt => {
					if (stmt.Calls(S.get, 1) && (target = GetForwardingTarget(name, stmt.Args[0])) != null)
						return stmt.WithArgs(new VList<LNode>(F.Braces(F.Call(S.Return, target))));
					if (stmt.Calls(S.set, 1) && (target = GetForwardingTarget(name, stmt.Args[0])) != null)
						return stmt.WithArgs(new VList<LNode>(F.Braces(F.Call(S.Assign, target, F.Id(S.value)))));
					return stmt;
				});
				if (body2 != body)
					return prop.WithArgChanged(3, body2);
			}
			return null;
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:25,代码来源:ForwardingMacro.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LOADING_STATE类代码示例发布时间:2022-05-24
下一篇:
C# LLVMValueRef类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap