예제 #1
0
 public virtual void VisitCaseLabel(CaseLabel caseLabel)
 {
     if (ThrowException)
     {
         throw (Exception)CreateException(caseLabel);
     }
 }
예제 #2
0
 public virtual void VisitCaseLabel(CaseLabel caseLabel)
 {
     if (this.ThrowException)
     {
         throw (System.Exception) this.CreateException(caseLabel);
     }
 }
예제 #3
0
 public SwitchBlock(IEmitter emitter, CaseLabel caseLabel, string varName, bool isFirst)
     : base(emitter, caseLabel)
 {
     this.Emitter = emitter;
     this.CaseLabel = caseLabel;
     varName_ = varName;
     isFirst_ = isFirst;
 }
예제 #4
0
        private void ProcessSwitchCase(XmlElement parent, CaseLabel switchCase)
        {
            XmlElement tmpElement = document.CreateElement("SwitchCase");

            tmpElement.SetAttribute("HashCode", switchCase.Value.ToString());
            tmpElement.SetAttribute("Address", switchCase.Address.ToString());
            parent.AppendChild(tmpElement);
        }
예제 #5
0
 public SwitchBlock(IEmitter emitter, CaseLabel caseLabel, string varName, bool isFirst)
     : base(emitter, caseLabel)
 {
     this.Emitter   = emitter;
     this.CaseLabel = caseLabel;
     varName_       = varName;
     isFirst_       = isFirst;
 }
예제 #6
0
        public JNode VisitCaseLabel(CaseLabel node)
        {
            var node2 = new JSwitchLabel
            {
                IsDefault  = node.Expression.IsNull, //the alternative doesn't work: node.Role == CaseLabel.DefaultKeywordRole,
                Expression = VisitExpression(node.Expression),
            };

            return(node2);
        }
예제 #7
0
        protected void VisitCaseLabel()
        {
            CaseLabel caseLabel = this.CaseLabel;

            if (!caseLabel.Expression.IsNull)
            {
                if (!isFirst_)
                {
                    this.Write(" or ");
                }
                this.Write(varName_, " == ");
                caseLabel.Expression.AcceptVisitor(this.Emitter);
            }
        }
예제 #8
0
        protected void VisitCaseLabel()
        {
            CaseLabel caseLabel = this.CaseLabel;

            if (caseLabel.Expression.IsNull)
            {
                this.Write("default");
            }
            else
            {
                this.Write("case ");
                caseLabel.Expression.AcceptVisitor(this.Emitter);
            }

            this.WriteColon();
            this.WriteNewLine();
        }
예제 #9
0
        bool CompareCase(CaseLabel label, GotoCaseStatement stmt)
        {
            if (label.IsDefault && stmt.IsDefaultCase)
            {
                return(true);
            }

            if (stmt.Expression is PrimitiveExpression && label.Label is PrimitiveExpression)
            {
                PrimitiveExpression e1 = stmt.Expression as PrimitiveExpression;
                PrimitiveExpression e2 = label.Label as PrimitiveExpression;

                return(object.Equals(e1.Value, e2.Value));
            }

            return(false);
        }
예제 #10
0
        protected void VisitCaseLabel()
        {
            CaseLabel caseLabel = CaseLabel;

            if (caseLabel.Expression.IsNull)
            {
                Write("default");
            }
            else
            {
                Write("case ");

                var rr     = Emitter.Resolver.ResolveNode(caseLabel.Expression.GetParent <SwitchStatement>().Expression);
                var caserr = Emitter.Resolver.ResolveNode(caseLabel.Expression);

                if (Helpers.Is64Type(rr.Type, Emitter.Resolver))
                {
                    if (caserr is ConstantResolveResult)
                    {
                        WriteScript(caserr.ConstantValue.ToString());
                    }
                    else
                    {
                        caseLabel.Expression.AcceptVisitor(Emitter);
                        WriteDot();
                        Write(JS.Funcs.TOSTIRNG);
                        WriteOpenCloseParentheses();
                    }
                }
                else
                {
                    caseLabel.Expression.AcceptVisitor(Emitter);
                }

                if (caserr.Type.Kind == TypeKind.Null)
                {
                    WriteColon();
                    WriteNewLine();
                    Write("case undefined");
                }
            }

            WriteColon();
            WriteNewLine();
        }
		public virtual object VisitCaseLabel(CaseLabel caseLabel, object data) {
			Debug.Assert((caseLabel != null));
			Debug.Assert((caseLabel.Label != null));
			Debug.Assert((caseLabel.ToExpression != null));
			nodeStack.Push(caseLabel.Label);
			caseLabel.Label.AcceptVisitor(this, data);
			caseLabel.Label = ((Expression)(nodeStack.Pop()));
			nodeStack.Push(caseLabel.ToExpression);
			caseLabel.ToExpression.AcceptVisitor(this, data);
			caseLabel.ToExpression = ((Expression)(nodeStack.Pop()));
			return null;
		}
예제 #12
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            CaseLabel o = other as CaseLabel;

            return(o != null && this.Expression.DoMatch(o.Expression, match));
        }
 protected internal Expression VisitCaseLabel(CaseLabel label)
 {
     return(label.Update(label.Target, label.DefaultValue));
 }
예제 #14
0
 public override object VisitCaseLabel(CaseLabel caseLabel, object data)
 {
     caseLabel.Label.Parent        = caseLabel;
     caseLabel.ToExpression.Parent = caseLabel;
     return(base.VisitCaseLabel(caseLabel, data));
 }
예제 #15
0
 public override StringBuilder VisitCaseLabel(CaseLabel caseLabel, int data)
 {
     return new StringBuilder("case ").Append(caseLabel.Expression.AcceptVisitor(this, data)).Append(":");
 }
예제 #16
0
			public override object Visit (Switch switchStatement)
			{
				var result = new SwitchStatement ();
				
				var location = LocationsBag.GetLocations (switchStatement);
				result.AddChild (new CSharpTokenNode (Convert (switchStatement.loc), "switch".Length), SwitchStatement.Roles.Keyword);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), SwitchStatement.Roles.LPar);
				result.AddChild ((INode)switchStatement.Expr.Accept (this), SwitchStatement.Roles.Expression);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), SwitchStatement.Roles.RPar);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), SwitchStatement.Roles.LBrace);
				foreach (var section in switchStatement.Sections) {
					var newSection = new MonoDevelop.CSharp.Dom.SwitchSection ();
					foreach (var caseLabel in section.Labels) {
						var newLabel = new CaseLabel ();
						newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), "case".Length), SwitchStatement.Roles.Keyword);
						if (caseLabel.Label != null)
							newLabel.AddChild ((INode)caseLabel.Label.Accept (this), SwitchStatement.Roles.Expression);
						
						newSection.AddChild (newLabel, MonoDevelop.CSharp.Dom.SwitchSection.CaseLabelRole);
					}
					newSection.AddChild ((INode)section.Block.Accept (this), MonoDevelop.CSharp.Dom.SwitchSection.Roles.Body);
					result.AddChild (newSection, SwitchStatement.SwitchSectionRole);
				}
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), SwitchStatement.Roles.RBrace);
				return result;
			}
예제 #17
0
 public abstract StringBuilder VisitCaseLabel(CaseLabel caseLabel, int data);
예제 #18
0
 public override object VisitCaseLabel(CaseLabel caseLabel, object data)
 {
     this.cases.Add(caseLabel);
     return(base.VisitCaseLabel(caseLabel, data));
 }
예제 #19
0
        private static bool IsDefaultCase(SwitchSection switchSection)
        {
            CaseLabel firstCaseLabel = switchSection.CaseLabels.FirstOrNullObject();

            return(firstCaseLabel.Expression.IsNull);
        }
예제 #20
0
 public override StringBuilder VisitCaseLabel(CaseLabel caseLabel, int data)
 {
     return(new StringBuilder("case ").Append(caseLabel.Expression.AcceptVisitor(this, data)).Append(":"));
 }
예제 #21
0
 public object VisitCaseLabel(CaseLabel caseLabel, object data)
 {
     throw new ApplicationException("CaseLabel was visited.");
 }
예제 #22
0
		public virtual void VisitCaseLabel(CaseLabel caseLabel)
		{
			DebugExpression(caseLabel);
			StartNode(caseLabel);
			if (caseLabel.Expression.IsNull) {
				WriteKeywordReference(CaseLabel.DefaultKeywordRole, currentSwitchReference);
			} else {
				WriteKeywordReference(CaseLabel.CaseKeywordRole, currentSwitchReference);
				Space();
				caseLabel.Expression.AcceptVisitor(this);
			}
			WriteToken(Roles.Colon, BoxedTextColor.Punctuation);
			EndNode(caseLabel);
		}
예제 #23
0
	void SwitchLabel(
#line  1690 "cs.ATG" 
out CaseLabel label) {

#line  1691 "cs.ATG" 
		Expression expr = null; label = null; 
		if (la.kind == 55) {
			lexer.NextToken();
			Expr(
#line  1693 "cs.ATG" 
out expr);
			Expect(9);

#line  1693 "cs.ATG" 
			label =  new CaseLabel(expr); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(9);

#line  1694 "cs.ATG" 
			label =  new CaseLabel(); 
		} else SynErr(205);
	}
예제 #24
0
        void ReleaseDesignerOutlets()
        {
            if (AContentView != null)
            {
                AContentView.Dispose();
                AContentView = null;
            }

            if (AreaLabel != null)
            {
                AreaLabel.Dispose();
                AreaLabel = null;
            }

            if (AuthorLabel != null)
            {
                AuthorLabel.Dispose();
                AuthorLabel = null;
            }

            if (BookSize != null)
            {
                BookSize.Dispose();
                BookSize = null;
            }

            if (BookSizeLabel != null)
            {
                BookSizeLabel.Dispose();
                BookSizeLabel = null;
            }

            if (BookTitleLabel != null)
            {
                BookTitleLabel.Dispose();
                BookTitleLabel = null;
            }

            if (CaseLabel != null)
            {
                CaseLabel.Dispose();
                CaseLabel = null;
            }

            if (CasesButton != null)
            {
                CasesButton.Dispose();
                CasesButton = null;
            }

            if (CaseTextField != null)
            {
                CaseTextField.Dispose();
                CaseTextField = null;
            }

            if (CaseView != null)
            {
                CaseView.Dispose();
                CaseView = null;
            }

            if (ContactEmailLabel != null)
            {
                ContactEmailLabel.Dispose();
                ContactEmailLabel = null;
            }

            if (ContactPhoneLabel != null)
            {
                ContactPhoneLabel.Dispose();
                ContactPhoneLabel = null;
            }

            if (CoverImageView != null)
            {
                CoverImageView.Dispose();
                CoverImageView = null;
            }

            if (CurrencyDate != null)
            {
                CurrencyDate.Dispose();
                CurrencyDate = null;
            }

            if (CurrencyDateLabel != null)
            {
                CurrencyDateLabel.Dispose();
                CurrencyDateLabel = null;
            }

            if (CurrentDayLabel != null)
            {
                CurrentDayLabel.Dispose();
                CurrentDayLabel = null;
            }

            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

            if (DescriptionView != null)
            {
                DescriptionView.Dispose();
                DescriptionView = null;
            }

            if (DespTextField != null)
            {
                DespTextField.Dispose();
                DespTextField = null;
            }

            if (ExpiredInfoTF != null)
            {
                ExpiredInfoTF.Dispose();
                ExpiredInfoTF = null;
            }

            if (ExpiredLabel != null)
            {
                ExpiredLabel.Dispose();
                ExpiredLabel = null;
            }

            if (ExpiredView != null)
            {
                ExpiredView.Dispose();
                ExpiredView = null;
            }

            if (InfoLabel != null)
            {
                InfoLabel.Dispose();
                InfoLabel = null;
            }

            if (InformationView != null)
            {
                InformationView.Dispose();
                InformationView = null;
            }

            if (InstalledDate != null)
            {
                InstalledDate.Dispose();
                InstalledDate = null;
            }

            if (InstalledLabel != null)
            {
                InstalledLabel.Dispose();
                InstalledLabel = null;
            }

            if (LoanButton != null)
            {
                LoanButton.Dispose();
                LoanButton = null;
            }

            if (PracticeArea != null)
            {
                PracticeArea.Dispose();
                PracticeArea = null;
            }

            if (ProgressBar != null)
            {
                ProgressBar.Dispose();
                ProgressBar = null;
            }

            if (ProgressStatusLabel != null)
            {
                ProgressStatusLabel.Dispose();
                ProgressStatusLabel = null;
            }

            if (ProgressView != null)
            {
                ProgressView.Dispose();
                ProgressView = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (Subcategory != null)
            {
                Subcategory.Dispose();
                Subcategory = null;
            }

            if (SubcategoryLabel != null)
            {
                SubcategoryLabel.Dispose();
                SubcategoryLabel = null;
            }

            if (TagsView != null)
            {
                TagsView.Dispose();
                TagsView = null;
            }

            if (TitleView != null)
            {
                TitleView.Dispose();
                TitleView = null;
            }

            if (UpdateButton != null)
            {
                UpdateButton.Dispose();
                UpdateButton = null;
            }

            if (UpdateInfoLabel != null)
            {
                UpdateInfoLabel.Dispose();
                UpdateInfoLabel = null;
            }

            if (Version != null)
            {
                Version.Dispose();
                Version = null;
            }

            if (VersionLabel != null)
            {
                VersionLabel.Dispose();
                VersionLabel = null;
            }

            if (WhatNewInfoLabel != null)
            {
                WhatNewInfoLabel.Dispose();
                WhatNewInfoLabel = null;
            }

            if (WhatNewInfoView != null)
            {
                WhatNewInfoView.Dispose();
                WhatNewInfoView = null;
            }

            if (WhatNewLabel != null)
            {
                WhatNewLabel.Dispose();
                WhatNewLabel = null;
            }

            if (WhatNewView != null)
            {
                WhatNewView.Dispose();
                WhatNewView = null;
            }

            if (DotButton != null)
            {
                DotButton.Dispose();
                DotButton = null;
            }
        }
예제 #25
0
 public override object VisitCaseLabel(CaseLabel caseLabel, object data)
 {
     return(base.VisitCaseLabel(caseLabel, data));
 }
예제 #26
0
 public virtual object VisitCaseLabel(CaseLabel caseLabel, object data)
 {
     throw new global::System.NotImplementedException("CaseLabel");
 }
예제 #27
0
	void CaseClause(
#line  3188 "VBNET.ATG" 
out CaseLabel caseClause) {

#line  3190 "VBNET.ATG" 
		Expression expr = null;
		Expression sexpr = null;
		BinaryOperatorType op = BinaryOperatorType.None;
		caseClause = null;
		
		if (la.kind == 98) {
			lexer.NextToken();

#line  3196 "VBNET.ATG" 
			caseClause = new CaseLabel(); 
		} else if (StartOf(43)) {
			if (la.kind == 131) {
				lexer.NextToken();
			}
			switch (la.kind) {
			case 28: {
				lexer.NextToken();

#line  3200 "VBNET.ATG" 
				op = BinaryOperatorType.LessThan; 
				break;
			}
			case 27: {
				lexer.NextToken();

#line  3201 "VBNET.ATG" 
				op = BinaryOperatorType.GreaterThan; 
				break;
			}
			case 31: {
				lexer.NextToken();

#line  3202 "VBNET.ATG" 
				op = BinaryOperatorType.LessThanOrEqual; 
				break;
			}
			case 30: {
				lexer.NextToken();

#line  3203 "VBNET.ATG" 
				op = BinaryOperatorType.GreaterThanOrEqual; 
				break;
			}
			case 10: {
				lexer.NextToken();

#line  3204 "VBNET.ATG" 
				op = BinaryOperatorType.Equality; 
				break;
			}
			case 29: {
				lexer.NextToken();

#line  3205 "VBNET.ATG" 
				op = BinaryOperatorType.InEquality; 
				break;
			}
			default: SynErr(285); break;
			}
			Expr(
#line  3207 "VBNET.ATG" 
out expr);

#line  3209 "VBNET.ATG" 
			caseClause = new CaseLabel(op, expr);
			
		} else if (StartOf(29)) {
			Expr(
#line  3211 "VBNET.ATG" 
out expr);
			if (la.kind == 201) {
				lexer.NextToken();
				Expr(
#line  3211 "VBNET.ATG" 
out sexpr);
			}

#line  3213 "VBNET.ATG" 
			caseClause = new CaseLabel(expr, sexpr);
			
		} else SynErr(286);
	}
예제 #28
0
		public override void VisitCaseLabel(CaseLabel caseLabel)
		{
			FixSemicolon(caseLabel.ColonToken);
		}
예제 #29
0
파일: TempEmitter.cs 프로젝트: yctri/Bridge
 public void VisitCaseLabel(CaseLabel caseLabel)
 {
     throw new NotImplementedException();
 }
예제 #30
0
			public override object Visit(SwitchLabel switchLabel)
			{
				var newLabel = new CaseLabel();
				if (!switchLabel.IsDefault) {
					newLabel.AddChild(new CSharpTokenNode(Convert(switchLabel.Location), CaseLabel.CaseKeywordRole), CaseLabel.CaseKeywordRole);
					if (switchLabel.Label != null)
						newLabel.AddChild((Expression)switchLabel.Label.Accept(this), Roles.Expression);
					var colonLocation = LocationsBag.GetLocations(switchLabel);
					if (colonLocation != null)
						newLabel.AddChild(new CSharpTokenNode(Convert(colonLocation [0]), Roles.Colon), Roles.Colon);
				} else {
					newLabel.AddChild(new CSharpTokenNode(Convert(switchLabel.Location), CaseLabel.DefaultKeywordRole), CaseLabel.DefaultKeywordRole);
					newLabel.AddChild(new CSharpTokenNode(new TextLocation(switchLabel.Location.Row, switchLabel.Location.Column + "default".Length), Roles.Colon), Roles.Colon);
				}
				return newLabel;
			}
예제 #31
0
		public virtual object VisitCaseLabel(CaseLabel caseLabel, object data) {
			Debug.Assert((caseLabel != null));
			Debug.Assert((caseLabel.Label != null));
			Debug.Assert((caseLabel.ToExpression != null));
			caseLabel.Label.AcceptVisitor(this, data);
			return caseLabel.ToExpression.AcceptVisitor(this, data);
		}
예제 #32
0
 public SwitchBlock(IEmitter emitter, CaseLabel caseLabel)
     : base(emitter, caseLabel)
 {
     Emitter   = emitter;
     CaseLabel = caseLabel;
 }
예제 #33
0
 public StringBuilder VisitCaseLabel(CaseLabel caseLabel)
 {
     throw new NotImplementedException();
 }
예제 #34
0
 public SwitchBlock(IEmitter emitter, CaseLabel caseLabel)
     : base(emitter, caseLabel)
 {
     this.Emitter = emitter;
     this.CaseLabel = caseLabel;
 }
예제 #35
0
 public virtual object Visit(CaseLabel caseLabel, object data)
 {
     Debug.Assert(caseLabel != null);
     Debug.Assert(caseLabel.Label != null);
     return(caseLabel.Label.AcceptVisitor(this, data));
 }
예제 #36
0
 private void SwitchLabel(out CaseLabel label)
 {
     Expression expr = null;
     label = null;
     if (this.la.kind == 0x36)
     {
         base.lexer.NextToken();
         this.Expr(out expr);
         base.Expect(9);
         label = new CaseLabel(expr);
     }
     else if (this.la.kind == 0x3e)
     {
         base.lexer.NextToken();
         base.Expect(9);
         label = new CaseLabel();
     }
     else
     {
         base.SynErr(0xb1);
     }
 }
예제 #37
0
        public void VisitCaseLabel(CaseLabel caseLabel)
        {
            JsonObject label = new JsonObject();
            label.Comment = "VisitCaseLabel";
            if (caseLabel.Expression.IsNull)
            {
                AddKeyword(label, CaseLabel.DefaultKeywordRole);

            }
            else
            {
                AddKeyword(label, CaseLabel.CaseKeywordRole);
                label.AddJsonValue("expression", GenExpression(caseLabel.Expression));
            }

            Push(label);
        }
예제 #38
0
 /// <summary>
 /// Sets the target label.
 /// </summary>
 /// <param name='targetLabel'>
 /// Target label.
 /// </param>
 public void SetTargetLabel(CaseLabel targetLabel)
 {
     this.targetLabel = targetLabel;
 }
예제 #39
0
 public SwitchBlock(IEmitter emitter, CaseLabel caseLabel)
 {
     this.Emitter   = emitter;
     this.CaseLabel = caseLabel;
 }
 public override void VisitCaseLabel(CaseLabel syntax)
 {
     _underlyingVisitor.VisitCaseLabel(syntax);
 }
예제 #41
0
파일: Lower.cs 프로젝트: evanw/minisharp
 public void VisitCaseLabel(CaseLabel node)
 {
     VisitChildren(node);
 }
예제 #42
0
 public override void VisitCaseLabel(CaseLabel caseLabel)
 {
     new SwitchBlock(this, caseLabel).Emit();
 }
예제 #43
0
 public override void VisitCaseLabel(CaseLabel caseLabel)
 {
     //new SwitchBlock(this, caseLabel).Emit();
     throw new System.NotSupportedException();
 }
		public virtual object TrackedVisitCaseLabel(CaseLabel caseLabel, object data) {
			return base.VisitCaseLabel(caseLabel, data);
		}
		public virtual object VisitCaseLabel(CaseLabel caseLabel, object data) {
			throw new global::System.NotImplementedException("CaseLabel");
		}
		public sealed override object VisitCaseLabel(CaseLabel caseLabel, object data) {
			BeginVisit(caseLabel);
			object result = TrackedVisitCaseLabel(caseLabel, data);
			EndVisit(caseLabel);
			return result;
		}
		public override void VisitCaseLabel(CaseLabel caseLabel)
		{
			ForceSpacesBefore(caseLabel.ColonToken, false);
		}
 public virtual void VisitCaseLabel(CaseLabel caseLabel)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(caseLabel);
     }
 }
 public override void VisitCaseLabel(CaseLabel caseLabel)
 {
     throw NotSupportedToConsistency();
 }
예제 #50
0
            public override object Visit(Switch switchStatement)
            {
                var result = new SwitchStatement ();

                var location = LocationsBag.GetLocations (switchStatement);
                result.AddChild (new CSharpTokenNode (Convert (switchStatement.loc), SwitchStatement.SwitchKeywordRole), SwitchStatement.SwitchKeywordRole);
                if (location != null)
                    result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar);
                if (switchStatement.Expr != null)
                    result.AddChild ((Expression)switchStatement.Expr.Accept (this), Roles.Expression);
                if (location != null && location.Count > 1)
                    result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar);
                if (location != null && location.Count > 2)
                    result.AddChild (new CSharpTokenNode (Convert (location [2]), Roles.LBrace), Roles.LBrace);
                if (switchStatement.Sections != null) {
                    foreach (var section in switchStatement.Sections) {
                        var newSection = new SwitchSection ();
                        if (section.Labels != null) {
                            foreach (var caseLabel in section.Labels) {
                                var newLabel = new CaseLabel ();
                                if (caseLabel.Label != null) {
                                    newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), CaseLabel.CaseKeywordRole), CaseLabel.CaseKeywordRole);
                                    if (caseLabel.Label != null)
                                        newLabel.AddChild ((Expression)caseLabel.Label.Accept (this), Roles.Expression);
                                    var colonLocation = LocationsBag.GetLocations (caseLabel);
                                    if (colonLocation != null)
                                        newLabel.AddChild (new CSharpTokenNode (Convert (colonLocation [0]), Roles.Colon), Roles.Colon);
                                } else {
                                    newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), CaseLabel.DefaultKeywordRole), CaseLabel.DefaultKeywordRole);
                                    newLabel.AddChild (new CSharpTokenNode (new TextLocation (caseLabel.Location.Row, caseLabel.Location.Column + "default".Length), Roles.Colon), Roles.Colon);
                                }
                                newSection.AddChild (newLabel, SwitchSection.CaseLabelRole);
                            }
                        }

                        var blockStatement = section.Block;
                        var bodyBlock = new BlockStatement ();
                        int curLocal = 0;
                        AddBlockChildren (bodyBlock, blockStatement, ref curLocal);
                        foreach (var statement in bodyBlock.Statements) {
                            statement.Remove ();
                            newSection.AddChild (statement, Roles.EmbeddedStatement);

                        }
                        result.AddChild (newSection, SwitchStatement.SwitchSectionRole);
                    }
                }

                if (location != null && location.Count > 3) {
                    result.AddChild (new CSharpTokenNode (Convert (location [3]), Roles.RBrace), Roles.RBrace);
                } else {
                    // parser error, set end node to max value.
                    result.AddChild (new ErrorNode (), Roles.Error);
                }

                return result;
            }
예제 #51
0
 public abstract StringBuilder VisitCaseLabel(CaseLabel caseLabel, int data);
		public virtual void VisitCaseLabel (CaseLabel caseLabel)
		{
			VisitChildren (caseLabel);
		}
예제 #53
0
			public override object Visit (Switch switchStatement)
			{
				var result = new SwitchStatement ();
				
				var location = LocationsBag.GetLocations (switchStatement);
				result.AddChild (new CSharpTokenNode (Convert (switchStatement.loc), "switch".Length), SwitchStatement.Roles.Keyword);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), SwitchStatement.Roles.LPar);
				result.AddChild ((Expression)switchStatement.Expr.Accept (this), SwitchStatement.Roles.Expression);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), SwitchStatement.Roles.RPar);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), SwitchStatement.Roles.LBrace);
				foreach (var section in switchStatement.Sections) {
					var newSection = new SwitchSection ();
					foreach (var caseLabel in section.Labels) {
						var newLabel = new CaseLabel ();
						newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), "case".Length), SwitchStatement.Roles.Keyword);
						if (caseLabel.Label != null)
							newLabel.AddChild ((Expression)caseLabel.Label.Accept (this), SwitchStatement.Roles.Expression);
						
						newSection.AddChild (newLabel, SwitchSection.CaseLabelRole);
					}
					
					var blockStatement = section.Block;
					var bodyBlock = new BlockStatement ();
					int curLocal = 0;
					AddBlockChildren (bodyBlock, blockStatement, ref curLocal);
					foreach (var statement in bodyBlock.Statements) {
						statement.Remove ();
						newSection.AddChild (statement, SwitchSection.Roles.EmbeddedStatement);
						
					}
					result.AddChild (newSection, SwitchStatement.SwitchSectionRole);
				}
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), SwitchStatement.Roles.RBrace);
				return result;
			}
예제 #54
0
		public void VisitCaseLabel(CaseLabel caseLabel)
		{
			StartNode(caseLabel);
			if (caseLabel.Expression.IsNull) {
				WriteKeyword(CaseLabel.DefaultKeywordRole);
			} else {
				WriteKeyword(CaseLabel.CaseKeywordRole);
				Space();
				caseLabel.Expression.AcceptVisitor(this);
			}
			WriteToken(Roles.Colon);
			EndNode(caseLabel);
		}
 /// <inheritdoc/>
 public virtual void VisitCaseLabel(CaseLabel syntax)
 {
     VisitNode(syntax);
 }
예제 #56
0
 /// <summary>
 /// Sets the target label.
 /// </summary>
 /// <param name='targetLabel'>
 /// Target label.
 /// </param>
 public void SetTargetLabel(CaseLabel targetLabel)
 {
     this.targetLabel = targetLabel;
 }
예제 #57
0
 public override void VisitCaseLabel(CaseLabel caseLabel)
 {
     new SwitchBlock(this, caseLabel).Emit();
 }