Skip to content

Commit 64e0f75

Browse files
Adding v1.19 transition for reflect and reflectlite
Reduced to v1.19 only Update Go version to 1.19.13 to begin work on Go 1.19 support.
1 parent c7cfb39 commit 64e0f75

File tree

7 files changed

+37
-40
lines changed

7 files changed

+37
-40
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
- uses: actions/setup-go@v3
1414
with:
15-
go-version: "1.18.10"
15+
go-version: "1.19.13"
1616

1717
- name: golangci-lint
1818
uses: golangci/golangci-lint-action@v3

.github/workflows/measure-size.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fetch-depth: 0
1212
- uses: actions/setup-go@v2
1313
with:
14-
go-version: '~1.18.10'
14+
go-version: '~1.19.13'
1515
- uses: gopherjs/output-size-action/measure@main
1616
with:
1717
name: jQuery TodoMVC

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ Nearly everything, including Goroutines ([compatibility documentation](https://g
3131

3232
### Installation and Usage
3333

34-
GopherJS [requires Go 1.18 or newer](https://github.com/gopherjs/gopherjs/blob/master/doc/compatibility.md#go-version-compatibility). If you need an older Go
34+
GopherJS [requires Go 1.19 or newer](https://github.com/gopherjs/gopherjs/blob/master/doc/compatibility.md#go-version-compatibility). If you need an older Go
3535
version, you can use an [older GopherJS release](https://github.com/gopherjs/gopherjs/releases).
3636

3737
Install GopherJS with `go install`:
3838

3939
```
40-
go install github.com/gopherjs/gopherjs@v1.18.0-beta3 # Or replace 'v1.18.0-beta3' with another version.
40+
go install github.com/gopherjs/gopherjs@v1.19.0-alpha1 # Or replace 'v1.19.0-alpha1' with another version.
4141
```
4242

43-
If your local Go distribution as reported by `go version` is newer than Go 1.18, then you need to set the `GOPHERJS_GOROOT` environment variable to a directory that contains a Go 1.18 distribution. For example:
43+
If your local Go distribution as reported by `go version` is newer than Go 1.19, then you need to set the `GOPHERJS_GOROOT` environment variable to a directory that contains a Go 1.19 distribution. For example:
4444

4545
```
46-
go install golang.org/dl/go1.18.10@latest
47-
go1.18.10 download
48-
export GOPHERJS_GOROOT="$(go1.18.10 env GOROOT)" # Also add this line to your .profile or equivalent.
46+
go install golang.org/dl/go1.19.13@latest
47+
go1.19.13 download
48+
export GOPHERJS_GOROOT="$(go1.19.13 env GOROOT)" # Also add this line to your .profile or equivalent.
4949
```
5050

5151
Now you can use `gopherjs build [package]`, `gopherjs build [files]` or `gopherjs install [package]` which behave similar to the `go` tool. For `main` packages, these commands create a `.js` file and `.js.map` source map in the current directory or in `$GOPATH/bin`. The generated JavaScript file can be used as usual in a website. Use `gopherjs help [command]` to get a list of possible command line flags, e.g. for minification and automatically watching for changes.

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ workflows:
5454
parameters:
5555
go_version:
5656
type: string
57-
default: "1.18.10"
57+
default: "1.19.13"
5858
nvm_version:
5959
type: string
6060
default: "0.38.0"

compiler/natives/src/internal/reflectlite/reflectlite.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func reflectType(typ *js.Object) *rtype {
5050
rt := &rtype{
5151
size: uintptr(typ.Get("size").Int()),
5252
kind: uint8(typ.Get("kind").Int()),
53-
str: newNameOff(newName(internalStr(typ.Get("string")), "", typ.Get("exported").Bool())),
53+
str: newNameOff(newName(internalStr(typ.Get("string")), "", typ.Get("exported").Bool(), false)),
5454
}
5555
js.InternalObject(rt).Set(idJsType, typ)
5656
typ.Set(idReflectType, js.InternalObject(rt))
@@ -69,7 +69,7 @@ func reflectType(typ *js.Object) *rtype {
6969
continue
7070
}
7171
reflectMethods = append(reflectMethods, method{
72-
name: newNameOff(newName(internalStr(m.Get("name")), "", exported)),
72+
name: newNameOff(newName(internalStr(m.Get("name")), "", exported, false)),
7373
mtyp: newTypeOff(reflectType(m.Get("typ"))),
7474
})
7575
}
@@ -81,12 +81,12 @@ func reflectType(typ *js.Object) *rtype {
8181
continue
8282
}
8383
reflectMethods = append(reflectMethods, method{
84-
name: newNameOff(newName(internalStr(m.Get("name")), "", exported)),
84+
name: newNameOff(newName(internalStr(m.Get("name")), "", exported, false)),
8585
mtyp: newTypeOff(reflectType(m.Get("typ"))),
8686
})
8787
}
8888
ut := &uncommonType{
89-
pkgPath: newNameOff(newName(internalStr(typ.Get("pkg")), "", false)),
89+
pkgPath: newNameOff(newName(internalStr(typ.Get("pkg")), "", false, false)),
9090
mcount: uint16(methodSet.Length()),
9191
xcount: xcount,
9292
_methods: reflectMethods,
@@ -141,13 +141,13 @@ func reflectType(typ *js.Object) *rtype {
141141
for i := range imethods {
142142
m := methods.Index(i)
143143
imethods[i] = imethod{
144-
name: newNameOff(newName(internalStr(m.Get("name")), "", internalStr(m.Get("pkg")) == "")),
144+
name: newNameOff(newName(internalStr(m.Get("name")), "", internalStr(m.Get("pkg")) == "", false)),
145145
typ: newTypeOff(reflectType(m.Get("typ"))),
146146
}
147147
}
148148
setKindType(rt, &interfaceType{
149149
rtype: *rt,
150-
pkgPath: newName(internalStr(typ.Get("pkg")), "", false),
150+
pkgPath: newName(internalStr(typ.Get("pkg")), "", false, false),
151151
methods: imethods,
152152
})
153153
case Map:
@@ -168,19 +168,15 @@ func reflectType(typ *js.Object) *rtype {
168168
reflectFields := make([]structField, fields.Length())
169169
for i := range reflectFields {
170170
f := fields.Index(i)
171-
offsetEmbed := uintptr(i) << 1
172-
if f.Get("embedded").Bool() {
173-
offsetEmbed |= 1
174-
}
175171
reflectFields[i] = structField{
176-
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool()),
177-
typ: reflectType(f.Get("typ")),
178-
offsetEmbed: offsetEmbed,
172+
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool(), f.Get("embedded").Bool()),
173+
typ: reflectType(f.Get("typ")),
174+
offset: uintptr(i),
179175
}
180176
}
181177
setKindType(rt, &structType{
182178
rtype: *rt,
183-
pkgPath: newName(internalStr(typ.Get("pkgPath")), "", false),
179+
pkgPath: newName(internalStr(typ.Get("pkgPath")), "", false, false),
184180
fields: reflectFields,
185181
})
186182
}
@@ -242,6 +238,7 @@ type nameData struct {
242238
name string
243239
tag string
244240
exported bool
241+
embedded bool
245242
}
246243

247244
var nameMap = make(map[*byte]*nameData)
@@ -250,13 +247,15 @@ func (n name) name() (s string) { return nameMap[n.bytes].name }
250247
func (n name) tag() (s string) { return nameMap[n.bytes].tag }
251248
func (n name) pkgPath() string { return "" }
252249
func (n name) isExported() bool { return nameMap[n.bytes].exported }
250+
func (n name) embedded() bool { return nameMap[n.bytes].embedded }
253251

254-
func newName(n, tag string, exported bool) name {
252+
func newName(n, tag string, exported, embedded bool) name {
255253
b := new(byte)
256254
nameMap[b] = &nameData{
257255
name: n,
258256
tag: tag,
259257
exported: exported,
258+
embedded: embedded,
260259
}
261260
return name{
262261
bytes: b,

compiler/natives/src/reflect/reflect.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func reflectType(typ *js.Object) *rtype {
6363
rt := &rtype{
6464
size: uintptr(typ.Get("size").Int()),
6565
kind: uint8(typ.Get("kind").Int()),
66-
str: resolveReflectName(newName(internalStr(typ.Get("string")), "", typ.Get("exported").Bool())),
66+
str: resolveReflectName(newName(internalStr(typ.Get("string")), "", typ.Get("exported").Bool(), false)),
6767
}
6868
js.InternalObject(rt).Set("jsType", typ)
6969
typ.Set("reflectType", js.InternalObject(rt))
@@ -99,7 +99,7 @@ func reflectType(typ *js.Object) *rtype {
9999
})
100100
}
101101
ut := &uncommonType{
102-
pkgPath: resolveReflectName(newName(internalStr(typ.Get("pkg")), "", false)),
102+
pkgPath: resolveReflectName(newName(internalStr(typ.Get("pkg")), "", false, false)),
103103
mcount: uint16(methodSet.Length()),
104104
xcount: xcount,
105105
_methods: reflectMethods,
@@ -160,7 +160,7 @@ func reflectType(typ *js.Object) *rtype {
160160
}
161161
setKindType(rt, &interfaceType{
162162
rtype: *rt,
163-
pkgPath: newName(internalStr(typ.Get("pkg")), "", false),
163+
pkgPath: newName(internalStr(typ.Get("pkg")), "", false, false),
164164
methods: imethods,
165165
})
166166
case Map:
@@ -181,19 +181,15 @@ func reflectType(typ *js.Object) *rtype {
181181
reflectFields := make([]structField, fields.Length())
182182
for i := range reflectFields {
183183
f := fields.Index(i)
184-
offsetEmbed := uintptr(i) << 1
185-
if f.Get("embedded").Bool() {
186-
offsetEmbed |= 1
187-
}
188184
reflectFields[i] = structField{
189-
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool()),
190-
typ: reflectType(f.Get("typ")),
191-
offsetEmbed: offsetEmbed,
185+
name: newName(internalStr(f.Index.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool(), f.Get("embedded").Bool()),
186+
typ: reflectType(f.Get("typ")),
187+
offset: uintptr(i),
192188
}
193189
}
194190
setKindType(rt, &structType{
195191
rtype: *rt,
196-
pkgPath: newName(internalStr(typ.Get("pkgPath")), "", false),
192+
pkgPath: newName(internalStr(typ.Get("pkgPath")), "", false, false),
197193
fields: reflectFields,
198194
})
199195
}
@@ -257,6 +253,7 @@ type nameData struct {
257253
name string
258254
tag string
259255
exported bool
256+
embedded bool
260257
pkgPath string
261258
}
262259

@@ -266,16 +263,18 @@ func (n name) name() (s string) { return nameMap[n.bytes].name }
266263
func (n name) tag() (s string) { return nameMap[n.bytes].tag }
267264
func (n name) pkgPath() string { return nameMap[n.bytes].pkgPath }
268265
func (n name) isExported() bool { return nameMap[n.bytes].exported }
266+
func (n name) embedded() bool { return nameMap[n.bytes].embedded }
269267
func (n name) setPkgPath(pkgpath string) {
270268
nameMap[n.bytes].pkgPath = pkgpath
271269
}
272270

273-
func newName(n, tag string, exported bool) name {
271+
func newName(n, tag string, exported, embedded bool) name {
274272
b := new(byte)
275273
nameMap[b] = &nameData{
276274
name: n,
277275
tag: tag,
278276
exported: exported,
277+
embedded: embedded,
279278
}
280279
return name{
281280
bytes: b,

compiler/version_check.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//go:build go1.18
2-
// +build go1.18
1+
//go:build go1.19
32

43
package compiler
54

@@ -13,10 +12,10 @@ import (
1312
)
1413

1514
// Version is the GopherJS compiler version string.
16-
const Version = "1.18.0-beta3+go1.18.10"
15+
const Version = "1.19.0-alpha1+go1.19.13"
1716

1817
// GoVersion is the current Go 1.x version that GopherJS is compatible with.
19-
const GoVersion = 18
18+
const GoVersion = 19
2019

2120
// CheckGoVersion checks the version of the Go distribution
2221
// at goroot, and reports an error if it's not compatible

0 commit comments

Comments
 (0)