diff --git a/README.md b/README.md index 11930a20..53e6b3f9 100644 --- a/README.md +++ b/README.md @@ -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`! -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) * [os](https://pkg.go.dev/github.com/goplus/llgo/py/os) diff --git a/_pydemo/matrix/matrix.go b/_pydemo/matrix/matrix.go index ceecb933..5567d172 100644 --- a/_pydemo/matrix/matrix.go +++ b/_pydemo/matrix/matrix.go @@ -18,7 +18,5 @@ func main() { py.List(3.0, 2.0, 1.0), ) 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()) } diff --git a/cl/_testpy/pi/in.go b/cl/_testpy/pi/in.go new file mode 100644 index 00000000..934fe31a --- /dev/null +++ b/cl/_testpy/pi/in.go @@ -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) +} diff --git a/cl/_testpy/pi/out.ll b/cl/_testpy/pi/out.ll new file mode 100644 index 00000000..e69de29b diff --git a/cl/compile.go b/cl/compile.go index 43d88f9f..c98e2e3b 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -176,7 +176,7 @@ func (p *context) compileMethods(pkg llssa.Package, typ types.Type) { for i, n := 0, mthds.Len(); i < n; i++ { mthd := mthds.At(i) 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])) ) -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) 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 } */ - _ = call return nil, nil, ignoredFunc } 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? if v.Pkg == p.goPkg || v.Pkg == nil { // function in this package - goFn, pyFn, kind = p.compileFuncDecl(p.pkg, v, true) + goFn, pyFn, kind = p.compileFuncDecl(p.pkg, v) if kind != ignoredFunc { 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. continue } - ctx.compileFuncDecl(ret, member, false) + ctx.compileFuncDecl(ret, member) case *ssa.Type: ctx.compileType(ret, member) case *ssa.Global: diff --git a/cl/compile_test.go b/cl/compile_test.go index 6f417cbe..5b26c9e7 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -29,7 +29,7 @@ func testCompile(t *testing.T, src, expected string) { } func TestFromTestpy(t *testing.T) { - cltest.FromDir(t, "", "./_testpy", false) + cltest.FromDir(t, "pi", "./_testpy", false) } func TestFromTestlibc(t *testing.T) {