...
1
2
3
4
5 package pointer
6
7
8
9 import (
10 "fmt"
11 "go/token"
12
13 "golang.org/x/tools/go/ssa"
14 )
15
16 type cgnode struct {
17 fn *ssa.Function
18 obj nodeid
19 sites []*callsite
20 callersite *callsite
21 }
22
23
24 func (n *cgnode) contour() string {
25 if n.callersite == nil {
26 return "shared contour"
27 }
28 if n.callersite.instr != nil {
29 return fmt.Sprintf("as called from %s", n.callersite.instr.Parent())
30 }
31 return fmt.Sprintf("as called from intrinsic (targets=n%d)", n.callersite.targets)
32 }
33
34 func (n *cgnode) String() string {
35 return fmt.Sprintf("cg%d:%s", n.obj, n.fn)
36 }
37
38
39
40
41
42 type callsite struct {
43 targets nodeid
44 instr ssa.CallInstruction
45 }
46
47 func (c *callsite) String() string {
48 if c.instr != nil {
49 return c.instr.Common().Description()
50 }
51 return "synthetic function call"
52 }
53
54
55 func (c *callsite) pos() token.Pos {
56 if c.instr != nil {
57 return c.instr.Pos()
58 }
59 return token.NoPos
60 }
61
View as plain text