diff graal/com.oracle.truffle.object/src/com/oracle/truffle/object/PropertyImpl.java @ 21652:5f3dda39d205

Truffle: add DynamicObject#containsKey, make flags parameter optional, minor simplifications
author Andreas Woess <andreas.woess@oracle.com>
date Mon, 01 Jun 2015 12:55:56 +0200
parents b1530a6cce8c
children
line wrap: on
line diff
--- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/PropertyImpl.java	Mon Jun 01 13:49:38 2015 +0200
+++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/PropertyImpl.java	Mon Jun 01 12:55:56 2015 +0200
@@ -42,6 +42,8 @@
      * Generic, usual-case constructor for properties storing at least a name.
      *
      * @param key the name of the property
+     * @param location the storage location used to access the property
+     * @param flags property flags (optional)
      */
     protected PropertyImpl(Object key, Location location, int flags, boolean shadow, boolean relocatable) {
         this.key = Objects.requireNonNull(key);
@@ -67,8 +69,8 @@
 
     @Override
     public Property relocate(Location newLocation) {
-        if ((getLocation() == null || !getLocation().equals(newLocation)) && relocatable) {
-            return construct(getKey(), newLocation, getFlags());
+        if (!getLocation().equals(newLocation) && relocatable) {
+            return construct(key, newLocation, flags);
         }
         return this;
     }
@@ -163,8 +165,7 @@
         }
 
         PropertyImpl other = (PropertyImpl) obj;
-        return key.equals(other.key) && ((location == null && other.location == null) || (location != null && location.equals(other.location))) && flags == other.flags && shadow == other.shadow &&
-                        relocatable == other.relocatable;
+        return key.equals(other.key) && location.equals(other.location) && flags == other.flags && shadow == other.shadow && relocatable == other.relocatable;
     }
 
     @Override
@@ -189,7 +190,7 @@
         int result = 1;
         result = prime * result + getClass().hashCode();
         result = prime * result + key.hashCode();
-        result = prime * result + (location != null ? location.hashCode() : 0);
+        result = prime * result + location.hashCode();
         result = prime * result + flags;
         return result;
     }
@@ -240,7 +241,7 @@
 
     private Property relocateShadow(Location newLocation) {
         assert !isShadow() && getLocation() instanceof DeclaredLocation && relocatable;
-        return new PropertyImpl(getKey(), newLocation, flags, true, relocatable);
+        return new PropertyImpl(key, newLocation, flags, true, relocatable);
     }
 
     @SuppressWarnings("hiding")