use of com.oracle.truffle.llvm.runtime.SulongLibrary.CachedMainFunction in project graal by oracle.
the class LoadModulesNode method execute.
@Override
public Object execute(VirtualFrame frame) {
LLVMContext context = getContext();
synchronized (context) {
if (!hasInitialised) {
CompilerDirectives.transferToInterpreterAndInvalidate();
LLVMFunction mainFunction = findMainFunction();
if (mainFunction != null) {
main = new CachedMainFunction(mainFunction);
} else {
main = null;
}
initContext = this.insert(language.createInitializeContextNode());
hasInitialised = true;
}
LLVMScopeChain firstScopeChain = loadModule(frame, context);
context.addSourceForCache(bitcodeID, source);
context.addCalltargetForCache(libraryName, this.getCallTarget());
// Only the root library (not a dependency) will have a non-null scope.
if (firstScopeChain != null) {
SulongLibrary library = new SulongLibrary(this.libraryName, firstScopeChain, main, context, parserRuntime.getLocator(), parserRuntime.getBitcodeID());
if (main != null) {
context.setMainLibrary(library);
}
return library;
}
}
return null;
}
Aggregations