use of com.oracle.truffle.sl.runtime.SLFunction 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.sl.runtime.SLFunction in project graal by oracle.
the class SLCallFunctionsWithBuiltin method runTests.
@Specialization
public SLNull runTests(String startsWith, SLFunction harness) {
boolean found = false;
for (SLFunction function : getContext().getFunctionRegistry().getFunctions()) {
if (function.getName().startsWith(startsWith) && getSource(function) == getSource(harness) && getSource(function) != null) {
indirectCall.call(harness.getCallTarget(), new Object[] { function });
found = true;
}
}
if (!found) {
throw new SLAssertionError("No tests found to execute.", this);
}
return SLNull.SINGLETON;
}
Aggregations