use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalConstant in project sulong by graalvm.
the class LLVMParserRuntime method getGlobalVariable.
private LLVMExpressionNode getGlobalVariable(LLVMSymbolReadResolver symbolResolver, GlobalValueSymbol global) {
LLVMSourceSymbol sourceSymbol = null;
SymbolImpl g = global;
while (g instanceof GlobalAlias) {
if (sourceSymbol == null) {
sourceSymbol = ((GlobalAlias) g).getSourceSymbol();
}
g = aliases.get(g);
}
if (sourceSymbol == null && g instanceof GlobalValueSymbol) {
sourceSymbol = ((GlobalValueSymbol) g).getSourceSymbol();
}
if (g instanceof GlobalValueSymbol) {
final GlobalValueSymbol variable = (GlobalValueSymbol) g;
final LLVMSourceSymbol finalSourceSymbol = sourceSymbol;
Object globalVariableDescriptor = scope.lookupOrCreateGlobal(variable.getName(), !Linkage.isFileLocal(variable.getLinkage()), () -> {
final Object globalValue;
if (global instanceof GlobalVariable) {
globalValue = nodeFactory.allocateGlobalVariable(this, (GlobalVariable) global, finalSourceSymbol);
} else if (global instanceof GlobalConstant) {
globalValue = nodeFactory.allocateGlobalConstant(this, (GlobalConstant) global, finalSourceSymbol);
} else {
throw new AssertionError("Cannot allocate global: " + global);
}
return globalValue;
});
return nodeFactory.createLiteral(this, globalVariableDescriptor, new PointerType(variable.getType()));
} else {
return symbolResolver.resolve(g);
}
}
Aggregations