| 1 |
// Copyright 2026 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package dense_test |
| 6 |
|
| 7 |
import ( |
| 8 |
"honnef.co/go/tools/analysis/dfa" |
| 9 |
) |
| 10 |
|
| 11 |
type nodeSet uint64 |
| 12 |
|
| 13 |
type nodeSetUnion struct{} |
| 14 |
|
| 15 |
func (nodeSetUnion) Ident() nodeSet { return 0 } |
| 16 |
func (nodeSetUnion) Equals(a, b nodeSet) bool { return a == b } |
| 17 |
func (nodeSetUnion) Merge(a, b nodeSet) nodeSet { return a | b } |
| 18 |
|
| 19 |
var _ dfa.Semilattice[nodeSet] = nodeSetUnion{} |
| 20 |
|
| 21 |
func set(nodes ...int) nodeSet { |
| 22 |
var out nodeSet |
| 23 |
for _, node := range nodes { |
| 24 |
if node < 0 || node >= 64 { |
| 25 |
panic("NodeID out of range") |
| 26 |
} |
| 27 |
out |= 1 << node |
| 28 |
} |
| 29 |
return out |
| 30 |
} |