Commit 0505dfc6 authored by Robert Griesemer's avatar Robert Griesemer

go/types: make types.Typ a slice, unexport UniverseByte/Rune

In lieu of the more invasive https://go-review.googlesource.com/#/c/12373/ .

Change-Id: I0221783fcaa8af04520c80cd2993d7d542d2c431
Reviewed-on: https://go-review.googlesource.com/12486Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 72921c66
......@@ -712,10 +712,8 @@ pkg go/types, type TypeAndValue struct, Type Type
pkg go/types, type TypeAndValue struct, Value constant.Value
pkg go/types, type TypeName struct
pkg go/types, type Var struct
pkg go/types, var Typ [26]*Basic
pkg go/types, var Typ []*Basic
pkg go/types, var Universe *Scope
pkg go/types, var UniverseByte *Basic
pkg go/types, var UniverseRune *Basic
pkg go/types, var Unsafe *Package
pkg html/template, method (*Template) Option(...string) *Template
pkg image, const YCbCrSubsampleRatio410 = 5
......
......@@ -95,7 +95,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
// spec: "As a special case, append also accepts a first argument assignable
// to type []byte with a second argument of string type followed by ... .
// This form appends the bytes of the string.
if nargs == 2 && call.Ellipsis.IsValid() && x.assignableTo(check.conf, NewSlice(UniverseByte)) {
if nargs == 2 && call.Ellipsis.IsValid() && x.assignableTo(check.conf, NewSlice(universeByte)) {
arg(x, 1)
if x.mode == invalid {
return
......@@ -288,7 +288,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
switch t := y.typ.Underlying().(type) {
case *Basic:
if isString(y.typ) {
src = UniverseByte
src = universeByte
}
case *Slice:
src = t.elem
......
......@@ -1182,7 +1182,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
// (not a constant) even if the string and the
// index are constant
x.mode = value
x.typ = UniverseByte // use 'byte' name
x.typ = universeByte // use 'byte' name
}
case *Array:
......
......@@ -296,7 +296,7 @@ func defaultType(typ Type) Type {
case UntypedInt:
return Typ[Int]
case UntypedRune:
return UniverseRune // use 'rune' name
return universeRune // use 'rune' name
case UntypedFloat:
return Typ[Float64]
case UntypedComplex:
......
......@@ -628,7 +628,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
case *Basic:
if isString(typ) {
key = Typ[Int]
val = UniverseRune // use 'rune' name
val = universeRune // use 'rune' name
}
case *Array:
key = Typ[Int]
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file implements the universe and unsafe package scopes.
// This file sets up the universe scope and the unsafe package.
package types
......@@ -16,11 +16,11 @@ var (
Universe *Scope
Unsafe *Package
universeIota *Const
UniverseByte *Basic // uint8 alias, but has name "byte"
UniverseRune *Basic // int32 alias, but has name "rune"
universeByte *Basic // uint8 alias, but has name "byte"
universeRune *Basic // int32 alias, but has name "rune"
)
var Typ = [...]*Basic{
var Typ = []*Basic{
Invalid: {Invalid, 0, "invalid type"},
Bool: {Bool, IsBoolean, "bool"},
......@@ -186,8 +186,8 @@ func init() {
defPredeclaredFuncs()
universeIota = Universe.Lookup("iota").(*Const)
UniverseByte = Universe.Lookup("byte").(*TypeName).typ.(*Basic)
UniverseRune = Universe.Lookup("rune").(*TypeName).typ.(*Basic)
universeByte = Universe.Lookup("byte").(*TypeName).typ.(*Basic)
universeRune = Universe.Lookup("rune").(*TypeName).typ.(*Basic)
}
// Objects with names containing blanks are internal and not entered into
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment