annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java @ 18187:9619ba4daf4c

Rename Constant to JavaConstant.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 30 Oct 2014 12:21:07 +0100
parents ef357effbda7
children 0093dcea7092
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
1 /*
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
4 *
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
8 *
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
13 * accompanied this code).
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
14 *
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
18 *
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
21 * questions.
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
22 */
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.api.meta;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
24
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
25 /**
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
26 * The implementation type of the {@link JavaConstant#NULL_OBJECT null constant}.
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
27 */
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
28 final class NullConstant extends JavaConstant {
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
29
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
30 private static final long serialVersionUID = 8906209595800783961L;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
31
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
32 protected NullConstant() {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
33 super(LIRKind.reference(Kind.Object));
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
34 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
35
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
36 @Override
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
37 public boolean isNull() {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
38 return true;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
39 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
40
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
41 @Override
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
42 public boolean isDefaultForKind() {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
43 return true;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
44 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
45
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
46 @Override
18186
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
47 public Object asBoxedPrimitive() {
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
48 throw new IllegalArgumentException();
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
49 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
50
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
51 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
52 public int asInt() {
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
53 throw new IllegalArgumentException();
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
54 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
55
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
56 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
57 public boolean asBoolean() {
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
58 throw new IllegalArgumentException();
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
59 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
60
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
61 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
62 public long asLong() {
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
63 throw new IllegalArgumentException();
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
64 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
65
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
66 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
67 public float asFloat() {
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
68 throw new IllegalArgumentException();
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
69 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
70
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
71 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
72 public double asDouble() {
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
73 throw new IllegalArgumentException();
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
74 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
75
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17449
diff changeset
76 @Override
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
77 public String toValueString() {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
78 return "null";
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
79 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
80
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
81 @Override
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
82 public int hashCode() {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
83 return System.identityHashCode(this);
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
84 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
85
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
86 @Override
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
87 public boolean equals(Object o) {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
88 assert o == this || !(o instanceof NullConstant) : "null constant is a singleton";
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
89 return o == this;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
90 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
91 }