Mercurial > hg > truffle
comparison graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java @ 2297:099e697d8934
Renaming c1x4hotspotsrc => graal and HotSpotVM => Runtime
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 22 Apr 2011 15:08:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2296:34354e2e40a3 | 2297:099e697d8934 |
---|---|
1 /* | |
2 * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved. | |
3 * | |
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product | |
5 * that is described in this document. In particular, and without limitation, these intellectual property | |
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or | |
7 * more additional patents or pending patent applications in the U.S. and in other countries. | |
8 * | |
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun | |
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its | |
11 * supplements. | |
12 * | |
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or | |
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks | |
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the | |
16 * U.S. and other countries. | |
17 * | |
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open | |
19 * Company, Ltd. | |
20 */ | |
21 package com.sun.hotspot.c1x; | |
22 | |
23 import com.sun.cri.ci.*; | |
24 import com.sun.cri.ri.*; | |
25 | |
26 /** | |
27 * Implementation of RiType for unresolved HotSpot classes. | |
28 * | |
29 * @author Thomas Wuerthinger, Lukas Stadler | |
30 */ | |
31 public class HotSpotTypeUnresolved extends HotSpotType { | |
32 | |
33 public final String simpleName; | |
34 public final int dimensions; | |
35 | |
36 /** | |
37 * Creates a new unresolved type for a specified type descriptor. | |
38 */ | |
39 public HotSpotTypeUnresolved(Compiler compiler, String name) { | |
40 super(compiler); | |
41 assert name.length() > 0 : "name cannot be empty"; | |
42 | |
43 int dimensions = 0; | |
44 // Decode name if necessary. | |
45 if (name.charAt(name.length() - 1) == ';') { | |
46 int startIndex = 0; | |
47 while (name.charAt(startIndex) == '[') { | |
48 startIndex++; | |
49 dimensions++; | |
50 } | |
51 assert name.charAt(startIndex) == 'L'; | |
52 this.simpleName = name.substring(startIndex + 1, name.length() - 1); | |
53 this.name = name; | |
54 } else { | |
55 this.simpleName = name; | |
56 this.name = getFullName(name, dimensions); | |
57 } | |
58 | |
59 this.dimensions = dimensions; | |
60 } | |
61 | |
62 public HotSpotTypeUnresolved(Compiler compiler, String name, int dimensions) { | |
63 super(compiler); | |
64 assert dimensions >= 0; | |
65 this.simpleName = name; | |
66 this.dimensions = dimensions; | |
67 this.name = getFullName(name, dimensions); | |
68 } | |
69 | |
70 private String getFullName(String name, int dimensions) { | |
71 StringBuilder str = new StringBuilder(); | |
72 for (int i = 0; i < dimensions; i++) { | |
73 str.append('['); | |
74 } | |
75 str.append('L').append(simpleName).append(';'); | |
76 return str.toString(); | |
77 } | |
78 | |
79 @Override | |
80 public RiType uniqueConcreteSubtype() { | |
81 throw unresolved("uniqueConcreteSubtype"); | |
82 } | |
83 | |
84 @Override | |
85 public Class<?> javaClass() { | |
86 throw unresolved("javaClass"); | |
87 } | |
88 | |
89 @Override | |
90 public boolean hasSubclass() { | |
91 throw unresolved("hasSubclass()"); | |
92 } | |
93 | |
94 @Override | |
95 public boolean hasFinalizer() { | |
96 throw unresolved("hasFinalizer()"); | |
97 } | |
98 | |
99 @Override | |
100 public boolean hasFinalizableSubclass() { | |
101 throw unresolved("hasFinalizableSubclass()"); | |
102 } | |
103 | |
104 @Override | |
105 public boolean isInterface() { | |
106 throw unresolved("isInterface()"); | |
107 } | |
108 | |
109 @Override | |
110 public boolean isArrayClass() { | |
111 return dimensions > 0; | |
112 } | |
113 | |
114 @Override | |
115 public boolean isInstanceClass() { | |
116 throw unresolved("isInstanceClass()"); | |
117 } | |
118 | |
119 @Override | |
120 public int accessFlags() { | |
121 throw unresolved("accessFlags()"); | |
122 } | |
123 | |
124 @Override | |
125 public boolean isResolved() { | |
126 return false; | |
127 } | |
128 | |
129 @Override | |
130 public boolean isInitialized() { | |
131 throw unresolved("isInitialized()"); | |
132 } | |
133 | |
134 @Override | |
135 public boolean isSubtypeOf(RiType other) { | |
136 throw unresolved("isSubtypeOf()"); | |
137 } | |
138 | |
139 @Override | |
140 public boolean isInstance(CiConstant obj) { | |
141 throw unresolved("isInstance()"); | |
142 } | |
143 | |
144 @Override | |
145 public RiType componentType() { | |
146 assert isArrayClass() : "no array class" + name(); | |
147 return new HotSpotTypeUnresolved(compiler, simpleName, dimensions - 1); | |
148 } | |
149 | |
150 @Override | |
151 public RiType exactType() { | |
152 throw unresolved("exactType()"); | |
153 } | |
154 | |
155 @Override | |
156 public RiType superType() { | |
157 throw unresolved("superType()"); | |
158 } | |
159 | |
160 @Override | |
161 public RiType arrayOf() { | |
162 return new HotSpotTypeUnresolved(compiler, simpleName, dimensions + 1); | |
163 } | |
164 | |
165 @Override | |
166 public RiMethod resolveMethodImpl(RiMethod method) { | |
167 throw unresolved("resolveMethodImpl()"); | |
168 } | |
169 | |
170 @Override | |
171 public CiKind kind() { | |
172 return CiKind.Object; | |
173 } | |
174 | |
175 private CiUnresolvedException unresolved(String operation) { | |
176 throw new CiUnresolvedException(operation + " not defined for unresolved class " + simpleName); | |
177 } | |
178 | |
179 @Override | |
180 public int hashCode() { | |
181 return simpleName.hashCode(); | |
182 } | |
183 | |
184 @Override | |
185 public boolean equals(Object o) { | |
186 return o == this; | |
187 } | |
188 | |
189 @Override | |
190 public String toString() { | |
191 return "HotSpotType<" + simpleName + ", unresolved>"; | |
192 } | |
193 | |
194 @Override | |
195 public CiConstant getEncoding(RiType.Representation r) { | |
196 throw unresolved("getEncoding()"); | |
197 } | |
198 | |
199 @Override | |
200 public CiKind getRepresentationKind(RiType.Representation r) { | |
201 return CiKind.Object; | |
202 } | |
203 | |
204 } |