Java Code Examples for com.oracle.truffle.api.interop.InteropLibrary#isNull()

The following examples show how to use com.oracle.truffle.api.interop.InteropLibrary#isNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HashemLanguage.java    From mr-hashemi with Universal Permissive License v1.0 6 votes vote down vote up
public static String getMetaObject(Object value) {
    if (value == null) {
        return "ANY";
    }
    InteropLibrary interop = InteropLibrary.getFactory().getUncached(value);
    if (interop.isNumber(value) || value instanceof HashemBigNumber) {
        return "Number";
    } else if (interop.isBoolean(value)) {
        return "Boolean";
    } else if (interop.isString(value)) {
        return "String";
    } else if (interop.isNull(value)) {
        return "NULL";
    } else if (interop.isExecutable(value)) {
        return "Function";
    } else if (interop.hasMembers(value)) {
        return "Object";
    } else {
        return "Unsupported";
    }
}
 
Example 2
Source File: HashemLanguage.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
public static String toString(Object value) {
    try {
        if (value == null) {
            return "ANY";
        }
        InteropLibrary interop = InteropLibrary.getFactory().getUncached(value);
        if (interop.fitsInLong(value)) {
            return Long.toString(interop.asLong(value));
        } else if (interop.isBoolean(value)) {
            return Boolean.toString(interop.asBoolean(value));
        } else if (interop.isString(value)) {
            return interop.asString(value);
        } else if (interop.isNull(value)) {
            return "POOCH";
        } else if (interop.isExecutable(value)) {
            if (value instanceof HashemBebin) {
                return ((HashemBebin) value).getName();
            } else {
                return "Function";
            }
        } else if (interop.hasMembers(value)) {
            return "Object";
        } else if (value instanceof HashemBigNumber) {
            return value.toString();
        } else {
            return "Unsupported";
        }
    } catch (UnsupportedMessageException e) {
        CompilerDirectives.transferToInterpreter();
        throw new AssertionError();
    }
}
 
Example 3
Source File: HashemIsPoochBuiltin.java    From mr-hashemi with Universal Permissive License v1.0 4 votes vote down vote up
@Specialization(limit = "3")
public boolean isExecutable(Object obj, @CachedLibrary("obj") InteropLibrary values) {
    return values.isNull(obj);
}
 
Example 4
Source File: JavaObjectWrapper.java    From trufflesqueak with MIT License 4 votes vote down vote up
@ExportMessage
protected boolean isNull(@Shared("lib") @CachedLibrary(limit = "LIMIT") final InteropLibrary lib) {
    return lib.isNull(wrappedObject);
}