Mercurial > hg > truffle
changeset 22087:5d9e5f866821
add Shape.Allocator#copy()
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Mon, 17 Aug 2015 14:58:34 +0200 |
parents | 93bfc9602271 |
children | 22ce537a52fd |
files | truffle/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Shape.java truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Shape.java Mon Aug 17 15:49:18 2015 +0200 +++ b/truffle/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Shape.java Mon Aug 17 14:58:34 2015 +0200 @@ -280,6 +280,11 @@ public abstract Location declaredLocation(Object value); public abstract Allocator addLocation(Location location); + + /** + * Creates an copy of this allocator. + */ + public abstract Allocator copy(); } /**
--- 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) {