KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > flow > InsideSubRoutineFlowContext


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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 JavaDoc individualToString() {
32     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("Inside SubRoutine flow context"); //$NON-NLS-1$
33
buffer.append("[initsOnReturn -").append(this.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 ((SubRoutineStatement) this.associatedNode).isSubRoutineEscaping();
43 }
44     
45 public void recordReturnFrom(UnconditionalFlowInfo flowInfo) {
46     if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
47     if (this.initsOnReturn == FlowInfo.DEAD_END) {
48         this.initsOnReturn = (UnconditionalFlowInfo) flowInfo.copy();
49     } else {
50         this.initsOnReturn = this.initsOnReturn.mergedWith(flowInfo);
51     }
52     }
53 }
54
55 public SubRoutineStatement subroutine() {
56     return (SubRoutineStatement) this.associatedNode;
57 }
58 }
59
Popular Tags