go.mod go1.23

This commit is contained in:
visualfc
2025-05-04 21:33:53 +08:00
parent 8882c31eb4
commit e8a91696d6
7 changed files with 1529 additions and 1421 deletions

25
cl/_testgo/alias/in.go Normal file
View File

@@ -0,0 +1,25 @@
package main
type Point struct {
x float64
y float64
}
func (p *Point) Scale(factor float64) {
p.x *= factor
p.y *= factor
}
type MyPoint = Point
func (p *MyPoint) Move(dx, dy float64) {
p.x += dx
p.y += dy
}
func main() {
pt := &MyPoint{1, 2}
pt.Scale(2)
pt.Move(3, 4)
println(pt.x, pt.y)
}

75
cl/_testgo/alias/out.ll Normal file
View File

@@ -0,0 +1,75 @@
; ModuleID = 'github.com/goplus/llgo/cl/_testgo/alias'
source_filename = "github.com/goplus/llgo/cl/_testgo/alias"
%"github.com/goplus/llgo/cl/_testgo/alias.Point" = type { double, double }
@"github.com/goplus/llgo/cl/_testgo/alias.init$guard" = global i1 false, align 1
define void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Move"(ptr %0, double %1, double %2) {
_llgo_0:
%3 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
%4 = load double, ptr %3, align 8
%5 = fadd double %4, %1
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
store double %5, ptr %6, align 8
%7 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
%8 = load double, ptr %7, align 8
%9 = fadd double %8, %2
%10 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
store double %9, ptr %10, align 8
ret void
}
define void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Scale"(ptr %0, double %1) {
_llgo_0:
%2 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
%3 = load double, ptr %2, align 8
%4 = fmul double %3, %1
%5 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
store double %4, ptr %5, align 8
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
%7 = load double, ptr %6, align 8
%8 = fmul double %7, %1
%9 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
store double %8, ptr %9, align 8
ret void
}
define void @"github.com/goplus/llgo/cl/_testgo/alias.init"() {
_llgo_0:
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testgo/alias.init$guard", align 1
br i1 %0, label %_llgo_2, label %_llgo_1
_llgo_1: ; preds = %_llgo_0
store i1 true, ptr @"github.com/goplus/llgo/cl/_testgo/alias.init$guard", align 1
br label %_llgo_2
_llgo_2: ; preds = %_llgo_1, %_llgo_0
ret void
}
define void @"github.com/goplus/llgo/cl/_testgo/alias.main"() {
_llgo_0:
%0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
%1 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
%2 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
store double 1.000000e+00, ptr %1, align 8
store double 2.000000e+00, ptr %2, align 8
call void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Scale"(ptr %0, double 2.000000e+00)
call void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Move"(ptr %0, double 3.000000e+00, double 4.000000e+00)
%3 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
%4 = load double, ptr %3, align 8
%5 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
%6 = load double, ptr %5, align 8
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintFloat"(double %4)
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintFloat"(double %6)
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10)
ret void
}
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintFloat"(double)
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8)

View File

@@ -5,8 +5,8 @@ source_filename = "github.com/goplus/llgo/cl/_testgo/tpnamed"
%"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 }
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[error]" = type { ptr, ptr }
%"github.com/goplus/llgo/runtime/internal/runtime.iface" = type { ptr, ptr }
%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" = type { ptr, ptr }
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" = type { ptr, ptr }
%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" = type { ptr, ptr }
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" = type { ptr, ptr }
@"github.com/goplus/llgo/cl/_testgo/tpnamed.init$guard" = global i1 false, align 1
@@ -40,13 +40,13 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
define void @"github.com/goplus/llgo/cl/_testgo/tpnamed.main"() {
_llgo_0:
%0 = call [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[[0]byte]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1", ptr null })
%0 = call [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1", ptr null })
ret void
}
define %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"() {
define %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"() {
_llgo_0:
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1$1", ptr null }
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1$1", ptr null }
}
define [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1$1"() {
@@ -66,19 +66,19 @@ _llgo_0:
ret %"github.com/goplus/llgo/runtime/internal/runtime.iface" %1
}
define linkonce %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"(ptr %0) {
define linkonce %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"(ptr %0) {
_llgo_0:
%1 = tail call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"()
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %1
%1 = tail call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"()
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %1
}
define linkonce [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[[0]byte]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0) {
define linkonce [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %0) {
_llgo_0:
%1 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0, 1
%2 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0, 0
%3 = call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %2(ptr %1)
%4 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %3, 1
%5 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %3, 0
%1 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %0, 1
%2 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %0, 0
%3 = call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %2(ptr %1)
%4 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %3, 1
%5 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %3, 0
%6 = call [0 x i8] %5(ptr %4)
ret [0 x i8] %6
}

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@ source_filename = "github.com/goplus/llgo/cl/_testrt/any"
@"github.com/goplus/llgo/cl/_testrt/any.init$guard" = global i1 false, align 1
@_llgo_int8 = linkonce global ptr null, align 8
@"*_llgo_int8" = linkonce global ptr null, align 8
@0 = private unnamed_addr constant [34 x i8] c"type assertion any -> *int8 failed", align 1
@0 = private unnamed_addr constant [58 x i8] c"type assertion any -> *github.com/goplus/lib/c.Char failed", align 1
@_llgo_string = linkonce global ptr null, align 8
@_llgo_int = linkonce global ptr null, align 8
@1 = private unnamed_addr constant [32 x i8] c"type assertion any -> int failed", align 1
@@ -29,7 +29,7 @@ _llgo_1: ; preds = %_llgo_0
_llgo_2: ; preds = %_llgo_0
%6 = load ptr, ptr @_llgo_string, align 8
%7 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 34 }, ptr %7, align 8
store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 58 }, ptr %7, align 8
%8 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %6, 0
%9 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %8, ptr %7, 1
call void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %9)

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/goplus/llgo
go 1.22.0
go 1.23
toolchain go1.24.1

View File

@@ -538,20 +538,15 @@ func PathOf(pkg *types.Package) string {
// - method: pkg.T.name, pkg.(*T).name
func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string {
if recv != nil {
named, ptr := recvNamed(recv.Type())
var tName string
t := recv.Type()
if org {
if tp, ok := t.(*types.Pointer); ok {
tName = "(*" + tp.Elem().(*types.Named).Obj().Name() + ")"
} else {
tName = t.(*types.Named).Obj().Name()
}
tName = named.Obj().Name()
} else {
if tp, ok := t.(*types.Pointer); ok {
tName = "(*" + abi.NamedName(tp.Elem().(*types.Named)) + ")"
} else {
tName = abi.NamedName(t.(*types.Named))
}
tName = abi.NamedName(named)
}
if ptr {
tName = "(*" + tName + ")"
}
return PathOf(pkg) + "." + tName + "." + name
}
@@ -559,6 +554,18 @@ func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string
return ret
}
func recvNamed(t types.Type) (typ *types.Named, ptr bool) {
if tp, ok := t.(*types.Pointer); ok {
t = tp.Elem()
ptr = true
}
if _, ok := t.(*types.Alias); ok {
t = types.Unalias(t)
}
typ, _ = t.(*types.Named)
return
}
func TypeArgs(typeArgs []types.Type) string {
return abi.TypeArgs(typeArgs)
}