Search in sources :

Example 21 with Property

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

the class LayoutStrategy method defineProperty.

/**
 * @since 0.17 or earlier
 */
protected ShapeImpl defineProperty(ShapeImpl shape, Object key, Object value, int flags, LocationFactory locationFactory) {
    ShapeImpl oldShape = shape;
    if (!oldShape.isValid()) {
        oldShape = ensureValid(oldShape);
    }
    Property existing = oldShape.getProperty(key);
    return defineProperty(oldShape, key, value, flags, locationFactory, existing);
}
Also used : Property(com.oracle.truffle.api.object.Property)

Example 22 with Property

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

the class LayoutStrategy method propertySetFallback.

/**
 * @since 0.17 or earlier
 */
protected void propertySetFallback(Property property, DynamicObject store, Object value, ShapeImpl currentShape) {
    ShapeImpl oldShape = currentShape;
    ShapeImpl newShape = defineProperty(oldShape, property.getKey(), value, property.getFlags(), getDefaultLocationFactory());
    Property newProperty = newShape.getProperty(property.getKey());
    newProperty.setSafe(store, value, oldShape, newShape);
}
Also used : Property(com.oracle.truffle.api.object.Property)

Example 23 with Property

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

the class ShapeImpl method toStringLimit.

/**
 * @since 0.17 or earlier
 */
@TruffleBoundary
public String toStringLimit(int limit) {
    StringBuilder sb = new StringBuilder();
    sb.append('@');
    sb.append(Integer.toHexString(hashCode()));
    if (!isValid()) {
        sb.append('!');
    }
    sb.append("{");
    for (Iterator<Property> iterator = propertyMap.reverseOrderedValueIterator(); iterator.hasNext(); ) {
        Property p = iterator.next();
        sb.append(p);
        if (iterator.hasNext()) {
            sb.append(",");
        }
        if (sb.length() >= limit) {
            sb.append("...");
            break;
        }
        sb.append("\n");
    }
    sb.append("}");
    return sb.toString();
}
Also used : Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 24 with Property

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

the class ConsListPropertyMap method getStringKey.

private Property getStringKey(String key) {
    for (ConsListPropertyMap current = this; !current.isEmpty(); current = current.getParentMap()) {
        Property p = current.getLastProperty();
        Object pKey = p.getKey();
        if (pKey == key || (pKey instanceof String && ((String) pKey).equals(key))) {
            return p;
        }
    }
    return null;
}
Also used : Property(com.oracle.truffle.api.object.Property)

Example 25 with Property

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

the class ConsListPropertyMap method removeCopy.

@Override
public ConsListPropertyMap removeCopy(Property value) {
    Deque<Property> shelve = new ArrayDeque<>();
    ConsListPropertyMap current = this;
    while (!current.isEmpty()) {
        if (current.getLastProperty().equals(value)) {
            ConsListPropertyMap newMap = current.getParentMap();
            for (Property property : shelve) {
                newMap = newMap.putCopy(property);
            }
            return newMap;
        } else {
            shelve.push(current.getLastProperty());
            current = current.getParentMap();
        }
    }
    return this;
}
Also used : Property(com.oracle.truffle.api.object.Property) ArrayDeque(java.util.ArrayDeque)

Aggregations

Property (com.oracle.truffle.api.object.Property)31 DynamicObject (com.oracle.truffle.api.object.DynamicObject)8 Test (org.junit.Test)7 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)6 IncompatibleLocationException (com.oracle.truffle.api.object.IncompatibleLocationException)4 Location (com.oracle.truffle.api.object.Location)4 ArrayDeque (java.util.ArrayDeque)3 FinalLocationException (com.oracle.truffle.api.object.FinalLocationException)2 ObjectLocation (com.oracle.truffle.api.object.ObjectLocation)2 DeclaredLocation (com.oracle.truffle.object.Locations.DeclaredLocation)2 Layout (com.oracle.truffle.api.object.Layout)1 Shape (com.oracle.truffle.api.object.Shape)1 ValueLocation (com.oracle.truffle.object.Locations.ValueLocation)1 PropertyMap (com.oracle.truffle.object.PropertyMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Random (java.util.Random)1