1 2 3 package soot.jimple.parser.node; 4 5 import java.util.*; 6 import soot.jimple.parser.analysis.*; 7 8 public final class AFullMethodBody extends PMethodBody 9 { 10 private TLBrace _lBrace_; 11 private final LinkedList _declaration_ = new TypedLinkedList(new Declaration_Cast()); 12 private final LinkedList _statement_ = new TypedLinkedList(new Statement_Cast()); 13 private final LinkedList _catchClause_ = new TypedLinkedList(new CatchClause_Cast()); 14 private TRBrace _rBrace_; 15 16 public AFullMethodBody() 17 { 18 } 19 20 public AFullMethodBody( 21 TLBrace _lBrace_, 22 List _declaration_, 23 List _statement_, 24 List _catchClause_, 25 TRBrace _rBrace_) 26 { 27 setLBrace(_lBrace_); 28 29 { 30 this._declaration_.clear(); 31 this._declaration_.addAll(_declaration_); 32 } 33 34 { 35 this._statement_.clear(); 36 this._statement_.addAll(_statement_); 37 } 38 39 { 40 this._catchClause_.clear(); 41 this._catchClause_.addAll(_catchClause_); 42 } 43 44 setRBrace(_rBrace_); 45 46 } 47 48 public AFullMethodBody( 49 TLBrace _lBrace_, 50 XPDeclaration _declaration_, 51 XPStatement _statement_, 52 XPCatchClause _catchClause_, 53 TRBrace _rBrace_) 54 { 55 setLBrace(_lBrace_); 56 57 if(_declaration_ != null) 58 { 59 while(_declaration_ instanceof X1PDeclaration) 60 { 61 this._declaration_.addFirst(((X1PDeclaration) _declaration_).getPDeclaration()); 62 _declaration_ = ((X1PDeclaration) _declaration_).getXPDeclaration(); 63 } 64 this._declaration_.addFirst(((X2PDeclaration) _declaration_).getPDeclaration()); 65 } 66 67 if(_statement_ != null) 68 { 69 while(_statement_ instanceof X1PStatement) 70 { 71 this._statement_.addFirst(((X1PStatement) _statement_).getPStatement()); 72 _statement_ = ((X1PStatement) _statement_).getXPStatement(); 73 } 74 this._statement_.addFirst(((X2PStatement) _statement_).getPStatement()); 75 } 76 77 if(_catchClause_ != null) 78 { 79 while(_catchClause_ instanceof X1PCatchClause) 80 { 81 this._catchClause_.addFirst(((X1PCatchClause) _catchClause_).getPCatchClause()); 82 _catchClause_ = ((X1PCatchClause) _catchClause_).getXPCatchClause(); 83 } 84 this._catchClause_.addFirst(((X2PCatchClause) _catchClause_).getPCatchClause()); 85 } 86 87 setRBrace(_rBrace_); 88 89 } 90 public Object clone() 91 { 92 return new AFullMethodBody( 93 (TLBrace) cloneNode(_lBrace_), 94 cloneList(_declaration_), 95 cloneList(_statement_), 96 cloneList(_catchClause_), 97 (TRBrace) cloneNode(_rBrace_)); 98 } 99 100 public void apply(Switch sw) 101 { 102 ((Analysis) sw).caseAFullMethodBody(this); 103 } 104 105 public TLBrace getLBrace() 106 { 107 return _lBrace_; 108 } 109 110 public void setLBrace(TLBrace node) 111 { 112 if(_lBrace_ != null) 113 { 114 _lBrace_.parent(null); 115 } 116 117 if(node != null) 118 { 119 if(node.parent() != null) 120 { 121 node.parent().removeChild(node); 122 } 123 124 node.parent(this); 125 } 126 127 _lBrace_ = node; 128 } 129 130 public LinkedList getDeclaration() 131 { 132 return _declaration_; 133 } 134 135 public void setDeclaration(List list) 136 { 137 _declaration_.clear(); 138 _declaration_.addAll(list); 139 } 140 141 public LinkedList getStatement() 142 { 143 return _statement_; 144 } 145 146 public void setStatement(List list) 147 { 148 _statement_.clear(); 149 _statement_.addAll(list); 150 } 151 152 public LinkedList getCatchClause() 153 { 154 return _catchClause_; 155 } 156 157 public void setCatchClause(List list) 158 { 159 _catchClause_.clear(); 160 _catchClause_.addAll(list); 161 } 162 163 public TRBrace getRBrace() 164 { 165 return _rBrace_; 166 } 167 168 public void setRBrace(TRBrace node) 169 { 170 if(_rBrace_ != null) 171 { 172 _rBrace_.parent(null); 173 } 174 175 if(node != null) 176 { 177 if(node.parent() != null) 178 { 179 node.parent().removeChild(node); 180 } 181 182 node.parent(this); 183 } 184 185 _rBrace_ = node; 186 } 187 188 public String toString() 189 { 190 return "" 191 + toString(_lBrace_) 192 + toString(_declaration_) 193 + toString(_statement_) 194 + toString(_catchClause_) 195 + toString(_rBrace_); 196 } 197 198 void removeChild(Node child) 199 { 200 if(_lBrace_ == child) 201 { 202 _lBrace_ = null; 203 return; 204 } 205 206 if(_declaration_.remove(child)) 207 { 208 return; 209 } 210 211 if(_statement_.remove(child)) 212 { 213 return; 214 } 215 216 if(_catchClause_.remove(child)) 217 { 218 return; 219 } 220 221 if(_rBrace_ == child) 222 { 223 _rBrace_ = null; 224 return; 225 } 226 227 } 228 229 void replaceChild(Node oldChild, Node newChild) 230 { 231 if(_lBrace_ == oldChild) 232 { 233 setLBrace((TLBrace) newChild); 234 return; 235 } 236 237 for(ListIterator i = _declaration_.listIterator(); i.hasNext();) 238 { 239 if(i.next() == oldChild) 240 { 241 if(newChild != null) 242 { 243 i.set(newChild); 244 oldChild.parent(null); 245 return; 246 } 247 248 i.remove(); 249 oldChild.parent(null); 250 return; 251 } 252 } 253 254 for(ListIterator i = _statement_.listIterator(); i.hasNext();) 255 { 256 if(i.next() == oldChild) 257 { 258 if(newChild != null) 259 { 260 i.set(newChild); 261 oldChild.parent(null); 262 return; 263 } 264 265 i.remove(); 266 oldChild.parent(null); 267 return; 268 } 269 } 270 271 for(ListIterator i = _catchClause_.listIterator(); i.hasNext();) 272 { 273 if(i.next() == oldChild) 274 { 275 if(newChild != null) 276 { 277 i.set(newChild); 278 oldChild.parent(null); 279 return; 280 } 281 282 i.remove(); 283 oldChild.parent(null); 284 return; 285 } 286 } 287 288 if(_rBrace_ == oldChild) 289 { 290 setRBrace((TRBrace) newChild); 291 return; 292 } 293 294 } 295 296 private class Declaration_Cast implements Cast 297 { 298 public Object cast(Object o) 299 { 300 PDeclaration node = (PDeclaration) o; 301 302 if((node.parent() != null) && 303 (node.parent() != AFullMethodBody.this)) 304 { 305 node.parent().removeChild(node); 306 } 307 308 if((node.parent() == null) || 309 (node.parent() != AFullMethodBody.this)) 310 { 311 node.parent(AFullMethodBody.this); 312 } 313 314 return node; 315 } 316 } 317 318 private class Statement_Cast implements Cast 319 { 320 public Object cast(Object o) 321 { 322 PStatement node = (PStatement) o; 323 324 if((node.parent() != null) && 325 (node.parent() != AFullMethodBody.this)) 326 { 327 node.parent().removeChild(node); 328 } 329 330 if((node.parent() == null) || 331 (node.parent() != AFullMethodBody.this)) 332 { 333 node.parent(AFullMethodBody.this); 334 } 335 336 return node; 337 } 338 } 339 340 private class CatchClause_Cast implements Cast 341 { 342 public Object cast(Object o) 343 { 344 PCatchClause node = (PCatchClause) o; 345 346 if((node.parent() != null) && 347 (node.parent() != AFullMethodBody.this)) 348 { 349 node.parent().removeChild(node); 350 } 351 352 if((node.parent() == null) || 353 (node.parent() != AFullMethodBody.this)) 354 { 355 node.parent(AFullMethodBody.this); 356 } 357 358 return node; 359 } 360 } 361 } 362 | Popular Tags |