Inheritance: ICSharpCode.NRefactory.Ast.Statement
 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     if (tryCatchStatement.CatchClauses.Count > 0 && tryCatchStatement.FinallyBlock.IsNull)
     {
         UnlockWith(tryCatchStatement);
     }
     return base.VisitTryCatchStatement(tryCatchStatement, data);
 }
 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     if (tryCatchStatement.CatchClauses.Count > 0)
     {
         foreach (CatchClause catchClause in tryCatchStatement.CatchClauses)
         {
             if (catchClause.StatementBlock.Children.Count == 1 && catchClause.StatementBlock.Children[0] is ThrowStatement)
                 UnlockWith(tryCatchStatement);
         }
     }
     return base.VisitTryCatchStatement(tryCatchStatement, data);
 }
		/// <summary>
		/// Converts an NRefactory try-catch statement to a code dom
		/// try-catch statement.
		/// </summary>
		public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
		{
			// Convert try-catch body.
			AppendIndentedLine("try:");
			IncreaseIndent();
			tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
			DecreaseIndent();
			
			// Convert catches.
			foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
				AppendIndented("except ");
				Append(catchClause.TypeReference.Type);
				Append(", " + catchClause.VariableName + ":");
				AppendLine();
				
				// Convert catch child statements.
				IncreaseIndent();
				catchClause.StatementBlock.AcceptVisitor(this, data);
				DecreaseIndent();
			}
			
			// Convert finally block.
			AppendIndentedLine("finally:");
			IncreaseIndent();
			tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
			DecreaseIndent();
			
			return null;
		}
Esempio n. 4
0
	void TryStatement(
#line  1647 "cs.ATG" 
out Statement tryStatement) {

#line  1649 "cs.ATG" 
		Statement blockStmt = null, finallyStmt = null;
		List<CatchClause> catchClauses = null;
		
		Expect(114);
		Block(
#line  1653 "cs.ATG" 
out blockStmt);
		if (la.kind == 56) {
			CatchClauses(
#line  1655 "cs.ATG" 
out catchClauses);
			if (la.kind == 73) {
				lexer.NextToken();
				Block(
#line  1655 "cs.ATG" 
out finallyStmt);
			}
		} else if (la.kind == 73) {
			lexer.NextToken();
			Block(
#line  1656 "cs.ATG" 
out finallyStmt);
		} else SynErr(202);

#line  1659 "cs.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
			
	}
Esempio n. 5
0
 public virtual object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
     throw CreateException(tryCatchStatement);
 }
		public virtual object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
			return base.VisitTryCatchStatement(tryCatchStatement, data);
		}
 public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     this.AppendIndentedLine("try:");
     this.IncreaseIndent();
     tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
     this.DecreaseIndent();
     foreach (CatchClause catchClause in tryCatchStatement.CatchClauses)
     {
         this.AppendIndented("except ");
         this.Append(catchClause.TypeReference.Type);
         this.Append(string.Concat(", ", catchClause.VariableName, ":"));
         this.AppendLine();
         this.IncreaseIndent();
         catchClause.StatementBlock.AcceptVisitor(this, data);
         this.DecreaseIndent();
     }
     this.AppendIndentedLine("finally:");
     this.IncreaseIndent();
     tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
     this.DecreaseIndent();
     return null;
 }
		public object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
		{
			B.TryStatement t = new B.TryStatement(GetLexicalInfo(tryCatchStatement));
			t.EndSourceLocation = GetLocation(tryCatchStatement.EndLocation);
			t.ProtectedBlock = ConvertBlock(tryCatchStatement.StatementBlock);
			t.EnsureBlock = ConvertBlock(tryCatchStatement.FinallyBlock);
			foreach (CatchClause clause in tryCatchStatement.CatchClauses) {
				B.ExceptionHandler handler = new B.ExceptionHandler(GetLexicalInfo(clause));
				handler.Block = ConvertBlock(clause.StatementBlock);
				B.TypeReference typeRef = ConvertTypeReference(clause.TypeReference);
				string name = clause.VariableName;
				if (typeRef != null) {
					if (name == null || name.Length == 0)
						name = GenerateName();
					handler.Declaration = new B.Declaration(name, typeRef);
				} else {
					if (name != null && name.Length > 0)
						handler.Declaration = new B.Declaration(name, null);
				}
				t.ExceptionHandlers.Add(handler);
			}
			return t;
		}
Esempio n. 9
0
	void TryStatement(
#line  3245 "VBNET.ATG" 
out Statement tryStatement) {

#line  3247 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
		
		Expect(203);
		EndOfStmt();
		Block(
#line  3250 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 62 || la.kind == 100 || la.kind == 110) {
			CatchClauses(
#line  3251 "VBNET.ATG" 
out catchClauses);
		}
		if (la.kind == 110) {
			lexer.NextToken();
			EndOfStmt();
			Block(
#line  3252 "VBNET.ATG" 
out finallyStmt);
		}
		Expect(100);
		Expect(203);

#line  3255 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
Esempio n. 10
0
	void TryStatement(
#line  1667 "cs.ATG" 
out Statement tryStatement) {

#line  1669 "cs.ATG" 
		Statement blockStmt = null, finallyStmt = null;
		List<CatchClause> catchClauses = null;
		
		Expect(114);
		Block(
#line  1673 "cs.ATG" 
out blockStmt);
		if (la.kind == 56) {
			CatchClauses(
#line  1675 "cs.ATG" 
out catchClauses);
			if (la.kind == 73) {
				lexer.NextToken();
				Block(
#line  1675 "cs.ATG" 
out finallyStmt);
			}
		} else if (la.kind == 73) {
			lexer.NextToken();
			Block(
#line  1676 "cs.ATG" 
out finallyStmt);
		} else SynErr(203);

#line  1679 "cs.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		if (catchClauses != null) {
			foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement;
		}
		
	}
Esempio n. 11
0
	void TryStatement(
#line  2760 "VBNET.ATG" 
out Statement tryStatement) {

#line  2762 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
		
		Expect(174);
		EndOfStmt();
		Block(
#line  2765 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 58 || la.kind == 88 || la.kind == 97) {
			CatchClauses(
#line  2766 "VBNET.ATG" 
out catchClauses);
		}
		if (la.kind == 97) {
			lexer.NextToken();
			EndOfStmt();
			Block(
#line  2767 "VBNET.ATG" 
out finallyStmt);
		}
		Expect(88);
		Expect(174);

#line  2770 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
 private bool IsMatch(TryCatchStatement left, TryCatchStatement right)
 {
     return true;
 }
Esempio n. 13
0
		public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
		{
			return base.VisitTryCatchStatement(tryCatchStatement, data);
		}
Esempio n. 14
0
		IEnumerable<Statement> TransformNode(ILNode node)
		{
			if (node is ILLabel) {
				yield return new Ast.LabelStatement { Label = ((ILLabel)node).Name }.WithAnnotation(node.ILRanges);
			} else if (node is ILExpression) {
				AstNode codeExpr = TransformExpression((ILExpression)node);
				if (codeExpr != null) {
					if (codeExpr is Ast.Expression) {
						yield return new Ast.ExpressionStatement { Expression = (Ast.Expression)codeExpr };
					} else if (codeExpr is Ast.Statement) {
						yield return (Ast.Statement)codeExpr;
					} else {
						throw new Exception();
					}
				}
			} else if (node is ILWhileLoop) {
				ILWhileLoop ilLoop = (ILWhileLoop)node;
				Expression expr;
				WhileStatement whileStmt = new WhileStatement() {
					Condition = expr = ilLoop.Condition != null ? (Expression)TransformExpression(ilLoop.Condition) : new PrimitiveExpression(true),
					EmbeddedStatement = TransformBlock(ilLoop.BodyBlock)
				};
				expr.AddAnnotation(ilLoop.ILRanges);
				yield return whileStmt;
			} else if (node is ILCondition) {
				ILCondition conditionalNode = (ILCondition)node;
				bool hasFalseBlock = conditionalNode.FalseBlock.EntryGoto != null || conditionalNode.FalseBlock.Body.Count > 0;
				BlockStatement trueStmt;
				var ifElseStmt = new Ast.IfElseStatement {
					Condition = (Expression)TransformExpression(conditionalNode.Condition),
					TrueStatement = trueStmt = TransformBlock(conditionalNode.TrueBlock),
					FalseStatement = hasFalseBlock ? TransformBlock(conditionalNode.FalseBlock) : null
				};
				ifElseStmt.Condition.AddAnnotation(conditionalNode.ILRanges);
				if (ifElseStmt.FalseStatement == null)
					trueStmt.HiddenEnd = NRefactoryExtensions.CreateHidden(conditionalNode.FalseBlock.GetSelfAndChildrenRecursiveILRanges(), trueStmt.HiddenEnd);
				yield return ifElseStmt;
			} else if (node is ILSwitch) {
				ILSwitch ilSwitch = (ILSwitch)node;
				if (ilSwitch.Condition.InferredType.GetElementType() == ElementType.Boolean && (
					from cb in ilSwitch.CaseBlocks
					where cb.Values != null
					from val in cb.Values
					select val
				).Any(val => val != 0 && val != 1))
				{
					// If switch cases contain values other then 0 and 1, force the condition to be non-boolean
					ilSwitch.Condition.ExpectedType = corLib.Int32;
				}
				SwitchStatement switchStmt = new SwitchStatement() { Expression = (Expression)TransformExpression(ilSwitch.Condition) };
				switchStmt.Expression.AddAnnotation(ilSwitch.ILRanges);
				switchStmt.HiddenEnd = NRefactoryExtensions.CreateHidden(ilSwitch.EndILRanges, switchStmt.HiddenEnd);
				foreach (var caseBlock in ilSwitch.CaseBlocks) {
					SwitchSection section = new SwitchSection();
					if (caseBlock.Values != null) {
						section.CaseLabels.AddRange(caseBlock.Values.Select(i => new CaseLabel() { Expression = AstBuilder.MakePrimitive(i, (ilSwitch.Condition.ExpectedType ?? ilSwitch.Condition.InferredType).ToTypeDefOrRef()) }));
					} else {
						section.CaseLabels.Add(new CaseLabel());
					}
					section.Statements.Add(TransformBlock(caseBlock));
					switchStmt.SwitchSections.Add(section);
				}
				yield return switchStmt;
			} else if (node is ILTryCatchBlock) {
				ILTryCatchBlock tryCatchNode = ((ILTryCatchBlock)node);
				var tryCatchStmt = new Ast.TryCatchStatement();
				tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock);
				tryCatchStmt.TryBlock.HiddenStart = NRefactoryExtensions.CreateHidden(tryCatchNode.ILRanges, tryCatchStmt.TryBlock.HiddenStart);
				foreach (var catchClause in tryCatchNode.CatchBlocks) {
					if (catchClause.ExceptionVariable == null
					    && (catchClause.ExceptionType == null || catchClause.ExceptionType.GetElementType() == ElementType.Object))
					{
						tryCatchStmt.CatchClauses.Add(new Ast.CatchClause { Body = TransformBlock(catchClause) }.WithAnnotation(catchClause.StlocILRanges));
					} else {
						tryCatchStmt.CatchClauses.Add(
							new Ast.CatchClause {
								Type = AstBuilder.ConvertType(catchClause.ExceptionType),
								VariableNameToken = catchClause.ExceptionVariable == null ? null : Identifier.Create(catchClause.ExceptionVariable.Name).WithAnnotation(catchClause.ExceptionVariable.IsParameter ? TextTokenType.Parameter : TextTokenType.Local),
								Body = TransformBlock(catchClause)
							}.WithAnnotation(catchClause.ExceptionVariable).WithAnnotation(catchClause.StlocILRanges));
					}
				}
				if (tryCatchNode.FinallyBlock != null)
					tryCatchStmt.FinallyBlock = TransformBlock(tryCatchNode.FinallyBlock);
				if (tryCatchNode.FaultBlock != null) {
					CatchClause cc = new CatchClause();
					cc.Body = TransformBlock(tryCatchNode.FaultBlock);
					cc.Body.Add(new ThrowStatement()); // rethrow
					tryCatchStmt.CatchClauses.Add(cc);
				}
				yield return tryCatchStmt;
			} else if (node is ILFixedStatement) {
				ILFixedStatement fixedNode = (ILFixedStatement)node;
				FixedStatement fixedStatement = new FixedStatement();
				for (int i = 0; i < fixedNode.Initializers.Count; i++) {
					var initializer = fixedNode.Initializers[i];
					Debug.Assert(initializer.Code == ILCode.Stloc);
					ILVariable v = (ILVariable)initializer.Operand;
					VariableInitializer vi;
					fixedStatement.Variables.Add(vi =
						new VariableInitializer {
							NameToken = Identifier.Create(v.Name).WithAnnotation(v.IsParameter ? TextTokenType.Parameter : TextTokenType.Local),
							Initializer = (Expression)TransformExpression(initializer.Arguments[0])
						}.WithAnnotation(v));
					vi.AddAnnotation(ILRange.OrderAndJoin(initializer.GetSelfAndChildrenRecursiveILRanges()));
					if (i == 0)
						vi.AddAnnotation(ILRange.OrderAndJoin(fixedNode.ILRanges));
				}
				fixedStatement.Type = AstBuilder.ConvertType(((ILVariable)fixedNode.Initializers[0].Operand).Type);
				fixedStatement.EmbeddedStatement = TransformBlock(fixedNode.BodyBlock);
				yield return fixedStatement;
			} else if (node is ILBlock) {
				yield return TransformBlock((ILBlock)node);
			} else {
				throw new Exception("Unknown node type");
			}
		}
Esempio n. 15
0
 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     tryCatchStatement.StatementBlock.Parent = tryCatchStatement;
     tryCatchStatement.FinallyBlock.Parent = tryCatchStatement;
     foreach (CatchClause catchClause in tryCatchStatement.CatchClauses)
         catchClause.Parent = tryCatchStatement;
     return base.VisitTryCatchStatement(tryCatchStatement, data);
 }
 public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     if (tryCatchStatement.StatementBlock.Children.Count == 0)
         RemoveCurrentNode();
     return base.TrackedVisitTryCatchStatement(tryCatchStatement, data);
 }
Esempio n. 17
0
	void TryStatement(
#line  3597 "VBNET.ATG" 
out Statement tryStatement) {

#line  3599 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
		
		Expect(221);
		EndOfStmt();
		Block(
#line  3602 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 77 || la.kind == 115 || la.kind == 125) {
			CatchClauses(
#line  3603 "VBNET.ATG" 
out catchClauses);
		}
		if (la.kind == 125) {
			lexer.NextToken();
			EndOfStmt();
			Block(
#line  3604 "VBNET.ATG" 
out finallyStmt);
		}
		Expect(115);
		Expect(221);

#line  3607 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
Esempio n. 18
0
        IEnumerable<Ast.INode> TransformNode(Node node)
        {
            if (Options.NodeComments) {
                yield return MakeComment("// " + node.Description);
            }

            yield return new Ast.LabelStatement(node.Label);

            if (node is BasicBlock) {
                foreach(ILNode expr in ((BasicBlock)node).Body) {
                    if (expr is ILLabel) {
                        yield return new Ast.LabelStatement(((ILLabel)expr).Name);
                    } else {
                        Statement stmt = TransformExpressionToStatement((ILExpression)expr);
                        if (stmt != null) {
                            yield return stmt;
                        }
                    }
                }
                foreach(Ast.INode inode in TransformNodes(node.Childs)) {
                    yield return inode;
                }
                Node fallThroughNode = ((BasicBlock)node).FallThroughBasicBlock;
                // If there is default branch and it is not the following node
                if (fallThroughNode != null) {
                    yield return new Ast.GotoStatement(fallThroughNode.Label);
                }
            } else if (node is AcyclicGraph) {
                foreach(Ast.INode inode in TransformNodes(node.Childs)) {
                    yield return inode;
                }
            } else if (node is Loop) {
                Ast.BlockStatement blockStatement = new Ast.BlockStatement();
                blockStatement.Children.AddRange(TransformNodes(node.Childs));
                yield return new Ast.ForStatement(
                    null,
                    null,
                    null,
                    blockStatement
                );
            } else if (node is Block) {
                foreach(Ast.INode inode in TransformNodes(node.Childs)) {
                    yield return inode;
                }
            } else if (node is Branch) {
                yield return new Ast.LabelStatement(((Branch)node).FirstBasicBlock.Label);

                Ast.BlockStatement trueBlock = new Ast.BlockStatement();
                trueBlock.Children.Add(new Ast.GotoStatement(((Branch)node).TrueSuccessor.Label));

                Ast.BlockStatement falseBlock = new Ast.BlockStatement();
                falseBlock.Children.Add(new Ast.GotoStatement(((Branch)node).FalseSuccessor.Label));

                Ast.IfElseStatement ifElseStmt = new Ast.IfElseStatement(
                    MakeBranchCondition((Branch)node),
                    trueBlock,
                    falseBlock
                );
                trueBlock.Parent = ifElseStmt;
                falseBlock.Parent = ifElseStmt;

                yield return ifElseStmt;
            } else if (node is ConditionalNode) {
                ConditionalNode conditionalNode = (ConditionalNode)node;
                yield return new Ast.LabelStatement(conditionalNode.Condition.FirstBasicBlock.Label);

                Ast.BlockStatement trueBlock = new Ast.BlockStatement();
                // The block entry code
                trueBlock.Children.Add(new Ast.GotoStatement(conditionalNode.Condition.TrueSuccessor.Label));
                // Sugested content
                trueBlock.Children.AddRange(TransformNode(conditionalNode.TrueBody));

                Ast.BlockStatement falseBlock = new Ast.BlockStatement();
                // The block entry code
                falseBlock.Children.Add(new Ast.GotoStatement(conditionalNode.Condition.FalseSuccessor.Label));
                // Sugested content
                falseBlock.Children.AddRange(TransformNode(conditionalNode.FalseBody));

                Ast.IfElseStatement ifElseStmt = new Ast.IfElseStatement(
                    // Method bodies are swapped
                    new Ast.UnaryOperatorExpression(
                        new Ast.ParenthesizedExpression(
                            MakeBranchCondition(conditionalNode.Condition)
                        ),
                        UnaryOperatorType.Not
                    ),
                    falseBlock,
                    trueBlock
                );
                trueBlock.Parent = ifElseStmt;
                falseBlock.Parent = ifElseStmt;

                yield return ifElseStmt;
            } else if (node is TryCatchNode) {
                TryCatchNode tryCachNode = ((TryCatchNode)node);
                Ast.BlockStatement tryBlock = new Ast.BlockStatement();
                tryBlock.Children.AddRange(TransformNode(tryCachNode.Childs[0]));
                Ast.BlockStatement finallyBlock = null;
                if (tryCachNode.Childs[1].Childs.Count > 0) {
                    finallyBlock = new Ast.BlockStatement();
                    finallyBlock.Children.AddRange(TransformNode(tryCachNode.Childs[1]));
                }
                List<Ast.CatchClause> ccs = new List<CatchClause>();
                for (int i = 0; i < tryCachNode.Types.Count; i++) {
                    Ast.BlockStatement catchBlock = new Ast.BlockStatement();
                    catchBlock.Children.AddRange(TransformNode(tryCachNode.Childs[i + 2]));
                    Ast.CatchClause cc = new Ast.CatchClause(
                        new Ast.TypeReference(tryCachNode.Types[i].FullName),
                        "exception",
                        catchBlock
                    );
                    ccs.Add(cc);
                }
                Ast.TryCatchStatement tryCachStmt = new Ast.TryCatchStatement(tryBlock, ccs, finallyBlock);
                yield return tryCachStmt;
            } else {
                throw new Exception("Bad node type");
            }

            if (Options.NodeComments) {
                yield return MakeComment("");
            }
        }
Esempio n. 19
0
        public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
        {
            // add a try-catch-finally
            CodeTryCatchFinallyStatement tryStmt = new CodeTryCatchFinallyStatement();

            codeStack.Push(tryStmt.TryStatements);

            tryCatchStatement.StatementBlock.AcceptChildren(this, data);
            codeStack.Pop();

            if (!tryCatchStatement.FinallyBlock.IsNull) {
                codeStack.Push(tryStmt.FinallyStatements);

                tryCatchStatement.FinallyBlock.AcceptChildren(this,data);
                codeStack.Pop();
            }

            foreach (CatchClause clause in tryCatchStatement.CatchClauses)
            {
                CodeCatchClause catchClause = new CodeCatchClause(clause.VariableName);
                catchClause.CatchExceptionType = ConvType(clause.TypeReference);
                tryStmt.CatchClauses.Add(catchClause);

                codeStack.Push(catchClause.Statements);

                clause.StatementBlock.AcceptChildren(this, data);
                codeStack.Pop();
            }

            // Add Statement to Current Statement Collection
            AddStmt(tryStmt);

            return tryStmt;
        }
Esempio n. 20
0
 public override object VisitTryCatchStatement (TryCatchStatement node, object data)
 {
     if (node.CatchClauses.Count > 1)
         throw CreateException (node, "Multiple catch clauses are not supported");
     
     Write ("try ");
     node.StatementBlock.AcceptVisitor (this, null);
     foreach (var clause in node.CatchClauses) {
         PushLocals ();
         
         if (!clause.TypeReference.IsNull) {
             if (ResolveType (clause.TypeReference.Type) != "System.Exception")
                 throw CreateException (node, "Only System.Exception type is allowed in catch clauses");
         }
         var varName = clause.VariableName;
         if (String.IsNullOrEmpty (varName)) {
             varName = "$e";
         } else {
             Locals.Add (varName, null);
         }
         Write ("catch(", varName, ") ");
         clause.StatementBlock.AcceptVisitor (this, null);
         
         PopLocals ();
     }
     if (!node.FinallyBlock.IsNull) {
         Write ("finally ");
         node.FinallyBlock.AcceptVisitor (this, null);
     }
     
     return null;
 }
Esempio n. 21
0
	void TryStatement(
#line  1725 "cs.ATG" 
out Statement tryStatement) {

#line  1727 "cs.ATG" 
		BlockStatement blockStmt = null, finallyStmt = null;
		CatchClause catchClause = null;
		List<CatchClause> catchClauses = new List<CatchClause>();
		
		Expect(114);
		Block(
#line  1732 "cs.ATG" 
out blockStmt);
		while (la.kind == 56) {
			CatchClause(
#line  1734 "cs.ATG" 
out catchClause);

#line  1735 "cs.ATG" 
			if (catchClause != null) catchClauses.Add(catchClause); 
		}
		if (la.kind == 73) {
			lexer.NextToken();
			Block(
#line  1737 "cs.ATG" 
out finallyStmt);
		}

#line  1739 "cs.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		if (catchClauses != null) {
			foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement;
		}
		
	}
 public virtual bool VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object d)
 {
     if ((tryCatchStatement == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((tryCatchStatement.StatementBlock == null)) {
         return SetFailure();
     }
     if ((tryCatchStatement.CatchClauses == null)) {
         return SetFailure();
     }
     if ((tryCatchStatement.FinallyBlock == null)) {
         return SetFailure();
     }
     if(tryCatchStatement.GetType() != d.GetType()) {return SetFailure();}
     var data = (TryCatchStatement)d;
     if (!IsMatch(tryCatchStatement, data)) {
         return SetFailure();
     }
     tryCatchStatement.StatementBlock.AcceptVisitor(this, data.StatementBlock);
     if (tryCatchStatement.CatchClauses.Count == data.CatchClauses.Count) {
     for (int i=0; i<tryCatchStatement.CatchClauses.Count;i++) {
         CatchClause o = tryCatchStatement.CatchClauses[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.CatchClauses[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data.FinallyBlock);
 }
		public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
		{
			if (tryCatchStatement == null) {
				return data;
			}
			if (tryCatchStatement.StatementBlock != null) {
				tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
			}
			if (tryCatchStatement.CatchClauses != null) {
				foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
					if (catchClause != null) {
						if (catchClause.TypeReference != null && catchClause.VariableName != null) {
							AddVariable(catchClause.TypeReference,
							            catchClause.VariableName,
							            catchClause.StartLocation,
							            catchClause.StatementBlock.EndLocation,
							            false, false, null, null, false, catchClause.StartLocation);
						}
						catchClause.StatementBlock.AcceptVisitor(this, data);
					}
				}
			}
			if (tryCatchStatement.FinallyBlock != null) {
				return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
			}
			return data;
		}
 public object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     throw new NotImplementedException ();
 }
Esempio n. 25
0
		public virtual object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
			throw new global::System.NotImplementedException("TryCatchStatement");
		}
Esempio n. 26
0
 public virtual object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     Debug.Assert((tryCatchStatement != null));
     Debug.Assert((tryCatchStatement.StatementBlock != null));
     Debug.Assert((tryCatchStatement.CatchClauses != null));
     Debug.Assert((tryCatchStatement.FinallyBlock != null));
     tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
     foreach (CatchClause o in tryCatchStatement.CatchClauses) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
 }
		public sealed override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
			this.BeginVisit(tryCatchStatement);
			object result = this.TrackedVisitTryCatchStatement(tryCatchStatement, data);
			this.EndVisit(tryCatchStatement);
			return result;
		}
		public virtual object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
			Debug.Assert((tryCatchStatement != null));
			Debug.Assert((tryCatchStatement.StatementBlock != null));
			Debug.Assert((tryCatchStatement.CatchClauses != null));
			Debug.Assert((tryCatchStatement.FinallyBlock != null));
			nodeStack.Push(tryCatchStatement.StatementBlock);
			tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
			tryCatchStatement.StatementBlock = ((Statement)(nodeStack.Pop()));
			for (int i = 0; i < tryCatchStatement.CatchClauses.Count; i++) {
				CatchClause o = tryCatchStatement.CatchClauses[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (CatchClause)nodeStack.Pop();
				if (o == null)
					tryCatchStatement.CatchClauses.RemoveAt(i--);
				else
					tryCatchStatement.CatchClauses[i] = o;
			}
			nodeStack.Push(tryCatchStatement.FinallyBlock);
			tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
			tryCatchStatement.FinallyBlock = ((Statement)(nodeStack.Pop()));
			return null;
		}
Esempio n. 29
0
	void TryStatement(
//#line  3589 "VBNET.ATG" 
out Statement tryStatement) {

//#line  3591 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
		
		Expect(218);
		EndOfStmt();
		Block(
//#line  3594 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 75 || la.kind == 113 || la.kind == 123) {
			CatchClauses(
//#line  3595 "VBNET.ATG" 
out catchClauses);
		}
		if (la.kind == 123) {
			lexer.NextToken();
			EndOfStmt();
			Block(
//#line  3596 "VBNET.ATG" 
out finallyStmt);
		}
		Expect(113);
		Expect(218);

//#line  3599 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     Children = tryCatchStatement.StatementBlock.Children;
     return null;
 }