diff graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java @ 17446:9a804ec7f707

converted Constant and Value to be interfaces (GRAAL-874)
author Doug Simon <doug.simon@oracle.com>
date Wed, 15 Oct 2014 01:10:27 +0200
parents 1227fb471b6d
children c88ab4f1f04a
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java	Tue Oct 14 20:02:44 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java	Wed Oct 15 01:10:27 2014 +0200
@@ -22,15 +22,11 @@
  */
 package com.oracle.graal.api.meta;
 
-import java.io.*;
-
 /**
  * Abstract base class for values manipulated by the compiler. All values have a {@linkplain Kind
  * kind} and are immutable.
  */
-public abstract class Value implements Serializable, KindProvider {
-
-    private static final long serialVersionUID = -6909397188697766469L;
+public interface Value extends KindProvider {
 
     @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(LIRKind.Illegal) {
 
@@ -40,62 +36,25 @@
         }
     };
 
-    private final Kind kind;
-    private final LIRKind lirKind;
-
-    /**
-     * Initializes a new value of the specified kind.
-     *
-     * @param lirKind the kind
-     */
-    protected Value(LIRKind lirKind) {
-        this.lirKind = lirKind;
-        if (getPlatformKind() instanceof Kind) {
-            this.kind = (Kind) getPlatformKind();
-        } else {
-            this.kind = Kind.Illegal;
-        }
-    }
-
     /**
      * Returns a String representation of the kind, which should be the end of all
      * {@link #toString()} implementation of subclasses.
      */
-    protected final String getKindSuffix() {
+    default String getKindSuffix() {
         return "|" + getKind().getTypeChar();
     }
 
     /**
      * Returns the kind of this value.
      */
-    public final Kind getKind() {
-        return kind;
-    }
+    Kind getKind();
 
-    public final LIRKind getLIRKind() {
-        return lirKind;
-    }
+    LIRKind getLIRKind();
 
     /**
      * Returns the platform specific kind used to store this value.
      */
-    public final PlatformKind getPlatformKind() {
-        return lirKind.getPlatformKind();
-    }
-
-    @Override
-    public int hashCode() {
-        return 41 + lirKind.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof Value) {
-            Value that = (Value) obj;
-            return kind.equals(that.kind) && lirKind.equals(that.lirKind);
-        }
-        return false;
-    }
+    PlatformKind getPlatformKind();
 
     /**
      * Checks if this value is identical to {@code other}.
@@ -104,7 +63,7 @@
      * should be used.
      */
     @ExcludeFromIdentityComparisonVerification
-    public final boolean identityEquals(Value other) {
+    default boolean identityEquals(Value other) {
         return this == other;
     }
 }