mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/noder: explicitly handle function instantiations
This CL changes unified IR to explicitly handle function instantiations within expression handling, rather than leaving it to the underlying object reading logic. Change-Id: I009a56013fbe9fbc4dabf80eea98993d34af4272 Reviewed-on: https://go-review.googlesource.com/c/go/+/421817 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
6b80b62fd1
commit
2e6ffd6c5d
4 changed files with 67 additions and 46 deletions
|
|
@ -558,24 +558,7 @@ var objReader = map[*types.Sym]pkgReaderIndex{}
|
|||
// obj reads an instantiated object reference from the bitstream.
|
||||
func (r *reader) obj() ir.Node {
|
||||
r.Sync(pkgbits.SyncObject)
|
||||
|
||||
if r.Bool() {
|
||||
idx := r.Len()
|
||||
obj := r.dict.funcsObj[idx]
|
||||
if obj == nil {
|
||||
fn := r.dict.funcs[idx]
|
||||
targs := make([]*types.Type, len(fn.explicits))
|
||||
for i, targ := range fn.explicits {
|
||||
targs[i] = r.p.typIdx(targ, r.dict, true)
|
||||
}
|
||||
|
||||
obj = r.p.objIdx(fn.idx, nil, targs)
|
||||
assert(r.dict.funcsObj[idx] == nil)
|
||||
r.dict.funcsObj[idx] = obj
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
assert(!r.Bool()) // TODO(mdempsky): Remove; was derived func inst.
|
||||
idx := r.Reloc(pkgbits.RelocObj)
|
||||
|
||||
explicits := make([]*types.Type, r.Len())
|
||||
|
|
@ -1860,6 +1843,25 @@ func (r *reader) expr() (res ir.Node) {
|
|||
// TODO(mdempsky): Handle builtins directly in exprCall, like method calls?
|
||||
return typecheck.Callee(r.obj())
|
||||
|
||||
case exprFuncInst:
|
||||
if r.Bool() {
|
||||
idx := r.Len()
|
||||
obj := r.dict.funcsObj[idx]
|
||||
if obj == nil {
|
||||
fn := r.dict.funcs[idx]
|
||||
targs := make([]*types.Type, len(fn.explicits))
|
||||
for i, targ := range fn.explicits {
|
||||
targs[i] = r.p.typIdx(targ, r.dict, true)
|
||||
}
|
||||
|
||||
obj = r.p.objIdx(fn.idx, nil, targs)
|
||||
assert(r.dict.funcsObj[idx] == nil)
|
||||
r.dict.funcsObj[idx] = obj
|
||||
}
|
||||
return obj
|
||||
}
|
||||
return r.obj()
|
||||
|
||||
case exprConst:
|
||||
pos := r.pos()
|
||||
typ := r.typ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue