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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.flow;
13 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14 import org.eclipse.jdt.internal.compiler.ast.SubRoutineStatement;
17 * Reflects the context of code analysis, keeping track of enclosing
18 * try statements, exception handlers, etc...
20 public class InsideSubRoutineFlowContext extends FlowContext {
22 public UnconditionalFlowInfo initsOnReturn;
24 public InsideSubRoutineFlowContext(
26 ASTNode associatedNode) {
27 super(parent, associatedNode);
28 this.initsOnReturn = FlowInfo.DEAD_END;
31 public String individualToString() {
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();
38 public UnconditionalFlowInfo initsOnReturn(){
39 return this.initsOnReturn;
42 public boolean isNonReturningContext() {
43 return subRoutine().isSubRoutineEscaping();
46 public SubRoutineStatement subRoutine() {
47 return (SubRoutineStatement)associatedNode;
50 public void recordReturnFrom(FlowInfo flowInfo) {
52 if (!flowInfo.isReachable()) return;
53 if (initsOnReturn == FlowInfo.DEAD_END) {
54 initsOnReturn = flowInfo.copy().unconditionalInits();
56 initsOnReturn = initsOnReturn.mergedWith(flowInfo.copy().unconditionalInits());