Added DESC_INC and IMG_INC for the image of include/require in outline (maybe we...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / ConditionalFlowInfo.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.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.lookup.FieldBinding;
14 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
15
16 /**
17  * Record conditional initialization status during definite assignment analysis
18  *
19  */
20 public class ConditionalFlowInfo extends FlowInfo {
21         public FlowInfo initsWhenTrue;
22         public FlowInfo initsWhenFalse;
23 ConditionalFlowInfo(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse){
24         this.initsWhenTrue = initsWhenTrue;
25         this.initsWhenFalse = initsWhenFalse; 
26 }
27 public UnconditionalFlowInfo addInitializationsFrom(UnconditionalFlowInfo otherInits) {
28         return unconditionalInits().addInitializationsFrom(otherInits);
29 }
30 public UnconditionalFlowInfo addPotentialInitializationsFrom(UnconditionalFlowInfo otherInits) {
31         return unconditionalInits().addPotentialInitializationsFrom(otherInits);
32 }
33 public FlowInfo asNegatedCondition() {
34         FlowInfo extra = initsWhenTrue;
35         initsWhenTrue = initsWhenFalse;
36         initsWhenFalse = extra;
37         return this;
38 }
39 public FlowInfo copy() {
40         return new ConditionalFlowInfo(initsWhenTrue.copy(), initsWhenFalse.copy());
41 }
42 public FlowInfo initsWhenFalse() {
43         return initsWhenFalse;
44 }
45 public FlowInfo initsWhenTrue() {
46         return initsWhenTrue;
47 }
48 /**
49  * Check status of definite assignment for a field.
50  */
51 public boolean isDefinitelyAssigned(FieldBinding field) {
52         return initsWhenTrue.isDefinitelyAssigned(field) 
53                         && initsWhenFalse.isDefinitelyAssigned(field);
54         
55 }
56 /**
57  * Check status of definite assignment for a local variable.
58  */
59 public boolean isDefinitelyAssigned(LocalVariableBinding local) {
60         return initsWhenTrue.isDefinitelyAssigned(local) 
61                         && initsWhenFalse.isDefinitelyAssigned(local);
62         
63 }
64 public boolean isFakeReachable(){
65         return unconditionalInits().isFakeReachable();  
66         //should maybe directly be: false
67 }
68 /**
69  * Check status of potential assignment for a field.
70  */
71 public boolean isPotentiallyAssigned(FieldBinding field) {
72         return initsWhenTrue.isPotentiallyAssigned(field) 
73                         || initsWhenFalse.isPotentiallyAssigned(field);
74         
75 }
76 /**
77  * Check status of potential assignment for a local variable.
78  */
79 public boolean isPotentiallyAssigned(LocalVariableBinding local) {
80         return initsWhenTrue.isPotentiallyAssigned(local) 
81                         || initsWhenFalse.isPotentiallyAssigned(local);
82         
83 }
84 /**
85  * Record a field got definitely assigned.
86  */
87 public void markAsDefinitelyAssigned(FieldBinding field) {
88         initsWhenTrue.markAsDefinitelyAssigned(field);
89         initsWhenFalse.markAsDefinitelyAssigned(field); 
90 }
91 /**
92  * Record a field got definitely assigned.
93  */
94 public void markAsDefinitelyAssigned(LocalVariableBinding local) {
95         initsWhenTrue.markAsDefinitelyAssigned(local);
96         initsWhenFalse.markAsDefinitelyAssigned(local); 
97 }
98 /**
99  * Clear the initialization info for a field
100  */
101 public void markAsDefinitelyNotAssigned(FieldBinding field) {
102         initsWhenTrue.markAsDefinitelyNotAssigned(field);
103         initsWhenFalse.markAsDefinitelyNotAssigned(field);      
104 }
105 /**
106  * Clear the initialization info for a local variable
107  */
108 public void markAsDefinitelyNotAssigned(LocalVariableBinding local) {
109         initsWhenTrue.markAsDefinitelyNotAssigned(local);
110         initsWhenFalse.markAsDefinitelyNotAssigned(local);      
111 }
112 public FlowInfo markAsFakeReachable(boolean isFakeReachable) {
113         initsWhenTrue.markAsFakeReachable(isFakeReachable);
114         initsWhenFalse.markAsFakeReachable(isFakeReachable);
115         return this;
116 }
117 public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) {
118         return unconditionalInits().mergedWith(otherInits);
119 }
120 public String toString() {
121         return "FlowInfo<true: " + initsWhenTrue.toString() + ", false: " + initsWhenFalse.toString() + ">"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
122 }
123 public UnconditionalFlowInfo unconditionalInits() {
124         return initsWhenTrue.unconditionalInits().copy()
125                         .mergedWith(initsWhenFalse.unconditionalInits());
126 }
127 }