Esempio n. 1
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 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;
		}
		public virtual object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
			throw new global::System.NotImplementedException("TryCatchStatement");
		}
Esempio n. 4
0
	void TryStatement(out Statement tryStatement) {
		Statement blockStmt = null;
		Statement finallyStmt = null;
		CatchClause clause = null;
		List<CatchClause> catchClauses = new List<CatchClause>();

		Expect(218);
		EndOfStmt();
		Block(out blockStmt);
		while (la.kind == 75) {
			CatchClause(out clause);
			if (clause != null) catchClauses.Add(clause);
		}
		if (la.kind == 123) {
			Get();
			EndOfStmt();
			Block(out finallyStmt);
		}
		Expect(113);
		Expect(218);
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
	}
Esempio n. 5
0
		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.StatementBlock.AcceptVisitor(this, data);
					}
				}
			}
			if (tryCatchStatement.FinallyBlock != null) {
				return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
			}
			return 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 TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) {
			return base.VisitTryCatchStatement(tryCatchStatement, data);
		}
		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;
		}