Search in sources :

Example 11 with DynamicObject

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

the class ShapePropertiesTest method testObjectTypeGetter.

@Test
public void testObjectTypeGetter() {
    final DynamicObjectFactory factory = LAYOUT.createShapePropertiesTestShape(14);
    final DynamicObject object = LAYOUT.createShapePropertiesTest(factory, 22);
    Assert.assertEquals(14, LAYOUT.getShapeProperty(object.getShape().getObjectType()));
}
Also used : DynamicObjectFactory(com.oracle.truffle.api.object.DynamicObjectFactory) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 12 with DynamicObject

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

the class ShapePropertiesTest method testFactorySetter.

@Test
public void testFactorySetter() {
    final DynamicObjectFactory factory = LAYOUT.createShapePropertiesTestShape(14);
    Assert.assertEquals(14, LAYOUT.getShapeProperty(factory));
    final DynamicObject object = LAYOUT.createShapePropertiesTest(factory, 22);
    Assert.assertEquals(14, LAYOUT.getShapeProperty(object));
    final DynamicObjectFactory newFactory = LAYOUT.setShapeProperty(factory, 44);
    Assert.assertEquals(44, LAYOUT.getShapeProperty(newFactory));
    final DynamicObject newObject = LAYOUT.createShapePropertiesTest(newFactory, 22);
    Assert.assertEquals(44, LAYOUT.getShapeProperty(newObject));
}
Also used : DynamicObjectFactory(com.oracle.truffle.api.object.DynamicObjectFactory) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 13 with DynamicObject

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

the class TypesTest method testObject.

@Test
public void testObject() {
    final DynamicObject object = create();
    Assert.assertEquals(Runtime.getRuntime(), LAYOUT.getO(object));
    LAYOUT.setO(object, Object.class);
    Assert.assertEquals(Object.class, LAYOUT.getO(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 14 with DynamicObject

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

the class TypesTest method testInt.

@Test
public void testInt() {
    final DynamicObject object = create();
    Assert.assertEquals(3, LAYOUT.getI(object));
    LAYOUT.setI(object, 30);
    Assert.assertEquals(30, LAYOUT.getI(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 15 with DynamicObject

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

the class TypesTest method testIntArray.

@Test
public void testIntArray() {
    final DynamicObject object = create();
    Assert.assertArrayEquals(new int[] { 14 }, LAYOUT.getIa(object));
    LAYOUT.setIa(object, new int[] { 22 });
    Assert.assertArrayEquals(new int[] { 22 }, LAYOUT.getIa(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Aggregations

DynamicObject (com.oracle.truffle.api.object.DynamicObject)100 Test (org.junit.Test)91 Location (com.oracle.truffle.api.object.Location)17 Shape (com.oracle.truffle.api.object.Shape)16 DynamicObjectFactory (com.oracle.truffle.api.object.DynamicObjectFactory)8 ObjectLocation (com.oracle.truffle.api.object.ObjectLocation)7 Property (com.oracle.truffle.api.object.Property)7 ObjectType (com.oracle.truffle.api.object.ObjectType)6 IncompatibleLocationException (com.oracle.truffle.api.object.IncompatibleLocationException)4 Layout (com.oracle.truffle.api.object.Layout)4 FinalLocationException (com.oracle.truffle.api.object.FinalLocationException)2 PropertyBuilder (com.oracle.truffle.object.dsl.processor.model.PropertyBuilder)2 VariableElement (javax.lang.model.element.VariableElement)2 LocationFactory (com.oracle.truffle.api.object.LocationFactory)1 ShapeImpl (com.oracle.truffle.object.ShapeImpl)1 DefaultLayoutFactory (com.oracle.truffle.object.basic.DefaultLayoutFactory)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 IdentityHashMap (java.util.IdentityHashMap)1