1 /*******************************************************************************
2 * Copyright (c) 2000, 2009 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.lookup;
12
13 import org.eclipse.jdt.core.compiler.CharOperation;
14
15 public final class MemberTypeBinding extends NestedTypeBinding {
16
MemberTypeBinding(char[][] compoundName, ClassScope scope, SourceTypeBinding enclosingType)17 public MemberTypeBinding(char[][] compoundName, ClassScope scope, SourceTypeBinding enclosingType) {
18 super(compoundName, scope, enclosingType);
19 this.tagBits |= TagBits.MemberTypeMask;
20 }
21
MemberTypeBinding(MemberTypeBinding prototype)22 public MemberTypeBinding(MemberTypeBinding prototype) {
23 super(prototype);
24 }
25
checkSyntheticArgsAndFields()26 void checkSyntheticArgsAndFields() {
27 if (!isPrototype()) throw new IllegalStateException();
28 if (isStatic()) return;
29 if (isInterface()) return;
30 if (!isPrototype()) {
31 ((MemberTypeBinding) this.prototype).checkSyntheticArgsAndFields();
32 return;
33 }
34 this.addSyntheticArgumentAndField(this.enclosingType);
35 }
36 /* Answer the receiver's constant pool name.
37 *
38 * NOTE: This method should only be used during/after code gen.
39 */
40
constantPoolName()41 public char[] constantPoolName() /* java/lang/Object */ {
42
43 if (this.constantPoolName != null)
44 return this.constantPoolName;
45
46 if (!isPrototype()) {
47 return this.prototype.constantPoolName();
48 }
49
50 return this.constantPoolName = CharOperation.concat(enclosingType().constantPoolName(), this.sourceName, '$');
51 }
52
clone(TypeBinding outerType)53 public TypeBinding clone(TypeBinding outerType) {
54 MemberTypeBinding copy = new MemberTypeBinding(this);
55 copy.enclosingType = (SourceTypeBinding) outerType;
56 return copy;
57 }
58
59 /**
60 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#initializeDeprecatedAnnotationTagBits()
61 */
initializeDeprecatedAnnotationTagBits()62 public void initializeDeprecatedAnnotationTagBits() {
63 if (!isPrototype()) {
64 this.prototype.initializeDeprecatedAnnotationTagBits();
65 return;
66 }
67 if ((this.tagBits & TagBits.DeprecatedAnnotationResolved) == 0) {
68 super.initializeDeprecatedAnnotationTagBits();
69 if ((this.tagBits & TagBits.AnnotationDeprecated) == 0) {
70 // check enclosing type
71 ReferenceBinding enclosing;
72 if (((enclosing = enclosingType()).tagBits & TagBits.DeprecatedAnnotationResolved) == 0) {
73 enclosing.initializeDeprecatedAnnotationTagBits();
74 }
75 if (enclosing.isViewedAsDeprecated()) {
76 this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
77 }
78 }
79 }
80 }
toString()81 public String toString() {
82 if (this.hasTypeAnnotations()) {
83 return annotatedDebugName();
84 } else {
85 return "Member type : " + new String(sourceName()) + " " + super.toString(); //$NON-NLS-2$ //$NON-NLS-1$
86 }
87 }
88 }
89