mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: more String methods for prove types
These aid in debugging. Change-Id: Ieb38c996765f780f6103f8c3292639d408c25123 Reviewed-on: https://go-review.googlesource.com/87476 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
491f409a32
commit
44e20b64ef
2 changed files with 37 additions and 0 deletions
|
|
@ -707,6 +707,7 @@ var knownFormats = map[string]string{
|
||||||
"uint %04x": "",
|
"uint %04x": "",
|
||||||
"uint %5d": "",
|
"uint %5d": "",
|
||||||
"uint %d": "",
|
"uint %d": "",
|
||||||
|
"uint %x": "",
|
||||||
"uint16 %d": "",
|
"uint16 %d": "",
|
||||||
"uint16 %v": "",
|
"uint16 %v": "",
|
||||||
"uint16 %x": "",
|
"uint16 %x": "",
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,18 @@ const (
|
||||||
gt
|
gt
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var relationStrings = [...]string{
|
||||||
|
0: "none", lt: "<", eq: "==", lt | eq: "<=",
|
||||||
|
gt: ">", gt | lt: "!=", gt | eq: ">=", gt | eq | lt: "any",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r relation) String() string {
|
||||||
|
if r < relation(len(relationStrings)) {
|
||||||
|
return relationStrings[r]
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("relation(%d)", uint(r))
|
||||||
|
}
|
||||||
|
|
||||||
// domain represents the domain of a variable pair in which a set
|
// domain represents the domain of a variable pair in which a set
|
||||||
// of relations is known. For example, relations learned for unsigned
|
// of relations is known. For example, relations learned for unsigned
|
||||||
// pairs cannot be transferred to signed pairs because the same bit
|
// pairs cannot be transferred to signed pairs because the same bit
|
||||||
|
|
@ -58,6 +70,30 @@ const (
|
||||||
boolean
|
boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var domainStrings = [...]string{
|
||||||
|
"signed", "unsigned", "pointer", "boolean",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d domain) String() string {
|
||||||
|
s := ""
|
||||||
|
for i, ds := range domainStrings {
|
||||||
|
if d&(1<<uint(i)) != 0 {
|
||||||
|
if len(s) != 0 {
|
||||||
|
s += "|"
|
||||||
|
}
|
||||||
|
s += ds
|
||||||
|
d &^= 1 << uint(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if d != 0 {
|
||||||
|
if len(s) != 0 {
|
||||||
|
s += "|"
|
||||||
|
}
|
||||||
|
s += fmt.Sprintf("0x%x", uint(d))
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
type pair struct {
|
type pair struct {
|
||||||
v, w *Value // a pair of values, ordered by ID.
|
v, w *Value // a pair of values, ordered by ID.
|
||||||
// v can be nil, to mean the zero value.
|
// v can be nil, to mean the zero value.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue