Function pointers in global variables

This commit is contained in:
Ayke van Laethem
2018-08-30 05:36:09 +02:00
parent a4fd096393
commit 7956ca2f29
2 changed files with 19 additions and 1 deletions
+10
View File
@@ -755,6 +755,16 @@ func (c *Compiler) getInterpretedValue(value Value) (llvm.Value, error) {
case *ConstValue:
return c.parseConst(value.Expr)
case *FunctionValue:
if value.Elem == nil {
llvmType, err := c.getLLVMType(value.Type)
if err != nil {
return llvm.Value{}, err
}
return getZeroValue(llvmType)
}
return c.ir.GetFunction(value.Elem).llvmFn, nil
case *GlobalValue:
zero := llvm.ConstInt(llvm.Int32Type(), 0, false)
ptr := llvm.ConstInBoundsGEP(value.Global.llvmGlobal, []llvm.Value{zero})