Increment coroID per-struct, not per-package

This commit is contained in:
Nigel Tao committed 2020-02-05 17:15:09 +11:00
1 parent 4ab2de9b95
commit b37e55f4a5
2 files changed
+6 -3

No files matched your search

+2 -1
View File
@@ -499,7 +499,7 @@ type gen struct {
currFunk funk currFunk funk
funks map[t.QQID]funk funks map[t.QQID]funk
numPublicCoroutines uint32 numPublicCoroutines map[t.QID]uint32
} }
func (g *gen) generate() ([]byte, error) { func (g *gen) generate() ([]byte, error) {
@@ -544,6 +544,7 @@ func (g *gen) generate() ([]byte, error) {
} }
g.structMap = map[t.QID]*a.Struct{} g.structMap = map[t.QID]*a.Struct{}
g.privateDataFields = map[t.QQID]struct{}{} g.privateDataFields = map[t.QQID]struct{}{}
g.numPublicCoroutines = map[t.QID]uint32{}
for _, n := range g.structList { for _, n := range g.structList {
qid := n.QID() qid := n.QID()
g.structMap[qid] = n g.structMap[qid] = n
+4 -2
View File
@@ -199,14 +199,16 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
} }
func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error { func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error {
coroID := uint32(0)
if n.Public() && n.Effect().Coroutine() { if n.Public() && n.Effect().Coroutine() {
g.numPublicCoroutines++ g.numPublicCoroutines[n.Receiver()]++
coroID = g.numPublicCoroutines[n.Receiver()]
} }
g.currFunk = funk{ g.currFunk = funk{
astFunc: n, astFunc: n,
cName: g.funcCName(n), cName: g.funcCName(n),
coroID: g.numPublicCoroutines, coroID: coroID,
returnsStatus: n.Effect().Coroutine() || returnsStatus: n.Effect().Coroutine() ||
((n.Out() != nil) && n.Out().IsStatus()), ((n.Out() != nil) && n.Out().IsStatus()),