use of com.oracle.truffle.llvm.runtime.LLVMContext.ExternalLibrary in project sulong by graalvm.
the class Runner method parse.
/**
* Parse bitcode data and do first initializations to prepare bitcode execution.
*/
public CallTarget parse(LLVMLanguage language, LLVMContext context, Source source) throws IOException {
initializeContext(language, context);
try {
ByteBuffer bytes;
ExternalLibrary library;
if (source.getMimeType().equals(LLVMLanguage.LLVM_BITCODE_BASE64_MIME_TYPE)) {
bytes = ByteBuffer.wrap(decodeBase64(source.getCharacters()));
library = new ExternalLibrary("<STREAM>");
} else if (source.getMimeType().equals(LLVMLanguage.LLVM_SULONG_TYPE)) {
NativeLibraryDescriptor descriptor = Parser.parseLibraryDescriptor(source.getCharacters());
String filename = descriptor.getFilename();
bytes = read(filename);
library = new ExternalLibrary(Paths.get(filename), null);
} else if (source.getPath() != null) {
bytes = read(source.getPath());
library = new ExternalLibrary(Paths.get(source.getPath()), null);
} else {
throw new IllegalStateException();
}
LLVMParserResult parserResult = parse(language, context, source, library, bytes);
handleParserResult(context, parserResult);
return createLibraryCallTarget(context, library, parserResult);
} catch (Throwable t) {
throw new IOException("Error while trying to parse " + source.getPath(), t);
}
}
Aggregations