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: import java.math.BigInteger;
24:
25: /**
26: * Representation of a null reference. A null reference represents
27: * the null location in memory. Its type is void; it neither has a
28: * base nor an offset.
29: *
30: * @author Robert Grimm
31: * @version $Revision: 1.3 $
32: */
33: public class NullReference extends Reference {
34:
35: /** The canonical null reference. */
36: public static final NullReference NULL = new NullReference();
37:
38: /** Create a new null reference. */
39: private NullReference() {
40: super (VoidT.TYPE);
41: }
42:
43: public boolean isNull() {
44: return true;
45: }
46:
47: public boolean hasLocation() {
48: return true;
49: }
50:
51: public BigInteger getLocation() {
52: return BigInteger.ZERO;
53: }
54:
55: public boolean isConstant() {
56: return true;
57: }
58:
59: public void write(Appendable out) throws IOException {
60: out.append("<null>");
61: }
62:
63: }
|