IdentifierToken.java revision 0
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/*
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Copyright 1996-2003 Sun Microsystems, Inc. All Rights Reserved.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This code is free software; you can redistribute it and/or modify it
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * under the terms of the GNU General Public License version 2 only, as
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * published by the Free Software Foundation. Sun designates this
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * particular file as subject to the "Classpath" exception as provided
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * by Sun in the LICENSE file that accompanied this code.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This code is distributed in the hope that it will be useful, but WITHOUT
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * version 2 for more details (a copy is included in the LICENSE file that
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * accompanied this code).
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * You should have received a copy of the GNU General Public License version
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * 2 along with this work; if not, write to the Free Software Foundation,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * CA 95054 USA or visit www.sun.com if you need additional information or
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * have any questions.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpackage sun.tools.java;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/**
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Information about the occurrence of an identifier.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * The parser produces these to represent name which cannot yet be
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * bound to field definitions.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * WARNING: The contents of this source file are not part of any
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * supported API. Code that depends on them does so at its own risk:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * they are subject to change or removal without notice.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @see
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpublic
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkclass IdentifierToken {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk long where;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk int modifiers;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Identifier id;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public IdentifierToken(long where, Identifier id) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.where = where;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.id = id;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Use this constructor when the identifier is synthesized.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * The location will be 0.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public IdentifierToken(Identifier id) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.where = 0;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.id = id;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public IdentifierToken(long where, Identifier id, int modifiers) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.where = where;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.id = id;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.modifiers = modifiers;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** The source location of this identifier occurrence. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public long getWhere() {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return where;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** The identifier itself (possibly qualified). */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public Identifier getName() {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return id;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** The modifiers associated with the occurrence, if any. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public int getModifiers() {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return modifiers;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public String toString() {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return id.toString();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /**
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Return defaultWhere if id is null or id.where is missing (0).
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Otherwise, return id.where.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public static long getWhere(IdentifierToken id, long defaultWhere) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return (id != null && id.where != 0) ? id.where : defaultWhere;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk}
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk