annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java @ 7816:4e1278443941

Remove Kind.Jsr.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 18 Feb 2013 20:55:18 -0800
parents f3fcc94f7120
children 149fe42411df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
23 package com.oracle.graal.api.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
25 import java.lang.reflect.*;
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
26
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
28 * Denotes the basic kinds of types in CRI, including the all the Java primitive types, for example,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
29 * {@link Kind#Int} for {@code int} and {@link Kind#Object} for all object types. A kind has a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
30 * single character short name, a Java name, and a set of flags further describing its behavior.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 */
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
32 public enum Kind {
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
33 /** The primitive boolean kind, represented as an int on the stack. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
34 Boolean('z', "boolean", true, java.lang.Boolean.TYPE, java.lang.Boolean.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
35
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
36 /** The primitive byte kind, represented as an int on the stack. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
37 Byte('b', "byte", true, java.lang.Byte.TYPE, java.lang.Byte.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
38
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
39 /** The primitive short kind, represented as an int on the stack. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
40 Short('s', "short", true, java.lang.Short.TYPE, java.lang.Short.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
41
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
42 /** The primitive char kind, represented as an int on the stack. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
43 Char('c', "char", true, java.lang.Character.TYPE, java.lang.Character.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
44
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
45 /** The primitive int kind, represented as an int on the stack. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
46 Int('i', "int", true, java.lang.Integer.TYPE, java.lang.Integer.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
47
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
48 /** The primitive float kind. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
49 Float('f', "float", false, java.lang.Float.TYPE, java.lang.Float.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
50
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
51 /** The primitive long kind. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
52 Long('j', "long", false, java.lang.Long.TYPE, java.lang.Long.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
53
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
54 /** The primitive double kind. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
55 Double('d', "double", false, java.lang.Double.TYPE, java.lang.Double.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
56
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
57 /** The Object kind, also used for arrays. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
58 Object('a', "Object", false, null, null),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
59
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
60 /** The void float kind. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
61 Void('v', "void", false, java.lang.Void.TYPE, java.lang.Void.class),
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
62
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
63 /** The non-type. */
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
64 Illegal('-', "illegal", false, null, null);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
66 private final char typeChar;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
67 private final String javaName;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
68 private final boolean isStackInt;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
69 private final Class primitiveJavaClass;
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
70 private final Class boxedJavaClass;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
71
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
72 private Kind(char typeChar, String javaName, boolean isStackInt, Class primitiveJavaClass, Class boxedJavasClass) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
73 this.typeChar = typeChar;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
74 this.javaName = javaName;
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
75 this.isStackInt = isStackInt;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
76 this.primitiveJavaClass = primitiveJavaClass;
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
77 this.boxedJavaClass = boxedJavasClass;
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
78 assert primitiveJavaClass == null || javaName.equals(primitiveJavaClass.getName());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
81 /**
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
82 * Returns the name of the kind as a single character.
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
83 */
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
84 public char getTypeChar() {
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
85 return typeChar;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
86 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 /**
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
89 * Returns the name of this kind which will also be it Java programming language name if it is
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
90 * {@linkplain #isPrimitive() primitive} or {@code void}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 */
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
92 public String getJavaName() {
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
93 return javaName;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
94 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 * Checks whether this type is a Java primitive type.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
98 *
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
99 * @return {@code true} if this is {@link #Boolean}, {@link #Byte}, {@link #Char},
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
100 * {@link #Short}, {@link #Int}, {@link #Long}, {@link #Float}, {@link #Double}, or
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
101 * {@link #Void}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 public boolean isPrimitive() {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
104 return primitiveJavaClass != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 /**
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
108 * Returns the kind that represents this kind when on the Java operand stack.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
109 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 * @return the kind used on the operand stack
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 */
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
112 public Kind getStackKind() {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
113 if (isStackInt) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 return Int;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 return this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
119 /**
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
120 * Returns the kind corresponding to the Java type string.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
121 *
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
122 * @param typeString the Java type string
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
123 * @return the kind
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
124 */
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
125 public static Kind fromTypeString(String typeString) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 assert typeString.length() > 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 final char first = typeString.charAt(0);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 if (first == '[' || first == 'L') {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
129 return Kind.Object;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 }
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
131 return Kind.fromPrimitiveOrVoidTypeChar(first);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 /**
7645
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
135 * Returns the kind of a word given the size of a word in bytes.
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
136 *
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
137 * @param wordSizeInBytes the size of a word in bytes
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
138 * @return the kind representing a word value
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
139 */
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
140 public static Kind fromWordSize(int wordSizeInBytes) {
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
141 if (wordSizeInBytes == 8) {
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
142 return Kind.Long;
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
143 } else {
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
144 assert wordSizeInBytes == 4 : "Unsupported word size!";
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
145 return Kind.Int;
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
146 }
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
147 }
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
148
f3fcc94f7120 Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
149 /**
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6437
diff changeset
150 * Returns the kind from the character describing a primitive or void.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
151 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 * @param ch the character
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 * @return the kind
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 */
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
155 public static Kind fromPrimitiveOrVoidTypeChar(char ch) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 switch (ch) {
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
157 case 'Z':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
158 return Boolean;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
159 case 'C':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
160 return Char;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
161 case 'F':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
162 return Float;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
163 case 'D':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
164 return Double;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
165 case 'B':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
166 return Byte;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
167 case 'S':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
168 return Short;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
169 case 'I':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
170 return Int;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
171 case 'J':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
172 return Long;
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
173 case 'V':
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
174 return Void;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 throw new IllegalArgumentException("unknown primitive or void type character: " + ch);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
179 /**
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
180 * Returns the Kind representing the given Java class.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
181 *
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
182 * @param klass the class
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
183 * @return the kind
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
184 */
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
185 public static Kind fromJavaClass(Class<?> klass) {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
186 if (klass == Boolean.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
187 return Boolean;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
188 } else if (klass == Byte.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
189 return Byte;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
190 } else if (klass == Short.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
191 return Short;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
192 } else if (klass == Char.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
193 return Char;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
194 } else if (klass == Int.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
195 return Int;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
196 } else if (klass == Long.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
197 return Long;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
198 } else if (klass == Float.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
199 return Float;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
200 } else if (klass == Double.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
201 return Double;
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
202 } else if (klass == Void.primitiveJavaClass) {
6437
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
203 return Void;
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
204 } else {
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
205 return Object;
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
206 }
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
207 }
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
208
8f820c815cc2 Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6328
diff changeset
209 /**
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
210 * Returns the Java class representing this kind.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
211 *
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
212 * @return the Java class
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
213 */
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
214 public Class<?> toJavaClass() {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
215 return primitiveJavaClass;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
218 /**
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
219 * Returns the Java class for instances of boxed values of this kind.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
220 *
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
221 * @return the Java class
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
222 */
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
223 public Class<?> toBoxedJavaClass() {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
224 return boxedJavaClass;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 * Converts this value type to a string.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 return javaName;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
236 * Marker interface for types that should be {@linkplain Kind#format(Object) formatted} with
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
237 * their {@link Object#toString()} value.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 */
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
239 public interface FormatWithToString {
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
240 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 * Gets a formatted string for a given value of this kind.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
244 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 * @param value a value of this kind
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 * @return a formatted string for {@code value} based on this kind
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 public String format(Object value) {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6950
diff changeset
249 if (this == Kind.Object) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 if (value == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 return "null";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 if (value instanceof String) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 String s = (String) value;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 if (s.length() > 50) {
5793
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
256 return "String:\"" + s.substring(0, 30) + "...\"";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 } else {
5793
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
258 return "String:\"" + s + '"';
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 }
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
260 } else if (value instanceof JavaType) {
5793
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
261 return "JavaType:" + MetaUtil.toJavaName((JavaType) value);
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
262 } else if (value instanceof Enum || value instanceof FormatWithToString || value instanceof Number) {
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
263 return MetaUtil.getSimpleName(value.getClass(), true) + ":" + String.valueOf(value);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
264 } else if (value instanceof Class<?>) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
265 return "Class:" + ((Class<?>) value).getName();
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
266 } else if (value.getClass().isArray()) {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
267 return formatArray(value);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 } else {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
269 return MetaUtil.getSimpleName(value.getClass(), true) + "@" + System.identityHashCode(value);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 return value.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
277 private static final int MAX_FORMAT_ARRAY_LENGTH = 5;
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
278
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
279 private static String formatArray(Object array) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
280 Class<?> componentType = array.getClass().getComponentType();
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
281 assert componentType != null;
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
282 int arrayLength = Array.getLength(array);
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
283 StringBuilder buf = new StringBuilder(MetaUtil.getSimpleName(componentType, true)).append('[').append(arrayLength).append("]{");
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
284 int length = Math.min(MAX_FORMAT_ARRAY_LENGTH, arrayLength);
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
285 boolean primitive = componentType.isPrimitive();
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
286 for (int i = 0; i < length; i++) {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
287 if (primitive) {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
288 buf.append(Array.get(array, i));
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
289 } else {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
290 Object o = ((Object[]) array)[i];
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
291 buf.append(Kind.Object.format(o));
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
292 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
293 if (i != length - 1) {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
294 buf.append(", ");
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
295 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
296 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
297 if (arrayLength != length) {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
298 buf.append(", ...");
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
299 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
300 return buf.append('}').toString();
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
301 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
302
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
303 /**
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
304 * The minimum value that can be represented as a value of this kind.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
305 *
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
306 * @return the minimum value
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
307 */
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
308 public long getMinValue() {
5441
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
309 switch (this) {
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
310 case Boolean:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
311 return 0;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
312 case Byte:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
313 return java.lang.Byte.MIN_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
314 case Char:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
315 return java.lang.Character.MIN_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
316 case Short:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
317 return java.lang.Short.MIN_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
318 case Int:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
319 return java.lang.Integer.MIN_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
320 case Long:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
321 return java.lang.Long.MIN_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
322 default:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
323 throw new IllegalArgumentException("illegal call to minValue on " + this);
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
324 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
325 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
326
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
327 /**
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
328 * The maximum value that can be represented as a value of this kind.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
329 *
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
330 * @return the maximum value
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
331 */
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
332 public long getMaxValue() {
5441
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
333 switch (this) {
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
334 case Boolean:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
335 return 1;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
336 case Byte:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
337 return java.lang.Byte.MAX_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
338 case Char:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
339 return java.lang.Character.MAX_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
340 case Short:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
341 return java.lang.Short.MAX_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
342 case Int:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
343 return java.lang.Integer.MAX_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
344 case Long:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
345 return java.lang.Long.MAX_VALUE;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
346 default:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
347 throw new IllegalArgumentException("illegal call to maxValue on " + this);
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
348 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
349 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
350
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
351 /**
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
352 * Number of bits that are necessary to represent a value of this kind.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7099
diff changeset
353 *
6328
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
354 * @return the number of bits
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
355 */
6e66d97a16ae Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6313
diff changeset
356 public int getBitCount() {
5874
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
357 switch (this) {
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
358 case Boolean:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
359 return 1;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
360 case Byte:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
361 return 8;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
362 case Char:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
363 case Short:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
364 return 16;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
365 case Int:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
366 return 32;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
367 case Long:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
368 return 64;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
369 default:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
370 throw new IllegalArgumentException("illegal call to bits on " + this);
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
371 }
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
372 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 }