1
2
3
4
5
6
7 package ir
8
9 import (
10 "cmd/compile/internal/types"
11 "cmd/internal/src"
12 "fmt"
13 "go/constant"
14 )
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 type miniNode struct {
32 pos src.XPos
33 op Op
34 bits bitset8
35 esc uint16
36 }
37
38
39
40 func (n *miniNode) posOr(pos src.XPos) src.XPos {
41 if pos.IsKnown() {
42 return pos
43 }
44 return n.pos
45 }
46
47
48
49
50 func (n *miniNode) Op() Op { return n.op }
51 func (n *miniNode) Pos() src.XPos { return n.pos }
52 func (n *miniNode) SetPos(x src.XPos) { n.pos = x }
53 func (n *miniNode) Esc() uint16 { return n.esc }
54 func (n *miniNode) SetEsc(x uint16) { n.esc = x }
55
56 const (
57 miniWalkdefShift = 0
58 miniTypecheckShift = 2
59 miniDiag = 1 << 4
60 miniWalked = 1 << 5
61 )
62
63 func (n *miniNode) Typecheck() uint8 { return n.bits.get2(miniTypecheckShift) }
64 func (n *miniNode) SetTypecheck(x uint8) {
65 if x > 2 {
66 panic(fmt.Sprintf("cannot SetTypecheck %d", x))
67 }
68 n.bits.set2(miniTypecheckShift, x)
69 }
70
71 func (n *miniNode) Diag() bool { return n.bits&miniDiag != 0 }
72 func (n *miniNode) SetDiag(x bool) { n.bits.set(miniDiag, x) }
73
74 func (n *miniNode) Walked() bool { return n.bits&miniWalked != 0 }
75 func (n *miniNode) SetWalked(x bool) { n.bits.set(miniWalked, x) }
76
77
78
79 func (n *miniNode) Init() Nodes { return Nodes{} }
80
81
82
83 func (n *miniNode) no(name string) string { return "cannot " + name + " on " + n.op.String() }
84
85 func (n *miniNode) Type() *types.Type { return nil }
86 func (n *miniNode) SetType(*types.Type) { panic(n.no("SetType")) }
87 func (n *miniNode) Name() *Name { return nil }
88 func (n *miniNode) Sym() *types.Sym { return nil }
89 func (n *miniNode) Val() constant.Value { panic(n.no("Val")) }
90 func (n *miniNode) SetVal(v constant.Value) { panic(n.no("SetVal")) }
91 func (n *miniNode) NonNil() bool { return false }
92 func (n *miniNode) MarkNonNil() { panic(n.no("MarkNonNil")) }
93
View as plain text