Skip to content

Commit

Permalink
go/types: make types.Typ a slice, unexport UniverseByte/Rune
Browse files Browse the repository at this point in the history
In lieu of the more invasive https://go-review.googlesource.com/#/c/12373/ .

Change-Id: I0221783fcaa8af04520c80cd2993d7d542d2c431
Reviewed-on: https://go-review.googlesource.com/12486
Reviewed-by: Alan Donovan <[email protected]>
Run-TryBot: Robert Griesemer <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
griesemer committed Jul 21, 2015
1 parent 72921c6 commit 0505dfc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
4 changes: 1 addition & 3 deletions api/go1.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/go/types/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/go/types/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/go/types/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/go/types/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions src/go/types/universe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0505dfc

Please sign in to comment.