Search in sources :

Example 16 with Shape

use of com.oracle.truffle.api.object.Shape in project graal by oracle.

the class DynamicObjectImpl method changeFlags.

/**
 * @since 0.17 or earlier
 */
@TruffleBoundary
public boolean changeFlags(Object key, int newFlags) {
    Shape oldShape = getShape();
    Property existing = oldShape.getProperty(key);
    if (existing != null) {
        if (existing.getFlags() != newFlags) {
            Property newProperty = existing.copyWithFlags(newFlags);
            Shape newShape = oldShape.replaceProperty(existing, newProperty);
            this.setShape(newShape);
        }
        return true;
    } else {
        return false;
    }
}
Also used : Shape(com.oracle.truffle.api.object.Shape) Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 17 with Shape

use of com.oracle.truffle.api.object.Shape in project graal by oracle.

the class ObjectTypeTest method objectTypeRespondsToIsNull.

@Test
public void objectTypeRespondsToIsNull() {
    final Layout layout = Layout.newLayout().build();
    final Shape rootShape = layout.createShape(OBJECT_TYPE);
    final DynamicObject obj = rootShape.newInstance();
    final boolean is = JavaInteropTest.isNull(obj);
    assertFalse("It is not null", is);
}
Also used : Shape(com.oracle.truffle.api.object.Shape) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Layout(com.oracle.truffle.api.object.Layout) Test(org.junit.Test)

Example 18 with Shape

use of com.oracle.truffle.api.object.Shape in project graal by oracle.

the class ObjectTypeTest method objectTypeRespondsToIsBoxed.

@Test
public void objectTypeRespondsToIsBoxed() {
    final Layout layout = Layout.newLayout().build();
    final Shape rootShape = layout.createShape(OBJECT_TYPE);
    final DynamicObject obj = rootShape.newInstance();
    final boolean is = JavaInteropTest.isBoxed(obj);
    assertFalse("It is not boxed", is);
}
Also used : Shape(com.oracle.truffle.api.object.Shape) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Layout(com.oracle.truffle.api.object.Layout) Test(org.junit.Test)

Aggregations

Shape (com.oracle.truffle.api.object.Shape)18 DynamicObject (com.oracle.truffle.api.object.DynamicObject)16 Test (org.junit.Test)15 Location (com.oracle.truffle.api.object.Location)7 ObjectType (com.oracle.truffle.api.object.ObjectType)7 Layout (com.oracle.truffle.api.object.Layout)5 DefaultLayoutFactory (com.oracle.truffle.object.basic.DefaultLayoutFactory)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 DynamicObjectFactory (com.oracle.truffle.api.object.DynamicObjectFactory)1 LocationFactory (com.oracle.truffle.api.object.LocationFactory)1 ObjectLocation (com.oracle.truffle.api.object.ObjectLocation)1 Property (com.oracle.truffle.api.object.Property)1 ArrayList (java.util.ArrayList)1 IdentityHashMap (java.util.IdentityHashMap)1