Compare commits

..

83 Commits

Author SHA1 Message Date
xushiwei
9203c366e7 Merge pull request #1121 from visualfc/closure
fix reflect.pointer  for closure; fix runtime unsafe.pointer ptrBytes
2025-05-17 01:19:40 +08:00
xushiwei
11a8af1db2 Merge pull request #1122 from visualfc/syscall
runtime/internal/clite/syscall: fix init
2025-05-17 01:19:04 +08:00
visualfc
c8fb7eafa0 runtime/internal/clite/os: fix stat for macOS 2025-05-16 20:36:43 +08:00
visualfc
ffc1f712a3 runtime/internal/clite/syscall: fix init 2025-05-16 16:29:31 +08:00
visualfc
cfc8687851 lib/reflect: fix closure pointer 2025-05-16 12:00:59 +08:00
visualfc
953699b2fd internal/runtime: fix abi.UnsafePointer PtrBytes 2025-05-16 12:00:59 +08:00
xushiwei
9a16fff27e Merge pull request #1118 from tsingbx/llgo.buildflag
fix gop run . flag provided but not defined: -ldflags
2025-05-16 11:21:24 +08:00
xushiwei
ac0d104231 Merge pull request #1117 from visualfc/bound
cl: funcName check $bound
2025-05-16 10:59:25 +08:00
xushiwei
881efea006 Merge pull request #1119 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.18.1
build(deps): bump github.com/goplus/gogen from 1.18.0 to 1.18.1
2025-05-16 10:47:17 +08:00
dependabot[bot]
f6a380d293 build(deps): bump github.com/goplus/gogen from 1.18.0 to 1.18.1
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.18.0...v1.18.1)

---
updated-dependencies:
- dependency-name: github.com/goplus/gogen
  dependency-version: 1.18.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-16 00:57:11 +00:00
tsingbx
a971b93994 fix gop run . flag provided but not defined: -ldflags 2025-05-16 00:44:37 +08:00
visualfc
c4f0dd124d cl: funcName check $bound 2025-05-15 21:12:18 +08:00
xushiwei
93b9b7d44c Merge pull request #1112 from goplus/dependabot/go_modules/github.com/qiniu/x-1.14.6
build(deps): bump github.com/qiniu/x from 1.14.0 to 1.14.6
2025-05-13 11:03:01 +08:00
dependabot[bot]
7552bfe39b build(deps): bump github.com/qiniu/x from 1.14.0 to 1.14.6
Bumps [github.com/qiniu/x](https://github.com/qiniu/x) from 1.14.0 to 1.14.6.
- [Release notes](https://github.com/qiniu/x/releases)
- [Commits](https://github.com/qiniu/x/compare/v1.14.0...v1.14.6)

---
updated-dependencies:
- dependency-name: github.com/qiniu/x
  dependency-version: 1.14.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-13 00:30:42 +00:00
xushiwei
2601faaff2 Merge pull request #1111 from goplus/dependabot/go_modules/github.com/goplus/cobra-1.9.12
build(deps): bump github.com/goplus/cobra from 1.9.11 to 1.9.12
2025-05-13 01:02:28 +08:00
dependabot[bot]
cb2e28d086 build(deps): bump github.com/goplus/cobra from 1.9.11 to 1.9.12
Bumps [github.com/goplus/cobra](https://github.com/goplus/cobra) from 1.9.11 to 1.9.12.
- [Release notes](https://github.com/goplus/cobra/releases)
- [Commits](https://github.com/goplus/cobra/compare/v1.9.11...v1.9.12)

---
updated-dependencies:
- dependency-name: github.com/goplus/cobra
  dependency-version: 1.9.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-12 00:59:41 +00:00
xushiwei
337877313a Merge pull request #1109 from xushiwei/q
rm xtool/{cppkg,cpgithubpkg}
2025-05-12 04:04:08 +08:00
xushiwei
1693942cee rm xtool/{cppkg,cpgithubpkg} 2025-05-12 03:50:07 +08:00
xushiwei
867a1ce2f4 Merge pull request #1108 from xushiwei/q
github api: release/asset id => int64
2025-05-12 02:28:34 +08:00
xushiwei
26b997537f getAppManager: rm notFoundMgs 2025-05-12 02:26:46 +08:00
xushiwei
19056b8a19 Merge remote-tracking branch 'gop/main' into q 2025-05-12 02:25:26 +08:00
xushiwei
10d603b377 Merge pull request #1104 from luoliwoshang/unix/install
xtool/cppkg:install in linux
2025-05-12 02:24:36 +08:00
xushiwei
3f41c313ad github api: release/asset id => int64 2025-05-11 20:55:59 +08:00
xushiwei
d440949c1d Merge pull request #1103 from tsingbx/llgo.usage
add usage for llgo
2025-05-10 11:29:30 +08:00
xushiwei
64314dc6cf Merge pull request #1107 from xushiwei/q
github api: EnumTags
2025-05-10 11:28:17 +08:00
xushiwei
decb9d7f11 github api: EnumTags 2025-05-10 11:27:50 +08:00
tsingbx
975b0b74ee panic err => return 2025-05-10 07:15:48 +08:00
xushiwei
9aa7807b02 Merge pull request #1106 from xushiwei/q
xtool/cppkg: ConanStderr
2025-05-09 23:36:12 +08:00
xushiwei
337c6cfa25 xtool/cppkg: ConanStderr 2025-05-09 23:31:31 +08:00
luoliwoshang
f09a423ee7 xtool/cppkg:tips when app managers not found 2025-05-09 14:25:44 +08:00
tsingbx
3bf28f52c4 add usage for llgo 2025-05-09 12:59:11 +08:00
luoliwoshang
f794592f42 xtool/cppkg install by pipx 2025-05-09 10:20:05 +08:00
xushiwei
98bd05b47b Merge pull request #1102 from xushiwei/q
cmd/llog: main_cmd.gox => main_app.gox
2025-05-08 09:41:20 +08:00
xushiwei
3edbde0839 cmd/llog: main_cmd.gox => main_app.gox 2025-05-08 09:34:01 +08:00
xushiwei
a2d92eac0b Merge pull request #1100 from goplus/dependabot/go_modules/github.com/goplus/cobra-1.9.11
build(deps): bump github.com/goplus/cobra from 1.9.9 to 1.9.11
2025-05-08 09:31:35 +08:00
xushiwei
eb47c545ec Merge pull request #1101 from xushiwei/q
xtool/cppkg: InstallPkg allows to customize cacheDir
2025-05-08 09:30:06 +08:00
xushiwei
c858f79449 xtool/cppkg: InstallPkg allows to customize cacheDir 2025-05-08 09:26:45 +08:00
dependabot[bot]
27f6efbdec build(deps): bump github.com/goplus/cobra from 1.9.9 to 1.9.11
Bumps [github.com/goplus/cobra](https://github.com/goplus/cobra) from 1.9.9 to 1.9.11.
- [Release notes](https://github.com/goplus/cobra/releases)
- [Commits](https://github.com/goplus/cobra/compare/v1.9.9...v1.9.11)

---
updated-dependencies:
- dependency-name: github.com/goplus/cobra
  dependency-version: 1.9.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-08 00:59:40 +00:00
xushiwei
bba7494ffd Merge pull request #1099 from xushiwei/q
xtool/cppkg: InstallPkg KnownLatestVersion
2025-05-08 08:17:20 +08:00
xushiwei
0f79cad5a7 xtool/cppkg: InstallPkg KnownLatestVersion 2025-05-08 08:10:56 +08:00
xushiwei
9e7bacbe23 Merge pull request #1098 from xushiwei/q
cmd/llgo: main cmd
2025-05-07 22:31:39 +08:00
xushiwei
2301a4834d cmd/llog: main cmd 2025-05-07 22:30:54 +08:00
xushiwei
40e0f58079 Merge pull request #1094 from goplus/dependabot/go_modules/github.com/goplus/cobra-1.9.9
build(deps): bump github.com/goplus/cobra from 1.9.8 to 1.9.9
2025-05-07 03:40:46 +08:00
xushiwei
c23fb144cf Merge branch 'main' into dependabot/go_modules/github.com/goplus/cobra-1.9.9 2025-05-07 03:33:04 +08:00
xushiwei
caac681ac3 Merge pull request #1095 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.18.0
build(deps): bump github.com/goplus/gogen from 1.17.3 to 1.18.0
2025-05-07 03:32:18 +08:00
xushiwei
9ba3b3ef8f Merge pull request #1097 from goplus/dependabot/go_modules/github.com/goplus/mod-0.16.1
build(deps): bump github.com/goplus/mod from 0.16.0 to 0.16.1
2025-05-07 03:24:15 +08:00
dependabot[bot]
d7e523948b build(deps): bump github.com/goplus/mod from 0.16.0 to 0.16.1
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.16.0 to 0.16.1.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.16.0...v0.16.1)

---
updated-dependencies:
- dependency-name: github.com/goplus/mod
  dependency-version: 0.16.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 15:00:31 +00:00
dependabot[bot]
10a75138d1 build(deps): bump github.com/goplus/gogen from 1.17.3 to 1.18.0
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.17.3 to 1.18.0.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.17.3...v1.18.0)

---
updated-dependencies:
- dependency-name: github.com/goplus/gogen
  dependency-version: 1.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 15:00:25 +00:00
dependabot[bot]
d48b19c866 build(deps): bump github.com/goplus/cobra from 1.9.8 to 1.9.9
Bumps [github.com/goplus/cobra](https://github.com/goplus/cobra) from 1.9.8 to 1.9.9.
- [Release notes](https://github.com/goplus/cobra/releases)
- [Commits](https://github.com/goplus/cobra/compare/v1.9.8...v1.9.9)

---
updated-dependencies:
- dependency-name: github.com/goplus/cobra
  dependency-version: 1.9.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 15:00:21 +00:00
xushiwei
1fdcb55eba Merge pull request #1080 from xushiwei/q
xtool/cpgithubpkg
2025-05-06 09:44:05 +08:00
xushiwei
16cec9f045 merge upstream 2025-05-06 09:41:19 +08:00
xushiwei
438b0bd1b0 Merge pull request #1091 from visualfc/go123
go.mod go1.23
2025-05-06 08:32:06 +08:00
visualfc
e8a91696d6 go.mod go1.23 2025-05-05 10:19:23 +08:00
xushiwei
8882c31eb4 Merge pull request #1090 from xushiwei/cppkg
xtool/cppkg: support latest version
2025-05-04 17:40:07 +08:00
xushiwei
8455ee8226 xtool/cppkg: support latest version 2025-05-04 17:34:02 +08:00
xushiwei
3f74aded8a Merge pull request #1089 from xushiwei/cppkg
llgo cppkg: remove unused import
2025-05-04 16:44:38 +08:00
xushiwei
2e19c2013c llgo cppkg: remove unused import 2025-05-04 16:43:07 +08:00
xushiwei
1edaa2d09b Merge pull request #1088 from xushiwei/cppkg
cmd: llgo cppkg install
2025-05-04 16:06:20 +08:00
xushiwei
beee018287 cmd: llgo cppkg install 2025-05-04 16:01:58 +08:00
xushiwei
34266ea59d Merge pull request #1087 from xushiwei/cppkg
llgo.next => llgo
2025-05-04 15:39:50 +08:00
xushiwei
f26127ce98 llgo.next => llgo 2025-05-04 15:34:32 +08:00
xushiwei
ccf321d178 Merge pull request #1086 from xushiwei/cppkg
llgo.next: support build, run, cmptest
2025-05-04 15:23:40 +08:00
xushiwei
355721c47a llgo.next: support build, run, cmptest 2025-05-04 15:18:49 +08:00
xushiwei
d400663e5d Merge pull request #1085 from xushiwei/cppkg
cmd: llgo.next
2025-05-04 14:14:10 +08:00
xushiwei
2203be945a codecov: ignore llgo.next 2025-05-04 14:10:43 +08:00
xushiwei
b9a2bf4b42 fmt: ignore gop_autogen.go 2025-05-04 14:08:43 +08:00
xushiwei
cc08195cf2 cmd: llgo.next 2025-05-04 14:04:43 +08:00
xushiwei
50c40a7828 Merge pull request #1084 from xushiwei/cppkg
go mod tidy
2025-05-04 10:41:57 +08:00
xushiwei
158be3f949 go mod tidy 2025-05-04 10:28:24 +08:00
xushiwei
0f87c322ca Merge pull request #1082 from xushiwei/cppkg
xtool/cppkg: Main => Install
2025-05-04 00:15:26 +08:00
xushiwei
d5dd19b64c xtool/cppkg: Main => Install 2025-05-04 00:08:20 +08:00
xushiwei
3ac9055493 xtool/cpgithubpkg 2025-05-03 23:30:29 +08:00
xushiwei
3032d730b7 Merge pull request #1079 from xushiwei/q
package: xtool/cppkg
2025-05-03 23:22:55 +08:00
xushiwei
e93e7126b6 package: xtool/cppkg 2025-05-03 23:13:10 +08:00
xushiwei
9bcf41d28f Merge pull request #1078 from xushiwei/q
github api: release, tag, commit
2025-05-03 22:58:01 +08:00
xushiwei
604ce47d5e github api: release, tag, commit 2025-05-03 22:50:04 +08:00
xushiwei
e1ebe150d4 Merge pull request #1077 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.17.3
build(deps): bump github.com/goplus/gogen from 1.17.2 to 1.17.3
2025-04-28 08:28:56 +08:00
dependabot[bot]
ae992737e8 build(deps): bump github.com/goplus/gogen from 1.17.2 to 1.17.3
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.17.2 to 1.17.3.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.17.2...v1.17.3)

---
updated-dependencies:
- dependency-name: github.com/goplus/gogen
  dependency-version: 1.17.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-28 00:15:49 +00:00
xushiwei
c59d609eb8 Merge pull request #1076 from xushiwei/t
_cmptest: mathbigdemo
2025-04-28 01:18:10 +08:00
xushiwei
9f26d12a3e _cmptest: mathbigdemo 2025-04-28 01:03:13 +08:00
xushiwei
9102577eba Merge pull request #1075 from xushiwei/t
go/parser demo
2025-04-28 00:46:00 +08:00
xushiwei
f0fcfde22b README: go/parser 2025-04-28 00:37:11 +08:00
xushiwei
d9d813db56 go/parser demo 2025-04-28 00:35:45 +08:00
52 changed files with 2671 additions and 1471 deletions

4
.github/codecov.yml vendored
View File

@@ -1,9 +1,11 @@
coverage:
ignore:
- "chore"
- "cmd/internal"
- "cmd"
- "internal/build"
- "internal/llgen"
- "internal/mockable"
- "internal/packages"
- "internal/typepatch"
- "internal/github"
- "xtool"

View File

@@ -21,7 +21,7 @@ jobs:
run: |
for dir in . runtime; do
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 ./...'"
exit 1
fi

View File

@@ -335,6 +335,7 @@ Here are the Go packages that can be imported correctly:
* [regexp/syntax](https://pkg.go.dev/regexp/syntax)
* [go/token](https://pkg.go.dev/go/token)
* [go/scanner](https://pkg.go.dev/go/scanner)
* [go/parser](https://pkg.go.dev/go/parser)
## Dependencies

View 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)
}

View 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
View File

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

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

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

View File

@@ -319,7 +319,7 @@ _llgo_17: ; preds = %_llgo_4
%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
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
%112 = extractvalue { ptr, ptr } %110, 0
%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)
%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
%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
%123 = extractvalue { ptr, ptr } %121, 0
%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)
%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
%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
%134 = extractvalue { ptr, ptr } %132, 0
%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)
%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
%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
%146 = extractvalue { ptr, ptr } %144, 0
%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")
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:
%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
@@ -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")
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:
%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

View 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
View 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)

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View 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
}

View 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")

View File

@@ -29,7 +29,7 @@ _llgo_0:
%3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
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
%7 = alloca %"github.com/goplus/llgo/cl/_testrt/closureconv.Func", 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)
%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/_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
store { ptr, ptr } %3, 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)
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:
%3 = load { ptr }, ptr %0, align 8
%4 = extractvalue { ptr } %3, 0

View File

@@ -124,7 +124,7 @@ _llgo_6: ; preds = %_llgo_4
%32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
%33 = getelementptr inbounds { ptr }, ptr %32, i32 0, i32 0
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)
%36 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 1
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)
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:
%1 = load { ptr }, ptr %0, align 8
%2 = extractvalue { ptr } %1, 0

View File

@@ -402,6 +402,10 @@ func funcName(pkg *types.Package, fn *ssa.Function, org bool) string {
recv = parent.Signature.Recv()
} else {
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
if org := fn.Origin(); org != nil {

82
cmd/internal/base/pass.go Normal file
View 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
}

View File

@@ -35,13 +35,15 @@ var Cmd = &base.Command{
func init() {
Cmd.Run = runCmd
base.PassBuildFlags(Cmd)
flags.AddBuildFlags(&Cmd.Flag)
flags.AddOutputFlags(&Cmd.Flag)
}
func runCmd(cmd *base.Command, args []string) {
if err := cmd.Flag.Parse(args); err != nil {
panic(err)
return
}
conf := build.NewDefaultConf(build.ModeBuild)

View File

@@ -35,8 +35,9 @@ func init() {
}
func runCmd(cmd *base.Command, args []string) {
if err := cmd.Flag.Parse(args); err != nil {
panic(err)
return
}
conf := build.NewDefaultConf(0)

View File

@@ -39,8 +39,9 @@ func init() {
}
func runCmd(cmd *base.Command, args []string) {
if err := cmd.Flag.Parse(args); err != nil {
panic(err)
return
}
conf := build.NewDefaultConf(build.ModeInstall)

View File

@@ -47,6 +47,7 @@ var CmpTestCmd = &base.Command{
func init() {
Cmd.Run = runCmd
CmpTestCmd.Run = runCmpTest
base.PassBuildFlags(Cmd)
flags.AddBuildFlags(&Cmd.Flag)
flags.AddBuildFlags(&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) {
if err := cmd.Flag.Parse(args); err != nil {
panic(err)
return
}
conf := build.NewDefaultConf(mode)

View File

@@ -21,8 +21,9 @@ func init() {
}
func runCmd(cmd *base.Command, args []string) {
if err := cmd.Flag.Parse(args); err != nil {
panic(err)
return
}
conf := build.NewDefaultConf(build.ModeTest)

28
cmd/llgo/build_cmd.gox Normal file
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View File

@@ -1,16 +1,17 @@
module github.com/goplus/llgo
go 1.22.0
go 1.23
toolchain go1.24.1
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/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/mod v0.16.0
github.com/qiniu/x v1.13.19
github.com/goplus/mod v0.16.1
github.com/qiniu/x v1.14.6
golang.org/x/tools v0.30.0
)

14
go.sum
View File

@@ -1,15 +1,17 @@
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/goplus/gogen v1.17.2 h1:oQDWiVzZmDAdgNieJnrvrWTmxDTqYXGFMBa2rAbwjmA=
github.com/goplus/gogen v1.17.2/go.mod h1:owX2e1EyU5WD+Nm6oH2m/GXjLdlBYcwkLO4wN8HHXZI=
github.com/goplus/cobra v1.9.12 h1:0F9EdEbeGyITGz+mqoHoJ5KpUw97p1CkxV74IexHw5s=
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/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=
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/mod v0.16.0 h1:5CHXx3no7YaMN5HN2sgZe9MbQnc8118JLjbOeetSTfc=
github.com/goplus/mod v0.16.0/go.mod h1:U69PUD2e1MnI2DYhuumj1Z6wvZ1bNbKqHUk1MK8Diqo=
github.com/qiniu/x v1.13.19 h1:rZzWpifNjMtaMhhVnYHw9RGUn+84KGtclDZ9HAKtuZQ=
github.com/qiniu/x v1.13.19/go.mod h1:AiovSOCaRijaf3fj+0CBOpR1457pn24b0Vdb1JpwhII=
github.com/goplus/mod v0.16.1 h1:2O+rKubJTn+Fighz3kckwpW87STSZ6s3m/YECfXuNhE=
github.com/goplus/mod v0.16.1/go.mod h1:8d1P+pBavZfNQtJo4A742DgsLTtSf26BQn51owhmNqI=
github.com/qiniu/x v1.14.6 h1:JY8jOumYFshuqNAjVkF6zsYhbcwM8A199ALkUOvJPks=
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/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=

View File

@@ -87,12 +87,6 @@ func Remove(path *c.Char) c.Int
//go:linkname Rename C.rename
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
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.
//
//go:linkname Sysctl C.sysctl

View 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

View 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

View File

@@ -7,7 +7,6 @@
package syscall
import (
"strings"
"structs"
"unsafe"
)
@@ -297,11 +296,19 @@ func joinPath(dir, file string) string {
}
func isAbs(path string) bool {
return strings.HasPrefix(path, "/")
return hasPrefix(path, "/")
}
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 {

View File

@@ -24,7 +24,7 @@ import (
)
const (
LLGoPackage = "noinit"
LLGoPackage = true
)
var (
@@ -74,3 +74,25 @@ func Kill(pid int, signum Signal) error {
func ProcExit(code int32) {
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)))
}

View File

@@ -2,8 +2,6 @@
package syscall
import "strconv"
type Errno uintptr
func (e Errno) Error() string {
@@ -13,7 +11,7 @@ func (e Errno) Error() string {
return s
}
}
return "errno " + strconv.Itoa(int(e))
return "errno " + utoa(uint64(e))
}
func (e Errno) Is(target error) bool {
@@ -51,5 +49,5 @@ func (s Signal) String() string {
return str
}
}
return "signal " + strconv.Itoa(int(s))
return "signal " + itoa(int64(s))
}

View File

@@ -5,7 +5,6 @@
package syscall
import (
"strconv"
"unsafe"
)
@@ -79,7 +78,7 @@ func (e Errno) Error() string {
return s
}
}
return "errno " + strconv.Itoa(int(e))
return "errno " + utoa(uint64(e))
}
func (e Errno) Is(target error) bool {
@@ -209,7 +208,7 @@ func (s Signal) String() string {
case SIGSYS:
return "bad system call"
default:
return "signal " + strconv.Itoa(int(s))
return "signal " + utoa(uint64(s))
}
}

View 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")
}

View File

@@ -35,6 +35,7 @@ func statNolog(name string) (FileInfo, error) {
if err != nil {
return nil, &PathError{Op: "stat", Path: name, Err: err}
}
fillFileStatFromSys(&fs, name)
return &fs, nil
}
@@ -47,5 +48,6 @@ func lstatNolog(name string) (FileInfo, error) {
if err != nil {
return nil, &PathError{Op: "lstat", Path: name, Err: err}
}
fillFileStatFromSys(&fs, name)
return &fs, nil
}

View File

@@ -124,6 +124,9 @@ func (v Value) typ() *abi.Type {
// v.Kind() must be Pointer, Map, Chan, Func, or UnsafePointer
// if v.Kind() == Pointer, the base type must not be not-in-heap.
func (v Value) pointer() unsafe.Pointer {
if v.typ_.IsClosure() {
return v.ptr
}
if v.typ().Size() != goarch.PtrSize || !v.typ().Pointers() {
panic("can't call pointer on a non-pointer Value")
}

View 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"

View File

@@ -72,13 +72,13 @@ func Basic(_kind Kind) *Type {
kind := _kind & abi.KindMask
if tyBasic[kind] == nil {
name, size, align := basicTypeInfo(kind)
var bytes uintptr
if kind == abi.String {
bytes = pointerSize
var ptrBytes uintptr
if kind == abi.String || kind == abi.UnsafePointer {
ptrBytes = pointerSize
}
tyBasic[kind] = &Type{
Size_: size,
PtrBytes: bytes,
PtrBytes: ptrBytes,
Hash: uint32(kind),
Align_: uint8(align),
FieldAlign_: uint8(align),

View File

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