diff options
| author | Dan Scales <danscales@google.com> | 2021-09-22 08:52:41 -0700 |
|---|---|---|
| committer | Dan Scales <danscales@google.com> | 2021-09-22 23:17:55 +0000 |
| commit | ee69b09424f611d02d4b0f0da3eff875e075438f (patch) | |
| tree | 6c24b7f2360d70242cc61c94da297c9ac80319d4 /src/cmd/compile/internal/noder | |
| parent | 1319b1476ea6f55c780936d133a005054fa81234 (diff) | |
| download | go-ee69b09424f611d02d4b0f0da3eff875e075438f.tar.xz | |
cmd/compile: break out constants for local and global dictionary prefixes
Create constant LocalDictName for the pname/refix for dictionary
parameters or local variables, and constant GlobalDictPrefix for the
prefix for names of global dictionaries. I wanted to make sure these
constants were set up as we add more reference to dictionaries for
debugging, etc.
Change-Id: Ide801f842383300a2699c96943ec06decaecc358
Reviewed-on: https://go-review.googlesource.com/c/go/+/351450
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
| -rw-r--r-- | src/cmd/compile/internal/noder/stencil.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 7fca674132..c8ce230121 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -401,10 +401,7 @@ func (g *irgen) buildClosure(outer *ir.Func, x ir.Node) ir.Node { var dictVar *ir.Name var dictAssign *ir.AssignStmt if outer != nil { - // Note: for now this is a compile-time constant, so we don't really need a closure - // to capture it (a wrapper function would work just as well). But eventually it - // will be a read of a subdictionary from the parent dictionary. - dictVar = ir.NewNameAt(pos, typecheck.LookupNum(".dict", g.dnum)) + dictVar = ir.NewNameAt(pos, typecheck.LookupNum(typecheck.LocalDictName, g.dnum)) g.dnum++ dictVar.Class = ir.PAUTO typed(types.Types[types.TUINTPTR], dictVar) @@ -723,7 +720,7 @@ func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*typ newf.Dcl = make([]*ir.Name, 0, len(gf.Dcl)+1) // Create the needed dictionary param - dictionarySym := newsym.Pkg.Lookup(".dict") + dictionarySym := newsym.Pkg.Lookup(typecheck.LocalDictName) dictionaryType := types.Types[types.TUINTPTR] dictionaryName := ir.NewNameAt(gf.Pos(), dictionarySym) typed(dictionaryType, dictionaryName) @@ -731,7 +728,7 @@ func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*typ dictionaryName.Curfn = newf newf.Dcl = append(newf.Dcl, dictionaryName) for _, n := range gf.Dcl { - if n.Sym().Name == ".dict" { + if n.Sym().Name == typecheck.LocalDictName { panic("already has dictionary") } newf.Dcl = append(newf.Dcl, subst.localvar(n)) @@ -1127,7 +1124,7 @@ func (subst *subster) node(n ir.Node) ir.Node { // Copy that closure variable to a local one. // Note: this allows the dictionary to be captured by child closures. // See issue 47723. - ldict := ir.NewNameAt(x.Pos(), newfn.Sym().Pkg.Lookup(".dict")) + ldict := ir.NewNameAt(x.Pos(), newfn.Sym().Pkg.Lookup(typecheck.LocalDictName)) typed(types.Types[types.TUINTPTR], ldict) ldict.Class = ir.PAUTO ldict.Curfn = newfn |
