use of com.oracle.truffle.llvm.parser.binary.BinaryParserResult in project graal by oracle.
the class ParserDriver method parseLibraryWithSource.
/**
* Parses a single bitcode module and returns its {@link LLVMParserResult}. Explicit and
* implicit dependencies of {@code lib} are added to the . The returned {@link LLVMParserResult}
* is also added to the.
*
* @param source the {@link Source} of the library to be parsed
* @param bytes the bytes of the library to be parsed
* @return the parser result corresponding to {@code lib}
*/
private LLVMParserResult parseLibraryWithSource(Source source, ByteSequence bytes) {
BinaryParserResult binaryParserResult = BinaryParser.parse(bytes, source, context);
if (binaryParserResult != null) {
context.addLibraryPaths(binaryParserResult.getLibraryPaths());
TruffleFile file = createTruffleFile(binaryParserResult.getLibraryName(), source.getPath(), binaryParserResult.getLocator(), "<source library>");
processDependencies(binaryParserResult.getLibraryName(), file, binaryParserResult);
return parseBinary(binaryParserResult, file);
} else {
LibraryLocator.traceDelegateNative(context, source);
return null;
}
}
use of com.oracle.truffle.llvm.parser.binary.BinaryParserResult in project graal by oracle.
the class ExtractBitcode method main.
public static void main(String[] args) {
if (args.length != 2) {
usage(System.err);
System.exit(1);
}
try {
String inName = args[0];
String outName = args[1];
InputStream in = inName.equals("-") ? System.in : new FileInputStream(inName);
OutputStream out = outName.equals("-") ? System.out : new FileOutputStream(outName);
ByteSequence bytes = readFully(in);
BinaryParserResult result = BinaryParser.parse(bytes, null, null);
if (result == null) {
throw new IOException("No bitcode found in file '" + inName + "'");
}
out.write(result.getBitcode().toByteArray());
} catch (IOException e) {
System.err.println(e.getMessage());
System.exit(2);
}
}
Aggregations