01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2006-2007 Robert Grimm
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * version 2 as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17: * USA.
18: */
19: package xtc.type;
20:
21: import java.io.IOException;
22:
23: /**
24: * Representation of a cast reference.
25: *
26: * @author Robert Grimm
27: * @version $Revision: 1.3 $
28: */
29: public class CastReference extends RelativeReference {
30:
31: /**
32: * Create a new cast reference.
33: *
34: * @param base The base reference.
35: * @param type The cast-to type.
36: */
37: public CastReference(Type type, Reference base) {
38: super (type, base);
39:
40: // Update the type.
41: normalize();
42: }
43:
44: public boolean isPrefix() {
45: return true;
46: }
47:
48: public boolean isCast() {
49: return true;
50: }
51:
52: public int hashCode() {
53: return base.hashCode();
54: }
55:
56: public boolean equals(Object o) {
57: if (this == o)
58: return true;
59: if (!(o instanceof CastReference))
60: return false;
61: CastReference other = (CastReference) o;
62: return this .base.equals(other.base)
63: && this .type.equals(other.type);
64: }
65:
66: public void write(Appendable out) throws IOException {
67: out.append('(');
68: type.write(out);
69: out.append(')');
70: base.write(out);
71: }
72:
73: }
|