001: /*
002: * xtc - The eXTensible Compiler
003: * Copyright (C) 2006-2007 Robert Grimm
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License
007: * version 2 as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
017: * USA.
018: */
019: package xtc.type;
020:
021: import java.io.IOException;
022:
023: /**
024: * An internal type, identified by its name.
025: *
026: * @author Robert Grimm
027: * @version $Revision: 1.12 $
028: */
029: public class InternalT extends Type {
030:
031: /** The canonical variable argument list type. */
032: public static final InternalT VA_LIST = new InternalT(
033: "__builtin_va_list");
034:
035: /** Seal the canonical type. */
036: static {
037: VA_LIST.seal();
038: }
039:
040: /** The name. */
041: private final String name;
042:
043: /**
044: * Create a new internal type.
045: *
046: * @param name The name.
047: */
048: public InternalT(String name) {
049: this .name = name;
050: }
051:
052: /**
053: * Create a new internal type.
054: *
055: * @param template The type whose annotations to copy.
056: * @param name The name.
057: */
058: public InternalT(Type template, String name) {
059: super (template);
060: this .name = name;
061: }
062:
063: public InternalT copy() {
064: return new InternalT(this , name);
065: }
066:
067: public Type.Tag tag() {
068: return Type.Tag.INTERNAL;
069: }
070:
071: public boolean isInternal() {
072: return true;
073: }
074:
075: public InternalT toInternal() {
076: return this ;
077: }
078:
079: /**
080: * Get the name.
081: *
082: * @return The name.
083: */
084: public String getName() {
085: return name;
086: }
087:
088: public int hashCode() {
089: return name.hashCode();
090: }
091:
092: public boolean equals(Object o) {
093: if (!(o instanceof Type))
094: return false;
095: Type t = resolve(o);
096:
097: if (this == t)
098: return true;
099: if (!t.isInternal())
100: return false;
101: return name.equals(((InternalT) t).name);
102: }
103:
104: public void write(Appendable out) throws IOException {
105: out.append(name);
106: }
107:
108: public String toString() {
109: return name;
110: }
111:
112: }
|