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


C# LabelStatement类代码示例

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


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

示例1: LabelProducesLabel

        public void LabelProducesLabel()
        {
            var label = new LabelStatement("exit", JS.Return());

            Assert.AreEqual("exit", label.Name);
            Assert.AreEqual("return;", label.Statement.ToString());
            Assert.AreEqual("exit:return;", label.ToString());

            label.Name = "loop";
            label.Statement = JS.For();

            Assert.AreEqual("loop", label.Name);
            Assert.AreEqual("for(;;);", label.Statement.ToString());
            Assert.AreEqual("loop:for(;;);", label.ToString());
        }
开发者ID:DaveVdE,项目名称:adamjsgenerator,代码行数:15,代码来源:LabelStatementTests.cs

示例2: VisitLabelStatement

				public override void VisitLabelStatement (LabelStatement labelStatement)
				{
					base.VisitLabelStatement (labelStatement);

					var t = labelStatement.GetParent <TryCatchStatement> ();
					if (t == null)
						return;

					if (t.TryBlock.Statements.First () == labelStatement) {
						labelStatement.Remove ();
						t.Parent.InsertChildBefore (t, labelStatement, (Role<Statement>)t.Role);
					}
				}
开发者ID:RReverser,项目名称:Netjs,代码行数:13,代码来源:CsToTs.cs

示例3: Visit

			public override object Visit (LabeledStatement labeledStatement)
			{
				var result = new LabelStatement ();
				result.AddChild (new Identifier (labeledStatement.Name, Convert (labeledStatement.loc)), LabelStatement.Roles.Identifier);
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:6,代码来源:CSharpParser.cs

示例4: Visit

			public override object Visit(LabeledStatement labeledStatement)
			{
				var result = new LabelStatement();
				result.AddChild(Identifier.Create(labeledStatement.Name, Convert(labeledStatement.loc)), Roles.Identifier);
				var location = LocationsBag.GetLocations(labeledStatement);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.Colon), Roles.Colon);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:9,代码来源:CSharpParser.cs

示例5: VisitLabelStatement

		public override void VisitLabelStatement(LabelStatement labelStatement) {
			throw new InvalidOperationException("Visited a LabelStatement in the statement compiler, this should have been taken care of in parent.");
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:3,代码来源:StatementCompiler.cs

示例6: Visit

 public void Visit(LabelStatement expression)
 {
     if (!string.IsNullOrEmpty(expression.Name))
         outStream.Write("{0}: ", expression.Name);
     Visit(expression.Target);
 }
开发者ID:reshadi2,项目名称:mcjs,代码行数:6,代码来源:AstWriter.cs

示例7: Visit

 public override void Visit(LabelStatement node) { this.action(node); }
开发者ID:yaakoviyun,项目名称:sqlskim,代码行数:1,代码来源:AllNodesVisitor.cs

示例8: VisitLabelStatement

        public void VisitLabelStatement(LabelStatement statement)
        {
            Formatter.StartNode(statement);

            Formatter.WriteIdentifier(statement.Label);
            Formatter.WriteToken(":");

            Formatter.EndNode();
        }
开发者ID:JerreS,项目名称:AbstractCode,代码行数:9,代码来源:CSharpAstWriter.cs

示例9: VisitLabelStatement

		public object VisitLabelStatement(LabelStatement labelStatement, object data)
		{
			return new B.LabelStatement(GetLexicalInfo(labelStatement), labelStatement.Label);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:4,代码来源:ConvertVisitorStatements.cs

示例10: VisitLabelStatement

        public void VisitLabelStatement(LabelStatement labelStatement)
        {
            JsonObject statement = CreateJsonStatement(labelStatement);
            statement.AddJsonValue("identifier", GetIdentifier(labelStatement.GetChildByRole(Roles.Identifier)));

            Push(statement);
        }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:7,代码来源:AstCsToJson.cs

示例11: HasBreakto

			static bool HasBreakto (LabelStatement label)
			{
				var m = label.GetParent<MethodDeclaration> ();
				if (m == null)
					return false;

				return m.Descendants.OfType<BreakStatement> ().Any (x => {
					var l = x.Annotation<LabelStatement> ();
					if (l == null)
						return false;
					return l.Label == label.Label;
				});
			}
开发者ID:RReverser,项目名称:Netjs,代码行数:13,代码来源:CsToTs.cs

示例12: HasGoto

			static bool HasGoto (LabelStatement label)
			{
				var m = label.GetParent<MethodDeclaration> ();
				if (m == null)
					return false;

				return m.Descendants.OfType<GotoStatement> ().Any (x => x.Label == label.Label);
			}
开发者ID:RReverser,项目名称:Netjs,代码行数:8,代码来源:CsToTs.cs

示例13: VisitMethodDeclaration

				public override void VisitMethodDeclaration (MethodDeclaration methodDeclaration)
				{
					base.VisitMethodDeclaration (methodDeclaration);

					var gotos = methodDeclaration.Body.Descendants.OfType<GotoStatement> ().ToList ();
					if (gotos.Count == 0)
						return;

					var loop = new WhileStatement {
						Condition = new PrimitiveExpression (true),
					};
					var loopBlock = new BlockStatement ();
					var loopSwitch = new SwitchStatement {
						Expression = new IdentifierExpression ("_goto"),
					};
					var loopLabel = new LabelStatement {
						Label = "_GOTO_LOOP",
					};
					loopBlock.Statements.Add (loopSwitch);
					loop.EmbeddedStatement = loopBlock;

					var firstLabel = methodDeclaration.Body.Descendants.First (x => /*(x is GotoStatement) ||*/ (x is LabelStatement && HasGoto ((LabelStatement)x)));
					var stmtRole = (Role<Statement>)firstLabel.Role;

					var block = firstLabel.Parent;

					var labels = new List<Tuple<LabelStatement, List<AstNode>>> ();
					labels.Add (new Tuple<LabelStatement, List<AstNode>> (null, new List<AstNode> ()));

					var n = firstLabel.Parent.FirstChild;
					while (n != null && !n.IsNull) {

						var l = n as LabelStatement;
						if (l != null && gotos.Any (x => x.Label == l.Label)) {
							labels.Add (new Tuple<LabelStatement, List<AstNode>> (l, new List<AstNode> ()));
						} else {
							labels.Last ().Item2.Add (n);
						}

						var s = n.NextSibling;
						n.Remove ();
						n = s;
					}

					for (int i = 0; i < labels.Count; i++) {
						var ls = labels [i];

						var sec = new SwitchSection ();
						sec.CaseLabels.Add (ls.Item1 != null ? new CaseLabel (new PrimitiveExpression (i)) : new CaseLabel ());


						if (ls.Item2.Count == 0 || !StatementIsBranch (ls.Item2.Last ())) {
							if (i + 1 < labels.Count) {
								ls.Item2.Add (new GotoStatement (labels [i + 1].Item1.Label));
							} else {
								var br = new BreakStatement ();
								br.AddAnnotation (new LabelStatement { Label = "_GOTO_LOOP" });
								ls.Item2.Add (br);
							}

						}

						sec.Statements.AddRange (ls.Item2.OfType<Statement> ());
						loopSwitch.SwitchSections.Add (sec);

						if (ls.Item1 != null) {
							block.AddChild (
								new VariableDeclarationStatement (new PrimitiveType ("number"), ls.Item1.Label, new PrimitiveExpression (i)),
								stmtRole);
						}
					}

					block.AddChild (
						new VariableDeclarationStatement (new PrimitiveType ("number"), "_goto", new PrimitiveExpression (0)),
						stmtRole);

					block.AddChild (loopLabel, stmtRole);
					block.AddChild (loop, stmtRole);
				}
开发者ID:RReverser,项目名称:Netjs,代码行数:79,代码来源:CsToTs.cs

示例14: LabelBlock

 public LabelBlock(IEmitter emitter, LabelStatement labelStatement) : base(emitter, labelStatement) {
     labelStatement_ = labelStatement;
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:3,代码来源:GotoBlock.cs

示例15: VisitLabelStatement

			public override void VisitLabelStatement(LabelStatement labelStatement)
			{
				base.VisitLabelStatement(labelStatement);
				CheckNamedResolveResult(null, labelStatement, AffectedEntity.Label, labelStatement.LabelToken, Modifiers.None);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:5,代码来源:InconsistentNamingIssue.cs


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