1
0
mirror of https://github.com/golang/go synced 2024-11-23 13:30:08 -07:00

cmd/compile: rename types.IdealFoo to types.UntypedFoo

To be consistent with go/types.

Passes toolstash-check.

Change-Id: I5e02f529064a904310a164f8765082aa533cc799
Reviewed-on: https://go-review.googlesource.com/c/go/+/260699
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2020-10-08 20:33:36 +07:00
parent f3b58edd03
commit 46ab0c0c04
10 changed files with 58 additions and 58 deletions

View File

@ -160,12 +160,12 @@ func predeclared() []*types.Type {
types.Errortype, types.Errortype,
// untyped types // untyped types
types.Idealbool, types.UntypedBool,
types.Idealint, types.UntypedInt,
types.Idealrune, types.UntypedRune,
types.Idealfloat, types.UntypedFloat,
types.Idealcomplex, types.UntypedComplex,
types.Idealstring, types.UntypedString,
types.Types[TNIL], types.Types[TNIL],
// package unsafe // package unsafe

View File

@ -1019,17 +1019,17 @@ func nodlit(v Val) *Node {
func idealType(ct Ctype) *types.Type { func idealType(ct Ctype) *types.Type {
switch ct { switch ct {
case CTSTR: case CTSTR:
return types.Idealstring return types.UntypedString
case CTBOOL: case CTBOOL:
return types.Idealbool return types.UntypedBool
case CTINT: case CTINT:
return types.Idealint return types.UntypedInt
case CTRUNE: case CTRUNE:
return types.Idealrune return types.UntypedRune
case CTFLT: case CTFLT:
return types.Idealfloat return types.UntypedFloat
case CTCPLX: case CTCPLX:
return types.Idealcomplex return types.UntypedComplex
case CTNIL: case CTNIL:
return types.Types[TNIL] return types.Types[TNIL]
} }
@ -1080,17 +1080,17 @@ func defaultlit2(l *Node, r *Node, force bool) (*Node, *Node) {
func ctype(t *types.Type) Ctype { func ctype(t *types.Type) Ctype {
switch t { switch t {
case types.Idealbool: case types.UntypedBool:
return CTBOOL return CTBOOL
case types.Idealstring: case types.UntypedString:
return CTSTR return CTSTR
case types.Idealint: case types.UntypedInt:
return CTINT return CTINT
case types.Idealrune: case types.UntypedRune:
return CTRUNE return CTRUNE
case types.Idealfloat: case types.UntypedFloat:
return CTFLT return CTFLT
case types.Idealcomplex: case types.UntypedComplex:
return CTCPLX return CTCPLX
} }
Fatalf("bad type %v", t) Fatalf("bad type %v", t)
@ -1111,17 +1111,17 @@ func defaultType(t *types.Type) *types.Type {
} }
switch t { switch t {
case types.Idealbool: case types.UntypedBool:
return types.Types[TBOOL] return types.Types[TBOOL]
case types.Idealstring: case types.UntypedString:
return types.Types[TSTRING] return types.Types[TSTRING]
case types.Idealint: case types.UntypedInt:
return types.Types[TINT] return types.Types[TINT]
case types.Idealrune: case types.UntypedRune:
return types.Runetype return types.Runetype
case types.Idealfloat: case types.UntypedFloat:
return types.Types[TFLOAT64] return types.Types[TFLOAT64]
case types.Idealcomplex: case types.UntypedComplex:
return types.Types[TCOMPLEX128] return types.Types[TCOMPLEX128]
} }

View File

@ -773,17 +773,17 @@ func tconv2(b *bytes.Buffer, t *types.Type, flag FmtFlag, mode fmtMode, visited
if int(t.Etype) < len(basicnames) && basicnames[t.Etype] != "" { if int(t.Etype) < len(basicnames) && basicnames[t.Etype] != "" {
var name string var name string
switch t { switch t {
case types.Idealbool: case types.UntypedBool:
name = "untyped bool" name = "untyped bool"
case types.Idealstring: case types.UntypedString:
name = "untyped string" name = "untyped string"
case types.Idealint: case types.UntypedInt:
name = "untyped int" name = "untyped int"
case types.Idealrune: case types.UntypedRune:
name = "untyped rune" name = "untyped rune"
case types.Idealfloat: case types.UntypedFloat:
name = "untyped float" name = "untyped float"
case types.Idealcomplex: case types.UntypedComplex:
name = "untyped complex" name = "untyped complex"
default: default:
name = basicnames[t.Etype] name = basicnames[t.Etype]
@ -1333,7 +1333,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
n.Orig.exprfmt(s, prec, mode) n.Orig.exprfmt(s, prec, mode)
return return
} }
if n.Type != nil && n.Type.Etype != TIDEAL && n.Type.Etype != TNIL && n.Type != types.Idealbool && n.Type != types.Idealstring { if n.Type != nil && n.Type.Etype != TIDEAL && n.Type.Etype != TNIL && n.Type != types.UntypedBool && n.Type != types.UntypedString {
// Need parens when type begins with what might // Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-. // be misinterpreted as a unary operator: * or <-.
if n.Type.IsPtr() || (n.Type.IsChan() && n.Type.ChanDir() == types.Crecv) { if n.Type.IsPtr() || (n.Type.IsChan() && n.Type.ChanDir() == types.Crecv) {

View File

@ -751,11 +751,11 @@ func (w *exportWriter) param(f *types.Field) {
func constTypeOf(typ *types.Type) Ctype { func constTypeOf(typ *types.Type) Ctype {
switch typ { switch typ {
case types.Idealint, types.Idealrune: case types.UntypedInt, types.UntypedRune:
return CTINT return CTINT
case types.Idealfloat: case types.UntypedFloat:
return CTFLT return CTFLT
case types.Idealcomplex: case types.UntypedComplex:
return CTCPLX return CTCPLX
} }

View File

@ -375,7 +375,7 @@ func (p *importReader) value() (typ *types.Type, v Val) {
v.U = p.string() v.U = p.string()
case CTINT: case CTINT:
x := new(Mpint) x := new(Mpint)
x.Rune = typ == types.Idealrune x.Rune = typ == types.UntypedRune
p.mpint(&x.Val, typ) p.mpint(&x.Val, typ)
v.U = x v.U = x
case CTFLT: case CTFLT:

View File

@ -50,12 +50,12 @@ func initssaconfig() {
// Caching is disabled in the backend, so generating these here avoids allocations. // Caching is disabled in the backend, so generating these here avoids allocations.
_ = types.NewPtr(types.Types[TINTER]) // *interface{} _ = types.NewPtr(types.Types[TINTER]) // *interface{}
_ = types.NewPtr(types.NewPtr(types.Types[TSTRING])) // **string _ = types.NewPtr(types.NewPtr(types.Types[TSTRING])) // **string
_ = types.NewPtr(types.NewPtr(types.Idealstring)) // **string _ = types.NewPtr(types.NewPtr(types.UntypedString)) // **string
_ = types.NewPtr(types.NewSlice(types.Types[TINTER])) // *[]interface{} _ = types.NewPtr(types.NewSlice(types.Types[TINTER])) // *[]interface{}
_ = types.NewPtr(types.NewPtr(types.Bytetype)) // **byte _ = types.NewPtr(types.NewPtr(types.Bytetype)) // **byte
_ = types.NewPtr(types.NewSlice(types.Bytetype)) // *[]byte _ = types.NewPtr(types.NewSlice(types.Bytetype)) // *[]byte
_ = types.NewPtr(types.NewSlice(types.Types[TSTRING])) // *[]string _ = types.NewPtr(types.NewSlice(types.Types[TSTRING])) // *[]string
_ = types.NewPtr(types.NewSlice(types.Idealstring)) // *[]string _ = types.NewPtr(types.NewSlice(types.UntypedString)) // *[]string
_ = types.NewPtr(types.NewPtr(types.NewPtr(types.Types[TUINT8]))) // ***uint8 _ = types.NewPtr(types.NewPtr(types.NewPtr(types.Types[TUINT8]))) // ***uint8
_ = types.NewPtr(types.Types[TINT16]) // *int16 _ = types.NewPtr(types.Types[TINT16]) // *int16
_ = types.NewPtr(types.Types[TINT64]) // *int64 _ = types.NewPtr(types.Types[TINT64]) // *int64

View File

@ -825,7 +825,7 @@ func assignconvfn(n *Node, t *types.Type, context func() string) *Node {
// Convert ideal bool from comparison to plain bool // Convert ideal bool from comparison to plain bool
// if the next step is non-bool (like interface{}). // if the next step is non-bool (like interface{}).
if n.Type == types.Idealbool && !t.IsBoolean() { if n.Type == types.UntypedBool && !t.IsBoolean() {
if n.Op == ONAME || n.Op == OLITERAL { if n.Op == ONAME || n.Op == OLITERAL {
r := nod(OCONVNOP, n, nil) r := nod(OCONVNOP, n, nil)
r.Type = types.Types[TBOOL] r.Type = types.Types[TBOOL]

View File

@ -361,7 +361,7 @@ func typecheck1(n *Node, top int) (res *Node) {
ok |= ctxExpr ok |= ctxExpr
if n.Type == nil && n.Val().Ctype() == CTSTR { if n.Type == nil && n.Val().Ctype() == CTSTR {
n.Type = types.Idealstring n.Type = types.UntypedString
} }
case ONONAME: case ONONAME:
@ -623,8 +623,8 @@ func typecheck1(n *Node, top int) (res *Node) {
// no defaultlit for left // no defaultlit for left
// the outer context gives the type // the outer context gives the type
n.Type = l.Type n.Type = l.Type
if (l.Type == types.Idealfloat || l.Type == types.Idealcomplex) && r.Op == OLITERAL { if (l.Type == types.UntypedFloat || l.Type == types.UntypedComplex) && r.Op == OLITERAL {
n.Type = types.Idealint n.Type = types.UntypedInt
} }
break break
@ -777,7 +777,7 @@ func typecheck1(n *Node, top int) (res *Node) {
if iscmp[n.Op] { if iscmp[n.Op] {
evconst(n) evconst(n)
t = types.Idealbool t = types.UntypedBool
if n.Op != OLITERAL { if n.Op != OLITERAL {
l, r = defaultlit2(l, r, true) l, r = defaultlit2(l, r, true)
n.Left = l n.Left = l
@ -1458,7 +1458,7 @@ func typecheck1(n *Node, top int) (res *Node) {
// Determine result type. // Determine result type.
switch t.Etype { switch t.Etype {
case TIDEAL: case TIDEAL:
n.Type = types.Idealfloat n.Type = types.UntypedFloat
case TCOMPLEX64: case TCOMPLEX64:
n.Type = types.Types[TFLOAT32] n.Type = types.Types[TFLOAT32]
case TCOMPLEX128: case TCOMPLEX128:
@ -1504,7 +1504,7 @@ func typecheck1(n *Node, top int) (res *Node) {
return n return n
case TIDEAL: case TIDEAL:
t = types.Idealcomplex t = types.UntypedComplex
case TFLOAT32: case TFLOAT32:
t = types.Types[TCOMPLEX64] t = types.Types[TCOMPLEX64]
@ -2724,9 +2724,9 @@ func errorDetails(nl Nodes, tstruct *types.Type, isddd bool) string {
// e.g in error messages about wrong arguments to return. // e.g in error messages about wrong arguments to return.
func sigrepr(t *types.Type, isddd bool) string { func sigrepr(t *types.Type, isddd bool) string {
switch t { switch t {
case types.Idealstring: case types.UntypedString:
return "string" return "string"
case types.Idealbool: case types.UntypedBool:
return "bool" return "bool"
} }

View File

@ -123,21 +123,21 @@ func lexinit() {
asNode(s2.Def).SetSubOp(s.op) asNode(s2.Def).SetSubOp(s.op)
} }
types.Idealstring = types.New(TSTRING) types.UntypedString = types.New(TSTRING)
types.Idealbool = types.New(TBOOL) types.UntypedBool = types.New(TBOOL)
types.Types[TANY] = types.New(TANY) types.Types[TANY] = types.New(TANY)
s := builtinpkg.Lookup("true") s := builtinpkg.Lookup("true")
s.Def = asTypesNode(nodbool(true)) s.Def = asTypesNode(nodbool(true))
asNode(s.Def).Sym = lookup("true") asNode(s.Def).Sym = lookup("true")
asNode(s.Def).Name = new(Name) asNode(s.Def).Name = new(Name)
asNode(s.Def).Type = types.Idealbool asNode(s.Def).Type = types.UntypedBool
s = builtinpkg.Lookup("false") s = builtinpkg.Lookup("false")
s.Def = asTypesNode(nodbool(false)) s.Def = asTypesNode(nodbool(false))
asNode(s.Def).Sym = lookup("false") asNode(s.Def).Sym = lookup("false")
asNode(s.Def).Name = new(Name) asNode(s.Def).Name = new(Name)
asNode(s.Def).Type = types.Idealbool asNode(s.Def).Type = types.UntypedBool
s = lookup("_") s = lookup("_")
s.Block = -100 s.Block = -100
@ -351,7 +351,7 @@ func typeinit() {
sizeofString = Rnd(sliceLenOffset+int64(Widthptr), int64(Widthptr)) sizeofString = Rnd(sliceLenOffset+int64(Widthptr), int64(Widthptr))
dowidth(types.Types[TSTRING]) dowidth(types.Types[TSTRING])
dowidth(types.Idealstring) dowidth(types.UntypedString)
} }
func makeErrorInterface() *types.Type { func makeErrorInterface() *types.Type {

View File

@ -105,14 +105,14 @@ var (
Errortype *Type Errortype *Type
// Types to represent untyped string and boolean constants. // Types to represent untyped string and boolean constants.
Idealstring *Type UntypedString *Type
Idealbool *Type UntypedBool *Type
// Types to represent untyped numeric constants. // Types to represent untyped numeric constants.
Idealint = New(TIDEAL) UntypedInt = New(TIDEAL)
Idealrune = New(TIDEAL) UntypedRune = New(TIDEAL)
Idealfloat = New(TIDEAL) UntypedFloat = New(TIDEAL)
Idealcomplex = New(TIDEAL) UntypedComplex = New(TIDEAL)
) )
// A Type represents a Go type. // A Type represents a Go type.
@ -1436,7 +1436,7 @@ func (t *Type) IsUntyped() bool {
if t == nil { if t == nil {
return false return false
} }
if t == Idealstring || t == Idealbool { if t == UntypedString || t == UntypedBool {
return true return true
} }
switch t.Etype { switch t.Etype {