public void visitTryCatchFinally(TryCatchStatement statement) {
   statement.getTryStatement().visit(this);
   for (CatchStatement catchStatement : statement.getCatchStatements()) {
     catchStatement.visit(this);
   }
   Statement finallyStatement = statement.getFinallyStatement();
   if (finallyStatement instanceof EmptyStatement) {
     // dispatching to EmptyStatement will not call back visitor,
     // must call our visitEmptyStatement explicitly
     visitEmptyStatement((EmptyStatement) finallyStatement);
   } else {
     finallyStatement.visit(this);
   }
 }
 public void visitCatchStatement(CatchStatement statement) {
   pushState();
   Parameter p = statement.getVariable();
   p.setInStaticContext(currentScope.isInStaticContext());
   declare(p, statement);
   super.visitCatchStatement(statement);
   popState();
 }
Пример #3
0
 @Override
 public void visitTryCatchFinally(final TryCatchStatement statement) {
   visitStatement(statement);
   Map<Variable, VariableState> beforeTryCatch = new HashMap<Variable, VariableState>(getState());
   statement.getTryStatement().visit(this);
   for (CatchStatement catchStatement : statement.getCatchStatements()) {
     catchStatement.visit(this);
   }
   Statement finallyStatement = statement.getFinallyStatement();
   // we need to recall which final variables are unassigned so cloning the current state
   Map<Variable, VariableState> afterTryCatchState =
       new HashMap<Variable, VariableState>(getState());
   if (finallyStatement instanceof EmptyStatement) {
     // dispatching to EmptyStatement will not call back visitor,
     // must call our visitEmptyStatement explicitly
     visitEmptyStatement((EmptyStatement) finallyStatement);
   } else {
     finallyStatement.visit(this);
   }
   // and now we must reset to uninitialized state variables which were only initialized during
   // try/catch
   Map<Variable, VariableState> afterFinally = new HashMap<Variable, VariableState>(getState());
   for (Map.Entry<Variable, VariableState> entry : afterFinally.entrySet()) {
     Variable var = entry.getKey();
     VariableState afterFinallyState = entry.getValue();
     VariableState beforeTryCatchState = beforeTryCatch.get(var);
     if (afterFinallyState == VariableState.is_final
         && beforeTryCatchState != VariableState.is_final
         && afterTryCatchState.get(var) != beforeTryCatchState) {
       getState()
           .put(
               var,
               beforeTryCatchState == null ? VariableState.is_uninitialized : beforeTryCatchState);
     }
   }
 }
 public void visitCatchStatement(CatchStatement statement) {
   statement.getCode().visit(this);
 }
 public void visitCatchStatement(CatchStatement cs) {
   if (!(cs.getExceptionType().isDerivedFrom(ClassHelper.make(Throwable.class)))) {
     addError("Catch statement parameter type is not a subclass of Throwable.", cs);
   }
   super.visitCatchStatement(cs);
 }