public NameReference getUnspecifiedReferenceOptimized() { /* build a (unspecified) NameReference which may be qualified The optimization occurs for qualified reference while we are certain in this case the last item of the qualified name is a field access. This optimization is IMPORTANT while it results that when a NameReference is build, the type checker should always look for that it is not a type reference */ consumeNonTypeUseName(); int length; if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) { // single variable reference SingleNameReference ref = newSingleNameReference( this.identifierStack[this.identifierPtr], this.identifierPositionStack[this.identifierPtr--]); ref.bits &= ~ASTNode.RestrictiveFlagMASK; ref.bits |= Binding.LOCAL | Binding.FIELD; if (this.reportReferenceInfo) { addUnknownRef(ref); } return ref; } // Qualified-variable-reference // In fact it is variable-reference DOT field-ref , but it would result in a type // conflict tha can be only reduce by making a superclass (or inetrface ) between // nameReference and FiledReference or putting FieldReference under NameReference // or else..........This optimisation is not really relevant so just leave as it is char[][] tokens = new char[length][]; this.identifierPtr -= length; System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length); long[] positions = new long[length]; System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length); QualifiedNameReference ref = newQualifiedNameReference( tokens, positions, (int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart (int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd ref.bits &= ~ASTNode.RestrictiveFlagMASK; ref.bits |= Binding.LOCAL | Binding.FIELD; if (this.reportReferenceInfo) { addUnknownRef(ref); } return ref; }
public boolean visit(SingleNameReference singleNameReference, BlockScope scope) { this.collector.append("[v SNR " + cut(singleNameReference.toString()) + "]\n"); return super.visit(singleNameReference, scope); }
public void endVisit(SingleNameReference singleNameReference, BlockScope scope) { this.collector.append("[ev SNR " + cut(singleNameReference.toString()) + "]\n"); super.endVisit(singleNameReference, scope); }