00001 package edu.ksu.cis.bandera.specification.predicate.node;
00002
00003
00004
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.predicate.analysis.*;
00007
00008 public final class AStrongPrimitiveCastExp extends PCastExp
00009 {
00010 private TLParen _lParen_;
00011 private PPrimitiveType _primitiveType_;
00012 private final LinkedList _dim_ = new TypedLinkedList(new Dim_Cast());
00013 private TRParen _rParen_;
00014 private PUnaryExp _unaryExp_;
00015
00016 private class Dim_Cast implements Cast
00017 {
00018 public Object cast(Object o)
00019 {
00020 TDim node = (TDim) o;
00021
00022 if((node.parent() != null) &&
00023 (node.parent() != AStrongPrimitiveCastExp.this))
00024 {
00025 node.parent().removeChild(node);
00026 }
00027
00028 if((node.parent() == null) ||
00029 (node.parent() != AStrongPrimitiveCastExp.this))
00030 {
00031 node.parent(AStrongPrimitiveCastExp.this);
00032 }
00033
00034 return node;
00035 }
00036 }
00037 public AStrongPrimitiveCastExp()
00038 {
00039 }
00040 public AStrongPrimitiveCastExp(
00041 TLParen _lParen_,
00042 PPrimitiveType _primitiveType_,
00043 XTDim _dim_,
00044 TRParen _rParen_,
00045 PUnaryExp _unaryExp_)
00046 {
00047 setLParen(_lParen_);
00048
00049 setPrimitiveType(_primitiveType_);
00050
00051 if(_dim_ != null)
00052 {
00053 while(_dim_ instanceof X1TDim)
00054 {
00055 this._dim_.addFirst(((X1TDim) _dim_).getTDim());
00056 _dim_ = ((X1TDim) _dim_).getXTDim();
00057 }
00058 this._dim_.addFirst(((X2TDim) _dim_).getTDim());
00059 }
00060
00061 setRParen(_rParen_);
00062
00063 setUnaryExp(_unaryExp_);
00064
00065 }
00066 public AStrongPrimitiveCastExp(
00067 TLParen _lParen_,
00068 PPrimitiveType _primitiveType_,
00069 List _dim_,
00070 TRParen _rParen_,
00071 PUnaryExp _unaryExp_)
00072 {
00073 setLParen(_lParen_);
00074
00075 setPrimitiveType(_primitiveType_);
00076
00077 {
00078 Object temp[] = _dim_.toArray();
00079 for(int i = 0; i < temp.length; i++)
00080 {
00081 this._dim_.add(temp[i]);
00082 }
00083 }
00084
00085 setRParen(_rParen_);
00086
00087 setUnaryExp(_unaryExp_);
00088
00089 }
00090 public void apply(Switch sw)
00091 {
00092 ((Analysis) sw).caseAStrongPrimitiveCastExp(this);
00093 }
00094 public Object clone()
00095 {
00096 return new AStrongPrimitiveCastExp(
00097 (TLParen) cloneNode(_lParen_),
00098 (PPrimitiveType) cloneNode(_primitiveType_),
00099 cloneList(_dim_),
00100 (TRParen) cloneNode(_rParen_),
00101 (PUnaryExp) cloneNode(_unaryExp_));
00102 }
00103 public LinkedList getDim()
00104 {
00105 return _dim_;
00106 }
00107 public TLParen getLParen()
00108 {
00109 return _lParen_;
00110 }
00111 public PPrimitiveType getPrimitiveType()
00112 {
00113 return _primitiveType_;
00114 }
00115 public TRParen getRParen()
00116 {
00117 return _rParen_;
00118 }
00119 public PUnaryExp getUnaryExp()
00120 {
00121 return _unaryExp_;
00122 }
00123 void removeChild(Node child)
00124 {
00125 if(_lParen_ == child)
00126 {
00127 _lParen_ = null;
00128 return;
00129 }
00130
00131 if(_primitiveType_ == child)
00132 {
00133 _primitiveType_ = null;
00134 return;
00135 }
00136
00137 if(_dim_.remove(child))
00138 {
00139 return;
00140 }
00141
00142 if(_rParen_ == child)
00143 {
00144 _rParen_ = null;
00145 return;
00146 }
00147
00148 if(_unaryExp_ == child)
00149 {
00150 _unaryExp_ = null;
00151 return;
00152 }
00153
00154 }
00155 void replaceChild(Node oldChild, Node newChild)
00156 {
00157 if(_lParen_ == oldChild)
00158 {
00159 setLParen((TLParen) newChild);
00160 return;
00161 }
00162
00163 if(_primitiveType_ == oldChild)
00164 {
00165 setPrimitiveType((PPrimitiveType) newChild);
00166 return;
00167 }
00168
00169 for(ListIterator i = _dim_.listIterator(); i.hasNext();)
00170 {
00171 if(i.next() == oldChild)
00172 {
00173 if(newChild != null)
00174 {
00175 i.set(newChild);
00176 oldChild.parent(null);
00177 return;
00178 }
00179
00180 i.remove();
00181 oldChild.parent(null);
00182 return;
00183 }
00184 }
00185
00186 if(_rParen_ == oldChild)
00187 {
00188 setRParen((TRParen) newChild);
00189 return;
00190 }
00191
00192 if(_unaryExp_ == oldChild)
00193 {
00194 setUnaryExp((PUnaryExp) newChild);
00195 return;
00196 }
00197
00198 }
00199 public void setDim(List list)
00200 {
00201 Object temp[] = list.toArray();
00202 for(int i = 0; i < temp.length; i++)
00203 {
00204 _dim_.add(temp[i]);
00205 }
00206 }
00207 public void setLParen(TLParen node)
00208 {
00209 if(_lParen_ != null)
00210 {
00211 _lParen_.parent(null);
00212 }
00213
00214 if(node != null)
00215 {
00216 if(node.parent() != null)
00217 {
00218 node.parent().removeChild(node);
00219 }
00220
00221 node.parent(this);
00222 }
00223
00224 _lParen_ = node;
00225 }
00226 public void setPrimitiveType(PPrimitiveType node)
00227 {
00228 if(_primitiveType_ != null)
00229 {
00230 _primitiveType_.parent(null);
00231 }
00232
00233 if(node != null)
00234 {
00235 if(node.parent() != null)
00236 {
00237 node.parent().removeChild(node);
00238 }
00239
00240 node.parent(this);
00241 }
00242
00243 _primitiveType_ = node;
00244 }
00245 public void setRParen(TRParen node)
00246 {
00247 if(_rParen_ != null)
00248 {
00249 _rParen_.parent(null);
00250 }
00251
00252 if(node != null)
00253 {
00254 if(node.parent() != null)
00255 {
00256 node.parent().removeChild(node);
00257 }
00258
00259 node.parent(this);
00260 }
00261
00262 _rParen_ = node;
00263 }
00264 public void setUnaryExp(PUnaryExp node)
00265 {
00266 if(_unaryExp_ != null)
00267 {
00268 _unaryExp_.parent(null);
00269 }
00270
00271 if(node != null)
00272 {
00273 if(node.parent() != null)
00274 {
00275 node.parent().removeChild(node);
00276 }
00277
00278 node.parent(this);
00279 }
00280
00281 _unaryExp_ = node;
00282 }
00283 public String toString()
00284 {
00285 return ""
00286 + toString(_lParen_)
00287 + toString(_primitiveType_)
00288 + toString(_dim_)
00289 + toString(_rParen_)
00290 + toString(_unaryExp_);
00291 }
00292 }