compileBlock: support pyModule init

This commit is contained in:
xushiwei
2024-05-11 11:33:35 +08:00
parent 427d87be68
commit 00222c7808
4 changed files with 75 additions and 26 deletions

View File

@@ -327,6 +327,13 @@ func (p Package) NewConst(name string, val constant.Value) NamedConst {
}
*/
// NewPyModVar creates a new global variable for a Python module.
func (p Package) NewPyModVar(name string) Global {
ret := p.NewVar(name, types.NewPointer(types.Typ[types.Int]), InC)
ret.impl.SetLinkage(llvm.LinkOnceAnyLinkage)
return ret
}
// NewVar creates a new global variable.
func (p Package) NewVar(name string, typ types.Type, bg Background) Global {
t := p.Prog.Type(typ, bg)