001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */ 002 package org.extendj.ast; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.Set; 007 import java.util.Collections; 008 import java.util.Collection; 009 import java.util.ArrayList; 010 import beaver.*; 011 import java.util.*; 012 import java.io.ByteArrayOutputStream; 013 import java.io.PrintStream; 014 import java.lang.reflect.InvocationTargetException; 015 import java.lang.reflect.Method; 016 import org.jastadd.util.*; 017 import java.util.zip.*; 018 import java.io.*; 019 import org.jastadd.util.PrettyPrintable; 020 import org.jastadd.util.PrettyPrinter; 021 import java.io.FileNotFoundException; 022 import java.io.BufferedInputStream; 023 import java.io.DataInputStream; 024 /** 025 * @ast node 026 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:44 027 * @production NullType : {@link TypeDecl}; 028 029 */ 030 public class NullType extends TypeDecl implements Cloneable { 031 /** 032 * @aspect Java4PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:296 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print("null"); 037 } 038 /** 039 * @aspect CodeGeneration 040 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:247 041 */ 042 public void emitReturn(CodeGeneration gen) { gen.emit(Bytecode.ARETURN);} 043 /** 044 * @aspect CodeGeneration 045 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:330 046 */ 047 public void emitLoadLocal(CodeGeneration gen, int pos) { 048 gen.emitLoadReference(pos); 049 } 050 /** 051 * @aspect CodeGeneration 052 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:473 053 */ 054 public void emitStoreLocal(CodeGeneration gen, int pos) { 055 gen.emitStoreReference(pos); 056 } 057 /** 058 * @aspect CodeGenerationConversions 059 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:589 060 */ 061 void emitCastTo(CodeGeneration gen, TypeDecl type) { } 062 /** 063 * @aspect CodeGenerationBranch 064 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:794 065 */ 066 public void branchEQ(CodeGeneration gen, int label) { gen.emitCompare(Bytecode.IF_ACMPEQ, label); } 067 /** 068 * @aspect CodeGenerationBranch 069 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:803 070 */ 071 public void branchNE(CodeGeneration gen, int label) { gen.emitCompare(Bytecode.IF_ACMPNE, label); } 072 /** 073 * @declaredat ASTNode:1 074 */ 075 public NullType() { 076 super(); 077 } 078 /** 079 * Initializes the child array to the correct size. 080 * Initializes List and Opt nta children. 081 * @apilevel internal 082 * @ast method 083 * @declaredat ASTNode:10 084 */ 085 public void init$Children() { 086 children = new ASTNode[2]; 087 setChild(new List(), 1); 088 } 089 /** 090 * @declaredat ASTNode:14 091 */ 092 public NullType(Modifiers p0, String p1, List<BodyDecl> p2) { 093 setChild(p0, 0); 094 setID(p1); 095 setChild(p2, 1); 096 } 097 /** 098 * @declaredat ASTNode:19 099 */ 100 public NullType(Modifiers p0, beaver.Symbol p1, List<BodyDecl> p2) { 101 setChild(p0, 0); 102 setID(p1); 103 setChild(p2, 1); 104 } 105 /** 106 * @apilevel low-level 107 * @declaredat ASTNode:27 108 */ 109 protected int numChildren() { 110 return 2; 111 } 112 /** 113 * @apilevel internal 114 * @declaredat ASTNode:33 115 */ 116 public boolean mayHaveRewrite() { 117 return false; 118 } 119 /** 120 * @apilevel internal 121 * @declaredat ASTNode:39 122 */ 123 public void flushAttrCache() { 124 super.flushAttrCache(); 125 instanceOf_TypeDecl_reset(); 126 subtype_TypeDecl_reset(); 127 strictSubtype_TypeDecl_reset(); 128 } 129 /** 130 * @apilevel internal 131 * @declaredat ASTNode:48 132 */ 133 public void flushCollectionCache() { 134 super.flushCollectionCache(); 135 } 136 /** 137 * @apilevel internal 138 * @declaredat ASTNode:54 139 */ 140 public void flushRewriteCache() { 141 super.flushRewriteCache(); 142 } 143 /** 144 * @apilevel internal 145 * @declaredat ASTNode:60 146 */ 147 public NullType clone() throws CloneNotSupportedException { 148 NullType node = (NullType) super.clone(); 149 return node; 150 } 151 /** 152 * @apilevel internal 153 * @declaredat ASTNode:67 154 */ 155 public NullType copy() { 156 try { 157 NullType node = (NullType) clone(); 158 node.parent = null; 159 if (children != null) { 160 node.children = (ASTNode[]) children.clone(); 161 } 162 return node; 163 } catch (CloneNotSupportedException e) { 164 throw new Error("Error: clone not supported for " + getClass().getName()); 165 } 166 } 167 /** 168 * Create a deep copy of the AST subtree at this node. 169 * The copy is dangling, i.e. has no parent. 170 * @return dangling copy of the subtree at this node 171 * @apilevel low-level 172 * @deprecated Please use treeCopy or treeCopyNoTransform instead 173 * @declaredat ASTNode:86 174 */ 175 @Deprecated 176 public NullType fullCopy() { 177 return treeCopyNoTransform(); 178 } 179 /** 180 * Create a deep copy of the AST subtree at this node. 181 * The copy is dangling, i.e. has no parent. 182 * @return dangling copy of the subtree at this node 183 * @apilevel low-level 184 * @declaredat ASTNode:96 185 */ 186 public NullType treeCopyNoTransform() { 187 NullType tree = (NullType) copy(); 188 if (children != null) { 189 for (int i = 0; i < children.length; ++i) { 190 ASTNode child = (ASTNode) children[i]; 191 if (child != null) { 192 child = child.treeCopyNoTransform(); 193 tree.setChild(child, i); 194 } 195 } 196 } 197 return tree; 198 } 199 /** 200 * Create a deep copy of the AST subtree at this node. 201 * The subtree of this node is traversed to trigger rewrites before copy. 202 * The copy is dangling, i.e. has no parent. 203 * @return dangling copy of the subtree at this node 204 * @apilevel low-level 205 * @declaredat ASTNode:116 206 */ 207 public NullType treeCopy() { 208 doFullTraversal(); 209 return treeCopyNoTransform(); 210 } 211 /** 212 * @apilevel internal 213 * @declaredat ASTNode:123 214 */ 215 protected boolean is$Equal(ASTNode node) { 216 return super.is$Equal(node) && (tokenString_ID == ((NullType)node).tokenString_ID); 217 } 218 /** 219 * Replaces the Modifiers child. 220 * @param node The new node to replace the Modifiers child. 221 * @apilevel high-level 222 */ 223 public void setModifiers(Modifiers node) { 224 setChild(node, 0); 225 } 226 /** 227 * Retrieves the Modifiers child. 228 * @return The current node used as the Modifiers child. 229 * @apilevel high-level 230 */ 231 @ASTNodeAnnotation.Child(name="Modifiers") 232 public Modifiers getModifiers() { 233 return (Modifiers) getChild(0); 234 } 235 /** 236 * Retrieves the Modifiers child. 237 * <p><em>This method does not invoke AST transformations.</em></p> 238 * @return The current node used as the Modifiers child. 239 * @apilevel low-level 240 */ 241 public Modifiers getModifiersNoTransform() { 242 return (Modifiers) getChildNoTransform(0); 243 } 244 /** 245 * Replaces the lexeme ID. 246 * @param value The new value for the lexeme ID. 247 * @apilevel high-level 248 */ 249 public void setID(String value) { 250 tokenString_ID = value; 251 } 252 /** 253 * JastAdd-internal setter for lexeme ID using the Beaver parser. 254 * @param symbol Symbol containing the new value for the lexeme ID 255 * @apilevel internal 256 */ 257 public void setID(beaver.Symbol symbol) { 258 if (symbol.value != null && !(symbol.value instanceof String)) 259 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 260 tokenString_ID = (String)symbol.value; 261 IDstart = symbol.getStart(); 262 IDend = symbol.getEnd(); 263 } 264 /** 265 * Retrieves the value for the lexeme ID. 266 * @return The value for the lexeme ID. 267 * @apilevel high-level 268 */ 269 @ASTNodeAnnotation.Token(name="ID") 270 public String getID() { 271 return tokenString_ID != null ? tokenString_ID : ""; 272 } 273 /** 274 * Replaces the BodyDecl list. 275 * @param list The new list node to be used as the BodyDecl list. 276 * @apilevel high-level 277 */ 278 public void setBodyDeclList(List<BodyDecl> list) { 279 setChild(list, 1); 280 } 281 /** 282 * Retrieves the number of children in the BodyDecl list. 283 * @return Number of children in the BodyDecl list. 284 * @apilevel high-level 285 */ 286 public int getNumBodyDecl() { 287 return getBodyDeclList().getNumChild(); 288 } 289 /** 290 * Retrieves the number of children in the BodyDecl list. 291 * Calling this method will not trigger rewrites. 292 * @return Number of children in the BodyDecl list. 293 * @apilevel low-level 294 */ 295 public int getNumBodyDeclNoTransform() { 296 return getBodyDeclListNoTransform().getNumChildNoTransform(); 297 } 298 /** 299 * Retrieves the element at index {@code i} in the BodyDecl list. 300 * @param i Index of the element to return. 301 * @return The element at position {@code i} in the BodyDecl list. 302 * @apilevel high-level 303 */ 304 public BodyDecl getBodyDecl(int i) { 305 return (BodyDecl) getBodyDeclList().getChild(i); 306 } 307 /** 308 * Check whether the BodyDecl list has any children. 309 * @return {@code true} if it has at least one child, {@code false} otherwise. 310 * @apilevel high-level 311 */ 312 public boolean hasBodyDecl() { 313 return getBodyDeclList().getNumChild() != 0; 314 } 315 /** 316 * Append an element to the BodyDecl list. 317 * @param node The element to append to the BodyDecl list. 318 * @apilevel high-level 319 */ 320 public void addBodyDecl(BodyDecl node) { 321 List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 322 list.addChild(node); 323 } 324 /** 325 * @apilevel low-level 326 */ 327 public void addBodyDeclNoTransform(BodyDecl node) { 328 List<BodyDecl> list = getBodyDeclListNoTransform(); 329 list.addChild(node); 330 } 331 /** 332 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 333 * @param node The new node to replace the old list element. 334 * @param i The list index of the node to be replaced. 335 * @apilevel high-level 336 */ 337 public void setBodyDecl(BodyDecl node, int i) { 338 List<BodyDecl> list = getBodyDeclList(); 339 list.setChild(node, i); 340 } 341 /** 342 * Retrieves the BodyDecl list. 343 * @return The node representing the BodyDecl list. 344 * @apilevel high-level 345 */ 346 @ASTNodeAnnotation.ListChild(name="BodyDecl") 347 public List<BodyDecl> getBodyDeclList() { 348 List<BodyDecl> list = (List<BodyDecl>) getChild(1); 349 return list; 350 } 351 /** 352 * Retrieves the BodyDecl list. 353 * <p><em>This method does not invoke AST transformations.</em></p> 354 * @return The node representing the BodyDecl list. 355 * @apilevel low-level 356 */ 357 public List<BodyDecl> getBodyDeclListNoTransform() { 358 return (List<BodyDecl>) getChildNoTransform(1); 359 } 360 /** 361 * Retrieves the BodyDecl list. 362 * @return The node representing the BodyDecl list. 363 * @apilevel high-level 364 */ 365 public List<BodyDecl> getBodyDecls() { 366 return getBodyDeclList(); 367 } 368 /** 369 * Retrieves the BodyDecl list. 370 * <p><em>This method does not invoke AST transformations.</em></p> 371 * @return The node representing the BodyDecl list. 372 * @apilevel low-level 373 */ 374 public List<BodyDecl> getBodyDeclsNoTransform() { 375 return getBodyDeclListNoTransform(); 376 } 377 /** 378 * @attribute syn 379 * @aspect TypeAnalysis 380 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:227 381 */ 382 @ASTNodeAnnotation.Attribute 383 public boolean isNull() { 384 boolean isNull_value = true; 385 386 return isNull_value; 387 } 388 /** 389 * @apilevel internal 390 */ 391 protected java.util.Map instanceOf_TypeDecl_values; 392 /** 393 * @apilevel internal 394 */ 395 private void instanceOf_TypeDecl_reset() { 396 instanceOf_TypeDecl_values = null; 397 } 398 /** 399 * @attribute syn 400 * @aspect TypeWideningAndIdentity 401 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:442 402 */ 403 @ASTNodeAnnotation.Attribute 404 public boolean instanceOf(TypeDecl type) { 405 Object _parameters = type; 406 if (instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 407 ASTNode$State state = state(); 408 if (instanceOf_TypeDecl_values.containsKey(_parameters)) { 409 return (Boolean) instanceOf_TypeDecl_values.get(_parameters); 410 } 411 boolean intermediate = state.INTERMEDIATE_VALUE; 412 state.INTERMEDIATE_VALUE = false; 413 int num = state.boundariesCrossed; 414 boolean isFinal = this.is$Final(); 415 boolean instanceOf_TypeDecl_value = instanceOf_compute(type); 416 if (isFinal && num == state().boundariesCrossed) { 417 instanceOf_TypeDecl_values.put(_parameters, instanceOf_TypeDecl_value); 418 } else { 419 } 420 state.INTERMEDIATE_VALUE |= intermediate; 421 422 return instanceOf_TypeDecl_value; 423 } 424 /** 425 * @apilevel internal 426 */ 427 private boolean instanceOf_compute(TypeDecl type) { return subtype(type); } 428 /** 429 * @attribute syn 430 * @aspect TypeWideningAndIdentity 431 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:527 432 */ 433 @ASTNodeAnnotation.Attribute 434 public boolean isSupertypeOfNullType(NullType type) { 435 boolean isSupertypeOfNullType_NullType_value = true; 436 437 return isSupertypeOfNullType_NullType_value; 438 } 439 /** 440 * @attribute syn 441 * @aspect InnerClasses 442 * @declaredat /home/jesper/git/extendj/java4/backend/InnerClasses.jrag:113 443 */ 444 @ASTNodeAnnotation.Attribute 445 public TypeDecl stringPromotion() { 446 TypeDecl stringPromotion_value = typeObject(); 447 448 return stringPromotion_value; 449 } 450 /** 451 * @attribute syn 452 * @aspect LocalNum 453 * @declaredat /home/jesper/git/extendj/java4/backend/LocalNum.jrag:199 454 */ 455 @ASTNodeAnnotation.Attribute 456 public int variableSize() { 457 int variableSize_value = 1; 458 459 return variableSize_value; 460 } 461 /** 462 * @apilevel internal 463 */ 464 private void subtype_TypeDecl_reset() { 465 subtype_TypeDecl_values = null; 466 } 467 protected java.util.Map subtype_TypeDecl_values; 468 @ASTNodeAnnotation.Attribute 469 public boolean subtype(TypeDecl type) { 470 Object _parameters = type; 471 if (subtype_TypeDecl_values == null) subtype_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 472 ASTNode$State.CircularValue _value; 473 if (subtype_TypeDecl_values.containsKey(_parameters)) { 474 Object _o = subtype_TypeDecl_values.get(_parameters); 475 if (!(_o instanceof ASTNode$State.CircularValue)) { 476 return (Boolean) _o; 477 } else { 478 _value = (ASTNode$State.CircularValue) _o; 479 } 480 } else { 481 _value = new ASTNode$State.CircularValue(); 482 subtype_TypeDecl_values.put(_parameters, _value); 483 _value.value = true; 484 } 485 ASTNode$State state = state(); 486 boolean new_subtype_TypeDecl_value; 487 if (!state.IN_CIRCLE) { 488 state.IN_CIRCLE = true; 489 int num = state.boundariesCrossed; 490 boolean isFinal = this.is$Final(); 491 // TODO: fixme 492 // state().CIRCLE_INDEX = 1; 493 do { 494 _value.visited = state.CIRCLE_INDEX; 495 state.CHANGE = false; 496 new_subtype_TypeDecl_value = type.supertypeNullType(this); 497 if (new_subtype_TypeDecl_value != ((Boolean)_value.value)) { 498 state.CHANGE = true; 499 _value.value = new_subtype_TypeDecl_value; 500 } 501 state.CIRCLE_INDEX++; 502 } while (state.CHANGE); 503 if (isFinal && num == state().boundariesCrossed) { 504 subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value); 505 } else { 506 subtype_TypeDecl_values.remove(_parameters); 507 state.RESET_CYCLE = true; 508 boolean $tmp = type.supertypeNullType(this); 509 state.RESET_CYCLE = false; 510 } 511 state.IN_CIRCLE = false; 512 state.INTERMEDIATE_VALUE = false; 513 return new_subtype_TypeDecl_value; 514 } 515 if (state.CIRCLE_INDEX != _value.visited) { 516 _value.visited = state.CIRCLE_INDEX; 517 new_subtype_TypeDecl_value = type.supertypeNullType(this); 518 if (state.RESET_CYCLE) { 519 subtype_TypeDecl_values.remove(_parameters); 520 } 521 else if (new_subtype_TypeDecl_value != ((Boolean)_value.value)) { 522 state.CHANGE = true; 523 _value.value = new_subtype_TypeDecl_value; 524 } 525 state.INTERMEDIATE_VALUE = true; 526 return new_subtype_TypeDecl_value; 527 } 528 state.INTERMEDIATE_VALUE = true; 529 return (Boolean) _value.value; 530 } 531 /** 532 * @attribute syn 533 * @aspect GenericsSubtype 534 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:514 535 */ 536 @ASTNodeAnnotation.Attribute 537 public boolean supertypeNullType(NullType type) { 538 boolean supertypeNullType_NullType_value = true; 539 540 return supertypeNullType_NullType_value; 541 } 542 /** 543 * @apilevel internal 544 */ 545 private void strictSubtype_TypeDecl_reset() { 546 strictSubtype_TypeDecl_values = null; 547 } 548 protected java.util.Map strictSubtype_TypeDecl_values; 549 @ASTNodeAnnotation.Attribute 550 public boolean strictSubtype(TypeDecl type) { 551 Object _parameters = type; 552 if (strictSubtype_TypeDecl_values == null) strictSubtype_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 553 ASTNode$State.CircularValue _value; 554 if (strictSubtype_TypeDecl_values.containsKey(_parameters)) { 555 Object _o = strictSubtype_TypeDecl_values.get(_parameters); 556 if (!(_o instanceof ASTNode$State.CircularValue)) { 557 return (Boolean) _o; 558 } else { 559 _value = (ASTNode$State.CircularValue) _o; 560 } 561 } else { 562 _value = new ASTNode$State.CircularValue(); 563 strictSubtype_TypeDecl_values.put(_parameters, _value); 564 _value.value = true; 565 } 566 ASTNode$State state = state(); 567 boolean new_strictSubtype_TypeDecl_value; 568 if (!state.IN_CIRCLE) { 569 state.IN_CIRCLE = true; 570 int num = state.boundariesCrossed; 571 boolean isFinal = this.is$Final(); 572 // TODO: fixme 573 // state().CIRCLE_INDEX = 1; 574 do { 575 _value.visited = state.CIRCLE_INDEX; 576 state.CHANGE = false; 577 new_strictSubtype_TypeDecl_value = type.strictSupertypeNullType(this); 578 if (new_strictSubtype_TypeDecl_value != ((Boolean)_value.value)) { 579 state.CHANGE = true; 580 _value.value = new_strictSubtype_TypeDecl_value; 581 } 582 state.CIRCLE_INDEX++; 583 } while (state.CHANGE); 584 if (isFinal && num == state().boundariesCrossed) { 585 strictSubtype_TypeDecl_values.put(_parameters, new_strictSubtype_TypeDecl_value); 586 } else { 587 strictSubtype_TypeDecl_values.remove(_parameters); 588 state.RESET_CYCLE = true; 589 boolean $tmp = type.strictSupertypeNullType(this); 590 state.RESET_CYCLE = false; 591 } 592 state.IN_CIRCLE = false; 593 state.INTERMEDIATE_VALUE = false; 594 return new_strictSubtype_TypeDecl_value; 595 } 596 if (state.CIRCLE_INDEX != _value.visited) { 597 _value.visited = state.CIRCLE_INDEX; 598 new_strictSubtype_TypeDecl_value = type.strictSupertypeNullType(this); 599 if (state.RESET_CYCLE) { 600 strictSubtype_TypeDecl_values.remove(_parameters); 601 } 602 else if (new_strictSubtype_TypeDecl_value != ((Boolean)_value.value)) { 603 state.CHANGE = true; 604 _value.value = new_strictSubtype_TypeDecl_value; 605 } 606 state.INTERMEDIATE_VALUE = true; 607 return new_strictSubtype_TypeDecl_value; 608 } 609 state.INTERMEDIATE_VALUE = true; 610 return (Boolean) _value.value; 611 } 612 /** 613 * @attribute syn 614 * @aspect StrictSubtype 615 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:446 616 */ 617 @ASTNodeAnnotation.Attribute 618 public boolean strictSupertypeNullType(NullType type) { 619 boolean strictSupertypeNullType_NullType_value = true; 620 621 return strictSupertypeNullType_NullType_value; 622 } 623 /** 624 * @apilevel internal 625 */ 626 public ASTNode rewriteTo() { 627 return super.rewriteTo(); 628 } 629 }