1
2
3
4
5 package ir
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/internal/src"
10 "fmt"
11 "path/filepath"
12 "strings"
13 )
14
15
16
17
18 func checkStaticValueResult(n Node, newres Node) {
19 oldres := StaticValue(n)
20 if oldres != newres {
21 base.Fatalf("%s: new/old static value disagreement on %v:\nnew=%v\nold=%v", fmtFullPos(n.Pos()), n, newres, oldres)
22 }
23 }
24
25
26
27
28 func checkReassignedResult(n *Name, newres bool) {
29 origres := Reassigned(n)
30 if newres != origres {
31 base.Fatalf("%s: new/old reassigned disagreement on %v (class %s) newres=%v oldres=%v", fmtFullPos(n.Pos()), n, n.Class.String(), newres, origres)
32 }
33 }
34
35
36 func fmtFullPos(p src.XPos) string {
37 var sb strings.Builder
38 sep := ""
39 base.Ctxt.AllPos(p, func(pos src.Pos) {
40 fmt.Fprintf(&sb, sep)
41 sep = "|"
42 file := filepath.Base(pos.Filename())
43 fmt.Fprintf(&sb, "%s:%d:%d", file, pos.Line(), pos.Col())
44 })
45 return sb.String()
46 }
47
View as plain text