1 11 package org.eclipse.jdt.internal.compiler.ast; 12 13 import org.eclipse.jdt.internal.compiler.ASTVisitor; 14 import org.eclipse.jdt.internal.compiler.codegen.*; 15 import org.eclipse.jdt.internal.compiler.flow.*; 16 import org.eclipse.jdt.internal.compiler.impl.Constant; 17 import org.eclipse.jdt.internal.compiler.lookup.*; 18 19 public class QualifiedThisReference extends ThisReference { 20 21 public TypeReference qualification; 22 ReferenceBinding currentCompatibleType; 23 24 public QualifiedThisReference(TypeReference name, int sourceStart, int sourceEnd) { 25 super(sourceStart, sourceEnd); 26 qualification = name; 27 name.bits |= IgnoreRawTypeCheck; this.sourceStart = name.sourceStart; 29 } 30 31 public FlowInfo analyseCode( 32 BlockScope currentScope, 33 FlowContext flowContext, 34 FlowInfo flowInfo) { 35 36 return flowInfo; 37 } 38 39 public FlowInfo analyseCode( 40 BlockScope currentScope, 41 FlowContext flowContext, 42 FlowInfo flowInfo, 43 boolean valueRequired) { 44 45 return flowInfo; 46 } 47 48 55 public void generateCode( 56 BlockScope currentScope, 57 CodeStream codeStream, 58 boolean valueRequired) { 59 60 int pc = codeStream.position; 61 if (valueRequired) { 62 if ((bits & DepthMASK) != 0) { 63 Object [] emulationPath = 64 currentScope.getEmulationPath(this.currentCompatibleType, true , false); 65 codeStream.generateOuterAccess(emulationPath, this, this.currentCompatibleType, currentScope); 66 } else { 67 codeStream.aload_0(); 69 } 70 } 71 codeStream.recordPositionsFrom(pc, this.sourceStart); 72 } 73 74 public TypeBinding resolveType(BlockScope scope) { 75 76 constant = Constant.NotAConstant; 77 TypeBinding type = this.qualification.resolveType(scope, true ); 79 if (type == null) return null; 80 type = type.erasure(); 82 83 if (type instanceof ReferenceBinding) { 85 this.resolvedType = scope.environment().convertToParameterizedType((ReferenceBinding) type); 86 } else { 87 this.resolvedType = type; 89 } 90 91 int depth = 0; 94 this.currentCompatibleType = scope.referenceType().binding; 95 while (this.currentCompatibleType != null && this.currentCompatibleType != type) { 96 depth++; 97 this.currentCompatibleType = this.currentCompatibleType.isStatic() ? null : this.currentCompatibleType.enclosingType(); 98 } 99 bits &= ~DepthMASK; bits |= (depth & 0xFF) << DepthSHIFT; 102 if (this.currentCompatibleType == null) { 103 scope.problemReporter().noSuchEnclosingInstance(type, this, false); 104 return this.resolvedType; 105 } 106 107 if (depth == 0) { 109 checkAccess(scope.methodScope()); 110 } 112 return this.resolvedType; 113 } 114 115 public StringBuffer printExpression(int indent, StringBuffer output) { 116 117 return qualification.print(0, output).append(".this"); } 119 120 public void traverse( 121 ASTVisitor visitor, 122 BlockScope blockScope) { 123 124 if (visitor.visit(this, blockScope)) { 125 qualification.traverse(visitor, blockScope); 126 } 127 visitor.endVisit(this, blockScope); 128 } 129 130 public void traverse( 131 ASTVisitor visitor, 132 ClassScope blockScope) { 133 134 if (visitor.visit(this, blockScope)) { 135 qualification.traverse(visitor, blockScope); 136 } 137 visitor.endVisit(this, blockScope); 138 } 139 } 140 | Popular Tags |