comparison truffle/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Layout.java @ 22150:ac6dadffdf32

add Layout.newLayout() as replacement for `new LayoutBuilder()`
author Andreas Woess <andreas.woess@oracle.com>
date Mon, 14 Sep 2015 13:40:10 +0200
parents 1a1aa12ab310
children 494bfe8a25ff
comparison
equal deleted inserted replaced
22149:b84a11723d64 22150:ac6dadffdf32
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.api.object; 25 package com.oracle.truffle.api.object;
26 26
27 import java.util.*; 27 import java.util.EnumSet;
28 import java.util.ServiceLoader;
28 29
29 import com.oracle.truffle.api.nodes.NodeUtil.FieldOffsetProvider;
30 import com.oracle.truffle.api.object.Shape.Allocator; 30 import com.oracle.truffle.api.object.Shape.Allocator;
31 31
32 /** 32 /**
33 * Describes layout and behavior of a {@link DynamicObject} subclass and is used to create shapes. 33 * Describes layout and behavior of a {@link DynamicObject} subclass and is used to create shapes.
34 * 34 *
49 public enum ImplicitCast { 49 public enum ImplicitCast {
50 IntToDouble, 50 IntToDouble,
51 IntToLong, 51 IntToLong,
52 } 52 }
53 53
54 /**
55 * Create a new {@link LayoutBuilder}.
56 */
57 @SuppressWarnings("deprecation")
58 public static LayoutBuilder newLayout() {
59 return new LayoutBuilder();
60 }
61
62 /**
63 * Equivalent to {@code Layout.newLayout().build()}.
64 */
54 public static Layout createLayout() { 65 public static Layout createLayout() {
55 return createLayout(NONE); 66 return createLayout(NONE);
56 } 67 }
57 68
69 /**
70 * Equivalent to
71 * {@code Layout.newLayout().setAllowedImplicitCasts(allowedImplicitCasts).build()}.
72 */
73 @Deprecated
58 public static Layout createLayout(EnumSet<ImplicitCast> allowedImplicitCasts) { 74 public static Layout createLayout(EnumSet<ImplicitCast> allowedImplicitCasts) {
59 return new LayoutBuilder().setAllowedImplicitCasts(allowedImplicitCasts).build(); 75 return newLayout().setAllowedImplicitCasts(allowedImplicitCasts).build();
60 }
61
62 public static Layout createLayout(EnumSet<ImplicitCast> allowedImplicitCasts, FieldOffsetProvider fieldOffsetProvider) {
63 return new LayoutBuilder().setAllowedImplicitCasts(allowedImplicitCasts).setFieldOffsetProvider(fieldOffsetProvider).build();
64 } 76 }
65 77
66 public abstract DynamicObject newInstance(Shape shape); 78 public abstract DynamicObject newInstance(Shape shape);
67 79
68 public abstract Class<? extends DynamicObject> getType(); 80 public abstract Class<? extends DynamicObject> getType();