1 11 package org.eclipse.jdt.internal.compiler.flow; 12 13 import org.eclipse.jdt.internal.compiler.ast.ASTNode; 14 import org.eclipse.jdt.internal.compiler.lookup.Binding; 15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope; 16 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; 17 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 18 19 23 public class InitializationFlowContext extends ExceptionHandlingFlowContext { 24 25 public int exceptionCount; 26 public TypeBinding[] thrownExceptions = new TypeBinding[5]; 27 public ASTNode[] exceptionThrowers = new ASTNode[5]; 28 public FlowInfo[] exceptionThrowerFlowInfos = new FlowInfo[5]; 29 30 public InitializationFlowContext( 31 FlowContext parent, 32 ASTNode associatedNode, 33 BlockScope scope) { 34 super( 35 parent, 36 associatedNode, 37 Binding.NO_EXCEPTIONS, scope, 39 FlowInfo.DEAD_END); 40 } 41 42 public void checkInitializerExceptions( 43 BlockScope currentScope, 44 FlowContext initializerContext, 45 FlowInfo flowInfo) { 46 for (int i = 0; i < exceptionCount; i++) { 47 initializerContext.checkExceptionHandlers( 48 thrownExceptions[i], 49 exceptionThrowers[i], 50 exceptionThrowerFlowInfos[i], 51 currentScope); 52 } 53 } 54 55 public String individualToString() { 56 57 StringBuffer buffer = new StringBuffer ("Initialization flow context"); for (int i = 0; i < exceptionCount; i++) { 59 buffer.append('[').append(thrownExceptions[i].readableName()); 60 buffer.append('-').append(exceptionThrowerFlowInfos[i].toString()).append(']'); 61 } 62 return buffer.toString(); 63 } 64 65 public void recordHandlingException( 66 ReferenceBinding exceptionType, 67 UnconditionalFlowInfo flowInfo, 68 TypeBinding raisedException, 69 ASTNode invocationSite, 70 boolean wasMasked) { 71 72 int size = thrownExceptions.length; 74 if (exceptionCount == size) { 75 System.arraycopy( 76 thrownExceptions, 77 0, 78 (thrownExceptions = new TypeBinding[size * 2]), 79 0, 80 size); 81 System.arraycopy( 82 exceptionThrowers, 83 0, 84 (exceptionThrowers = new ASTNode[size * 2]), 85 0, 86 size); 87 System.arraycopy( 88 exceptionThrowerFlowInfos, 89 0, 90 (exceptionThrowerFlowInfos = new FlowInfo[size * 2]), 91 0, 92 size); 93 } 94 thrownExceptions[exceptionCount] = raisedException; 95 exceptionThrowers[exceptionCount] = invocationSite; 96 exceptionThrowerFlowInfos[exceptionCount++] = flowInfo.copy(); 97 } 98 } 99 | Popular Tags |