Skip to content
This repository was archived by the owner on Aug 27, 2018. It is now read-only.

Commit 27c2888

Browse files
committed
Test out GopherJS struct val fix
1 parent 448b987 commit 27c2888

File tree

14 files changed

+258
-160
lines changed

14 files changed

+258
-160
lines changed

.vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
./_vendor/src/golang.org/x/sys 9a7256cb28ed514b4e1e5f68959914c4c28a92e0 https://go.googlesource.com/sys
33
./_vendor/src/golang.org/x/crypto 3cb07270c9455e8ad27956a70891c962d121a228 https://go.googlesource.com/crypto
44
./_vendor/src/golang.org/x/tools 620ecdb8d7943e20dc030b61bfe898d1b000bdea https://go.googlesource.com/tools
5-
./_vendor/src/github.com/gopherjs/gopherjs 9659c814f1d54d63f9c623449a7111d3864c1361 git@github.com:gopherjs/gopherjs
5+
./_vendor/src/github.com/gopherjs/gopherjs 0f63f82815efd2bc45b0fa360e4f5732b02efdc6 git@github.com:gopherjs/gopherjs 669
66
./_vendor/src/github.com/gopherjs/jsbuiltin 67703bfb044e3192fbcab025c3aeaeedafad1f2f git@github.com:gopherjs/jsbuiltin
77
./_vendor/src/github.com/kisielk/gotool 0de1eaf82fa3f583ce21fde859f1e7e0c5e9b220 git@github.com:kisielk/gotool
88
./_vendor/src/github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1 git@github.com:fsnotify/fsnotify

_vendor/src/github.com/gopherjs/gopherjs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ How it works:
134134

135135
JavaScript has no concept of concurrency (except web workers, but those are too strictly separated to be used for goroutines). Because of that, instructions in JavaScript are never blocking. A blocking call would effectively freeze the responsiveness of your web page, so calls with callback arguments are used instead.
136136

137-
GopherJS does some heavy lifting to work around this restriction: Whenever an instruction is blocking (e.g. communicating with a channel that isn't ready), the whole stack will unwind (= all functions return) and the goroutine will be put to sleep. Then another goroutine which is ready to resume gets picked and its stack with all local variables will be restored. This is done by preserving each stack frame inside a closure.
137+
GopherJS does some heavy lifting to work around this restriction: Whenever an instruction is blocking (e.g. communicating with a channel that isn't ready), the whole stack will unwind (= all functions return) and the goroutine will be put to sleep. Then another goroutine which is ready to resume gets picked and its stack with all local variables will be restored.
138138

139139
### GopherJS Development
140140
If you're looking to make changes to the GopherJS compiler, see [Developer Guidelines](https://github.com/gopherjs/gopherjs/wiki/Developer-Guidelines) for additional developer information.

_vendor/src/github.com/gopherjs/gopherjs/build/build.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ func NewBuildContext(installSuffix string, buildTags []string) *build.Context {
6262
// If an error occurs, Import returns a non-nil error and a nil
6363
// *PackageData.
6464
func Import(path string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) {
65-
return importWithSrcDir(path, "", mode, installSuffix, buildTags)
65+
wd, err := os.Getwd()
66+
if err != nil {
67+
// Getwd may fail if we're in GOARCH=js mode. That's okay, handle
68+
// it by falling back to empty working directory. It just means
69+
// Import will not be able to resolve relative import paths.
70+
wd = ""
71+
}
72+
return importWithSrcDir(path, wd, mode, installSuffix, buildTags)
6673
}
6774

6875
func importWithSrcDir(path string, srcDir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) {
@@ -516,6 +523,8 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
516523
}
517524

518525
for _, importedPkgPath := range pkg.Imports {
526+
// Ignore all imports that aren't mentioned in import specs of pkg.
527+
// For example, this ignores imports such as runtime/internal/sys and runtime/internal/atomic.
519528
ignored := true
520529
for _, pos := range pkg.ImportPos[importedPkgPath] {
521530
importFile := filepath.Base(pos.Filename)
@@ -529,16 +538,17 @@ func (s *Session) BuildPackage(pkg *PackageData) (*compiler.Archive, error) {
529538
break
530539
}
531540
}
541+
532542
if importedPkgPath == "unsafe" || ignored {
533543
continue
534544
}
535545
importedPkg, _, err := s.buildImportPathWithSrcDir(importedPkgPath, pkg.Dir)
536546
if err != nil {
537547
return nil, err
538548
}
539-
impModeTime := importedPkg.SrcModTime
540-
if impModeTime.After(pkg.SrcModTime) {
541-
pkg.SrcModTime = impModeTime
549+
impModTime := importedPkg.SrcModTime
550+
if impModTime.After(pkg.SrcModTime) {
551+
pkg.SrcModTime = impModTime
542552
}
543553
}
544554

_vendor/src/github.com/gopherjs/gopherjs/circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
machine:
22
node:
3-
version: 6.2.2
3+
version: 8.2.1
44
environment:
55
SOURCE_MAP_SUPPORT: false
66

_vendor/src/github.com/gopherjs/gopherjs/compiler/expressions.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ func (c *funcContext) translateExpr(expr ast.Expr) *expression {
539539
plainFun := astutil.RemoveParens(e.Fun)
540540

541541
if astutil.IsTypeExpr(plainFun, c.p.Info.Info) {
542-
return c.formatExpr("%s", c.translateConversion(e.Args[0], c.p.TypeOf(plainFun)))
542+
return c.formatExpr("(%s)", c.translateConversion(e.Args[0], c.p.TypeOf(plainFun)))
543543
}
544544

545545
sig := c.p.TypeOf(plainFun).Underlying().(*types.Signature)
@@ -1113,7 +1113,12 @@ func (c *funcContext) translateImplicitConversion(expr ast.Expr, desiredType typ
11131113

11141114
exprType := c.p.TypeOf(expr)
11151115
if types.Identical(exprType, desiredType) {
1116-
return c.translateExpr(expr)
1116+
switch exprType.Underlying().(type) {
1117+
case *types.Interface:
1118+
return c.formatExpr("$copyIntf(%e)", expr)
1119+
default:
1120+
return c.translateExpr(expr)
1121+
}
11171122
}
11181123

11191124
basicExprType, isBasicExpr := exprType.Underlying().(*types.Basic)
@@ -1130,11 +1135,14 @@ func (c *funcContext) translateImplicitConversion(expr ast.Expr, desiredType typ
11301135
// wrap JS object into js.Object struct when converting to interface
11311136
return c.formatExpr("new $jsObjectPtr(%e)", expr)
11321137
}
1138+
if _, isArray := exprType.Underlying().(*types.Array); isArray {
1139+
return c.formatExpr("new %1s($clone(%e, %1s))", c.typeName(exprType), expr)
1140+
}
11331141
if isWrapped(exprType) {
11341142
return c.formatExpr("new %s(%e)", c.typeName(exprType), expr)
11351143
}
11361144
if _, isStruct := exprType.Underlying().(*types.Struct); isStruct {
1137-
return c.formatExpr("new %1e.constructor.elem(%1e)", expr)
1145+
return c.formatExpr("new %1e.constructor.elem($clone(%1e, %s))", expr, c.typeName(exprType))
11381146
}
11391147
}
11401148

_vendor/src/github.com/gopherjs/gopherjs/compiler/natives/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
// in src subfolder.
66
package natives
77

8-
//go:generate vfsgendev -source="github.com/gopherjs/gopherjs/compiler/natives".FS
8+
//go:generate vfsgendev -source="github.com/gopherjs/gopherjs/compiler/natives".FS -tag=gopherjsdev

_vendor/src/github.com/gopherjs/gopherjs/compiler/natives/fs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build dev
1+
// +build gopherjsdev
22

33
package natives
44

0 commit comments

Comments
 (0)