vkPyFunc => vkPyFuncRef

This commit is contained in:
xushiwei
2024-05-12 23:08:44 +08:00
parent 23692430d5
commit f7dfab481b
8 changed files with 42 additions and 33 deletions

View File

@@ -285,16 +285,16 @@ func (p Function) Block(idx int) BasicBlock {
// -----------------------------------------------------------------------------
type aPyObject struct {
type aPyObjRef struct {
Expr
Obj Global
}
// PyObject represents a python object.
type PyObject = *aPyObject
// PyObjRef represents a python object reference.
type PyObjRef = *aPyObjRef
// NewPyFunc creates a new python function.
func (p Package) NewPyFunc(name string, sig *types.Signature, doInit bool) PyObject {
func (p Package) NewPyFunc(name string, sig *types.Signature, doInit bool) PyObjRef {
if v, ok := p.pyobjs[name]; ok {
return v
}
@@ -305,20 +305,20 @@ func (p Package) NewPyFunc(name string, sig *types.Signature, doInit bool) PyObj
obj.Init(prog.Null(obj.Type))
obj.impl.SetLinkage(llvm.LinkOnceAnyLinkage)
}
ty := &aType{obj.ll, rawType{sig}, vkPyFunc}
ty := &aType{obj.ll, rawType{types.NewPointer(sig)}, vkPyFuncRef}
expr := Expr{obj.impl, ty}
ret := &aPyObject{expr, obj}
ret := &aPyObjRef{expr, obj}
p.pyobjs[name] = ret
return ret
}
// PyObjOf returns a python object by name.
func (p Package) PyObjOf(name string) PyObject {
func (p Package) PyObjOf(name string) PyObjRef {
return p.pyobjs[name]
}
// PyObjs returns all used python objects in this project.
func (p Package) PyObjs() map[string]PyObject {
func (p Package) PyObjs() map[string]PyObjRef {
return p.pyobjs
}