]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: make types.Typ a slice, unexport UniverseByte/Rune
authorRobert Griesemer <gri@golang.org>
Tue, 21 Jul 2015 19:32:59 +0000 (12:32 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 21 Jul 2015 20:28:23 +0000 (20:28 +0000)
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 <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
api/go1.5.txt
src/go/types/builtins.go
src/go/types/expr.go
src/go/types/predicates.go
src/go/types/stmt.go
src/go/types/universe.go

index 69ffeee33967e5b01b6b15a6ab1c25abd11d37d7..069a87649bb9d47ebbd07c118a18c36a31cf8658 100644 (file)
@@ -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
index 3b81b0760b5d9d70ec77b0c8f8c87b931b250bf2..9a2b665cbfe0893ff5bf97f268584619ba1dfb48 100644 (file)
@@ -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
index 63a014a92934c737d6bb6c12df557fc03957fdbb..9a057befa1620787c5322a09f49e0705fadb9675 100644 (file)
@@ -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:
index b5c39d9d167f35e30b42bfd1031bf79defddecc8..993c6d290b13ad06439c119ab9ffdd91e5037f71 100644 (file)
@@ -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:
index 7fdcb7925c95dca2ca4c5de3ff088ba7d810d305..731059ef7d7e7fce076459b0c8b4557866e58946 100644 (file)
@@ -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]
index 79f9db5265a78ef7cc4d8cc924c131388bfb1253..38a3a3eadbb06e6a6c585b197e244b06f122ed85 100644 (file)
@@ -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