public virtual Statement VisitCatch(Catch Catch) { if (Catch == null) return null; Catch.Variable = this.VisitTargetExpression(Catch.Variable); Catch.Type = this.VisitTypeReference(Catch.Type); Catch.Block = this.VisitBlock(Catch.Block); return Catch; }
public override Statement VisitCatch(Catch Catch) { if (Catch == null) return null; return base.VisitCatch((Catch)Catch.Clone()); }
private Catch ParseCatch(TokenSet followers){ Catch Catch = new Catch(); Catch.SourceContext = this.scanner.CurrentSourceContext; Debug.Assert(this.currentToken == Token.Catch); this.GetNextToken(); if (this.currentToken == Token.LeftParenthesis){ this.Skip(Token.LeftParenthesis); Catch.Type = Catch.TypeExpression = this.ParseTypeExpression(Identifier.Empty, followers|Token.Identifier|Token.RightParenthesis); if (Parser.IdentifierOrNonReservedKeyword[this.currentToken]){ Catch.Variable = this.scanner.GetIdentifier(); this.GetNextToken(); } this.Skip(Token.RightParenthesis); } Catch.Block = this.ParseBlock(followers); return Catch; }
/// <summary> /// Add explicit Catch statements at beginning of each catch handler. /// If a Catch handler has a next handler that differs from the ExceptionHandler enclosing the handler block, then we split /// the Catch statement into a separate block. /// /// Special case for Finally handlers that have been turned into catch handlers by the finally-elimination: /// - Move the special instruction FINALLYVARPREFIX<n> = pop() to the header. /// </summary> private void AddCatchStatements (IEnumerable/*<ExceptionHandler>*/ all_ehs, IList new_blocks) { if (all_ehs == null) return; foreach(ExceptionHandler eh in all_ehs) { switch (eh.HandlerType) { case NodeType.Catch: { Block handlerblock = eh.HandlerStartBlock; Block nexthandler = (Block)e2_next[handlerblock]; Block exnhandler = ExceptionHandler(handlerblock); Debug.Assert(nexthandler != null); // put Catch into separate block. Statement catchStatement = new Catch(null, null, eh.FilterType); catchStatement.SourceContext = handlerblock.SourceContext; link_handler_header_statement_to_block(new_blocks, catchStatement, handlerblock, nexthandler, exnhandler); break; } case NodeType.Filter: { // insert a Filter instruction at the beginning of filter block Block handlerblock = eh.HandlerStartBlock; Block nexthandler = (Block)e2_next[handlerblock]; Block exnhandler = ExceptionHandler(handlerblock); Debug.Assert(nexthandler != null); // put Filter into separate block. Statement filterStatement = new Filter(); filterStatement.SourceContext = handlerblock.SourceContext; link_handler_header_statement_to_block(new_blocks, filterStatement, handlerblock, nexthandler, exnhandler); // Commented out, since we treat filter's differently now. // insert a Catch all instruction at the beginning of the handler block // prepend_statement_to_block( // new Catch(null, null, System.Compiler.SystemTypes.Exception), // eh.HandlerStartBlock); break; } default: continue; } } }
public override Statement VisitCatch(Catch Catch) { WriteStart("catch ("); this.VisitTypeReference(Catch.TypeExpression); if (Catch.Variable != null) { Write(" "); this.VisitExpression(Catch.Variable); } WriteFinish(")"); this.VisitBlock(Catch.Block); return Catch; }
public EventingVisitor(Action<Catch> visitCatch) { VisitedCatch += visitCatch; } public event Action<Catch> VisitedCatch; public override Statement VisitCatch(Catch Catch) { if (VisitedCatch != null) VisitedCatch(Catch); return base.VisitCatch(Catch); }