public override object Visit(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.Type != null && catchClause.VariableName != null) { AddVariable(new TypeReference (catchClause.Type), catchClause.VariableName, catchClause.StatementBlock.StartLocation, catchClause.StatementBlock.EndLocation); } catchClause.StatementBlock.AcceptVisitor(this, data); } } } if (tryCatchStatement.FinallyBlock != null) { return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data); } return data; }
public override object Visit(TryCatchStatement tryCatchStatement, object data) { ProcessSpecials(tryCatchStatement.Specials); // add a try-catch-finally CodeTryCatchFinallyStatement tryStmt = new CodeTryCatchFinallyStatement(); codeStack.Push(tryStmt.TryStatements); ProcessSpecials(tryCatchStatement.StatementBlock.Specials); tryCatchStatement.StatementBlock.AcceptChildren(this, data); codeStack.Pop(); if (tryCatchStatement.FinallyBlock != null) { codeStack.Push(tryStmt.FinallyStatements); ProcessSpecials(tryCatchStatement.FinallyBlock.Specials); tryCatchStatement.FinallyBlock.AcceptChildren(this,data); codeStack.Pop(); } if (tryCatchStatement.CatchClauses != null) { foreach (CatchClause clause in tryCatchStatement.CatchClauses) { CodeCatchClause catchClause = new CodeCatchClause(clause.VariableName); catchClause.CatchExceptionType = new CodeTypeReference(clause.Type); tryStmt.CatchClauses.Add(catchClause); codeStack.Push(catchClause.Statements); ProcessSpecials(clause.StatementBlock.Specials); clause.StatementBlock.AcceptChildren(this, data); codeStack.Pop(); } } // Add Statement to Current Statement Collection AddStmt(tryStmt); return tryStmt; }
public override object Visit(TryCatchStatement tryCatchStatement, object data) { DebugOutput(tryCatchStatement); AppendIndentation();sourceText.Append("Try"); AppendNewLine(); ++indentLevel; tryCatchStatement.StatementBlock.AcceptVisitor(this, data); --indentLevel; if (tryCatchStatement.CatchClauses != null) { int generated = 0; foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) { AppendIndentation();sourceText.Append("Catch "); if (catchClause.VariableName == null) { sourceText.Append("generatedExceptionVariable" + generated.ToString()); ++generated; } else { sourceText.Append(catchClause.VariableName); } sourceText.Append(" As "); sourceText.Append(catchClause.Type); AppendNewLine(); ++indentLevel; catchClause.StatementBlock.AcceptVisitor(this, data); --indentLevel; } } if (tryCatchStatement.FinallyBlock != null) { AppendIndentation();sourceText.Append("Finally"); AppendNewLine(); ++indentLevel; tryCatchStatement.FinallyBlock.AcceptVisitor(this, data); --indentLevel; } AppendIndentation();sourceText.Append("End Try"); AppendNewLine(); return null; }
public override object Visit(TryCatchStatement tryCatchStatement, object data) { Console.WriteLine(tryCatchStatement.ToString()); return tryCatchStatement.AcceptChildren(this, data); }
public virtual object Visit(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) { catchClause.StatementBlock.AcceptVisitor(this, data); } } } if (tryCatchStatement.FinallyBlock != null) { return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data); } return data; }
void TryStatement( #line 1684 "cs.ATG" out Statement tryStatement) { #line 1686 "cs.ATG" Statement blockStmt = null, finallyStmt = null; ArrayList catchClauses = null; Expect(113); Block( #line 1690 "cs.ATG" out blockStmt); if (la.kind == 55) { CatchClauses( #line 1692 "cs.ATG" out catchClauses); if (la.kind == 72) { lexer.NextToken(); Block( #line 1692 "cs.ATG" out finallyStmt); } } else if (la.kind == 72) { lexer.NextToken(); Block( #line 1693 "cs.ATG" out finallyStmt); } else SynErr(175); #line 1696 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); }
public override object Visit(TryCatchStatement tryCatchStatement, object data) { outputFormatter.Indent(); outputFormatter.PrintToken(Tokens.Try); outputFormatter.Space(); outputFormatter.PrintToken(Tokens.OpenCurlyBrace); outputFormatter.NewLine(); ++outputFormatter.IndentationLevel; tryCatchStatement.StatementBlock.AcceptChildren(this, data); --outputFormatter.IndentationLevel; if (tryCatchStatement.CatchClauses != null) { // int generated = 0; foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) { outputFormatter.Indent(); outputFormatter.PrintToken(Tokens.CloseCurlyBrace); outputFormatter.NewLine(); outputFormatter.Indent(); outputFormatter.PrintToken(Tokens.Catch); outputFormatter.Space(); if (catchClause.Type == null) { } else { outputFormatter.PrintToken(Tokens.OpenParenthesis); outputFormatter.PrintIdentifier(catchClause.Type); if (catchClause.VariableName != null) { outputFormatter.Space(); outputFormatter.PrintIdentifier(catchClause.VariableName); } outputFormatter.PrintToken(Tokens.CloseParenthesis); } outputFormatter.Space(); outputFormatter.PrintToken(Tokens.OpenCurlyBrace); outputFormatter.NewLine(); ++outputFormatter.IndentationLevel; catchClause.StatementBlock.AcceptChildren(this, data); --outputFormatter.IndentationLevel; } } if (tryCatchStatement.FinallyBlock != null) { outputFormatter.Indent(); outputFormatter.PrintToken(Tokens.CloseCurlyBrace); outputFormatter.NewLine(); outputFormatter.Indent(); outputFormatter.PrintToken(Tokens.Finally); outputFormatter.Space(); outputFormatter.PrintToken(Tokens.OpenCurlyBrace); outputFormatter.NewLine(); ++outputFormatter.IndentationLevel; tryCatchStatement.FinallyBlock.AcceptChildren(this, data); --outputFormatter.IndentationLevel; } outputFormatter.Indent(); outputFormatter.PrintToken(Tokens.CloseCurlyBrace); outputFormatter.NewLine(); return null; }