public override object Visit(TryCatchStatement tryCatchStatement, object data)
 {
     return null;
 }
        public object Visit(TryCatchStatement tryCatchStatement, object data)
        {
            DebugOutput(tryCatchStatement);
            exitConstructStack.Push(new DictionaryEntry(typeof(TryCatchStatement), null));
            AppendIndentation();
            sourceText.Append("try {");
            AppendNewLine();

            ++indentLevel;
            tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
            --indentLevel;
            AppendIndentation();
            sourceText.Append("}");
            if (tryCatchStatement.CatchClauses != null) {
                foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
                    sourceText.Append(" catch ");
                    if (catchClause.Type != null) {
                        sourceText.Append("(");
                        sourceText.Append(GetTypeString(catchClause.Type));
                        if (catchClause.VariableName != null) {
                            sourceText.Append(" ");
                            sourceText.Append(catchClause.VariableName);
                        }
                        sourceText.Append(") ");
                    }
                    sourceText.Append("{");
                    AppendNewLine();
                    ++indentLevel;
                    if (catchClause.Condition != null) {
                        AppendIndentation();
                        sourceText.Append("//TODO: review the original conditional catch clause");
                        AppendNewLine();
                        AppendIndentation();
                        sourceText.Append("if (");
                        sourceText.Append(catchClause.Condition.AcceptVisitor(this, data));
                        sourceText.Append(") {");
                        AppendNewLine();
                        ++indentLevel;
                        catchClause.StatementBlock.AcceptVisitor(this, data);
                        --indentLevel;
                        AppendIndentation();
                        sourceText.Append("}");
                        AppendNewLine();
                    } else {
                        catchClause.StatementBlock.AcceptVisitor(this, data);
                    }
                    --indentLevel;
                    AppendIndentation();
                    sourceText.Append("}");
                }
            }

            if (tryCatchStatement.FinallyBlock != null) {
                sourceText.Append(" finally {");
                AppendNewLine();

                ++indentLevel;
                tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
                --indentLevel;
                AppendIndentation();
                sourceText.Append("}");
            }
            AppendNewLine();
            GenerateExitConstructLabel();
            return null;
        }
Esempio n. 3
0
	void TryStatement(
#line  2489 "VBNET.ATG" 
out Statement tryStatement) {

#line  2491 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;
		ArrayList catchClauses = null;
		
		Expect(176);
		EndOfStmt();
		Block(
#line  2495 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 59 || la.kind == 89 || la.kind == 98) {
			CatchClauses(
#line  2497 "VBNET.ATG" 
out catchClauses);
			if (la.kind == 98) {
				lexer.NextToken();
				EndOfStmt();
				Block(
#line  2498 "VBNET.ATG" 
out finallyStmt);
			}
		} else if (la.kind == 98) {
			lexer.NextToken();
			EndOfStmt();
			Block(
#line  2499 "VBNET.ATG" 
out finallyStmt);
		} else SynErr(235);
		Expect(89);
		Expect(176);

#line  2503 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
 public virtual object Visit(TryCatchStatement tryCatchStatement, object data)
 {
     if (tryCatchStatement.StatementBlock == null) {
         return null;
     }
     return tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
 }