Mercurial > hg > truffle
diff truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/LayoutStrategy.java @ 22288:47172a9b40ac
Object model refactoring, add Shape#defineProperty
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Wed, 07 Oct 2015 19:15:14 +0200 |
parents | dc83cc1f94f2 |
children | cf203af4610c |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/LayoutStrategy.java Wed Oct 07 20:27:40 2015 +0200 +++ b/truffle/com.oracle.truffle.object/src/com/oracle/truffle/object/LayoutStrategy.java Wed Oct 07 19:15:14 2015 +0200 @@ -29,20 +29,36 @@ import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.object.ShapeImpl.BaseAllocator; -public interface LayoutStrategy { - boolean updateShape(DynamicObject object); +public abstract class LayoutStrategy { + public abstract boolean updateShape(DynamicObject object); + + public abstract Shape ensureValid(Shape newShape); + + public abstract Shape ensureSpace(Shape shape, Location location); - Shape returnCached(Shape newShape); + public abstract boolean isAutoExtArray(); + + public abstract BaseAllocator createAllocator(Layout shape); - Shape ensureSpace(Shape shape, Location location); + public abstract BaseAllocator createAllocator(Shape shape); - boolean isAutoExtArray(); + protected abstract ShapeAndProperty generalizeProperty(Property oldProperty, Object value, Shape currentShape, Shape nextShape); - Property generalizeProperty(DynamicObject object, Property oldProperty, Object value); + public static class ShapeAndProperty { + private final Shape shape; + private final Property property; - Property generalizeProperty(DynamicObject object, Property oldProperty, Object value, Shape oldShape, Shape newShape); + public ShapeAndProperty(Shape shape, Property property) { + this.shape = shape; + this.property = property; + } - BaseAllocator createAllocator(Layout shape); + public Shape getShape() { + return shape; + } - BaseAllocator createAllocator(Shape shape); + public Property getProperty() { + return property; + } + } }