use of com.oracle.truffle.llvm.initialization.LoadModulesNode.LLVMLoadingPhase in project graal by oracle.
the class LoadNativeNode method execute.
@Override
@SuppressWarnings("unchecked")
public Object execute(VirtualFrame frame) {
Object[] arguments = frame.getArguments();
Object library = null;
LLVMLoadingPhase phase;
if (arguments.length > 0 && (arguments[0] instanceof LLVMLoadingPhase)) {
phase = (LLVMLoadingPhase) arguments[0];
} else if (arguments.length == 0 || (arguments.length > 0 && (arguments[0] instanceof LLVMDLOpen.RTLDFlags))) {
if (path == null) {
throw new LLVMParserException(this, "Toplevel executable %s does not contain bitcode", path);
}
phase = LLVMLoadingPhase.INIT_SYMBOLS;
} else {
throw new LLVMParserException(this, "LoadNativeNode is called either with unexpected arguments or as a toplevel");
}
if (LLVMLoadingPhase.INIT_SYMBOLS.isActive(phase)) {
LLVMContext context = LLVMContext.get(this);
library = parseAndInitialiseNativeLib(context);
}
if (LLVMLoadingPhase.BUILD_DEPENDENCY.isActive(phase)) {
ArrayList<CallTarget> dependencies = (ArrayList<CallTarget>) frame.getArguments()[2];
dependencies.add(this.getCallTarget());
}
return library;
}
Aggregations