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

C# LabelStatement类代码示例

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

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



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


示例16: VisitLabelStatement

		public virtual object VisitLabelStatement(LabelStatement labelStatement, object data) {
			Debug.Assert((labelStatement != null));
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:AbstractASTVisitor.cs


示例17: VisitLabelStatement

 public StringBuilder VisitLabelStatement(LabelStatement labelStatement, int data)
 {
     throw new SLSharpException("SL# does not support labels.");
 }
开发者ID:hach-que,项目名称:SLSharp,代码行数:4,代码来源:VisitorBase.Illegal.cs


示例18: VisitLabelStatement

		public virtual void VisitLabelStatement(LabelStatement labelStatement)
		{
			DebugExpression(labelStatement);
			StartNode(labelStatement);
			WriteIdentifier(labelStatement.GetChildByRole(Roles.Identifier), BoxedTextColor.Label);
			WriteToken(Roles.Colon, BoxedTextColor.Punctuation);
			bool foundLabelledStatement = false;
			for (AstNode tmp = labelStatement.NextSibling; tmp != null; tmp = tmp.NextSibling) {
				if (tmp.Role == labelStatement.Role) {
					foundLabelledStatement = true;
				}
			}
			if (!foundLabelledStatement) {
				// introduce an EmptyStatement so that the output becomes syntactically valid
				WriteToken(Roles.Semicolon, BoxedTextColor.Punctuation);
			}
			NewLine();
			EndNode(labelStatement);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:19,代码来源:CSharpOutputVisitor.cs


示例19: VisitLabelStatement

		public override void VisitLabelStatement(LabelStatement labelStatement)
		{
			// TODO
			VisitChildren(labelStatement);
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:5,代码来源:AstFormattingVisitor.cs


示例20: ParseStatementOrLocal_Helper

    // Do the real work
    protected void ParseStatementOrLocal_Helper(out Statement s, out LocalVarDecl v)
    {   
        s = null;
        v = null;
        
        // For each statement, we know which type based off the first token.
        // Expect for an identifier, in which case it could be a few things.
        Token t = m_lexer.PeekNextToken();
        
        #if false
        // Skip past any ';' (as empty statements)
        while(t.TokenType == Token.Type.cSemi)
        {
            ConsumeNextToken();
            t = m_lexer.PeekNextToken();            
        }
        #endif
                       
        if (IsStartOfExp(t))
        {
            FileRange f = BeginRange();
            
            // This could be either an expression or a type
            Exp e = ParseExp();
            t = m_lexer.PeekNextToken();

            
            // Case 1 - Var declaration:
            // If an identifier follows, then we just read a type and this is
            // a var declaration:
            // Type id ';'
            // Type id '=' exp ';'
            if (t.TokenType == Token.Type.cId)
            {
                TypeSig tSig  = this.ConvertExpToType(e);

                Identifier id = ReadExpectedIdentifier();
                
                v = new LocalVarDecl(id, tSig);
                                
                // Check for optional assignment (if there's an '=' after the name)
                Token t3 = m_lexer.PeekNextToken();
                if (t3.TokenType == Token.Type.cAssign)
                {
                    ConsumeNextToken();                     // '='
                    Exp eRHS = ParseExp();                  // exp                
                    ReadExpectedToken(Token.Type.cSemi);    // ';'
                    
                    SimpleObjExp oleft = new SimpleObjExp(id);
                    StatementExp se = new AssignStmtExp(oleft, eRHS);
                    s = new ExpStatement(se);
                    
                    se.SetLocation(EndRange(f));
                } else {                
                    ReadExpectedToken(Token.Type.cSemi);    // ';'
                }


                
                return;
            } // end decl case

            // Case 2 - label declaration
            else if (t.TokenType == Token.Type.cColon)
            {                
                SimpleObjExp o2 = e as SimpleObjExp;
                if (o2 != null)
                {
                    ConsumeNextToken(); // ':'
                    s = new LabelStatement(o2.Name);
                    return; // skip reading a ';'
                } 
                
                ThrowError(new ParserErrorException(Code.cBadLabelDef, t.Location, 
                    "Bad label definition (labels must be a single identifier)"));                                
            } // end case for label decls
                        
            // Expect a StatementExp
            else if (t.TokenType == Token.Type.cSemi) {
                ReadExpectedToken(Token.Type.cSemi);
                
                // Else we must be a StatementExp
                StatementExp se = e as StatementExp;
                if (se == null)
                    //this.ThrowError_ExpectedStatementExp(e.Location);
                    ThrowError(E_ExpectedStatementExp(e.Location));
                
                se.SetLocation(EndRange(f));
                s = new ExpStatement(se);            
                return;
            }
    
            ThrowError(E_UnexpectedToken(t));
        } // end start of expressions
        
        switch(t.TokenType)
        {
        // Empty statement
        case Token.Type.cSemi:
//.........这里部分代码省略.........
开发者ID:chenzuo,项目名称:blue,代码行数:101,代码来源:Parser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LabelSymbol类代码示例发布时间:2022-05-24
下一篇:
C# Label类代码示例发布时间: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