public virtual object Visit(GotoCase gotoCase)
 {
     return(null);
 }
Esempio n. 2
0
 public virtual Statement VisitGotoCase(GotoCase gotoCase, GotoCase changes, GotoCase deletions, GotoCase insertions){
   this.UpdateSourceContext(gotoCase, changes);
   if (gotoCase == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return gotoCase;
 }
    public virtual Differences VisitGotoCase(GotoCase gotoCase1, GotoCase gotoCase2){
      Differences differences = new Differences(gotoCase1, gotoCase2);
      if (gotoCase1 == null || gotoCase2 == null){
        if (gotoCase1 != gotoCase2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      GotoCase changes = (GotoCase)gotoCase2.Clone();
      GotoCase deletions = (GotoCase)gotoCase2.Clone();
      GotoCase insertions = (GotoCase)gotoCase2.Clone();

      Differences diff = this.VisitExpression(gotoCase1.CaseLabel, gotoCase2.CaseLabel);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.CaseLabel = diff.Changes as Identifier;
      deletions.CaseLabel = diff.Deletions as Identifier;
      insertions.CaseLabel = diff.Insertions as Identifier;
      Debug.Assert(diff.Changes == changes.CaseLabel && diff.Deletions == deletions.CaseLabel && diff.Insertions == insertions.CaseLabel);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
			public override object Visit (GotoCase gotoCase)
			{
				var result = new GotoCaseStatement ();
				result.AddChild (new CSharpTokenNode (Convert (gotoCase.loc), GotoCaseStatement.GotoKeywordRole), GotoCaseStatement.GotoKeywordRole);
				
				var location = LocationsBag.GetLocations (gotoCase);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), GotoCaseStatement.CaseKeywordRole), GotoCaseStatement.CaseKeywordRole);
				if (gotoCase.Expr != null)
					result.AddChild ((Expression)gotoCase.Expr.Accept (this), Roles.Expression);
				if (location != null && location.Count > 1)
					result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.Semicolon), Roles.Semicolon);
				return result;
			}
Esempio n. 5
0
void case_974()
#line 6487 "cs-parser.jay"
{
		yyVal = new GotoCase ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
Esempio n. 6
0
 public virtual Statement VisitGotoCase(GotoCase gotoCase){
   if (gotoCase == null) return null;
   gotoCase.CaseLabel = this.VisitExpression(gotoCase.CaseLabel);
   return gotoCase;
 }
Esempio n. 7
0
 public override Statement VisitGotoCase(GotoCase gotoCase) {
   if (gotoCase == null) return null;
   if (this.switchCaseCount <= 0) {
     this.HandleError(gotoCase, Error.InvalidGotoCase);
     return null;
   }
   Literal lit = gotoCase.CaseLabel as Literal;
   if (lit == null && gotoCase.CaseLabel != null) {
     this.HandleError(gotoCase.CaseLabel, Error.ConstantExpected);
     return null;
   }
   object labelVal = null;
   if (lit != null) {
     if (this.currentSwitchGoverningType != null)
       lit = this.typeSystem.ImplicitLiteralCoercionForLabel(lit, lit.Type, this.currentSwitchGoverningType, this.TypeViewer);
     if (lit == null) return null;
     lit.SourceContext = gotoCase.CaseLabel.SourceContext;
     gotoCase.CaseLabel = lit;
     labelVal = lit.Value;
   }
   SwitchCaseList currentCases = this.currentSwitchCases;
   for (int i = 0, n = currentCases == null ? 0 : currentCases.Count; i < n; i++) {
     SwitchCase scase = currentCases[i];
     if (scase == null) continue;
     if (gotoCase.CaseLabel == null) {
       if (scase.Label != null) continue;
       return new Branch(null, scase.Body, gotoCase.SourceContext);
     }
     Literal caseLit = scase.Label as Literal;
     object caseVal = caseLit == null ? null : caseLit.Value;
     if (caseVal == null || labelVal == null) continue;
     object labelValAsCaseType = labelVal;
     try {
       labelValAsCaseType = System.Convert.ChangeType(labelVal, caseVal.GetType());
     } catch { }
     if (caseVal.Equals(labelValAsCaseType))
       return new Branch(null, scase.Body, gotoCase.SourceContext);
   }
   if (gotoCase.CaseLabel == null)
     this.HandleError(gotoCase, Error.LabelNotFound, "default:");
   else
     this.HandleError(gotoCase, Error.LabelNotFound, "case "+gotoCase.CaseLabel.SourceContext.SourceText+":");
   return null;
 }
Esempio n. 8
0
 public virtual void VisitGotoCase(GotoCase gotoCase)
 {
   if (gotoCase == null) return;
   this.VisitExpression(gotoCase.CaseLabel);
 }
Esempio n. 9
0
		public virtual object Visit (GotoCase gotoCase)
		{
			return null;
		}
Esempio n. 10
0
 public override Statement VisitGotoCase(GotoCase gotoCase)
 {
     if (gotoCase == null) return null;
     return base.VisitGotoCase((GotoCase)gotoCase.Clone());
 }
Esempio n. 11
0
 public virtual Statement VisitGotoCase(GotoCase gotoCase1, GotoCase gotoCase2)
 {
     if (gotoCase1 == null) return null;
     if (gotoCase2 == null)
     {
         gotoCase1.CaseLabel = this.VisitExpression(gotoCase1.CaseLabel, null);
     }
     else
     {
         gotoCase1.CaseLabel = this.VisitExpression(gotoCase1.CaseLabel, gotoCase2.CaseLabel);
     }
     return gotoCase1;
 }