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)
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)
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))
// 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
return
}
- if i := strings.LastIndex(name, "."); i >= 0 && !strings.HasPrefix(name, ".dict") { // TODO: just use autotmp names for dictionaries?
+ if i := strings.LastIndex(name, "."); i >= 0 && !strings.HasPrefix(name, LocalDictName) {
base.Fatalf("unexpected dot in identifier: %v", name)
}
// information (e.g. length field for OSLICELIT).
const go117ExportTypes = true
const Go117ExportTypes = go117ExportTypes
+
+// The name used for dictionary parameters or local variables.
+const LocalDictName = ".dict"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/types"
+ "cmd/internal/objabi"
"cmd/internal/src"
)
}
}
name := makeInstName1(gf.Name, targs, hasBrackets)
- name = ".dict." + name
+ name = fmt.Sprintf("%s.%s", objabi.GlobalDictPrefix, name)
return gf.Pkg.Lookup(name)
}
if strings.HasPrefix(s.Name, "go.itab.") && s.Type == objabi.SRODATA {
flag2 |= goobj.SymFlagItab
}
- if strings.HasPrefix(s.Name, w.ctxt.Pkgpath) && strings.HasPrefix(s.Name[len(w.ctxt.Pkgpath):], "..dict") {
+ if strings.HasPrefix(s.Name, w.ctxt.Pkgpath) && strings.HasPrefix(s.Name[len(w.ctxt.Pkgpath):], ".") && strings.HasPrefix(s.Name[len(w.ctxt.Pkgpath)+1:], objabi.GlobalDictPrefix) {
flag2 |= goobj.SymFlagDict
}
name := s.Name