diff truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 22087:5d9e5f866821

add Shape.Allocator#copy()
author Andreas Woess <andreas.woess@oracle.com>
date Mon, 17 Aug 2015 14:58:34 +0200
parents 9c8c0937da41
children 22ce537a52fd
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java	Mon Aug 17 15:49:18 2015 +0200
+++ b/truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java	Mon Aug 17 14:58:34 2015 +0200
@@ -910,7 +910,7 @@
         return null;
     }
 
-    public abstract static class BaseAllocator extends Allocator implements LocationVisitor {
+    public abstract static class BaseAllocator extends Allocator implements LocationVisitor, Cloneable {
         protected final LayoutImpl layout;
         protected int objectArraySize;
         protected int objectFieldSize;
@@ -1046,6 +1046,20 @@
         public void visitPrimitiveField(int index, int count) {
             primitiveFieldSize = Math.max(primitiveFieldSize, index + count);
         }
+
+        @Override
+        public final BaseAllocator copy() {
+            return clone();
+        }
+
+        @Override
+        protected final BaseAllocator clone() {
+            try {
+                return (BaseAllocator) super.clone();
+            } catch (CloneNotSupportedException e) {
+                throw new AssertionError(e);
+            }
+        }
     }
 
     private static void debugRegisterShape(ShapeImpl newShape) {