Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9203c366e7 | ||
|
|
11a8af1db2 | ||
|
|
c8fb7eafa0 | ||
|
|
ffc1f712a3 | ||
|
|
cfc8687851 | ||
|
|
953699b2fd | ||
|
|
9a16fff27e | ||
|
|
ac0d104231 | ||
|
|
881efea006 | ||
|
|
f6a380d293 | ||
|
|
a971b93994 | ||
|
|
c4f0dd124d | ||
|
|
93b9b7d44c | ||
|
|
7552bfe39b | ||
|
|
2601faaff2 | ||
|
|
cb2e28d086 | ||
|
|
337877313a | ||
|
|
1693942cee | ||
|
|
867a1ce2f4 | ||
|
|
26b997537f | ||
|
|
19056b8a19 | ||
|
|
10d603b377 | ||
|
|
3f41c313ad | ||
|
|
d440949c1d | ||
|
|
64314dc6cf | ||
|
|
decb9d7f11 | ||
|
|
975b0b74ee | ||
|
|
9aa7807b02 | ||
|
|
337c6cfa25 | ||
|
|
f09a423ee7 | ||
|
|
3bf28f52c4 | ||
|
|
f794592f42 | ||
|
|
98bd05b47b | ||
|
|
3edbde0839 | ||
|
|
a2d92eac0b | ||
|
|
eb47c545ec | ||
|
|
c858f79449 | ||
|
|
27f6efbdec | ||
|
|
bba7494ffd | ||
|
|
0f79cad5a7 | ||
|
|
9e7bacbe23 | ||
|
|
2301a4834d | ||
|
|
40e0f58079 | ||
|
|
c23fb144cf | ||
|
|
caac681ac3 | ||
|
|
9ba3b3ef8f | ||
|
|
d7e523948b | ||
|
|
10a75138d1 | ||
|
|
d48b19c866 | ||
|
|
1fdcb55eba | ||
|
|
16cec9f045 | ||
|
|
438b0bd1b0 | ||
|
|
e8a91696d6 | ||
|
|
8882c31eb4 | ||
|
|
8455ee8226 | ||
|
|
3f74aded8a | ||
|
|
2e19c2013c | ||
|
|
1edaa2d09b | ||
|
|
beee018287 | ||
|
|
34266ea59d | ||
|
|
f26127ce98 | ||
|
|
ccf321d178 | ||
|
|
355721c47a | ||
|
|
d400663e5d | ||
|
|
2203be945a | ||
|
|
b9a2bf4b42 | ||
|
|
cc08195cf2 | ||
|
|
50c40a7828 | ||
|
|
158be3f949 | ||
|
|
0f87c322ca | ||
|
|
d5dd19b64c | ||
|
|
3ac9055493 | ||
|
|
3032d730b7 | ||
|
|
e93e7126b6 | ||
|
|
9bcf41d28f | ||
|
|
604ce47d5e | ||
|
|
e1ebe150d4 | ||
|
|
ae992737e8 | ||
|
|
c59d609eb8 | ||
|
|
9f26d12a3e | ||
|
|
9102577eba | ||
|
|
f0fcfde22b | ||
|
|
d9d813db56 |
4
.github/codecov.yml
vendored
4
.github/codecov.yml
vendored
@@ -1,9 +1,11 @@
|
|||||||
coverage:
|
coverage:
|
||||||
ignore:
|
ignore:
|
||||||
- "chore"
|
- "chore"
|
||||||
- "cmd/internal"
|
- "cmd"
|
||||||
- "internal/build"
|
- "internal/build"
|
||||||
- "internal/llgen"
|
- "internal/llgen"
|
||||||
- "internal/mockable"
|
- "internal/mockable"
|
||||||
- "internal/packages"
|
- "internal/packages"
|
||||||
- "internal/typepatch"
|
- "internal/typepatch"
|
||||||
|
- "internal/github"
|
||||||
|
- "xtool"
|
||||||
|
|||||||
2
.github/workflows/fmt.yml
vendored
2
.github/workflows/fmt.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
for dir in . runtime; do
|
for dir in . runtime; do
|
||||||
pushd $dir
|
pushd $dir
|
||||||
if [ -n "$(go fmt ./...)" ]; then
|
if [ -n "$(go fmt ./... | grep -v gop_autogen.go)" ]; then
|
||||||
echo "Some files are not properly formatted. Please run 'go fmt ./...'"
|
echo "Some files are not properly formatted. Please run 'go fmt ./...'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ Here are the Go packages that can be imported correctly:
|
|||||||
* [regexp/syntax](https://pkg.go.dev/regexp/syntax)
|
* [regexp/syntax](https://pkg.go.dev/regexp/syntax)
|
||||||
* [go/token](https://pkg.go.dev/go/token)
|
* [go/token](https://pkg.go.dev/go/token)
|
||||||
* [go/scanner](https://pkg.go.dev/go/scanner)
|
* [go/scanner](https://pkg.go.dev/go/scanner)
|
||||||
|
* [go/parser](https://pkg.go.dev/go/parser)
|
||||||
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|||||||
33
_cmptest/_goconstdemo/goconst.go
Normal file
33
_cmptest/_goconstdemo/goconst.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go/constant"
|
||||||
|
"go/token"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Create the complex number 2.3 + 5i.
|
||||||
|
ar := constant.MakeFloat64(2.3)
|
||||||
|
ai := constant.MakeImag(constant.MakeInt64(5))
|
||||||
|
a := constant.BinaryOp(ar, token.ADD, ai)
|
||||||
|
|
||||||
|
// Compute (2.3 + 5i) * 11.
|
||||||
|
b := constant.MakeUint64(11)
|
||||||
|
c := constant.BinaryOp(a, token.MUL, b)
|
||||||
|
|
||||||
|
// Convert c into a complex128.
|
||||||
|
Ar, exact := constant.Float64Val(constant.Real(c))
|
||||||
|
if !exact {
|
||||||
|
fmt.Printf("Could not represent real part %s exactly as float64\n", constant.Real(c))
|
||||||
|
}
|
||||||
|
Ai, exact := constant.Float64Val(constant.Imag(c))
|
||||||
|
if !exact {
|
||||||
|
fmt.Printf("Could not represent imaginary part %s as exactly as float64\n", constant.Imag(c))
|
||||||
|
}
|
||||||
|
C := complex(Ar, Ai)
|
||||||
|
|
||||||
|
fmt.Println("literal", 25.3+55i)
|
||||||
|
fmt.Println("go/constant", c)
|
||||||
|
fmt.Println("complex128", C)
|
||||||
|
}
|
||||||
25
_cmptest/mathbigdemo/big.go
Normal file
25
_cmptest/mathbigdemo/big.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Initialize two big ints with the first two numbers in the sequence.
|
||||||
|
a := big.NewInt(0)
|
||||||
|
b := big.NewInt(1)
|
||||||
|
|
||||||
|
// Initialize limit as 10^99, the smallest integer with 100 digits.
|
||||||
|
var limit big.Int
|
||||||
|
limit.Exp(big.NewInt(10), big.NewInt(99), nil)
|
||||||
|
|
||||||
|
// Loop while a is smaller than 1e100.
|
||||||
|
for a.Cmp(&limit) < 0 {
|
||||||
|
// Compute the next Fibonacci number, storing it in a.
|
||||||
|
a.Add(a, b)
|
||||||
|
// Swap a and b so that b is the next number in the sequence.
|
||||||
|
a, b = b, a
|
||||||
|
}
|
||||||
|
fmt.Println(a) // 100-digit Fibonacci number
|
||||||
|
}
|
||||||
25
cl/_testgo/alias/in.go
Normal file
25
cl/_testgo/alias/in.go
Normal 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
75
cl/_testgo/alias/out.ll
Normal 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)
|
||||||
@@ -319,7 +319,7 @@ _llgo_17: ; preds = %_llgo_4
|
|||||||
%108 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
%108 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
%109 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %108, i32 0, i32 0
|
%109 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %108, i32 0, i32 0
|
||||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %43, ptr %109, align 8
|
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %43, ptr %109, align 8
|
||||||
%110 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.one$bound", ptr undef }, ptr %108, 1
|
%110 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.one$bound", ptr undef }, ptr %108, 1
|
||||||
%111 = extractvalue { ptr, ptr } %110, 1
|
%111 = extractvalue { ptr, ptr } %110, 1
|
||||||
%112 = extractvalue { ptr, ptr } %110, 0
|
%112 = extractvalue { ptr, ptr } %110, 0
|
||||||
%113 = call i64 %112(ptr %111)
|
%113 = call i64 %112(ptr %111)
|
||||||
@@ -339,7 +339,7 @@ _llgo_19: ; preds = %_llgo_6
|
|||||||
%119 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
%119 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
%120 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %119, i32 0, i32 0
|
%120 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %119, i32 0, i32 0
|
||||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %51, ptr %120, align 8
|
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %51, ptr %120, align 8
|
||||||
%121 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.one$bound", ptr undef }, ptr %119, 1
|
%121 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.one$bound", ptr undef }, ptr %119, 1
|
||||||
%122 = extractvalue { ptr, ptr } %121, 1
|
%122 = extractvalue { ptr, ptr } %121, 1
|
||||||
%123 = extractvalue { ptr, ptr } %121, 0
|
%123 = extractvalue { ptr, ptr } %121, 0
|
||||||
%124 = call i64 %123(ptr %122)
|
%124 = call i64 %123(ptr %122)
|
||||||
@@ -359,7 +359,7 @@ _llgo_21: ; preds = %_llgo_12
|
|||||||
%130 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
%130 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
%131 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %130, i32 0, i32 0
|
%131 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %130, i32 0, i32 0
|
||||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %93, ptr %131, align 8
|
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %93, ptr %131, align 8
|
||||||
%132 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.two$bound", ptr undef }, ptr %130, 1
|
%132 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.two$bound", ptr undef }, ptr %130, 1
|
||||||
%133 = extractvalue { ptr, ptr } %132, 1
|
%133 = extractvalue { ptr, ptr } %132, 1
|
||||||
%134 = extractvalue { ptr, ptr } %132, 0
|
%134 = extractvalue { ptr, ptr } %132, 0
|
||||||
%135 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" %134(ptr %133)
|
%135 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" %134(ptr %133)
|
||||||
@@ -380,7 +380,7 @@ _llgo_23: ; preds = %_llgo_14
|
|||||||
%142 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
%142 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
%143 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %142, i32 0, i32 0
|
%143 = getelementptr inbounds { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %142, i32 0, i32 0
|
||||||
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %101, ptr %143, align 8
|
store %"github.com/goplus/llgo/runtime/internal/runtime.iface" %101, ptr %143, align 8
|
||||||
%144 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.two$bound", ptr undef }, ptr %142, 1
|
%144 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.two$bound", ptr undef }, ptr %142, 1
|
||||||
%145 = extractvalue { ptr, ptr } %144, 1
|
%145 = extractvalue { ptr, ptr } %144, 1
|
||||||
%146 = extractvalue { ptr, ptr } %144, 0
|
%146 = extractvalue { ptr, ptr } %144, 0
|
||||||
%147 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" %146(ptr %145)
|
%147 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" %146(ptr %145)
|
||||||
@@ -585,7 +585,7 @@ declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamedInterface"
|
|||||||
|
|
||||||
declare void @"github.com/goplus/llgo/runtime/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/runtime/internal/runtime.Slice")
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/runtime/internal/runtime.Slice")
|
||||||
|
|
||||||
define i64 @"github.com/goplus/llgo/cl/_testgo/ifaceprom.one$bound"(ptr %0) {
|
define i64 @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.one$bound"(ptr %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = load { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %0, align 8
|
%1 = load { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %0, align 8
|
||||||
%2 = extractvalue { %"github.com/goplus/llgo/runtime/internal/runtime.iface" } %1, 0
|
%2 = extractvalue { %"github.com/goplus/llgo/runtime/internal/runtime.iface" } %1, 0
|
||||||
@@ -603,7 +603,7 @@ _llgo_0:
|
|||||||
|
|
||||||
declare i1 @"github.com/goplus/llgo/runtime/internal/runtime.StringEqual"(%"github.com/goplus/llgo/runtime/internal/runtime.String", %"github.com/goplus/llgo/runtime/internal/runtime.String")
|
declare i1 @"github.com/goplus/llgo/runtime/internal/runtime.StringEqual"(%"github.com/goplus/llgo/runtime/internal/runtime.String", %"github.com/goplus/llgo/runtime/internal/runtime.String")
|
||||||
|
|
||||||
define %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/cl/_testgo/ifaceprom.two$bound"(ptr %0) {
|
define %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/cl/_testgo/ifaceprom.I.two$bound"(ptr %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = load { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %0, align 8
|
%1 = load { %"github.com/goplus/llgo/runtime/internal/runtime.iface" }, ptr %0, align 8
|
||||||
%2 = extractvalue { %"github.com/goplus/llgo/runtime/internal/runtime.iface" } %1, 0
|
%2 = extractvalue { %"github.com/goplus/llgo/runtime/internal/runtime.iface" } %1, 0
|
||||||
|
|||||||
24
cl/_testgo/reflectfn/in.go
Normal file
24
cl/_testgo/reflectfn/in.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
func demo() {
|
||||||
|
println("demo")
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
v := 100
|
||||||
|
fn := func() {
|
||||||
|
println(v)
|
||||||
|
}
|
||||||
|
fdemo := demo
|
||||||
|
fmt.Println(fn)
|
||||||
|
fmt.Println(demo)
|
||||||
|
fmt.Println(fdemo)
|
||||||
|
fmt.Println(reflect.ValueOf(fn).UnsafePointer())
|
||||||
|
fmt.Println(reflect.ValueOf(demo).UnsafePointer())
|
||||||
|
fmt.Println(reflect.ValueOf(fdemo).UnsafePointer())
|
||||||
|
}
|
||||||
244
cl/_testgo/reflectfn/out.ll
Normal file
244
cl/_testgo/reflectfn/out.ll
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
; ModuleID = 'github.com/goplus/llgo/cl/_testgo/reflectfn'
|
||||||
|
source_filename = "github.com/goplus/llgo/cl/_testgo/reflectfn"
|
||||||
|
|
||||||
|
%"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 }
|
||||||
|
%"github.com/goplus/llgo/runtime/internal/runtime.eface" = type { ptr, ptr }
|
||||||
|
%"github.com/goplus/llgo/runtime/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||||
|
%"github.com/goplus/llgo/runtime/internal/runtime.iface" = type { ptr, ptr }
|
||||||
|
%reflect.Value = type { ptr, ptr, i64 }
|
||||||
|
%"github.com/goplus/llgo/runtime/abi.StructField" = type { %"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/runtime/internal/runtime.String", i1 }
|
||||||
|
|
||||||
|
@"github.com/goplus/llgo/cl/_testgo/reflectfn.init$guard" = global i1 false, align 1
|
||||||
|
@0 = private unnamed_addr constant [4 x i8] c"demo", align 1
|
||||||
|
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8
|
||||||
|
@_llgo_Pointer = linkonce global ptr null, align 8
|
||||||
|
@"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8" = linkonce global ptr null, align 8
|
||||||
|
@1 = private unnamed_addr constant [2 x i8] c"$f", align 1
|
||||||
|
@2 = private unnamed_addr constant [5 x i8] c"$data", align 1
|
||||||
|
@3 = private unnamed_addr constant [43 x i8] c"github.com/goplus/llgo/cl/_testgo/reflectfn", align 1
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testgo/reflectfn.demo"() {
|
||||||
|
_llgo_0:
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 4 })
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testgo/reflectfn.init"() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.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/reflectfn.init$guard", align 1
|
||||||
|
call void @fmt.init()
|
||||||
|
call void @reflect.init()
|
||||||
|
call void @"github.com/goplus/llgo/cl/_testgo/reflectfn.init$after"()
|
||||||
|
br label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testgo/reflectfn.main"() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 8)
|
||||||
|
store i64 100, ptr %0, align 4
|
||||||
|
%1 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||||
|
%2 = getelementptr inbounds { ptr }, ptr %1, i32 0, i32 0
|
||||||
|
store ptr %0, ptr %2, align 8
|
||||||
|
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.main$1", ptr undef }, ptr %1, 1
|
||||||
|
%4 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%5 = getelementptr inbounds %"github.com/goplus/llgo/runtime/internal/runtime.eface", ptr %4, i64 0
|
||||||
|
%6 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||||
|
%7 = load ptr, ptr @_llgo_Pointer, align 8
|
||||||
|
%8 = load ptr, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
%9 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store { ptr, ptr } %3, ptr %9, align 8
|
||||||
|
%10 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %8, 0
|
||||||
|
%11 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %10, ptr %9, 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %11, ptr %5, align 8
|
||||||
|
%12 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %4, 0
|
||||||
|
%13 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %12, i64 1, 1
|
||||||
|
%14 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %13, i64 1, 2
|
||||||
|
%15 = call { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %14)
|
||||||
|
%16 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%17 = getelementptr inbounds %"github.com/goplus/llgo/runtime/internal/runtime.eface", ptr %16, i64 0
|
||||||
|
%18 = load ptr, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
%19 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store { ptr, ptr } { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/reflectfn.demo", ptr null }, ptr %19, align 8
|
||||||
|
%20 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %18, 0
|
||||||
|
%21 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %20, ptr %19, 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %21, ptr %17, align 8
|
||||||
|
%22 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %16, 0
|
||||||
|
%23 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %22, i64 1, 1
|
||||||
|
%24 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %23, i64 1, 2
|
||||||
|
%25 = call { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %24)
|
||||||
|
%26 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%27 = getelementptr inbounds %"github.com/goplus/llgo/runtime/internal/runtime.eface", ptr %26, i64 0
|
||||||
|
%28 = load ptr, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
%29 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store { ptr, ptr } { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/reflectfn.demo", ptr null }, ptr %29, align 8
|
||||||
|
%30 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %28, 0
|
||||||
|
%31 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %30, ptr %29, 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %31, ptr %27, align 8
|
||||||
|
%32 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %26, 0
|
||||||
|
%33 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %32, i64 1, 1
|
||||||
|
%34 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %33, i64 1, 2
|
||||||
|
%35 = call { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %34)
|
||||||
|
%36 = load ptr, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
%37 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store { ptr, ptr } %3, ptr %37, align 8
|
||||||
|
%38 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %36, 0
|
||||||
|
%39 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %38, ptr %37, 1
|
||||||
|
%40 = call %reflect.Value @reflect.ValueOf(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %39)
|
||||||
|
%41 = call ptr @reflect.Value.UnsafePointer(%reflect.Value %40)
|
||||||
|
%42 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%43 = getelementptr inbounds %"github.com/goplus/llgo/runtime/internal/runtime.eface", ptr %42, i64 0
|
||||||
|
%44 = load ptr, ptr @_llgo_Pointer, align 8
|
||||||
|
%45 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %44, 0
|
||||||
|
%46 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %45, ptr %41, 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %46, ptr %43, align 8
|
||||||
|
%47 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %42, 0
|
||||||
|
%48 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %47, i64 1, 1
|
||||||
|
%49 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %48, i64 1, 2
|
||||||
|
%50 = call { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %49)
|
||||||
|
%51 = load ptr, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
%52 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store { ptr, ptr } { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/reflectfn.demo", ptr null }, ptr %52, align 8
|
||||||
|
%53 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %51, 0
|
||||||
|
%54 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %53, ptr %52, 1
|
||||||
|
%55 = call %reflect.Value @reflect.ValueOf(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %54)
|
||||||
|
%56 = call ptr @reflect.Value.UnsafePointer(%reflect.Value %55)
|
||||||
|
%57 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%58 = getelementptr inbounds %"github.com/goplus/llgo/runtime/internal/runtime.eface", ptr %57, i64 0
|
||||||
|
%59 = load ptr, ptr @_llgo_Pointer, align 8
|
||||||
|
%60 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %59, 0
|
||||||
|
%61 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %60, ptr %56, 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %61, ptr %58, align 8
|
||||||
|
%62 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %57, 0
|
||||||
|
%63 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %62, i64 1, 1
|
||||||
|
%64 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %63, i64 1, 2
|
||||||
|
%65 = call { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %64)
|
||||||
|
%66 = load ptr, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
%67 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store { ptr, ptr } { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/reflectfn.demo", ptr null }, ptr %67, align 8
|
||||||
|
%68 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %66, 0
|
||||||
|
%69 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %68, ptr %67, 1
|
||||||
|
%70 = call %reflect.Value @reflect.ValueOf(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %69)
|
||||||
|
%71 = call ptr @reflect.Value.UnsafePointer(%reflect.Value %70)
|
||||||
|
%72 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%73 = getelementptr inbounds %"github.com/goplus/llgo/runtime/internal/runtime.eface", ptr %72, i64 0
|
||||||
|
%74 = load ptr, ptr @_llgo_Pointer, align 8
|
||||||
|
%75 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %74, 0
|
||||||
|
%76 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %75, ptr %71, 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %76, ptr %73, align 8
|
||||||
|
%77 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %72, 0
|
||||||
|
%78 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %77, i64 1, 1
|
||||||
|
%79 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %78, i64 1, 2
|
||||||
|
%80 = call { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %79)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testgo/reflectfn.main$1"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = load { ptr }, ptr %0, align 8
|
||||||
|
%2 = extractvalue { ptr } %1, 0
|
||||||
|
%3 = load i64, ptr %2, align 4
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintInt"(i64 %3)
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String")
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8)
|
||||||
|
|
||||||
|
declare void @fmt.init()
|
||||||
|
|
||||||
|
declare void @reflect.init()
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testgo/reflectfn.init$after"() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||||
|
%1 = icmp eq ptr %0, null
|
||||||
|
br i1 %1, label %_llgo_1, label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_1: ; preds = %_llgo_0
|
||||||
|
%2 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||||
|
%3 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %2, 0
|
||||||
|
%4 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %3, i64 0, 1
|
||||||
|
%5 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %4, i64 0, 2
|
||||||
|
%6 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||||
|
%7 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %6, 0
|
||||||
|
%8 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %7, i64 0, 1
|
||||||
|
%9 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %8, i64 0, 2
|
||||||
|
%10 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Func"(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %5, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %9, i1 false)
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr %10)
|
||||||
|
store ptr %10, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||||
|
br label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
|
%11 = load ptr, ptr @_llgo_Pointer, align 8
|
||||||
|
%12 = icmp eq ptr %11, null
|
||||||
|
br i1 %12, label %_llgo_3, label %_llgo_4
|
||||||
|
|
||||||
|
_llgo_3: ; preds = %_llgo_2
|
||||||
|
%13 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 58)
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr %13)
|
||||||
|
store ptr %13, ptr @_llgo_Pointer, align 8
|
||||||
|
br label %_llgo_4
|
||||||
|
|
||||||
|
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||||
|
%14 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||||
|
%15 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %14, 0
|
||||||
|
%16 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %15, i64 0, 1
|
||||||
|
%17 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %16, i64 0, 2
|
||||||
|
%18 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||||
|
%19 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %18, 0
|
||||||
|
%20 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %19, i64 0, 1
|
||||||
|
%21 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %20, i64 0, 2
|
||||||
|
%22 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Func"(%"github.com/goplus/llgo/runtime/internal/runtime.Slice" %17, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %21, i1 false)
|
||||||
|
%23 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @1, i64 2 }, ptr %22, i64 0, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false)
|
||||||
|
%24 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 58)
|
||||||
|
%25 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 5 }, ptr %24, i64 8, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false)
|
||||||
|
%26 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 112)
|
||||||
|
%27 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %26, i64 0
|
||||||
|
store %"github.com/goplus/llgo/runtime/abi.StructField" %23, ptr %27, align 8
|
||||||
|
%28 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %26, i64 1
|
||||||
|
store %"github.com/goplus/llgo/runtime/abi.StructField" %25, ptr %28, align 8
|
||||||
|
%29 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %26, 0
|
||||||
|
%30 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %29, i64 2, 1
|
||||||
|
%31 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %30, i64 2, 2
|
||||||
|
%32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 43 }, i64 16, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %31)
|
||||||
|
store ptr %32, ptr @"github.com/goplus/llgo/cl/_testgo/reflectfn.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Func"(%"github.com/goplus/llgo/runtime/internal/runtime.Slice", %"github.com/goplus/llgo/runtime/internal/runtime.Slice", i1)
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr)
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64)
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String", i64, %"github.com/goplus/llgo/runtime/internal/runtime.Slice")
|
||||||
|
|
||||||
|
declare %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/runtime/internal/runtime.String", i1)
|
||||||
|
|
||||||
|
declare { i64, %"github.com/goplus/llgo/runtime/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/runtime/internal/runtime.Slice")
|
||||||
|
|
||||||
|
define linkonce void @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/reflectfn.demo"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
tail call void @"github.com/goplus/llgo/cl/_testgo/reflectfn.demo"()
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare %reflect.Value @reflect.ValueOf(%"github.com/goplus/llgo/runtime/internal/runtime.eface")
|
||||||
|
|
||||||
|
declare ptr @reflect.Value.UnsafePointer(%reflect.Value)
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintInt"(i64)
|
||||||
@@ -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/runtime/internal/runtime.String" = type { ptr, i64 }
|
||||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[error]" = type { ptr, ptr }
|
%"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/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.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" = type { ptr, ptr }
|
||||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" = 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
|
@"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"() {
|
define void @"github.com/goplus/llgo/cl/_testgo/tpnamed.main"() {
|
||||||
_llgo_0:
|
_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
|
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:
|
_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"() {
|
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
|
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:
|
_llgo_0:
|
||||||
%1 = tail call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$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[[0]byte]" %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:
|
_llgo_0:
|
||||||
%1 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0, 1
|
%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[[0]byte]" %0, 0
|
%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[[0]byte]" %2(ptr %1)
|
%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[[0]byte]" %3, 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[[0]byte]" %3, 0
|
%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)
|
%6 = call [0 x i8] %5(ptr %4)
|
||||||
ret [0 x i8] %6
|
ret [0 x i8] %6
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
@"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
|
||||||
@"*_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_string = linkonce global ptr null, align 8
|
||||||
@_llgo_int = 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
|
@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
|
_llgo_2: ; preds = %_llgo_0
|
||||||
%6 = load ptr, ptr @_llgo_string, align 8
|
%6 = load ptr, ptr @_llgo_string, align 8
|
||||||
%7 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
%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
|
%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
|
%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)
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %9)
|
||||||
|
|||||||
25
cl/_testrt/closurebound/in.go
Normal file
25
cl/_testrt/closurebound/in.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
se := demo1{}
|
||||||
|
f := se.encode
|
||||||
|
if f() != 1 {
|
||||||
|
panic("error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var my = demo2{}.encode
|
||||||
|
|
||||||
|
type demo1 struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (se demo1) encode() int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
type demo2 struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (se demo2) encode() int {
|
||||||
|
return 2
|
||||||
|
}
|
||||||
117
cl/_testrt/closurebound/out.ll
Normal file
117
cl/_testrt/closurebound/out.ll
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
; ModuleID = 'github.com/goplus/llgo/cl/_testrt/closurebound'
|
||||||
|
source_filename = "github.com/goplus/llgo/cl/_testrt/closurebound"
|
||||||
|
|
||||||
|
%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" = type {}
|
||||||
|
%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" = type {}
|
||||||
|
%"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 }
|
||||||
|
%"github.com/goplus/llgo/runtime/internal/runtime.eface" = type { ptr, ptr }
|
||||||
|
|
||||||
|
@"github.com/goplus/llgo/cl/_testrt/closurebound.init$guard" = global i1 false, align 1
|
||||||
|
@"github.com/goplus/llgo/cl/_testrt/closurebound.my" = global { ptr, ptr } zeroinitializer, align 8
|
||||||
|
@0 = private unnamed_addr constant [5 x i8] c"error", align 1
|
||||||
|
@_llgo_string = linkonce global ptr null, align 8
|
||||||
|
|
||||||
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" %0) {
|
||||||
|
_llgo_0:
|
||||||
|
ret i64 1
|
||||||
|
}
|
||||||
|
|
||||||
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.(*demo1).encode"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = load %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1", ptr %0, align 1
|
||||||
|
%2 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" %1)
|
||||||
|
ret i64 %2
|
||||||
|
}
|
||||||
|
|
||||||
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" %0) {
|
||||||
|
_llgo_0:
|
||||||
|
ret i64 2
|
||||||
|
}
|
||||||
|
|
||||||
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.(*demo2).encode"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = load %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2", ptr %0, align 1
|
||||||
|
%2 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" %1)
|
||||||
|
ret i64 %2
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testrt/closurebound.init"() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.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/_testrt/closurebound.init$guard", align 1
|
||||||
|
call void @"github.com/goplus/llgo/cl/_testrt/closurebound.init$after"()
|
||||||
|
%1 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||||
|
%2 = getelementptr inbounds { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" }, ptr %1, i32 0, i32 0
|
||||||
|
store %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" zeroinitializer, ptr %2, align 1
|
||||||
|
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode$bound", ptr undef }, ptr %1, 1
|
||||||
|
store { ptr, ptr } %3, ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.my", align 8
|
||||||
|
br label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testrt/closurebound.main"() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0)
|
||||||
|
%1 = getelementptr inbounds { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" }, ptr %0, i32 0, i32 0
|
||||||
|
store %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" zeroinitializer, ptr %1, align 1
|
||||||
|
%2 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode$bound", ptr undef }, ptr %0, 1
|
||||||
|
%3 = extractvalue { ptr, ptr } %2, 1
|
||||||
|
%4 = extractvalue { ptr, ptr } %2, 0
|
||||||
|
%5 = call i64 %4(ptr %3)
|
||||||
|
%6 = icmp ne i64 %5, 1
|
||||||
|
br i1 %6, label %_llgo_1, label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_1: ; preds = %_llgo_0
|
||||||
|
%7 = load ptr, ptr @_llgo_string, align 8
|
||||||
|
%8 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||||
|
store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 5 }, ptr %8, align 8
|
||||||
|
%9 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %7, 0
|
||||||
|
%10 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %9, ptr %8, 1
|
||||||
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %10)
|
||||||
|
unreachable
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode$bound"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = load { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" }, ptr %0, align 1
|
||||||
|
%2 = extractvalue { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" } %1, 0
|
||||||
|
%3 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo2.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo2" %2)
|
||||||
|
ret i64 %3
|
||||||
|
}
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
||||||
|
|
||||||
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode$bound"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = load { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" }, ptr %0, align 1
|
||||||
|
%2 = extractvalue { %"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" } %1, 0
|
||||||
|
%3 = call i64 @"github.com/goplus/llgo/cl/_testrt/closurebound.demo1.encode"(%"github.com/goplus/llgo/cl/_testrt/closurebound.demo1" %2)
|
||||||
|
ret i64 %3
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/_testrt/closurebound.init$after"() {
|
||||||
|
_llgo_0:
|
||||||
|
%0 = load ptr, ptr @_llgo_string, align 8
|
||||||
|
%1 = icmp eq ptr %0, null
|
||||||
|
br i1 %1, label %_llgo_1, label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_1: ; preds = %_llgo_0
|
||||||
|
%2 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 24)
|
||||||
|
store ptr %2, ptr @_llgo_string, align 8
|
||||||
|
br label %_llgo_2
|
||||||
|
|
||||||
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64)
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface")
|
||||||
@@ -29,7 +29,7 @@ _llgo_0:
|
|||||||
%3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
%3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||||
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
||||||
store ptr %1, ptr %4, align 8
|
store ptr %1, ptr %4, align 8
|
||||||
%5 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.add$bound", ptr undef }, ptr %3, 1
|
%5 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.(*Call).add$bound", ptr undef }, ptr %3, 1
|
||||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/closureconv.Call", ptr %1, i32 0, i32 0
|
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/closureconv.Call", ptr %1, i32 0, i32 0
|
||||||
%7 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", align 8
|
%7 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", align 8
|
||||||
store { ptr, ptr } %5, ptr %7, align 8
|
store { ptr, ptr } %5, ptr %7, align 8
|
||||||
@@ -46,7 +46,7 @@ _llgo_0:
|
|||||||
%1 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
%1 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||||
%2 = getelementptr inbounds { ptr }, ptr %1, i32 0, i32 0
|
%2 = getelementptr inbounds { ptr }, ptr %1, i32 0, i32 0
|
||||||
store ptr %0, ptr %2, align 8
|
store ptr %0, ptr %2, align 8
|
||||||
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.add$bound", ptr undef }, ptr %1, 1
|
%3 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/closureconv.(*Call).add$bound", ptr undef }, ptr %1, 1
|
||||||
%4 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", align 8
|
%4 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", align 8
|
||||||
store { ptr, ptr } %3, ptr %4, align 8
|
store { ptr, ptr } %3, ptr %4, align 8
|
||||||
%5 = load %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", ptr %4, align 8
|
%5 = load %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", ptr %4, align 8
|
||||||
@@ -158,7 +158,7 @@ _llgo_0:
|
|||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
||||||
|
|
||||||
define i64 @"github.com/goplus/llgo/cl/_testrt/closureconv.add$bound"(ptr %0, i64 %1, i64 %2) {
|
define i64 @"github.com/goplus/llgo/cl/_testrt/closureconv.(*Call).add$bound"(ptr %0, i64 %1, i64 %2) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%3 = load { ptr }, ptr %0, align 8
|
%3 = load { ptr }, ptr %0, align 8
|
||||||
%4 = extractvalue { ptr } %3, 0
|
%4 = extractvalue { ptr } %3, 0
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ _llgo_6: ; preds = %_llgo_4
|
|||||||
%32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
%32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
||||||
%33 = getelementptr inbounds { ptr }, ptr %32, i32 0, i32 0
|
%33 = getelementptr inbounds { ptr }, ptr %32, i32 0, i32 0
|
||||||
store ptr %30, ptr %33, align 8
|
store ptr %30, ptr %33, align 8
|
||||||
%34 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/intgen.next$bound", ptr undef }, ptr %32, 1
|
%34 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next$bound", ptr undef }, ptr %32, 1
|
||||||
%35 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 5, { ptr, ptr } %34)
|
%35 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 5, { ptr, ptr } %34)
|
||||||
%36 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 1
|
%36 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 1
|
||||||
br label %_llgo_7
|
br label %_llgo_7
|
||||||
@@ -182,7 +182,7 @@ declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
|||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
||||||
|
|
||||||
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.next$bound"(ptr %0) {
|
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next$bound"(ptr %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = load { ptr }, ptr %0, align 8
|
%1 = load { ptr }, ptr %0, align 8
|
||||||
%2 = extractvalue { ptr } %1, 0
|
%2 = extractvalue { ptr } %1, 0
|
||||||
|
|||||||
@@ -402,6 +402,10 @@ func funcName(pkg *types.Package, fn *ssa.Function, org bool) string {
|
|||||||
recv = parent.Signature.Recv()
|
recv = parent.Signature.Recv()
|
||||||
} else {
|
} else {
|
||||||
recv = fn.Signature.Recv()
|
recv = fn.Signature.Recv()
|
||||||
|
// check $bound
|
||||||
|
if recv == nil && strings.HasSuffix(fn.Name(), "$bound") && len(fn.FreeVars) == 1 {
|
||||||
|
recv = types.NewVar(token.NoPos, nil, "", fn.FreeVars[0].Type())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var fnName string
|
var fnName string
|
||||||
if org := fn.Origin(); org != nil {
|
if org := fn.Origin(); org != nil {
|
||||||
|
|||||||
82
cmd/internal/base/pass.go
Normal file
82
cmd/internal/base/pass.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package base
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type stringValue struct {
|
||||||
|
p *PassArgs
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *stringValue) String() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *stringValue) Set(v string) error {
|
||||||
|
p.p.Args = append(p.p.Args, fmt.Sprintf("-%v=%v", p.name, v))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type boolValue struct {
|
||||||
|
p *PassArgs
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *boolValue) String() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *boolValue) Set(v string) error {
|
||||||
|
p.p.Args = append(p.p.Args, fmt.Sprintf("-%v=%v", p.name, v))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *boolValue) IsBoolFlag() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
type PassArgs struct {
|
||||||
|
Args []string
|
||||||
|
Flag *flag.FlagSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PassArgs) Tags() string {
|
||||||
|
for _, v := range p.Args {
|
||||||
|
if strings.HasPrefix(v, "-tags=") {
|
||||||
|
return v[6:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PassArgs) Var(names ...string) {
|
||||||
|
for _, name := range names {
|
||||||
|
p.Flag.Var(&stringValue{p: p, name: name}, name, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PassArgs) Bool(names ...string) {
|
||||||
|
for _, name := range names {
|
||||||
|
p.Flag.Var(&boolValue{p: p, name: name}, name, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPassArgs(flag *flag.FlagSet) *PassArgs {
|
||||||
|
p := &PassArgs{Flag: flag}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func PassBuildFlags(cmd *Command) *PassArgs {
|
||||||
|
p := NewPassArgs(&cmd.Flag)
|
||||||
|
p.Bool("n", "x")
|
||||||
|
p.Bool("a")
|
||||||
|
p.Bool("linkshared", "race", "msan", "asan",
|
||||||
|
"trimpath", "work")
|
||||||
|
p.Var("p", "asmflags", "compiler", "buildmode",
|
||||||
|
"gcflags", "gccgoflags", "installsuffix",
|
||||||
|
"ldflags", "pkgdir", "toolexec", "buildvcs")
|
||||||
|
return p
|
||||||
|
}
|
||||||
@@ -35,13 +35,15 @@ var Cmd = &base.Command{
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Cmd.Run = runCmd
|
Cmd.Run = runCmd
|
||||||
|
base.PassBuildFlags(Cmd)
|
||||||
flags.AddBuildFlags(&Cmd.Flag)
|
flags.AddBuildFlags(&Cmd.Flag)
|
||||||
flags.AddOutputFlags(&Cmd.Flag)
|
flags.AddOutputFlags(&Cmd.Flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(cmd *base.Command, args []string) {
|
func runCmd(cmd *base.Command, args []string) {
|
||||||
|
|
||||||
if err := cmd.Flag.Parse(args); err != nil {
|
if err := cmd.Flag.Parse(args); err != nil {
|
||||||
panic(err)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := build.NewDefaultConf(build.ModeBuild)
|
conf := build.NewDefaultConf(build.ModeBuild)
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(cmd *base.Command, args []string) {
|
func runCmd(cmd *base.Command, args []string) {
|
||||||
|
|
||||||
if err := cmd.Flag.Parse(args); err != nil {
|
if err := cmd.Flag.Parse(args); err != nil {
|
||||||
panic(err)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := build.NewDefaultConf(0)
|
conf := build.NewDefaultConf(0)
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(cmd *base.Command, args []string) {
|
func runCmd(cmd *base.Command, args []string) {
|
||||||
|
|
||||||
if err := cmd.Flag.Parse(args); err != nil {
|
if err := cmd.Flag.Parse(args); err != nil {
|
||||||
panic(err)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := build.NewDefaultConf(build.ModeInstall)
|
conf := build.NewDefaultConf(build.ModeInstall)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ var CmpTestCmd = &base.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
Cmd.Run = runCmd
|
Cmd.Run = runCmd
|
||||||
CmpTestCmd.Run = runCmpTest
|
CmpTestCmd.Run = runCmpTest
|
||||||
|
base.PassBuildFlags(Cmd)
|
||||||
flags.AddBuildFlags(&Cmd.Flag)
|
flags.AddBuildFlags(&Cmd.Flag)
|
||||||
flags.AddBuildFlags(&CmpTestCmd.Flag)
|
flags.AddBuildFlags(&CmpTestCmd.Flag)
|
||||||
flags.AddCmpTestFlags(&CmpTestCmd.Flag)
|
flags.AddCmpTestFlags(&CmpTestCmd.Flag)
|
||||||
@@ -61,8 +62,9 @@ func runCmpTest(cmd *base.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCmdEx(cmd *base.Command, args []string, mode build.Mode) {
|
func runCmdEx(cmd *base.Command, args []string, mode build.Mode) {
|
||||||
|
|
||||||
if err := cmd.Flag.Parse(args); err != nil {
|
if err := cmd.Flag.Parse(args); err != nil {
|
||||||
panic(err)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := build.NewDefaultConf(mode)
|
conf := build.NewDefaultConf(mode)
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(cmd *base.Command, args []string) {
|
func runCmd(cmd *base.Command, args []string) {
|
||||||
|
|
||||||
if err := cmd.Flag.Parse(args); err != nil {
|
if err := cmd.Flag.Parse(args); err != nil {
|
||||||
panic(err)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := build.NewDefaultConf(build.ModeTest)
|
conf := build.NewDefaultConf(build.ModeTest)
|
||||||
|
|||||||
28
cmd/llgo/build_cmd.gox
Normal file
28
cmd/llgo/build_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
self "github.com/goplus/llgo/cmd/internal/build"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "build [flags] [packages]"
|
||||||
|
|
||||||
|
short "Compile packages and dependencies"
|
||||||
|
|
||||||
|
flagOff
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
self.Cmd.Run self.Cmd, args
|
||||||
|
}
|
||||||
28
cmd/llgo/clean_cmd.gox
Normal file
28
cmd/llgo/clean_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
self "github.com/goplus/llgo/cmd/internal/clean"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "clean [flags] [packages]"
|
||||||
|
|
||||||
|
short "Remove object files and cached files"
|
||||||
|
|
||||||
|
flagOff
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
self.Cmd.Run self.Cmd, args
|
||||||
|
}
|
||||||
28
cmd/llgo/cmptest_cmd.gox
Normal file
28
cmd/llgo/cmptest_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
self "github.com/goplus/llgo/cmd/internal/run"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "cmptest [flags] package [arguments...]"
|
||||||
|
|
||||||
|
short "Compile and run with llgo, compare result (stdout/stderr/exitcode) with go or llgo.expect; generate llgo.expect file if -gen is specified"
|
||||||
|
|
||||||
|
flagOff
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
self.CmpTestCmd.Run self.CmpTestCmd, args
|
||||||
|
}
|
||||||
22
cmd/llgo/get_cmd.gox
Normal file
22
cmd/llgo/get_cmd.gox
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use "get [flags] [packages]"
|
||||||
|
|
||||||
|
short "Add dependencies to current module and install them"
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
panic "todo"
|
||||||
|
}
|
||||||
213
cmd/llgo/gop_autogen.go
Normal file
213
cmd/llgo/gop_autogen.go
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
// Code generated by gop (Go+); DO NOT EDIT.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/goplus/cobra/xcmd"
|
||||||
|
"github.com/goplus/llgo/cmd/internal/build"
|
||||||
|
"github.com/goplus/llgo/cmd/internal/clean"
|
||||||
|
"github.com/goplus/llgo/cmd/internal/install"
|
||||||
|
"github.com/goplus/llgo/cmd/internal/run"
|
||||||
|
"github.com/goplus/llgo/cmd/internal/test"
|
||||||
|
"github.com/goplus/llgo/internal/env"
|
||||||
|
"github.com/qiniu/x/stringutil"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
const _ = true
|
||||||
|
|
||||||
|
type Cmd_build struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type Cmd_clean struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type Cmd_cmptest struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type Cmd_get struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type Cmd_install struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type App struct {
|
||||||
|
xcmd.App
|
||||||
|
}
|
||||||
|
type Cmd_run struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type Cmd_test struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
type Cmd_version struct {
|
||||||
|
xcmd.Command
|
||||||
|
*App
|
||||||
|
}
|
||||||
|
//line cmd/llgo/main_app.gox:1
|
||||||
|
func (this *App) MainEntry() {
|
||||||
|
//line cmd/llgo/main_app.gox:1:1
|
||||||
|
this.Short(`llgo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python.`)
|
||||||
|
}
|
||||||
|
func (this *App) Main() {
|
||||||
|
_gop_obj0 := &Cmd_build{App: this}
|
||||||
|
_gop_obj1 := &Cmd_clean{App: this}
|
||||||
|
_gop_obj2 := &Cmd_cmptest{App: this}
|
||||||
|
_gop_obj3 := &Cmd_get{App: this}
|
||||||
|
_gop_obj4 := &Cmd_install{App: this}
|
||||||
|
_gop_obj5 := &Cmd_run{App: this}
|
||||||
|
_gop_obj6 := &Cmd_test{App: this}
|
||||||
|
_gop_obj7 := &Cmd_version{App: this}
|
||||||
|
xcmd.Gopt_App_Main(this, _gop_obj0, _gop_obj1, _gop_obj2, _gop_obj3, _gop_obj4, _gop_obj5, _gop_obj6, _gop_obj7)
|
||||||
|
}
|
||||||
|
//line cmd/llgo/build_cmd.gox:20
|
||||||
|
func (this *Cmd_build) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/build_cmd.gox:20:1
|
||||||
|
this.Use("build [flags] [packages]")
|
||||||
|
//line cmd/llgo/build_cmd.gox:22:1
|
||||||
|
this.Short("Compile packages and dependencies")
|
||||||
|
//line cmd/llgo/build_cmd.gox:24:1
|
||||||
|
this.FlagOff()
|
||||||
|
//line cmd/llgo/build_cmd.gox:26:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/build_cmd.gox:27:1
|
||||||
|
build.Cmd.Run(build.Cmd, args)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_build) Classfname() string {
|
||||||
|
return "build"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/clean_cmd.gox:20
|
||||||
|
func (this *Cmd_clean) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/clean_cmd.gox:20:1
|
||||||
|
this.Use("clean [flags] [packages]")
|
||||||
|
//line cmd/llgo/clean_cmd.gox:22:1
|
||||||
|
this.Short("Remove object files and cached files")
|
||||||
|
//line cmd/llgo/clean_cmd.gox:24:1
|
||||||
|
this.FlagOff()
|
||||||
|
//line cmd/llgo/clean_cmd.gox:26:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/clean_cmd.gox:27:1
|
||||||
|
clean.Cmd.Run(clean.Cmd, args)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_clean) Classfname() string {
|
||||||
|
return "clean"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/cmptest_cmd.gox:20
|
||||||
|
func (this *Cmd_cmptest) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/cmptest_cmd.gox:20:1
|
||||||
|
this.Use("cmptest [flags] package [arguments...]")
|
||||||
|
//line cmd/llgo/cmptest_cmd.gox:22:1
|
||||||
|
this.Short("Compile and run with llgo, compare result (stdout/stderr/exitcode) with go or llgo.expect; generate llgo.expect file if -gen is specified")
|
||||||
|
//line cmd/llgo/cmptest_cmd.gox:24:1
|
||||||
|
this.FlagOff()
|
||||||
|
//line cmd/llgo/cmptest_cmd.gox:26:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/cmptest_cmd.gox:27:1
|
||||||
|
run.CmpTestCmd.Run(run.CmpTestCmd, args)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_cmptest) Classfname() string {
|
||||||
|
return "cmptest"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/get_cmd.gox:16
|
||||||
|
func (this *Cmd_get) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/get_cmd.gox:16:1
|
||||||
|
this.Use("get [flags] [packages]")
|
||||||
|
//line cmd/llgo/get_cmd.gox:18:1
|
||||||
|
this.Short("Add dependencies to current module and install them")
|
||||||
|
//line cmd/llgo/get_cmd.gox:20:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/get_cmd.gox:21:1
|
||||||
|
panic("todo")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_get) Classfname() string {
|
||||||
|
return "get"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/install_cmd.gox:20
|
||||||
|
func (this *Cmd_install) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/install_cmd.gox:20:1
|
||||||
|
this.Use("install [flags] [packages]")
|
||||||
|
//line cmd/llgo/install_cmd.gox:22:1
|
||||||
|
this.Short("Compile and install packages and dependencies")
|
||||||
|
//line cmd/llgo/install_cmd.gox:24:1
|
||||||
|
this.FlagOff()
|
||||||
|
//line cmd/llgo/install_cmd.gox:26:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/install_cmd.gox:27:1
|
||||||
|
install.Cmd.Run(install.Cmd, args)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_install) Classfname() string {
|
||||||
|
return "install"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/run_cmd.gox:20
|
||||||
|
func (this *Cmd_run) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/run_cmd.gox:20:1
|
||||||
|
this.Use("run [flags] package [arguments...]")
|
||||||
|
//line cmd/llgo/run_cmd.gox:22:1
|
||||||
|
this.Short("Compile and run Go program")
|
||||||
|
//line cmd/llgo/run_cmd.gox:24:1
|
||||||
|
this.FlagOff()
|
||||||
|
//line cmd/llgo/run_cmd.gox:26:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/run_cmd.gox:27:1
|
||||||
|
run.Cmd.Run(run.Cmd, args)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_run) Classfname() string {
|
||||||
|
return "run"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/test_cmd.gox:20
|
||||||
|
func (this *Cmd_test) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/test_cmd.gox:20:1
|
||||||
|
this.Use("test [flags] package [arguments...]")
|
||||||
|
//line cmd/llgo/test_cmd.gox:22:1
|
||||||
|
this.Short("Compile and run Go test")
|
||||||
|
//line cmd/llgo/test_cmd.gox:24:1
|
||||||
|
this.FlagOff()
|
||||||
|
//line cmd/llgo/test_cmd.gox:26:1
|
||||||
|
this.Run__1(func(args []string) {
|
||||||
|
//line cmd/llgo/test_cmd.gox:27:1
|
||||||
|
test.Cmd.Run(test.Cmd, args)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_test) Classfname() string {
|
||||||
|
return "test"
|
||||||
|
}
|
||||||
|
//line cmd/llgo/version_cmd.gox:22
|
||||||
|
func (this *Cmd_version) Main(_gop_arg0 string) {
|
||||||
|
this.Command.Main(_gop_arg0)
|
||||||
|
//line cmd/llgo/version_cmd.gox:22:1
|
||||||
|
this.Use("version")
|
||||||
|
//line cmd/llgo/version_cmd.gox:24:1
|
||||||
|
this.Short("Print LLGo version")
|
||||||
|
//line cmd/llgo/version_cmd.gox:26:1
|
||||||
|
this.Run__0(func() {
|
||||||
|
//line cmd/llgo/version_cmd.gox:27:1
|
||||||
|
fmt.Println(stringutil.Concat("llgo ", env.Version(), " ", runtime.GOOS, "/", runtime.GOARCH))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (this *Cmd_version) Classfname() string {
|
||||||
|
return "version"
|
||||||
|
}
|
||||||
|
func main() {
|
||||||
|
new(App).Main()
|
||||||
|
}
|
||||||
28
cmd/llgo/install_cmd.gox
Normal file
28
cmd/llgo/install_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
self "github.com/goplus/llgo/cmd/internal/install"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "install [flags] [packages]"
|
||||||
|
|
||||||
|
short "Compile and install packages and dependencies"
|
||||||
|
|
||||||
|
flagOff
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
self.Cmd.Run self.Cmd, args
|
||||||
|
}
|
||||||
1
cmd/llgo/main_app.gox
Normal file
1
cmd/llgo/main_app.gox
Normal file
@@ -0,0 +1 @@
|
|||||||
|
short `llgo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python.`
|
||||||
28
cmd/llgo/run_cmd.gox
Normal file
28
cmd/llgo/run_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
self "github.com/goplus/llgo/cmd/internal/run"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "run [flags] package [arguments...]"
|
||||||
|
|
||||||
|
short "Compile and run Go program"
|
||||||
|
|
||||||
|
flagOff
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
self.Cmd.Run self.Cmd, args
|
||||||
|
}
|
||||||
28
cmd/llgo/test_cmd.gox
Normal file
28
cmd/llgo/test_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
self "github.com/goplus/llgo/cmd/internal/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "test [flags] package [arguments...]"
|
||||||
|
|
||||||
|
short "Compile and run Go test"
|
||||||
|
|
||||||
|
flagOff
|
||||||
|
|
||||||
|
run args => {
|
||||||
|
self.Cmd.Run self.Cmd, args
|
||||||
|
}
|
||||||
28
cmd/llgo/version_cmd.gox
Normal file
28
cmd/llgo/version_cmd.gox
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"github.com/goplus/llgo/internal/env"
|
||||||
|
)
|
||||||
|
|
||||||
|
use "version"
|
||||||
|
|
||||||
|
short "Print LLGo version"
|
||||||
|
|
||||||
|
run => {
|
||||||
|
echo "llgo ${env.version} ${runtime.GOOS}/${runtime.GOARCH}"
|
||||||
|
}
|
||||||
11
go.mod
11
go.mod
@@ -1,16 +1,17 @@
|
|||||||
module github.com/goplus/llgo
|
module github.com/goplus/llgo
|
||||||
|
|
||||||
go 1.22.0
|
go 1.23
|
||||||
|
|
||||||
toolchain go1.24.1
|
toolchain go1.24.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/goplus/gogen v1.17.2
|
github.com/goplus/cobra v1.9.12 //gop:class
|
||||||
|
github.com/goplus/gogen v1.18.1
|
||||||
github.com/goplus/lib v0.2.0
|
github.com/goplus/lib v0.2.0
|
||||||
github.com/goplus/llgo/runtime v0.0.0-20250403035532-0a8a4eb6a653
|
github.com/goplus/llgo/runtime v0.0.0-00010101000000-000000000000
|
||||||
github.com/goplus/llvm v0.8.3
|
github.com/goplus/llvm v0.8.3
|
||||||
github.com/goplus/mod v0.16.0
|
github.com/goplus/mod v0.16.1
|
||||||
github.com/qiniu/x v1.13.19
|
github.com/qiniu/x v1.14.6
|
||||||
golang.org/x/tools v0.30.0
|
golang.org/x/tools v0.30.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
14
go.sum
14
go.sum
@@ -1,15 +1,17 @@
|
|||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/goplus/gogen v1.17.2 h1:oQDWiVzZmDAdgNieJnrvrWTmxDTqYXGFMBa2rAbwjmA=
|
github.com/goplus/cobra v1.9.12 h1:0F9EdEbeGyITGz+mqoHoJ5KpUw97p1CkxV74IexHw5s=
|
||||||
github.com/goplus/gogen v1.17.2/go.mod h1:owX2e1EyU5WD+Nm6oH2m/GXjLdlBYcwkLO4wN8HHXZI=
|
github.com/goplus/cobra v1.9.12/go.mod h1:p4LhfNJDKEpiGjGiNn0crUXL5dUPA5DX2ztYpEJR34E=
|
||||||
|
github.com/goplus/gogen v1.18.1 h1:ys18IiQwQ4QeQ3Mmk4vzql0Yfr6r+hkkQdjaL/M0Isc=
|
||||||
|
github.com/goplus/gogen v1.18.1/go.mod h1:owX2e1EyU5WD+Nm6oH2m/GXjLdlBYcwkLO4wN8HHXZI=
|
||||||
github.com/goplus/lib v0.2.0 h1:AjqkN1XK5H23wZMMlpaUYAMCDAdSBQ2NMFrLtSh7W4g=
|
github.com/goplus/lib v0.2.0 h1:AjqkN1XK5H23wZMMlpaUYAMCDAdSBQ2NMFrLtSh7W4g=
|
||||||
github.com/goplus/lib v0.2.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=
|
github.com/goplus/lib v0.2.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=
|
||||||
github.com/goplus/llvm v0.8.3 h1:is1zOwhiQZWtLnOmSMVPO+1sPa2uK/XJ/FjTSfIjGBU=
|
github.com/goplus/llvm v0.8.3 h1:is1zOwhiQZWtLnOmSMVPO+1sPa2uK/XJ/FjTSfIjGBU=
|
||||||
github.com/goplus/llvm v0.8.3/go.mod h1:PeVK8GgzxwAYCiMiUAJb5wJR6xbhj989tu9oulKLLT4=
|
github.com/goplus/llvm v0.8.3/go.mod h1:PeVK8GgzxwAYCiMiUAJb5wJR6xbhj989tu9oulKLLT4=
|
||||||
github.com/goplus/mod v0.16.0 h1:5CHXx3no7YaMN5HN2sgZe9MbQnc8118JLjbOeetSTfc=
|
github.com/goplus/mod v0.16.1 h1:2O+rKubJTn+Fighz3kckwpW87STSZ6s3m/YECfXuNhE=
|
||||||
github.com/goplus/mod v0.16.0/go.mod h1:U69PUD2e1MnI2DYhuumj1Z6wvZ1bNbKqHUk1MK8Diqo=
|
github.com/goplus/mod v0.16.1/go.mod h1:8d1P+pBavZfNQtJo4A742DgsLTtSf26BQn51owhmNqI=
|
||||||
github.com/qiniu/x v1.13.19 h1:rZzWpifNjMtaMhhVnYHw9RGUn+84KGtclDZ9HAKtuZQ=
|
github.com/qiniu/x v1.14.6 h1:JY8jOumYFshuqNAjVkF6zsYhbcwM8A199ALkUOvJPks=
|
||||||
github.com/qiniu/x v1.13.19/go.mod h1:AiovSOCaRijaf3fj+0CBOpR1457pn24b0Vdb1JpwhII=
|
github.com/qiniu/x v1.14.6/go.mod h1:AiovSOCaRijaf3fj+0CBOpR1457pn24b0Vdb1JpwhII=
|
||||||
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
|
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
|
||||||
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||||
|
|||||||
@@ -87,12 +87,6 @@ func Remove(path *c.Char) c.Int
|
|||||||
//go:linkname Rename C.rename
|
//go:linkname Rename C.rename
|
||||||
func Rename(oldpath *c.Char, newpath *c.Char) c.Int
|
func Rename(oldpath *c.Char, newpath *c.Char) c.Int
|
||||||
|
|
||||||
//go:linkname Stat C.stat
|
|
||||||
func Stat(path *c.Char, buf *StatT) c.Int
|
|
||||||
|
|
||||||
//go:linkname Lstat C.lstat
|
|
||||||
func Lstat(path *c.Char, buf *StatT) c.Int
|
|
||||||
|
|
||||||
//go:linkname Truncate C.truncate
|
//go:linkname Truncate C.truncate
|
||||||
func Truncate(path *c.Char, length OffT) c.Int
|
func Truncate(path *c.Char, length OffT) c.Int
|
||||||
|
|
||||||
@@ -285,7 +279,7 @@ func Exit(c.Int)
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Upon successful completion, the value 0 is returned; otherwise the value -1
|
// Upon successful completion, the value 0 is returned; otherwise the value -1
|
||||||
// is returned and the global variable errno is set to indicate the error.
|
// is returned and the global variable errno is set to indicate the error.
|
||||||
//
|
//
|
||||||
//go:linkname Sysctl C.sysctl
|
//go:linkname Sysctl C.sysctl
|
||||||
|
|||||||
16
runtime/internal/clite/os/stat.go
Normal file
16
runtime/internal/clite/os/stat.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//go:build !darwin
|
||||||
|
// +build !darwin
|
||||||
|
|
||||||
|
package os
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "unsafe"
|
||||||
|
|
||||||
|
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname Stat C.stat
|
||||||
|
func Stat(path *c.Char, buf *StatT) c.Int
|
||||||
|
|
||||||
|
//go:linkname Lstat C.lstat
|
||||||
|
func Lstat(path *c.Char, buf *StatT) c.Int
|
||||||
13
runtime/internal/clite/os/stat_darwin.go
Normal file
13
runtime/internal/clite/os/stat_darwin.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package os
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "unsafe"
|
||||||
|
|
||||||
|
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname Stat C.stat64
|
||||||
|
func Stat(path *c.Char, buf *StatT) c.Int
|
||||||
|
|
||||||
|
//go:linkname Lstat C.lstat64
|
||||||
|
func Lstat(path *c.Char, buf *StatT) c.Int
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"structs"
|
"structs"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
@@ -297,11 +296,19 @@ func joinPath(dir, file string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isAbs(path string) bool {
|
func isAbs(path string) bool {
|
||||||
return strings.HasPrefix(path, "/")
|
return hasPrefix(path, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDir(path string) bool {
|
func isDir(path string) bool {
|
||||||
return strings.HasSuffix(path, "/")
|
return hasSuffix(path, "/")
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasPrefix(s, prefix string) bool {
|
||||||
|
return len(s) >= len(prefix) && s[:len(prefix)] == prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasSuffix(s, suffix string) bool {
|
||||||
|
return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stat_t struct {
|
type Stat_t struct {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LLGoPackage = "noinit"
|
LLGoPackage = true
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -74,3 +74,25 @@ func Kill(pid int, signum Signal) error {
|
|||||||
func ProcExit(code int32) {
|
func ProcExit(code int32) {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _utoa(buf []byte, val uint64) []byte {
|
||||||
|
i := len(buf) - 1
|
||||||
|
for val >= 10 {
|
||||||
|
buf[i] = byte(val%10 + '0')
|
||||||
|
i--
|
||||||
|
val /= 10
|
||||||
|
}
|
||||||
|
buf[i] = byte(val + '0')
|
||||||
|
return buf[i:]
|
||||||
|
}
|
||||||
|
|
||||||
|
func utoa(val uint64) string {
|
||||||
|
return string(_utoa(make([]byte, 20), val))
|
||||||
|
}
|
||||||
|
|
||||||
|
func itoa(val int64) string {
|
||||||
|
if val < 0 {
|
||||||
|
return "-" + string(_utoa(make([]byte, 20), uint64(-val)))
|
||||||
|
}
|
||||||
|
return string(_utoa(make([]byte, 20), uint64(val)))
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import "strconv"
|
|
||||||
|
|
||||||
type Errno uintptr
|
type Errno uintptr
|
||||||
|
|
||||||
func (e Errno) Error() string {
|
func (e Errno) Error() string {
|
||||||
@@ -13,7 +11,7 @@ func (e Errno) Error() string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "errno " + strconv.Itoa(int(e))
|
return "errno " + utoa(uint64(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e Errno) Is(target error) bool {
|
func (e Errno) Is(target error) bool {
|
||||||
@@ -51,5 +49,5 @@ func (s Signal) String() string {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "signal " + strconv.Itoa(int(s))
|
return "signal " + itoa(int64(s))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,7 +78,7 @@ func (e Errno) Error() string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "errno " + strconv.Itoa(int(e))
|
return "errno " + utoa(uint64(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e Errno) Is(target error) bool {
|
func (e Errno) Is(target error) bool {
|
||||||
@@ -209,7 +208,7 @@ func (s Signal) String() string {
|
|||||||
case SIGSYS:
|
case SIGSYS:
|
||||||
return "bad system call"
|
return "bad system call"
|
||||||
default:
|
default:
|
||||||
return "signal " + strconv.Itoa(int(s))
|
return "signal " + utoa(uint64(s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
runtime/internal/lib/math/big/prime.go
Normal file
26
runtime/internal/lib/math/big/prime.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package big
|
||||||
|
|
||||||
|
// ProbablyPrime reports whether x is probably prime,
|
||||||
|
// applying the Miller-Rabin test with n pseudorandomly chosen bases
|
||||||
|
// as well as a Baillie-PSW test.
|
||||||
|
//
|
||||||
|
// If x is prime, ProbablyPrime returns true.
|
||||||
|
// If x is chosen randomly and not prime, ProbablyPrime probably returns false.
|
||||||
|
// The probability of returning true for a randomly chosen non-prime is at most ¼ⁿ.
|
||||||
|
//
|
||||||
|
// ProbablyPrime is 100% accurate for inputs less than 2⁶⁴.
|
||||||
|
// See Menezes et al., Handbook of Applied Cryptography, 1997, pp. 145-149,
|
||||||
|
// and FIPS 186-4 Appendix F for further discussion of the error probabilities.
|
||||||
|
//
|
||||||
|
// ProbablyPrime is not suitable for judging primes that an adversary may
|
||||||
|
// have crafted to fool the test.
|
||||||
|
//
|
||||||
|
// As of Go 1.8, ProbablyPrime(0) is allowed and applies only a Baillie-PSW test.
|
||||||
|
// Before Go 1.8, ProbablyPrime applied only the Miller-Rabin tests, and ProbablyPrime(0) panicked.
|
||||||
|
func (x *Int) ProbablyPrime(n int) bool {
|
||||||
|
panic("ProbablyPrime: todo")
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@ func statNolog(name string) (FileInfo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &PathError{Op: "stat", Path: name, Err: err}
|
return nil, &PathError{Op: "stat", Path: name, Err: err}
|
||||||
}
|
}
|
||||||
|
fillFileStatFromSys(&fs, name)
|
||||||
return &fs, nil
|
return &fs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,5 +48,6 @@ func lstatNolog(name string) (FileInfo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &PathError{Op: "lstat", Path: name, Err: err}
|
return nil, &PathError{Op: "lstat", Path: name, Err: err}
|
||||||
}
|
}
|
||||||
|
fillFileStatFromSys(&fs, name)
|
||||||
return &fs, nil
|
return &fs, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ func (v Value) typ() *abi.Type {
|
|||||||
// v.Kind() must be Pointer, Map, Chan, Func, or UnsafePointer
|
// v.Kind() must be Pointer, Map, Chan, Func, or UnsafePointer
|
||||||
// if v.Kind() == Pointer, the base type must not be not-in-heap.
|
// if v.Kind() == Pointer, the base type must not be not-in-heap.
|
||||||
func (v Value) pointer() unsafe.Pointer {
|
func (v Value) pointer() unsafe.Pointer {
|
||||||
|
if v.typ_.IsClosure() {
|
||||||
|
return v.ptr
|
||||||
|
}
|
||||||
if v.typ().Size() != goarch.PtrSize || !v.typ().Pointers() {
|
if v.typ().Size() != goarch.PtrSize || !v.typ().Pointers() {
|
||||||
panic("can't call pointer on a non-pointer Value")
|
panic("can't call pointer on a non-pointer Value")
|
||||||
}
|
}
|
||||||
|
|||||||
13
runtime/internal/lib/runtime/compiler.go
Normal file
13
runtime/internal/lib/runtime/compiler.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
// Compiler is the name of the compiler toolchain that built the
|
||||||
|
// running binary. Known toolchains are:
|
||||||
|
//
|
||||||
|
// - gc Also known as cmd/compile.
|
||||||
|
// - gccgo The gccgo front end, part of the GCC compiler suite.
|
||||||
|
// - llgo Our project
|
||||||
|
const Compiler = "llgo"
|
||||||
@@ -72,13 +72,13 @@ func Basic(_kind Kind) *Type {
|
|||||||
kind := _kind & abi.KindMask
|
kind := _kind & abi.KindMask
|
||||||
if tyBasic[kind] == nil {
|
if tyBasic[kind] == nil {
|
||||||
name, size, align := basicTypeInfo(kind)
|
name, size, align := basicTypeInfo(kind)
|
||||||
var bytes uintptr
|
var ptrBytes uintptr
|
||||||
if kind == abi.String {
|
if kind == abi.String || kind == abi.UnsafePointer {
|
||||||
bytes = pointerSize
|
ptrBytes = pointerSize
|
||||||
}
|
}
|
||||||
tyBasic[kind] = &Type{
|
tyBasic[kind] = &Type{
|
||||||
Size_: size,
|
Size_: size,
|
||||||
PtrBytes: bytes,
|
PtrBytes: ptrBytes,
|
||||||
Hash: uint32(kind),
|
Hash: uint32(kind),
|
||||||
Align_: uint8(align),
|
Align_: uint8(align),
|
||||||
FieldAlign_: uint8(align),
|
FieldAlign_: uint8(align),
|
||||||
|
|||||||
27
ssa/type.go
27
ssa/type.go
@@ -538,20 +538,15 @@ func PathOf(pkg *types.Package) string {
|
|||||||
// - method: pkg.T.name, pkg.(*T).name
|
// - method: pkg.T.name, pkg.(*T).name
|
||||||
func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string {
|
func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string {
|
||||||
if recv != nil {
|
if recv != nil {
|
||||||
|
named, ptr := recvNamed(recv.Type())
|
||||||
var tName string
|
var tName string
|
||||||
t := recv.Type()
|
|
||||||
if org {
|
if org {
|
||||||
if tp, ok := t.(*types.Pointer); ok {
|
tName = named.Obj().Name()
|
||||||
tName = "(*" + tp.Elem().(*types.Named).Obj().Name() + ")"
|
|
||||||
} else {
|
} else {
|
||||||
tName = t.(*types.Named).Obj().Name()
|
tName = abi.NamedName(named)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if tp, ok := t.(*types.Pointer); ok {
|
|
||||||
tName = "(*" + abi.NamedName(tp.Elem().(*types.Named)) + ")"
|
|
||||||
} else {
|
|
||||||
tName = abi.NamedName(t.(*types.Named))
|
|
||||||
}
|
}
|
||||||
|
if ptr {
|
||||||
|
tName = "(*" + tName + ")"
|
||||||
}
|
}
|
||||||
return PathOf(pkg) + "." + tName + "." + name
|
return PathOf(pkg) + "." + tName + "." + name
|
||||||
}
|
}
|
||||||
@@ -559,6 +554,18 @@ func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string
|
|||||||
return ret
|
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 {
|
func TypeArgs(typeArgs []types.Type) string {
|
||||||
return abi.TypeArgs(typeArgs)
|
return abi.TypeArgs(typeArgs)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user