changeset 17606:45d7b2c7029d

Use correct kind for narrow int constants.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 16 Oct 2014 10:21:29 +0200
parents cdd0b5d3d9bf
children 52b4284cb496
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Thu Oct 16 10:06:27 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Thu Oct 16 10:21:29 2014 +0200
@@ -272,10 +272,19 @@
      */
     public static Constant forPrimitiveInt(int bits, long i) {
         assert bits <= 64;
-        if (bits > 32) {
-            return new PrimitiveConstant(Kind.Long, i);
-        } else {
-            return new PrimitiveConstant(Kind.Int, (int) i);
+        switch (bits) {
+            case 1:
+                return forBoolean(i != 0);
+            case 8:
+                return forByte((byte) i);
+            case 16:
+                return forShort((short) i);
+            case 32:
+                return forInt((int) i);
+            case 64:
+                return forLong(i);
+            default:
+                throw new IllegalArgumentException("unsupported integer width: " + bits);
         }
     }