use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class SLException method typeError.
/**
* Provides a user-readable message for run-time type errors. SL is strongly typed, i.e., there
* are no automatic type conversions of values.
*/
@TruffleBoundary
public static SLException typeError(Node operation, Object... values) {
StringBuilder result = new StringBuilder();
result.append("Type error");
if (operation != null) {
SourceSection ss = operation.getEncapsulatingSourceSection();
if (ss != null && ss.isAvailable()) {
result.append(" at ").append(ss.getSource().getName()).append(" line ").append(ss.getStartLine()).append(" col ").append(ss.getStartColumn());
}
}
result.append(": operation");
if (operation != null) {
NodeInfo nodeInfo = SLContext.lookupNodeInfo(operation.getClass());
if (nodeInfo != null) {
result.append(" \"").append(nodeInfo.shortName()).append("\"");
}
}
result.append(" not defined for");
String sep = " ";
for (int i = 0; i < values.length; i++) {
Object value = values[i];
result.append(sep);
sep = ", ";
if (value instanceof Long || value instanceof SLBigNumber) {
result.append("Number ").append(value);
} else if (value instanceof Boolean) {
result.append("Boolean ").append(value);
} else if (value instanceof String) {
result.append("String \"").append(value).append("\"");
} else if (value instanceof SLFunction) {
result.append("Function ").append(value);
} else if (value == SLNull.SINGLETON) {
result.append("NULL");
} else if (value == null) {
// value is not evaluated because of short circuit evaluation
result.append("ANY");
} else {
result.append(value);
}
}
return new SLException(result.toString(), operation);
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class DynamicObjectImpl method delete.
/**
* @since 0.17 or earlier
*/
@Override
@TruffleBoundary
public boolean delete(Object key) {
ShapeImpl oldShape = getShape();
Property existing = oldShape.getProperty(key);
if (existing != null) {
oldShape.getLayout().getStrategy().objectRemoveProperty(this, existing, oldShape);
return true;
} else {
return false;
}
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method lookup.
@Substitute
@TruffleBoundary
static long lookup(@SuppressWarnings("unused") long nativeContext, long library, String name) {
// clear previous error
Dlfcn.dlerror();
PointerBase ret;
if (library == 0) {
ret = PosixUtils.dlsym(Dlfcn.RTLD_DEFAULT(), name);
} else {
ret = PosixUtils.dlsym(WordFactory.pointer(library), name);
}
if (ret.equal(WordFactory.zero())) {
CompilerDirectives.transferToInterpreter();
String error = PosixUtils.dlerror();
if (error != null) {
throw new UnsatisfiedLinkError(error);
}
}
return ret.rawValue();
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class TruffleNFISupport method utf8ToJavaString.
@TruffleBoundary
static String utf8ToJavaString(CCharPointer str) {
if (str.equal(WordFactory.zero())) {
return null;
} else {
UnsignedWord len = SubstrateUtil.strlen(str);
ByteBuffer buffer = SubstrateUtil.wrapAsByteBuffer(str, (int) len.rawValue());
return UTF8.decode(buffer).toString();
}
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class LocalNativeScope method pinArray.
@TruffleBoundary
PointerBase pinArray(Object arr) {
PinnedObject ret = PinnedObject.create(arr);
pinned[pinCount++] = ret;
return ret.addressOfArrayElement(0);
}
Aggregations