Skip to content

Commit f9b66ec

Browse files
committed
Merge keepOriginal and pruneOriginal into a single struct
1 parent a8add9b commit f9b66ec

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

build/build.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
135135
var files []*ast.File
136136

137137
type overrideInfo struct {
138-
keepOverridden bool
138+
keepOriginal bool
139+
pruneOriginal bool
139140
}
140141
replacedDeclNames := make(map[string]overrideInfo)
141-
pruneOriginalFuncs := make(map[string]bool)
142142

143143
isXTest := strings.HasSuffix(pkg.ImportPath, "_test")
144144
importPath := pkg.ImportPath
@@ -177,8 +177,10 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
177177
switch d := decl.(type) {
178178
case *ast.FuncDecl:
179179
k := astutil.FuncKey(d)
180-
replacedDeclNames[k] = overrideInfo{keepOverridden: astutil.KeepOriginal(d)}
181-
pruneOriginalFuncs[k] = astutil.PruneOriginal(d)
180+
replacedDeclNames[k] = overrideInfo{
181+
keepOriginal: astutil.KeepOriginal(d),
182+
pruneOriginal: astutil.PruneOriginal(d),
183+
}
182184
case *ast.GenDecl:
183185
switch d.Tok {
184186
case token.TYPE:
@@ -242,12 +244,12 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
242244
case *ast.FuncDecl:
243245
k := astutil.FuncKey(d)
244246
if info, ok := replacedDeclNames[k]; ok {
245-
if pruneOriginalFuncs[k] {
247+
if info.pruneOriginal {
246248
// Prune function bodies, since it may contain code invalid for
247249
// GopherJS and pin unwanted imports.
248250
d.Body = nil
249251
}
250-
if info.keepOverridden {
252+
if info.keepOriginal {
251253
// Allow overridden function calls
252254
// The standard library implementation of foo() becomes _gopherjs_overridden_foo()
253255
d.Name.Name = "_gopherjs_overridden_" + d.Name.Name

0 commit comments

Comments
 (0)