Search in sources :

Example 21 with DynamicObject

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

the class VolatileTest method testGetAndSetVolatile.

@Test
public void testGetAndSetVolatile() {
    final DynamicObject object = LAYOUT.createVolatileTest(14, null);
    Assert.assertEquals(14, LAYOUT.getVolatileInt(object));
    Assert.assertEquals(14, LAYOUT.getAndSetVolatileInt(object, 22));
    Assert.assertEquals(22, LAYOUT.getVolatileInt(object));
    Assert.assertNull(LAYOUT.getVolatileThread(object));
    Assert.assertEquals(null, LAYOUT.getAndSetVolatileThread(object, Thread.currentThread()));
    Assert.assertEquals(Thread.currentThread(), LAYOUT.getVolatileThread(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 22 with DynamicObject

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

the class Snippets method inheritanceUse.

void inheritanceUse() {
    // BEGIN: inheritanceuse
    DynamicObject object = SuperImpl.INSTANCE.createSuper(14, 2);
    BaseImpl.INSTANCE.isBase(object);
    BaseImpl.INSTANCE.getA(object);
// END: inheritanceuse
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject)

Example 23 with DynamicObject

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

the class ObjectTypeTest method objectTypeRespondsToIsArray.

@Test
public void objectTypeRespondsToIsArray() {
    final Layout layout = Layout.newLayout().build();
    final Shape rootShape = layout.createShape(OBJECT_TYPE);
    final DynamicObject obj = rootShape.newInstance();
    final boolean is = JavaInteropTest.isArray(obj);
    assertFalse("It is not array", 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 24 with DynamicObject

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

the class BasicTest method testSet.

@Test
public void testSet() {
    final DynamicObject object = LAYOUT.createBasicTest(14);
    LAYOUT.setValue(object, 22);
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 25 with DynamicObject

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

the class BasicTest method testCreate.

@Test
public void testCreate() {
    final DynamicObject object = LAYOUT.createBasicTest(14);
    Assert.assertNotNull(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