changeset 19336:723142fed324

Change DynamicObject from an interface to an abstract class.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 12 Feb 2015 22:33:34 +0100
parents 5414f848de51
children dd3e15cfe5b8
files graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java
diffstat 2 files changed, 28 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java	Thu Feb 12 22:03:20 2015 +0100
+++ b/graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java	Thu Feb 12 22:33:34 2015 +0100
@@ -27,11 +27,11 @@
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.interop.*;
 
-public interface DynamicObject extends TypedObject, TruffleObject {
+public abstract class DynamicObject implements TypedObject, TruffleObject {
     /**
      * Get the object's current shape.
      */
-    Shape getShape();
+    public abstract Shape getShape();
 
     /**
      * Get property value.
@@ -40,7 +40,7 @@
      * @param defaultValue return value if property is not found
      * @return property value or defaultValue if object has no such property
      */
-    Object get(Object key, Object defaultValue);
+    public abstract Object get(Object key, Object defaultValue);
 
     /**
      * Set value of existing property.
@@ -49,7 +49,7 @@
      * @param value value to be set
      * @return {@code true} if successful or {@code false} if property not found
      */
-    boolean set(Object key, Object value);
+    public abstract boolean set(Object key, Object value);
 
     /**
      * Define new property or redefine existing property.
@@ -58,7 +58,7 @@
      * @param value value to be set
      * @param flags flags to be set
      */
-    void define(Object key, Object value, int flags);
+    public abstract void define(Object key, Object value, int flags);
 
     /**
      * Define new property with a static location or change existing property.
@@ -68,7 +68,7 @@
      * @param flags flags to be set
      * @param locationFactory factory function that creates a location for a given shape and value
      */
-    void define(Object key, Object value, int flags, LocationFactory locationFactory);
+    public abstract void define(Object key, Object value, int flags, LocationFactory locationFactory);
 
     /**
      * Change property flags.
@@ -77,7 +77,7 @@
      * @param newFlags flags to be set
      * @return {@code true} if successful or {@code false} if property not found
      */
-    boolean changeFlags(Object key, int newFlags);
+    public abstract boolean changeFlags(Object key, int newFlags);
 
     /**
      * Change property flags.
@@ -86,7 +86,7 @@
      * @param flagsUpdateFunction function updating old flags to new flags
      * @return {@code true} if successful or {@code false} if property not found
      */
-    boolean changeFlags(Object key, FlagsFunction flagsUpdateFunction);
+    public abstract boolean changeFlags(Object key, FlagsFunction flagsUpdateFunction);
 
     /**
      * Delete property.
@@ -94,17 +94,17 @@
      * @param key property identifier
      * @return {@code true} if successful or {@code false} if property not found
      */
-    boolean delete(Object key);
+    public abstract boolean delete(Object key);
 
     /**
      * Returns the number of properties in this object.
      */
-    int size();
+    public abstract int size();
 
     /**
      * Returns {@code true} if this object contains no properties.
      */
-    boolean isEmpty();
+    public abstract boolean isEmpty();
 
     /**
      * Set object shape and grow storage if necessary.
@@ -112,7 +112,7 @@
      * @param oldShape the object's current shape (must equal {@link #getShape()})
      * @param newShape the new shape to be set
      */
-    void setShapeAndGrow(Shape oldShape, Shape newShape);
+    public abstract void setShapeAndGrow(Shape oldShape, Shape newShape);
 
     /**
      * Set object shape and resize storage if necessary.
@@ -120,14 +120,14 @@
      * @param oldShape the object's current shape (must equal {@link #getShape()})
      * @param newShape the new shape to be set
      */
-    void setShapeAndResize(Shape oldShape, Shape newShape);
+    public abstract void setShapeAndResize(Shape oldShape, Shape newShape);
 
     /**
      * Ensure object shape is up-to-date.
      *
      * @return {@code true} if shape has changed
      */
-    boolean updateShape();
+    public abstract boolean updateShape();
 
     public interface FlagsFunction {
         int apply(int t);
--- a/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java	Thu Feb 12 22:03:20 2015 +0100
+++ b/graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java	Thu Feb 12 22:33:34 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.truffle.object.Locations.ValueLocation;
 import com.oracle.truffle.object.debug.*;
 
-public abstract class DynamicObjectImpl implements DynamicObject, Cloneable {
+public abstract class DynamicObjectImpl extends DynamicObject implements Cloneable {
     private ShapeImpl shape;
 
     public static final DebugCounter reshapeCount = DebugCounter.create("Reshape count");
@@ -49,6 +49,7 @@
         return getShape();
     }
 
+    @Override
     public ShapeImpl getShape() {
         return shape;
     }
@@ -64,6 +65,7 @@
         setShapeAndResize(getShape(), newShape);
     }
 
+    @Override
     public final void setShapeAndResize(Shape oldShape, Shape newShape) {
         assert getShape() == oldShape : "wrong old shape";
         if (oldShape != newShape) {
@@ -81,6 +83,7 @@
      *
      * @see #setShapeAndResize(Shape, Shape)
      */
+    @Override
     public final void setShapeAndGrow(Shape oldShape, Shape newShape) {
         assert getShape() == oldShape : "wrong old shape";
         if (oldShape != newShape) {
@@ -183,6 +186,7 @@
         }
     }
 
+    @Override
     @TruffleBoundary
     public boolean changeFlags(Object id, int newFlags) {
         Shape oldShape = getShape();
@@ -199,6 +203,7 @@
         }
     }
 
+    @Override
     @TruffleBoundary
     public boolean changeFlags(Object id, FlagsFunction updateFunction) {
         Shape oldShape = getShape();
@@ -271,6 +276,7 @@
         return getShape().getObjectType().hashCode(this);
     }
 
+    @Override
     @TruffleBoundary
     public Object get(Object id, Object defaultValue) {
         Property existing = getShape().getProperty(id);
@@ -281,6 +287,7 @@
         }
     }
 
+    @Override
     @TruffleBoundary
     public boolean set(Object id, Object value) {
         Property existing = getShape().getProperty(id);
@@ -292,6 +299,7 @@
         }
     }
 
+    @Override
     @TruffleBoundary
     public void define(Object id, Object value, int flags) {
         ShapeImpl oldShape = getShape();
@@ -318,6 +326,7 @@
         }
     }
 
+    @Override
     @TruffleBoundary
     public void define(Object id, Object value, int flags, LocationFactory locationFactory) {
         ShapeImpl oldShape = getShape();
@@ -333,6 +342,7 @@
         }
     }
 
+    @Override
     @TruffleBoundary
     public boolean delete(Object id) {
         ShapeImpl oldShape = getShape();
@@ -347,14 +357,17 @@
         }
     }
 
+    @Override
     public int size() {
         return getShape().getPropertyCount();
     }
 
+    @Override
     public boolean isEmpty() {
         return size() == 0;
     }
 
+    @Override
     public final boolean updateShape() {
         return getShape().getLayout().getStrategy().updateShape(this);
     }