compileFuncDecl remove param: call bool
This commit is contained in:
@@ -31,7 +31,7 @@ See [github.com/goplus/llgo/c](https://pkg.go.dev/github.com/goplus/llgo/c) for
|
|||||||
|
|
||||||
You can import a Python library in `llgo`!
|
You can import a Python library in `llgo`!
|
||||||
|
|
||||||
And `llgo` can import any Python library into `llgo` through a program called `llpyg`. The currently imported packages include:
|
And you can import any Python library into `llgo` through a program called `llpyg`. The currently imported packages include:
|
||||||
|
|
||||||
* [sys](https://pkg.go.dev/github.com/goplus/llgo/py/sys)
|
* [sys](https://pkg.go.dev/github.com/goplus/llgo/py/sys)
|
||||||
* [os](https://pkg.go.dev/github.com/goplus/llgo/py/os)
|
* [os](https://pkg.go.dev/github.com/goplus/llgo/py/os)
|
||||||
|
|||||||
@@ -18,7 +18,5 @@ func main() {
|
|||||||
py.List(3.0, 2.0, 1.0),
|
py.List(3.0, 2.0, 1.0),
|
||||||
)
|
)
|
||||||
x := numpy.Add(a, b)
|
x := numpy.Add(a, b)
|
||||||
c.Printf(c.Str("a = %s\n"), a.Str().CStr())
|
|
||||||
c.Printf(c.Str("a = %s\n"), b.Str().CStr())
|
|
||||||
c.Printf(c.Str("a+b = %s\n"), x.Str().CStr())
|
c.Printf(c.Str("a+b = %s\n"), x.Str().CStr())
|
||||||
}
|
}
|
||||||
|
|||||||
10
cl/_testpy/pi/in.go
Normal file
10
cl/_testpy/pi/in.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
|
"github.com/goplus/llgo/py/math"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
c.Printf(c.Str("pi = %f\n"), math.Pi)
|
||||||
|
}
|
||||||
0
cl/_testpy/pi/out.ll
Normal file
0
cl/_testpy/pi/out.ll
Normal file
@@ -176,7 +176,7 @@ func (p *context) compileMethods(pkg llssa.Package, typ types.Type) {
|
|||||||
for i, n := 0, mthds.Len(); i < n; i++ {
|
for i, n := 0, mthds.Len(); i < n; i++ {
|
||||||
mthd := mthds.At(i)
|
mthd := mthds.At(i)
|
||||||
if ssaMthd := prog.MethodValue(mthd); ssaMthd != nil {
|
if ssaMthd := prog.MethodValue(mthd); ssaMthd != nil {
|
||||||
p.compileFuncDecl(pkg, ssaMthd, false)
|
p.compileFuncDecl(pkg, ssaMthd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ var (
|
|||||||
argvTy = types.NewPointer(types.NewPointer(types.Typ[types.Int8]))
|
argvTy = types.NewPointer(types.NewPointer(types.Typ[types.Int8]))
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function, call bool) (llssa.Function, llssa.PyObjRef, int) {
|
func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function) (llssa.Function, llssa.PyObjRef, int) {
|
||||||
pkgTypes, name, ftype := p.funcName(f, true)
|
pkgTypes, name, ftype := p.funcName(f, true)
|
||||||
if ftype != goFunc {
|
if ftype != goFunc {
|
||||||
/*
|
/*
|
||||||
@@ -221,7 +221,6 @@ func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function, call bool)
|
|||||||
return nil, pkg.NewPyFunc(fnName, f.Signature, call), pyFunc
|
return nil, pkg.NewPyFunc(fnName, f.Signature, call), pyFunc
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
_ = call
|
|
||||||
return nil, nil, ignoredFunc
|
return nil, nil, ignoredFunc
|
||||||
}
|
}
|
||||||
fn := pkg.FuncOf(name)
|
fn := pkg.FuncOf(name)
|
||||||
@@ -805,7 +804,7 @@ func (p *context) compileFunction(v *ssa.Function) (goFn llssa.Function, pyFn ll
|
|||||||
// v.Pkg == nil: means auto generated function?
|
// v.Pkg == nil: means auto generated function?
|
||||||
if v.Pkg == p.goPkg || v.Pkg == nil {
|
if v.Pkg == p.goPkg || v.Pkg == nil {
|
||||||
// function in this package
|
// function in this package
|
||||||
goFn, pyFn, kind = p.compileFuncDecl(p.pkg, v, true)
|
goFn, pyFn, kind = p.compileFuncDecl(p.pkg, v)
|
||||||
if kind != ignoredFunc {
|
if kind != ignoredFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -924,7 +923,7 @@ func NewPackage(prog llssa.Program, pkg *ssa.Package, files []*ast.File) (ret ll
|
|||||||
// Do not try to build generic (non-instantiated) functions.
|
// Do not try to build generic (non-instantiated) functions.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ctx.compileFuncDecl(ret, member, false)
|
ctx.compileFuncDecl(ret, member)
|
||||||
case *ssa.Type:
|
case *ssa.Type:
|
||||||
ctx.compileType(ret, member)
|
ctx.compileType(ret, member)
|
||||||
case *ssa.Global:
|
case *ssa.Global:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func testCompile(t *testing.T, src, expected string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFromTestpy(t *testing.T) {
|
func TestFromTestpy(t *testing.T) {
|
||||||
cltest.FromDir(t, "", "./_testpy", false)
|
cltest.FromDir(t, "pi", "./_testpy", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFromTestlibc(t *testing.T) {
|
func TestFromTestlibc(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user