Search in sources :

Example 1 with SLObject

use of com.oracle.truffle.sl.runtime.SLObject in project graal by oracle.

the class SLLanguage method createObject.

/**
 * Allocate an empty object. All new objects initially have no properties. Properties are added
 * when they are first stored, i.e., the store triggers a shape change of the object.
 */
public SLObject createObject(AllocationReporter reporter) {
    reporter.onEnter(null, 0, AllocationReporter.SIZE_UNKNOWN);
    SLObject object = new SLObject(rootShape);
    reporter.onReturnValue(object, 0, AllocationReporter.SIZE_UNKNOWN);
    return object;
}
Also used : SLObject(com.oracle.truffle.sl.runtime.SLObject)

Example 2 with SLObject

use of com.oracle.truffle.sl.runtime.SLObject in project graal by oracle.

the class SLReadPropertyNode method readSLObject.

@Specialization(limit = "LIBRARY_LIMIT")
protected Object readSLObject(SLObject receiver, Object name, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) {
    TruffleString nameTS = toTruffleStringNode.execute(name);
    Object result = objectLibrary.getOrDefault(receiver, nameTS, null);
    if (result == null) {
        // read was not successful. In SL we only have basic support for errors.
        throw SLUndefinedNameException.undefinedProperty(this, nameTS);
    }
    return result;
}
Also used : TruffleString(com.oracle.truffle.api.strings.TruffleString) SLObject(com.oracle.truffle.sl.runtime.SLObject) Specialization(com.oracle.truffle.api.dsl.Specialization)

Aggregations

SLObject (com.oracle.truffle.sl.runtime.SLObject)2 Specialization (com.oracle.truffle.api.dsl.Specialization)1 TruffleString (com.oracle.truffle.api.strings.TruffleString)1