1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.*; 28 29 import org.aspectj.compiler.base.bcg.CodeBuilder; 30 31 35 36 public class QualifiedSuperExpr extends SuperExpr { 37 38 public NameType getThisType() { 39 return (NameType) typeD.getType(); 40 } 41 42 public void unparse(CodeWriter writer) { 43 writer.write(typeD.getType().getId()); 44 writer.write(".super"); 45 } 46 47 50 public ASTObject walkMemberMunger(MemberClassMunger w) { 52 final AST ast = getAST(); 53 NameType currentType = w.currentType(); 54 NameType targetType = (NameType) getTypeD().getType(); 55 56 if (currentType == targetType) { 57 return ast.forceCast(targetType.getSuperClassType(), ast.makeThis(currentType)); 58 } else { 59 CodeDec dec = getEnclosingCodeDec(); 60 if (dec instanceof ConstructorDec) { 61 ConstructorDec cdec = (ConstructorDec) dec; 62 Expr seed = ast.makeVar(cdec.getEnclosingInstanceFormal()); 63 return ast.forceCast(targetType.getSuperClassType(), 64 w.buildExprFromEnclosing(seed, targetType)); 65 } else { 66 Expr seed = ast.makeThis(currentType); 67 return ast.forceCast(targetType.getSuperClassType(), 68 w.buildExprFromThis(seed, targetType)); 69 } 70 } 71 } 72 73 protected void cgValue(CodeBuilder cb) { 76 throw new RuntimeException ("Invalid expression " + this); 77 } 78 79 protected TypeD typeD; 81 public TypeD getTypeD() { return typeD; } 82 public void setTypeD(TypeD _typeD) { 83 if (_typeD != null) _typeD.setParent(this); 84 typeD = _typeD; 85 } 86 87 public QualifiedSuperExpr(SourceLocation location, TypeD _typeD) { 88 super(location); 89 setTypeD(_typeD); 90 } 91 protected QualifiedSuperExpr(SourceLocation source) { 92 super(source); 93 } 94 95 public ASTObject copyWalk(CopyWalker walker) { 96 QualifiedSuperExpr ret = new QualifiedSuperExpr(getSourceLocation()); 97 ret.preCopy(walker, this); 98 if (typeD != null) ret.setTypeD( (TypeD)walker.process(typeD) ); 99 return ret; 100 } 101 102 public ASTObject getChildAt(int childIndex) { 103 switch(childIndex) { 104 case 0: return typeD; 105 default: return super.getChildAt(childIndex); 106 } 107 } 108 public String getChildNameAt(int childIndex) { 109 switch(childIndex) { 110 case 0: return "typeD"; 111 default: return super.getChildNameAt(childIndex); 112 } 113 } 114 public void setChildAt(int childIndex, ASTObject child) { 115 switch(childIndex) { 116 case 0: setTypeD((TypeD)child); return; 117 default: super.setChildAt(childIndex, child); return; 118 } 119 } 120 public int getChildCount() { 121 return 1; 122 } 123 124 public String getDefaultDisplayName() { 125 return "QualifiedSuperExpr()"; 126 } 127 128 } 130 | Popular Tags |