use of com.oracle.truffle.nfi.types.NativeLibraryDescriptor in project graal by oracle.
the class ParseLibraryDescriptorTest method parseWithTwoFlags.
@Test
public void parseWithTwoFlags() {
NativeLibraryDescriptor test = Parser.parseLibraryDescriptor("load(RTLD_NOW | RTLD_GLOBAL) testfile");
Assert.assertEquals("file name", "testfile", test.getFilename());
Assert.assertEquals("flag count", 2, test.getFlags().size());
Assert.assertEquals("RTLD_NOW", test.getFlags().get(0));
Assert.assertEquals("RTLD_GLOBAL", test.getFlags().get(1));
}
use of com.oracle.truffle.nfi.types.NativeLibraryDescriptor in project graal by oracle.
the class ParseLibraryDescriptorTest method parseDefault.
@Test
public void parseDefault() {
NativeLibraryDescriptor def = Parser.parseLibraryDescriptor("default");
Assert.assertTrue("isDefaultLibrary", def.isDefaultLibrary());
}
use of com.oracle.truffle.nfi.types.NativeLibraryDescriptor 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