func visitMakeChan(instr *ssa.MakeChan, infer *TypeInfer, ctx *Context) { newch := &Value{instr, ctx.F.InstanceID(), ctx.L.Index} ctx.F.locals[instr] = newch chType, ok := instr.Type().(*types.Chan) if !ok { infer.Logger.Fatal(ErrMakeChanNonChan) } bufSz, ok := instr.Size.(*ssa.Const) if !ok { infer.Logger.Fatal(ErrNonConstChanBuf) } infer.Logger.Printf(ctx.F.Sprintf(ChanSymbol+"%s = %s {t:%s, buf:%d} @ %s", newch, fmtChan("chan"), chType.Elem(), bufSz.Int64(), fmtPos(infer.SSA.FSet.Position(instr.Pos()).String()))) ctx.F.FuncDef.AddStmts(&migo.NewChanStatement{Name: instr, Chan: newch.String(), Size: bufSz.Int64()}) // Make sure it is not a duplicated extraargs var found bool for _, ea := range ctx.F.extraargs { if phi, ok := ea.(*ssa.Phi); ok { if instr.Block().Index < len(phi.Edges) { if phi.Edges[instr.Block().Index].Name() == instr.Name() { found = true } } } } if !found { ctx.F.extraargs = append(ctx.F.extraargs, instr) } }