removed NPE in XMLPreferenceInitializer
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / InsideSubRoutineFlowContext.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.flow;
12
13 import net.sourceforge.phpdt.internal.compiler.ast.ASTNode;
14
15 /**
16  * Reflects the context of code analysis, keeping track of enclosing
17  *      try statements, exception handlers, etc...
18  */
19 public class InsideSubRoutineFlowContext extends FlowContext {
20
21         public UnconditionalFlowInfo initsOnReturn;
22         
23         public InsideSubRoutineFlowContext(
24                 FlowContext parent,
25                 ASTNode associatedNode) {
26                 super(parent, associatedNode);
27                 this.initsOnReturn = FlowInfo.DEAD_END;                         
28         }
29
30         public String individualToString() {
31                 
32                 StringBuffer buffer = new StringBuffer("Inside SubRoutine flow context"); //$NON-NLS-1$
33                 buffer.append("[initsOnReturn -").append(initsOnReturn.toString()).append(']'); //$NON-NLS-1$
34                 return buffer.toString();
35         }
36                 
37         public UnconditionalFlowInfo initsOnReturn(){
38                 return this.initsOnReturn;
39         }
40                 
41         public boolean isNonReturningContext() {
42                 return associatedNode.cannotReturn();
43         }
44         
45         public ASTNode subRoutine() {
46                 return associatedNode;
47         }
48         
49         public void recordReturnFrom(FlowInfo flowInfo) {
50
51                 if (!flowInfo.isReachable()) return; 
52                 if (initsOnReturn == FlowInfo.DEAD_END) {
53                         initsOnReturn = flowInfo.copy().unconditionalInits();
54                 } else {
55                         initsOnReturn = initsOnReturn.mergedWith(flowInfo.unconditionalInits());
56                 }
57         }
58 }