本文整理匯總了Golang中golang.org/x/tools/go/pointer.PointsToSet.Labels方法的典型用法代碼示例。如果您正苦於以下問題:Golang PointsToSet.Labels方法的具體用法?Golang PointsToSet.Labels怎麽用?Golang PointsToSet.Labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類golang.org/x/tools/go/pointer.PointsToSet
的用法示例。
在下文中一共展示了PointsToSet.Labels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkPointsToExpectation
func checkPointsToExpectation(e *expectation, pts pointer.PointsToSet, lineMapping map[string]string, prog *ssa.Program) bool {
expected := make(map[string]int)
surplus := make(map[string]int)
exact := true
for _, g := range e.args {
if g == "..." {
exact = false
continue
}
expected[g]++
}
// Find the set of labels that the probe's
// argument (x in print(x)) may point to.
for _, label := range pts.Labels() {
name := labelString(label, lineMapping, prog)
if expected[name] > 0 {
expected[name]--
} else if exact {
surplus[name]++
}
}
// Report multiset difference:
ok := true
for _, count := range expected {
if count > 0 {
ok = false
e.errorf("value does not alias these expected labels: %s", join(expected))
break
}
}
for _, count := range surplus {
if count > 0 {
ok = false
e.errorf("value may additionally alias these labels: %s", join(surplus))
break
}
}
return ok
}