From 47521d3579fc6f9fb5429db4fbb251b9f16b75a4 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 14 May 2024 19:38:30 +0800 Subject: [PATCH] llpyg fix: empty params --- chore/llpyg/llpyg.go | 3 +++ cl/_testpy/math/out.ll | 1 - cl/compile.go | 13 ++++++---- py/math/llgo_autogen.lla | Bin 567 -> 561 bytes py/os/gen.go | 52 +++++++++++++++++++-------------------- py/os/llgo_autogen.lla | Bin 560 -> 543 bytes 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/chore/llpyg/llpyg.go b/chore/llpyg/llpyg.go index 2031ed70..fb319a1a 100644 --- a/chore/llpyg/llpyg.go +++ b/chore/llpyg/llpyg.go @@ -124,6 +124,9 @@ func (ctx *context) genParams(pkg *gogen.Package, sig string) (*types.Tuple, boo return nil, false, true } sig = strings.TrimSuffix(strings.TrimPrefix(sig, "("), ")") + if sig == "" { // empty params + return nil, false, false + } parts := strings.Split(sig, ",") n := len(parts) if last := strings.TrimSpace(parts[n-1]); last == "/" { diff --git a/cl/_testpy/math/out.ll b/cl/_testpy/math/out.ll index f5feead3..70bdd7e5 100644 --- a/cl/_testpy/math/out.ll +++ b/cl/_testpy/math/out.ll @@ -1,7 +1,6 @@ ; ModuleID = 'math' source_filename = "math" -@__llgo_py.math.sqrt = external global ptr @"math.init$guard" = global ptr null @__llgo_py.math = linkonce global ptr null @0 = private unnamed_addr constant [5 x i8] c"math\00", align 1 diff --git a/cl/compile.go b/cl/compile.go index 78dbb47b..a9aebce2 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -214,11 +214,14 @@ var ( func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function, call bool) (llssa.Function, llssa.PyObjRef, int) { pkgTypes, name, ftype := p.funcName(f, true) if ftype != goFunc { - if ftype == pyFunc { - // TODO(xsw): pyMod == "" - fnName := pysymPrefix + p.pyMod + "." + name - return nil, pkg.NewPyFunc(fnName, f.Signature, call), pyFunc - } + /* + if ftype == pyFunc { + // TODO(xsw): pyMod == "" + fnName := pysymPrefix + p.pyMod + "." + name + return nil, pkg.NewPyFunc(fnName, f.Signature, call), pyFunc + } + */ + _ = call return nil, nil, ignoredFunc } fn := pkg.FuncOf(name) diff --git a/py/math/llgo_autogen.lla b/py/math/llgo_autogen.lla index 5e9568a36ce19676794a477931da84b8523332d7..a1199546d23795186d1da03665ba7726bd7b8ee3 100644 GIT binary patch delta 506 zcmdnavXP}ez?+#xgn@y9gF$@Gx`>)CrOCC73=G;V3=I4XG7LF6>G|=Ar6u|4sd;)i zIiVq(49xeuozorwacKoN10%~h z?V3_5>NWHAhCA)7TW2$_EXg&Rx32X`mza$Ap8ei7PLqo4^;o@ro-10sq9x{)DBn_3 zm7M|hVqQ0P?^)JXnNhfgCDhwIIu@~YEOSJV4=I{17|7^yt-!l(iz0ags7?ybDoa&*rsaM-} z&%1Wz&$c)JmMm}3n|t-8;kQ>agZ%?_H!WgGdB4SOQ8wQfhle#u*PnmhvD{#9tCNh( z3by+vCGuulUo`K`&%E@Zvv6ME&3kvBRPNXD%FVgO_cmMB%=_Yt0wdm;Ka_k`%DTF0 rc6HD7yjA(zyG|Ao`7u~)kdF1t>7 z9ds>JC3W56B5Bbp>#CMq+Iq5Lm&hdTsDhYBfA=0yP6^999JF9czK(g9*NLTZ4_0q! zJ9FvE$>1v%l@YZP)qYiqS|VOIcJEo%R+&*4!MSSMClgN5pcUn7js8VTJr>8;+Gb9Y<|M#`8TQKaSS0{F$X6I9GmV`7?FMO!Kzzv^$hcu z=t}r=G`!dH@RjUHykPSC{5Sqk1~E3>3;GP6;xSG4m-YA^yHWMsuyOT#&7enX4z04D zF2St5nzwxBwJU$Nz5BOeaf6=q>c`1%t|Tv)TNst%%6Z~mX01!cb(t6Q4!vCGf85hO zv4p!-UG-i%Cg%vd6H@_j~4P}EK4W>R1~1B^5V1^^DU-O&I5 diff --git a/py/os/gen.go b/py/os/gen.go index c1597c2f..ba847ce2 100644 --- a/py/os/gen.go +++ b/py/os/gen.go @@ -220,17 +220,17 @@ func Chroot(path *py.Object) *py.Object // Return the name of the controlling terminal for this process. // //go:linkname Ctermid py.ctermid -func Ctermid(_ *py.Object) *py.Object +func Ctermid() *py.Object // Return a unicode string representing the current working directory. // //go:linkname Getcwd py.getcwd -func Getcwd(_ *py.Object) *py.Object +func Getcwd() *py.Object // Return a bytes string representing the current working directory. // //go:linkname Getcwdb py.getcwdb -func Getcwdb(_ *py.Object) *py.Object +func Getcwdb() *py.Object // Create a hard link to a file. // @@ -373,7 +373,7 @@ func Umask(mask *py.Object) *py.Object // (sysname, nodename, release, version, machine) // //go:linkname Uname py.uname -func Uname(_ *py.Object) *py.Object +func Uname() *py.Object // Remove a file (same as remove()). // @@ -410,7 +410,7 @@ func Remove(path *py.Object) *py.Object // All fields are floating point numbers. // //go:linkname Times py.times -func Times(_ *py.Object) *py.Object +func Times() *py.Object // Execute an executable path with arguments, replacing current process. // @@ -439,7 +439,7 @@ func Execve(path *py.Object, argv *py.Object, env *py.Object) *py.Object // Return 0 to child process and PID of child to parent process. // //go:linkname Fork py.fork -func Fork(_ *py.Object) *py.Object +func Fork() *py.Object // Get the maximum scheduling priority for policy. // @@ -454,7 +454,7 @@ func SchedGetPriorityMin(policy *py.Object) *py.Object // Voluntarily relinquish the CPU. // //go:linkname SchedYield py.sched_yield -func SchedYield(_ *py.Object) *py.Object +func SchedYield() *py.Object // Open a pseudo-terminal. // @@ -462,7 +462,7 @@ func SchedYield(_ *py.Object) *py.Object // for both the master and slave ends. // //go:linkname Openpty py.openpty -func Openpty(_ *py.Object) *py.Object +func Openpty() *py.Object // Prepare the tty of which fd is a file descriptor for a new login session. // @@ -481,22 +481,22 @@ func LoginTty(fd *py.Object) *py.Object // To both, return fd of newly opened pseudo-terminal. // //go:linkname Forkpty py.forkpty -func Forkpty(_ *py.Object) *py.Object +func Forkpty() *py.Object // Return the current process's effective group id. // //go:linkname Getegid py.getegid -func Getegid(_ *py.Object) *py.Object +func Getegid() *py.Object // Return the current process's effective user id. // //go:linkname Geteuid py.geteuid -func Geteuid(_ *py.Object) *py.Object +func Geteuid() *py.Object // Return the current process's group id. // //go:linkname Getgid py.getgid -func Getgid(_ *py.Object) *py.Object +func Getgid() *py.Object // Returns a list of groups to which a user belongs. // @@ -511,17 +511,17 @@ func Getgrouplist(user *py.Object, group *py.Object) *py.Object // Return list of supplemental group IDs for the process. // //go:linkname Getgroups py.getgroups -func Getgroups(_ *py.Object) *py.Object +func Getgroups() *py.Object // Return the current process id. // //go:linkname Getpid py.getpid -func Getpid(_ *py.Object) *py.Object +func Getpid() *py.Object // Return the current process group id. // //go:linkname Getpgrp py.getpgrp -func Getpgrp(_ *py.Object) *py.Object +func Getpgrp() *py.Object // Return the parent's process id. // @@ -529,17 +529,17 @@ func Getpgrp(_ *py.Object) *py.Object // return its id; others systems will return the id of the 'init' process (1). // //go:linkname Getppid py.getppid -func Getppid(_ *py.Object) *py.Object +func Getppid() *py.Object // Return the current process's user id. // //go:linkname Getuid py.getuid -func Getuid(_ *py.Object) *py.Object +func Getuid() *py.Object // Return the actual login name. // //go:linkname Getlogin py.getlogin -func Getlogin(_ *py.Object) *py.Object +func Getlogin() *py.Object // Kill a process with a signal. // @@ -603,7 +603,7 @@ func Getpgid(pid *py.Object) *py.Object // Make the current process the leader of its process group. // //go:linkname Setpgrp py.setpgrp -func Setpgrp(_ *py.Object) *py.Object +func Setpgrp() *py.Object // Wait for completion of a child process. // @@ -612,7 +612,7 @@ func Setpgrp(_ *py.Object) *py.Object // (pid, status) // //go:linkname Wait py.wait -func Wait(_ *py.Object) *py.Object +func Wait() *py.Object // Wait for completion of a child process. // @@ -651,7 +651,7 @@ func Getsid(pid *py.Object) *py.Object // Call the system call setsid(). // //go:linkname Setsid py.setsid -func Setsid(_ *py.Object) *py.Object +func Setsid() *py.Object // Call the system call setpgid(pid, pgrp). // @@ -853,7 +853,7 @@ func Isatty(fd *py.Object) *py.Object // (read_fd, write_fd) // //go:linkname Pipe py.pipe -func Pipe(_ *py.Object) *py.Object +func Pipe() *py.Object // Create a "fifo" (a POSIX named pipe). // @@ -948,7 +948,7 @@ func Fsync(fd *py.Object) *py.Object // Force write of everything to disk. // //go:linkname Sync py.sync -func Sync(_ *py.Object) *py.Object +func Sync() *py.Object // Return True if the process returning status was dumped to a core file. // @@ -1043,7 +1043,7 @@ func Pathconf(path *py.Object, name *py.Object) *py.Object // on the hosting operating system. This function never returns. // //go:linkname Abort py.abort -func Abort(_ *py.Object) *py.Object +func Abort() *py.Object // Return average recent system load information. // @@ -1052,7 +1052,7 @@ func Abort(_ *py.Object) *py.Object // Raises OSError if the load average was unobtainable. // //go:linkname Getloadavg py.getloadavg -func Getloadavg(_ *py.Object) *py.Object +func Getloadavg() *py.Object // Return a bytes object containing random bytes suitable for cryptographic use. // @@ -1066,7 +1066,7 @@ func Urandom(size *py.Object) *py.Object // “len(os.sched_getaffinity(0))“ // //go:linkname CpuCount py.cpu_count -func CpuCount(_ *py.Object) *py.Object +func CpuCount() *py.Object // Get the close-on-exe flag of the specified file descriptor. // diff --git a/py/os/llgo_autogen.lla b/py/os/llgo_autogen.lla index e88a4ffa3f069814f8cbdf5f9f3f98ed75b333f4..ddd1bf03489fed553ecf86b054d24c18c4dc2af1 100644 GIT binary patch delta 489 zcmdnMGM}YBz?+#xgn@y9gMnerx`>zc@t?C985n*sGcfQo$S~yOr02&cmX_qFr{?M9 zD1eaJxK*!!O%`l+t1NvrpE7=75#-G1=h zZ4JZD*c-Q(Ea~()w(s|(e}%J?{WeTDdvfx#&Chz(*n@kY@g04}mzNmg_50Db;AN|~ zTru6H=BiT~B_DLR$7Au_#6>qeMY_Tc>35vd?cj)&(zj(LS3aDWJ$1!)k%imX zrZ}s-Uc_;0k)2QJ9}YQsDS7!=|zPQt0VvEDC%dS7@?Zdfy70p8tC_+ktBp z%-i%Cg Z%-AAs@_j}PP#jI>Vp3q+0*oC71^_!b*wp|4 delta 506 zcmbQwvVo;Oz?+#xgn@y9gF%XQZNz@XnP+Mk85mSq7#R2&WEgUC((~gJOH1<8Q}gt4 zazaBm8JI;rI;4pLacKoN10%~avyEE)4q(W_~8xq<3<~c4`r=V z2vgTX_wqb>r z<@N(T>twF-)z1^Y(Ku&6(`TQrLdWA6LQcjUo+6-U7Q}r+>g2<&w!I%&>^!eW?NMN; zOJ2|ORAIT}?W{b(BWDT#n6@J)Of%0j9${49seT_T)i*!ljB~%o6sbaHFGvD z`dG3}Y