1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.flow;
13 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
14 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
15 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
16 import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
19 * Reflects the context of code analysis, keeping track of enclosing
20 * try statements, exception handlers, etc...
22 public class InitializationFlowContext extends ExceptionHandlingFlowContext {
24 public int exceptionCount;
25 public TypeBinding[] thrownExceptions = new TypeBinding[5];
26 public ASTNode[] exceptionThrowers = new ASTNode[5];
27 public FlowInfo[] exceptionThrowerFlowInfos = new FlowInfo[5];
29 public InitializationFlowContext(
31 ASTNode associatedNode,
36 NoExceptions, // no exception allowed by default
41 public void checkInitializerExceptions(
42 BlockScope currentScope,
43 FlowContext initializerContext,
45 for (int i = 0; i < exceptionCount; i++) {
46 initializerContext.checkExceptionHandlers(
49 exceptionThrowerFlowInfos[i],
54 public String individualToString() {
56 StringBuffer buffer = new StringBuffer("Initialization flow context"); //$NON-NLS-1$
57 for (int i = 0; i < exceptionCount; i++) {
58 buffer.append('[').append(thrownExceptions[i].readableName());
59 buffer.append('-').append(exceptionThrowerFlowInfos[i].toString()).append(']');
61 return buffer.toString();
64 public void recordHandlingException(
65 ReferenceBinding exceptionType,
66 UnconditionalFlowInfo flowInfo,
67 TypeBinding raisedException,
68 ASTNode invocationSite,
71 // even if unreachable code, need to perform unhandled exception diagnosis
72 int size = thrownExceptions.length;
73 if (exceptionCount == size) {
77 (thrownExceptions = new TypeBinding[size * 2]),
83 (exceptionThrowers = new ASTNode[size * 2]),
87 exceptionThrowerFlowInfos,
89 (exceptionThrowerFlowInfos = new FlowInfo[size * 2]),
93 thrownExceptions[exceptionCount] = raisedException;
94 exceptionThrowers[exceptionCount] = invocationSite;
95 exceptionThrowerFlowInfos[exceptionCount++] = flowInfo.copy();