diff options
Diffstat (limited to 'src/cmd/compile/internal/gc/subr.go')
-rw-r--r-- | src/cmd/compile/internal/gc/subr.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index 153e6210cc..0d197886b0 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -12,6 +12,7 @@ import ( "fmt" "os" "sort" + "strconv" "strings" "unicode" "unicode/utf8" @@ -223,6 +224,15 @@ func LookupBytes(name []byte) *Sym { return localpkg.LookupBytes(name) } +// LookupN looks up the symbol starting with prefix and ending with +// the decimal n. If prefix is too long, LookupN panics. +func LookupN(prefix string, n int) *Sym { + var buf [20]byte // plenty long enough for all current users + copy(buf[:], prefix) + b := strconv.AppendInt(buf[:len(prefix)], int64(n), 10) + return LookupBytes(b) +} + var initSyms []*Sym var nopkg = &Pkg{ |