01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.lookup;
11:
12: import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
13: import org.eclipse.jdt.internal.compiler.impl.Constant;
14:
15: public abstract class VariableBinding extends Binding {
16:
17: public int modifiers;
18: public TypeBinding type;
19: public char[] name;
20: protected Constant constant;
21: public int id; // for flow-analysis (position in flowInfo bit vector)
22: public long tagBits;
23:
24: public VariableBinding(char[] name, TypeBinding type,
25: int modifiers, Constant constant) {
26: this .name = name;
27: this .type = type;
28: this .modifiers = modifiers;
29: this .constant = constant;
30: }
31:
32: public Constant constant() {
33: return this .constant;
34: }
35:
36: public abstract AnnotationBinding[] getAnnotations();
37:
38: public final boolean isBlankFinal() {
39: return (modifiers & ExtraCompilerModifiers.AccBlankFinal) != 0;
40: }
41:
42: /* Answer true if the receiver is final and cannot be changed
43: */
44:
45: public final boolean isFinal() {
46: return (modifiers & ClassFileConstants.AccFinal) != 0;
47: }
48:
49: public char[] readableName() {
50: return name;
51: }
52:
53: public void setConstant(Constant constant) {
54: this .constant = constant;
55: }
56:
57: public String toString() {
58: String s = (type != null) ? type.debugName() : "UNDEFINED TYPE"; //$NON-NLS-1$
59: s += " "; //$NON-NLS-1$
60: s += (name != null) ? new String(name) : "UNNAMED FIELD"; //$NON-NLS-1$
61: return s;
62: }
63: }
|