1// Copyright 2015 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 5package ssa 6 7type ID int32 8 9// idAlloc provides an allocator for unique integers. 10type idAlloc struct { 11 last ID 12} 13 14// get allocates an ID and returns it. IDs are always > 0. 15func (a *idAlloc) get() ID { 16 x := a.last 17 x++ 18 if x == 1<<31-1 { 19 panic("too many ids for this function") 20 } 21 a.last = x 22 return x 23} 24 25// num returns the maximum ID ever returned + 1. 26func (a *idAlloc) num() int { 27 return int(a.last + 1) 28} 29