mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Replaced incorrect recursion-free rendering of DFS with something that was correct. Enhanced test with all permutations of IF successors to ensure that all possible DFS traversals are exercised. Test is improved version of https://go-review.googlesource.com/#/c/22334 Update 15084. Change-Id: I6e944c41244e47fe5f568dfc2b360ff93b94079e Reviewed-on: https://go-review.googlesource.com/22347 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: David Chase <drchase@google.com>
28 lines
576 B
Go
28 lines
576 B
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ssa
|
|
|
|
type ID int32
|
|
|
|
// idAlloc provides an allocator for unique integers.
|
|
type idAlloc struct {
|
|
last ID
|
|
}
|
|
|
|
// get allocates an ID and returns it. IDs are always > 0.
|
|
func (a *idAlloc) get() ID {
|
|
x := a.last
|
|
x++
|
|
if x == 1<<31-1 {
|
|
panic("too many ids for this function")
|
|
}
|
|
a.last = x
|
|
return x
|
|
}
|
|
|
|
// num returns the maximum ID ever returned + 1.
|
|
func (a *idAlloc) num() int {
|
|
return int(a.last + 1)
|
|
}
|