public override Object Visit(CatchStatement node, Object obj) { node.Exception.Accept(this, obj); node.Statements.Accept(this, obj); return(null); }
private static Statement DetectStatement(Statement head) { Statement res; if ((res = DoStatement.IsHead(head)) != null) { return(res); } if ((res = SwitchStatement.IsHead(head)) != null) { return(res); } if ((res = IfStatement.IsHead(head)) != null) { return(res); } // synchronized statements will be identified later // right now they are recognized as catchall if ((res = SequenceStatement.IsHead2Block(head)) != null) { return(res); } if ((res = CatchStatement.IsHead(head)) != null) { return(res); } if ((res = CatchAllStatement.IsHead(head)) != null) { return(res); } return(null); }
public override object Visit(CatchStatement node, object obj) { if (node.Location == ((AstNode)obj).Location || found) { found = true; return(this.table); } return(base.Visit(node, obj)); }
private static void TestEquality(CatchStatement expected, CatchStatement actual, string propertyName) { try { ExpressionsAreEqual(expected.Parameter, actual.Parameter, "Parameter"); } catch (DataAssertionException e) { e.Add(propertyName); throw e; } TestEquality((BlockStatement)expected, (BlockStatement)actual, propertyName); }
public override Object Visit(CatchStatement node, Object obj) { int indent = Convert.ToInt32(obj); this.printIndentation(indent); this.output.WriteLine("CatchStatement [{0}:{1}]", node.Location.Line, node.Location.Column); node.Exception.Accept(this, indent + 1); node.Statements.Accept(this, indent + 1); return(null); }
private static void MapClassMethods(ClassesProcessor.ClassNode node, Dictionary < ClassWrapper, MethodWrapper> map) { bool noSynthFlag = DecompilerContext.GetOption(IFernflowerPreferences.Synthetic_Not_Set ); ClassWrapper wrapper = node.GetWrapper(); foreach (MethodWrapper method in wrapper.GetMethods()) { StructMethod mt = method.methodStruct; if ((noSynthFlag || mt.IsSynthetic()) && mt.GetDescriptor().Equals("(Ljava/lang/String;)Ljava/lang/Class;" ) && mt.HasModifier(ICodeConstants.Acc_Static)) { RootStatement root = method.root; if (root != null && root.GetFirst().type == Statement.Type_Trycatch) { CatchStatement cst = (CatchStatement)root.GetFirst(); if (cst.GetStats().Count == 2 && cst.GetFirst().type == Statement.Type_Basicblock && cst.GetStats()[1].type == Statement.Type_Basicblock && cst.GetVars()[0].GetVarType ().Equals(new VarType(ICodeConstants.Type_Object, 0, "java/lang/ClassNotFoundException" ))) { BasicBlockStatement body = (BasicBlockStatement)cst.GetFirst(); BasicBlockStatement handler = (BasicBlockStatement)cst.GetStats()[1]; if (body.GetExprents().Count == 1 && handler.GetExprents().Count == 1) { if (Body_Expr.Equals(body.GetExprents()[0]) && Handler_Expr.Equals(handler.GetExprents ()[0])) { Sharpen.Collections.Put(map, wrapper, method); break; } } } } } } // iterate nested classes foreach (ClassesProcessor.ClassNode nd in node.nested) { MapClassMethods(nd, map); } }
public override void WriteTo(TextWriter w) { w.Write("try"); TryBody.WriteTo(w); if (CatchStatement != null) { w.Write("catch("); w.Write(CaughtErrorIdentifier); w.Write("){"); CatchStatement.WriteTo(w); w.Write("}"); } w.Write("finally{"); foreach (var stmt in FinallyStatements) { stmt.WriteTo(w); } w.Write("}"); }
public Statement GetStatement() { var catchStatement = new CatchStatement(); catchStatement.Block = statementInterpreterHandler.GetStatement(catchClauseSyntax.Block); catchStatement.Filter = catchClauseSyntax.Filter == null ? null : statementInterpreterHandler.GetStatement(catchClauseSyntax.Filter.FilterExpression); if (catchClauseSyntax.Declaration != null) { catchStatement.Type = semanticModel.GetTypeInfo(catchClauseSyntax.Declaration.Type).GetClassType(); if (!catchClauseSyntax.Declaration.Identifier.IsKind(Microsoft.CodeAnalysis.CSharp.SyntaxKind.None)) { catchStatement.Variable = new LocalVariableDeclaration { Type = catchStatement.Type, Name = catchClauseSyntax.Declaration.Identifier.ValueText }; } } return(catchStatement); }
public abstract Object Visit(CatchStatement node, Object obj);
public override Object Visit(CatchStatement node, Object obj) { return(new CatchStatement((IdDeclaration)node.Exception.Accept(this, obj), (Block)node.Statements.Accept(this, obj), node.Location)); }
public ReadOnlyCatchStatement(CatchStatement catchStatement) { statements = ReadOnlyStatement.Create(catchStatement.Statements); type = new ReadOnlyTypeReference(catchStatement.Type); variableName = catchStatement.Name; }
private void CheckStatementCurlyBracketPlacement(Element element, Statement statement) { Param.AssertNotNull(element, "element"); Param.AssertNotNull(statement, "statement"); switch (statement.StatementType) { case StatementType.Else: // Check that there is nothing between the starting else keyword and the opening bracket. this.CheckChainedStatementCurlyBracketPlacement(element, statement); this.CheckBlockStatementsCurlyBracketPlacement(element, statement); // Check that there is nothing between the closing bracket and the else keyword of the attached else statement. ElseStatement elseStatement = (ElseStatement)statement; if (elseStatement.AttachedElseStatement != null) { this.CheckTrailingStatementCurlyBracketPlacement(element, statement); } break; case StatementType.Catch: case StatementType.Finally: // Check that there is nothing between the starting catch or finally keyword and the opening bracket. this.CheckChainedStatementCurlyBracketPlacement(element, statement); this.CheckBlockStatementsCurlyBracketPlacement(element, statement); break; case StatementType.If: this.CheckBlockStatementsCurlyBracketPlacement(element, statement); // Check that there is nothing between the closing bracket and the else keyword of the attached else statement. IfStatement ifStatement = (IfStatement)statement; if (ifStatement.AttachedElseStatement != null) { this.CheckTrailingStatementCurlyBracketPlacement(element, statement); } break; case StatementType.Try: // Check that there is nothing between the starting try keyword and the opening bracket. this.CheckBlockStatementsCurlyBracketPlacement(element, statement); TryStatement tryStatement = (TryStatement)statement; if (tryStatement.FinallyStatement != null || (tryStatement.CatchStatements != null && tryStatement.CatchStatements.Count > 0)) { // There is something attached to the end of this try statement. Check that there is nothing between // the closing bracket of the try statement and the start of the attached statement. this.CheckTrailingStatementCurlyBracketPlacement(element, tryStatement); } if (tryStatement.CatchStatements != null && tryStatement.CatchStatements.Count > 0) { CatchStatement[] catchStatementArray = new CatchStatement[tryStatement.CatchStatements.Count]; tryStatement.CatchStatements.CopyTo(catchStatementArray, 0); for (int i = 0; i < catchStatementArray.Length; ++i) { if (catchStatementArray.Length > i + 1 || tryStatement.FinallyStatement != null) { // There is something attached to the end of this catch statement, either another catch or a finally. // Check that there is nothing between the closing bracket of this catch statement and the start of the attached // statement. this.CheckTrailingStatementCurlyBracketPlacement(element, catchStatementArray[i]); } } } break; case StatementType.Checked: case StatementType.Fixed: case StatementType.For: case StatementType.Foreach: case StatementType.Lock: case StatementType.Switch: case StatementType.Unchecked: case StatementType.Unsafe: case StatementType.Using: case StatementType.While: // Check that there is nothing between the starting keyword and the opening bracket. this.CheckBlockStatementsCurlyBracketPlacement(element, statement); break; case StatementType.DoWhile: this.CheckBlockStatementsCurlyBracketPlacement(element, statement); this.CheckTrailingStatementCurlyBracketPlacement(element, statement); break; default: break; } }