Makefile fixup
[org.ibex.tool.git] / repo / org.ibex.tool / src / org / eclipse / jdt / internal / compiler / flow / InsideSubRoutineFlowContext.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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 org.eclipse.jdt.internal.compiler.flow;
12
13 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14 import org.eclipse.jdt.internal.compiler.ast.SubRoutineStatement;
15
16 /**
17  * Reflects the context of code analysis, keeping track of enclosing
18  *      try statements, exception handlers, etc...
19  */
20 public class InsideSubRoutineFlowContext extends FlowContext {
21
22         public UnconditionalFlowInfo initsOnReturn;
23         
24         public InsideSubRoutineFlowContext(
25                 FlowContext parent,
26                 ASTNode associatedNode) {
27                 super(parent, associatedNode);
28                 this.initsOnReturn = FlowInfo.DEAD_END;                         
29         }
30
31         public String individualToString() {
32                 
33                 StringBuffer buffer = new StringBuffer("Inside SubRoutine flow context"); //$NON-NLS-1$
34                 buffer.append("[initsOnReturn -").append(initsOnReturn.toString()).append(']'); //$NON-NLS-1$
35                 return buffer.toString();
36         }
37                 
38         public UnconditionalFlowInfo initsOnReturn(){
39                 return this.initsOnReturn;
40         }
41                 
42         public boolean isNonReturningContext() {
43                 return subRoutine().isSubRoutineEscaping();
44         }
45         
46         public SubRoutineStatement subRoutine() {
47                 return (SubRoutineStatement)associatedNode;
48         }
49         
50         public void recordReturnFrom(FlowInfo flowInfo) {
51
52                 if (!flowInfo.isReachable()) return; 
53                 if (initsOnReturn == FlowInfo.DEAD_END) {
54                         initsOnReturn = flowInfo.copy().unconditionalInits();
55                 } else {
56                         initsOnReturn = initsOnReturn.mergedWith(flowInfo.copy().unconditionalInits());
57                 }
58         }
59 }