Problem with LLVM-C bindings
Daniel
dtoffe at gmail.com
Thu Oct 26 01:28:42 UTC 2023
Hi all, I'm having a problem with llvm-c bindings, it is likely a
trivial thing, but this is my first D project, and I'm not an
expert in C either.
- symtable.d
struct Symbol {
string name;
SymbolKind kind;
SymbolType type;
LLVMValueRef valueRef;
public LLVMValueRef getValueRef() {
return valueRef;
}
public void setValueRef(LLVMValueRef valueRef) {
this.valueRef = valueRef;
}
}
- ast.d
class ConstDeclNode : AstNode {
string constName;
int constValue;
Symbol constSymbol;
Symbol getConstSymbol() {
return constSymbol;
}
void setConstSymbol(Symbol constSymbol) {
this.constSymbol = constSymbol;
}
- codegen.d
valRef = LLVMBuildAlloca(llvmBuilder, int32Type,
symbolName.toStringz());
vars[symbolName] = valRef;
node.getVarSymbol().setValueRef(valRef);
---snip---
variableRef = vars[symbolName]; =>
WORKS
variableRef = node.getVarSymbol().getValueRef(); =>
DOESN'T WORK
Here, vars[] is declared in codegen.d, I set and get
LLVMValueRefs and everything goes well, but I tried to store the
LLVMValueRefs in the Symbol structure which is in another D
module and cannot get it to work, the program stops there when
trying to access those values.
Any hint about what to try will be greatly appreciated.
Daniel
More information about the Digitalmars-d
mailing list