Merge pull request #270 from xushiwei/q

llgo/ssa: NoArgsNoRet
This commit is contained in:
xushiwei
2024-06-04 20:03:49 +08:00
committed by GitHub
2 changed files with 8 additions and 15 deletions

View File

@@ -641,8 +641,7 @@ func (p Package) String() string {
func (p Package) afterBuilder() Builder { func (p Package) afterBuilder() Builder {
if p.afterb == nil { if p.afterb == nil {
sigAfterInit := types.NewSignatureType(nil, nil, nil, nil, nil, false) fn := p.NewFunc(p.Path()+".init$after", NoArgsNoRet, InC)
fn := p.NewFunc(p.Path()+".init$after", sigAfterInit, InC)
fnb := fn.MakeBody(1) fnb := fn.MakeBody(1)
p.afterb = unsafe.Pointer(fnb) p.afterb = unsafe.Pointer(fnb)
} }

View File

@@ -30,8 +30,7 @@ import (
func TestEndDefer(t *testing.T) { func TestEndDefer(t *testing.T) {
prog := NewProgram(nil) prog := NewProgram(nil)
pkg := prog.NewPackage("foo", "foo") pkg := prog.NewPackage("foo", "foo")
sigMain := types.NewSignatureType(nil, nil, nil, nil, nil, false) fn := pkg.NewFunc("main", NoArgsNoRet, InC)
fn := pkg.NewFunc("main", sigMain, InC)
b := fn.MakeBody(1) b := fn.MakeBody(1)
fn.defer_ = &aDefer{} fn.defer_ = &aDefer{}
fn.endDefer(b) fn.endDefer(b)
@@ -46,8 +45,7 @@ func TestUnsafeString(t *testing.T) {
return pkg return pkg
}) })
pkg := prog.NewPackage("foo", "foo") pkg := prog.NewPackage("foo", "foo")
sigMain := types.NewSignatureType(nil, nil, nil, nil, nil, false) b := pkg.NewFunc("main", NoArgsNoRet, InC).MakeBody(1)
b := pkg.NewFunc("main", sigMain, InC).MakeBody(1)
b.Println(b.BuiltinCall("String", b.CStr("hello"), prog.Val(5))) b.Println(b.BuiltinCall("String", b.CStr("hello"), prog.Val(5)))
b.Return() b.Return()
} }
@@ -119,8 +117,7 @@ func TestIndexType(t *testing.T) {
func TestCvtType(t *testing.T) { func TestCvtType(t *testing.T) {
gt := newGoTypes() gt := newGoTypes()
callback := types.NewSignatureType(nil, nil, nil, nil, nil, false) params := types.NewTuple(types.NewParam(0, nil, "", NoArgsNoRet))
params := types.NewTuple(types.NewParam(0, nil, "", callback))
sig := types.NewSignatureType(nil, nil, nil, params, nil, false) sig := types.NewSignatureType(nil, nil, nil, params, nil, false)
ret1 := gt.cvtFunc(sig, nil) ret1 := gt.cvtFunc(sig, nil)
if ret1 == sig { if ret1 == sig {
@@ -179,9 +176,8 @@ func TestPyFunc(t *testing.T) {
py.Scope().Insert(o) py.Scope().Insert(o)
prog.SetPython(py) prog.SetPython(py)
pkg := prog.NewPackage("bar", "foo/bar") pkg := prog.NewPackage("bar", "foo/bar")
sig := types.NewSignatureType(nil, nil, nil, nil, nil, false) a := pkg.PyNewFunc("a", NoArgsNoRet, false)
a := pkg.PyNewFunc("a", sig, false) if pkg.PyNewFunc("a", NoArgsNoRet, false) != a {
if pkg.PyNewFunc("a", sig, false) != a {
t.Fatal("NewPyFunc(a) failed") t.Fatal("NewPyFunc(a) failed")
} }
foo := pkg.PyNewModVar("foo", false) foo := pkg.PyNewModVar("foo", false)
@@ -333,8 +329,7 @@ func TestFuncCall(t *testing.T) {
fn.MakeBody(1). fn.MakeBody(1).
Return(prog.Val(1)) Return(prog.Val(1))
sigMain := types.NewSignatureType(nil, nil, nil, nil, nil, false) b := pkg.NewFunc("main", NoArgsNoRet, InGo).MakeBody(1)
b := pkg.NewFunc("main", sigMain, InGo).MakeBody(1)
b.Call(fn.Expr, prog.Val(1), prog.Val(1.2)) b.Call(fn.Expr, prog.Val(1), prog.Val(1.2))
b.Return() b.Return()
@@ -383,8 +378,7 @@ _llgo_0:
func TestJump(t *testing.T) { func TestJump(t *testing.T) {
prog := NewProgram(nil) prog := NewProgram(nil)
pkg := prog.NewPackage("bar", "foo/bar") pkg := prog.NewPackage("bar", "foo/bar")
sig := types.NewSignatureType(nil, nil, nil, nil, nil, false) fn := pkg.NewFunc("loop", NoArgsNoRet, InGo)
fn := pkg.NewFunc("loop", sig, InGo)
b := fn.MakeBody(1) b := fn.MakeBody(1)
b.Jump(fn.Block(0)) b.Jump(fn.Block(0))
assertPkg(t, pkg, `; ModuleID = 'foo/bar' assertPkg(t, pkg, `; ModuleID = 'foo/bar'