Commit e8475c94 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile/internal/types: shorten struct type names

They are in the types package, no need to mention the Type suffix.

Change-Id: Ie4fe1e3c1793514145e33f9df373d715f63e1aad
Reviewed-on: https://go-review.googlesource.com/39911
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 5c850cc2
...@@ -58,7 +58,7 @@ func expandiface(t *types.Type) { ...@@ -58,7 +58,7 @@ func expandiface(t *types.Type) {
// Access fields directly to avoid recursively calling dowidth // Access fields directly to avoid recursively calling dowidth
// within Type.Fields(). // within Type.Fields().
t.Extra.(*types.InterType).Fields.Set(fields) t.Extra.(*types.Interface).Fields.Set(fields)
} }
func offmod(t *types.Type) { func offmod(t *types.Type) {
...@@ -337,7 +337,7 @@ func dowidth(t *types.Type) { ...@@ -337,7 +337,7 @@ func dowidth(t *types.Type) {
w = widstruct(t1, t1.Recvs(), 0, 0) w = widstruct(t1, t1.Recvs(), 0, 0)
w = widstruct(t1, t1.Params(), w, Widthreg) w = widstruct(t1, t1.Params(), w, Widthreg)
w = widstruct(t1, t1.Results(), w, Widthreg) w = widstruct(t1, t1.Results(), w, Widthreg)
t1.Extra.(*types.FuncType).Argwid = w t1.Extra.(*types.Func).Argwid = w
if w%int64(Widthreg) != 0 { if w%int64(Widthreg) != 0 {
Warn("bad type %v %d\n", t1, w) Warn("bad type %v %d\n", t1, w)
} }
......
...@@ -505,16 +505,16 @@ func (p *importer) typ() *types.Type { ...@@ -505,16 +505,16 @@ func (p *importer) typ() *types.Type {
t = p.newtyp(TARRAY) t = p.newtyp(TARRAY)
bound := p.int64() bound := p.int64()
elem := p.typ() elem := p.typ()
t.Extra = &types.ArrayType{Elem: elem, Bound: bound} t.Extra = &types.Array{Elem: elem, Bound: bound}
case sliceTag: case sliceTag:
t = p.newtyp(TSLICE) t = p.newtyp(TSLICE)
elem := p.typ() elem := p.typ()
t.Extra = types.SliceType{Elem: elem} t.Extra = types.Slice{Elem: elem}
case dddTag: case dddTag:
t = p.newtyp(TDDDFIELD) t = p.newtyp(TDDDFIELD)
t.Extra = types.DDDFieldType{T: p.typ()} t.Extra = types.DDDField{T: p.typ()}
case structTag: case structTag:
t = p.newtyp(TSTRUCT) t = p.newtyp(TSTRUCT)
...@@ -523,7 +523,7 @@ func (p *importer) typ() *types.Type { ...@@ -523,7 +523,7 @@ func (p *importer) typ() *types.Type {
case pointerTag: case pointerTag:
t = p.newtyp(types.Tptr) t = p.newtyp(types.Tptr)
t.Extra = types.PtrType{Elem: p.typ()} t.Extra = types.Ptr{Elem: p.typ()}
case signatureTag: case signatureTag:
t = p.newtyp(TFUNC) t = p.newtyp(TFUNC)
......
...@@ -24,18 +24,18 @@ func TestSizeof(t *testing.T) { ...@@ -24,18 +24,18 @@ func TestSizeof(t *testing.T) {
}{ }{
{Sym{}, 60, 104}, {Sym{}, 60, 104},
{Type{}, 52, 88}, {Type{}, 52, 88},
{MapType{}, 20, 40}, {Map{}, 20, 40},
{ForwardType{}, 20, 32}, {Forward{}, 20, 32},
{FuncType{}, 28, 48}, {Func{}, 28, 48},
{StructType{}, 12, 24}, {Struct{}, 12, 24},
{InterType{}, 4, 8}, {Interface{}, 4, 8},
{ChanType{}, 8, 16}, {Chan{}, 8, 16},
{ArrayType{}, 12, 16}, {Array{}, 12, 16},
{DDDFieldType{}, 4, 8}, {DDDField{}, 4, 8},
{FuncArgsType{}, 4, 8}, {FuncArgs{}, 4, 8},
{ChanArgsType{}, 4, 8}, {ChanArgs{}, 4, 8},
{PtrType{}, 4, 8}, {Ptr{}, 4, 8},
{SliceType{}, 4, 8}, {Slice{}, 4, 8},
} }
for _, tt := range tests { for _, tt := range tests {
......
...@@ -123,18 +123,18 @@ type Type struct { ...@@ -123,18 +123,18 @@ type Type struct {
// As an optimization, those etype-specific structs which contain exactly // As an optimization, those etype-specific structs which contain exactly
// one pointer-shaped field are stored as values rather than pointers when possible. // one pointer-shaped field are stored as values rather than pointers when possible.
// //
// TMAP: *MapType // TMAP: *Map
// TFORW: *ForwardType // TFORW: *Forward
// TFUNC: *FuncType // TFUNC: *Func
// TSTRUCT: *StructType // TSTRUCT: *Struct
// TINTER: *InterType // TINTER: *Inter
// TDDDFIELD: DDDFieldType // TDDDFIELD: DDDField
// TFUNCARGS: FuncArgsType // TFUNCARGS: FuncArgs
// TCHANARGS: ChanArgsType // TCHANARGS: ChanArgs
// TCHAN: *ChanType // TCHAN: *Chan
// TPTR32, TPTR64: PtrType // TPTR32, TPTR64: Ptr
// TARRAY: *ArrayType // TARRAY: *Array
// TSLICE: SliceType // TSLICE: Slice
Extra interface{} Extra interface{}
// Width is the width of this Type in bytes. // Width is the width of this Type in bytes.
...@@ -181,8 +181,8 @@ func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) } ...@@ -181,8 +181,8 @@ func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) }
func (t *Type) SetDeferwidth(b bool) { t.flags.set(typeDeferwidth, b) } func (t *Type) SetDeferwidth(b bool) { t.flags.set(typeDeferwidth, b) }
func (t *Type) SetRecur(b bool) { t.flags.set(typeRecur, b) } func (t *Type) SetRecur(b bool) { t.flags.set(typeRecur, b) }
// MapType contains Type fields specific to maps. // Map contains Type fields specific to maps.
type MapType struct { type Map struct {
Key *Type // Key type Key *Type // Key type
Val *Type // Val (elem) type Val *Type // Val (elem) type
...@@ -192,25 +192,25 @@ type MapType struct { ...@@ -192,25 +192,25 @@ type MapType struct {
} }
// MapType returns t's extra map-specific fields. // MapType returns t's extra map-specific fields.
func (t *Type) MapType() *MapType { func (t *Type) MapType() *Map {
t.wantEtype(TMAP) t.wantEtype(TMAP)
return t.Extra.(*MapType) return t.Extra.(*Map)
} }
// ForwardType contains Type fields specific to forward types. // Forward contains Type fields specific to forward types.
type ForwardType struct { type Forward struct {
Copyto []*Node // where to copy the eventual value to Copyto []*Node // where to copy the eventual value to
Embedlineno src.XPos // first use of this type as an embedded type Embedlineno src.XPos // first use of this type as an embedded type
} }
// ForwardType returns t's extra forward-type-specific fields. // ForwardType returns t's extra forward-type-specific fields.
func (t *Type) ForwardType() *ForwardType { func (t *Type) ForwardType() *Forward {
t.wantEtype(TFORW) t.wantEtype(TFORW)
return t.Extra.(*ForwardType) return t.Extra.(*Forward)
} }
// FuncType contains Type fields specific to func types. // Func contains Type fields specific to func types.
type FuncType struct { type Func struct {
Receiver *Type // function receiver Receiver *Type // function receiver
Results *Type // function results Results *Type // function results
Params *Type // function params Params *Type // function params
...@@ -226,13 +226,13 @@ type FuncType struct { ...@@ -226,13 +226,13 @@ type FuncType struct {
} }
// FuncType returns t's extra func-specific fields. // FuncType returns t's extra func-specific fields.
func (t *Type) FuncType() *FuncType { func (t *Type) FuncType() *Func {
t.wantEtype(TFUNC) t.wantEtype(TFUNC)
return t.Extra.(*FuncType) return t.Extra.(*Func)
} }
// StructType contains Type fields specific to struct types. // StructType contains Type fields specific to struct types.
type StructType struct { type Struct struct {
fields Fields fields Fields
// Maps have three associated internal structs (see struct MapType). // Maps have three associated internal structs (see struct MapType).
...@@ -253,56 +253,56 @@ const ( ...@@ -253,56 +253,56 @@ const (
) )
// StructType returns t's extra struct-specific fields. // StructType returns t's extra struct-specific fields.
func (t *Type) StructType() *StructType { func (t *Type) StructType() *Struct {
t.wantEtype(TSTRUCT) t.wantEtype(TSTRUCT)
return t.Extra.(*StructType) return t.Extra.(*Struct)
} }
// InterType contains Type fields specific to interface types. // Interface contains Type fields specific to interface types.
type InterType struct { type Interface struct {
Fields Fields Fields Fields
} }
// PtrType contains Type fields specific to pointer types. // Ptr contains Type fields specific to pointer types.
type PtrType struct { type Ptr struct {
Elem *Type // element type Elem *Type // element type
} }
// DDDFieldType contains Type fields specific to TDDDFIELD types. // DDDField contains Type fields specific to TDDDFIELD types.
type DDDFieldType struct { type DDDField struct {
T *Type // reference to a slice type for ... args T *Type // reference to a slice type for ... args
} }
// ChanArgsType contains Type fields specific to TCHANARGS types. // ChanArgs contains Type fields specific to TCHANARGS types.
type ChanArgsType struct { type ChanArgs struct {
T *Type // reference to a chan type whose elements need a width check T *Type // reference to a chan type whose elements need a width check
} }
// // FuncArgsType contains Type fields specific to TFUNCARGS types. // // FuncArgs contains Type fields specific to TFUNCARGS types.
type FuncArgsType struct { type FuncArgs struct {
T *Type // reference to a func type whose elements need a width check T *Type // reference to a func type whose elements need a width check
} }
// ChanType contains Type fields specific to channel types. // Chan contains Type fields specific to channel types.
type ChanType struct { type Chan struct {
Elem *Type // element type Elem *Type // element type
Dir ChanDir // channel direction Dir ChanDir // channel direction
} }
// ChanType returns t's extra channel-specific fields. // ChanType returns t's extra channel-specific fields.
func (t *Type) ChanType() *ChanType { func (t *Type) ChanType() *Chan {
t.wantEtype(TCHAN) t.wantEtype(TCHAN)
return t.Extra.(*ChanType) return t.Extra.(*Chan)
} }
// ArrayType contains Type fields specific to array types. // Array contains Type fields specific to array types.
type ArrayType struct { type Array struct {
Elem *Type // element type Elem *Type // element type
Bound int64 // number of elements; <0 if unknown yet Bound int64 // number of elements; <0 if unknown yet
} }
// SliceType contains Type fields specific to slice types. // Slice contains Type fields specific to slice types.
type SliceType struct { type Slice struct {
Elem *Type // element type Elem *Type // element type
} }
...@@ -406,25 +406,25 @@ func New(et EType) *Type { ...@@ -406,25 +406,25 @@ func New(et EType) *Type {
// TODO(josharian): lazily initialize some of these? // TODO(josharian): lazily initialize some of these?
switch t.Etype { switch t.Etype {
case TMAP: case TMAP:
t.Extra = new(MapType) t.Extra = new(Map)
case TFORW: case TFORW:
t.Extra = new(ForwardType) t.Extra = new(Forward)
case TFUNC: case TFUNC:
t.Extra = new(FuncType) t.Extra = new(Func)
case TSTRUCT: case TSTRUCT:
t.Extra = new(StructType) t.Extra = new(Struct)
case TINTER: case TINTER:
t.Extra = new(InterType) t.Extra = new(Interface)
case TPTR32, TPTR64: case TPTR32, TPTR64:
t.Extra = PtrType{} t.Extra = Ptr{}
case TCHANARGS: case TCHANARGS:
t.Extra = ChanArgsType{} t.Extra = ChanArgs{}
case TFUNCARGS: case TFUNCARGS:
t.Extra = FuncArgsType{} t.Extra = FuncArgs{}
case TDDDFIELD: case TDDDFIELD:
t.Extra = DDDFieldType{} t.Extra = DDDField{}
case TCHAN: case TCHAN:
t.Extra = new(ChanType) t.Extra = new(Chan)
} }
return t return t
} }
...@@ -435,7 +435,7 @@ func NewArray(elem *Type, bound int64) *Type { ...@@ -435,7 +435,7 @@ func NewArray(elem *Type, bound int64) *Type {
Fatalf("NewArray: invalid bound %v", bound) Fatalf("NewArray: invalid bound %v", bound)
} }
t := New(TARRAY) t := New(TARRAY)
t.Extra = &ArrayType{Elem: elem, Bound: bound} t.Extra = &Array{Elem: elem, Bound: bound}
t.SetNotInHeap(elem.NotInHeap()) t.SetNotInHeap(elem.NotInHeap())
return t return t
} }
...@@ -450,7 +450,7 @@ func NewSlice(elem *Type) *Type { ...@@ -450,7 +450,7 @@ func NewSlice(elem *Type) *Type {
} }
t := New(TSLICE) t := New(TSLICE)
t.Extra = SliceType{Elem: elem} t.Extra = Slice{Elem: elem}
elem.SliceOf = t elem.SliceOf = t
return t return t
} }
...@@ -458,7 +458,7 @@ func NewSlice(elem *Type) *Type { ...@@ -458,7 +458,7 @@ func NewSlice(elem *Type) *Type {
// NewDDDArray returns a new [...]T array Type. // NewDDDArray returns a new [...]T array Type.
func NewDDDArray(elem *Type) *Type { func NewDDDArray(elem *Type) *Type {
t := New(TARRAY) t := New(TARRAY)
t.Extra = &ArrayType{Elem: elem, Bound: -1} t.Extra = &Array{Elem: elem, Bound: -1}
t.SetNotInHeap(elem.NotInHeap()) t.SetNotInHeap(elem.NotInHeap())
return t return t
} }
...@@ -504,7 +504,7 @@ func NewPtr(elem *Type) *Type { ...@@ -504,7 +504,7 @@ func NewPtr(elem *Type) *Type {
} }
t := New(Tptr) t := New(Tptr)
t.Extra = PtrType{Elem: elem} t.Extra = Ptr{Elem: elem}
t.Width = int64(Widthptr) t.Width = int64(Widthptr)
t.Align = uint8(Widthptr) t.Align = uint8(Widthptr)
if NewPtrCacheEnabled { if NewPtrCacheEnabled {
...@@ -516,21 +516,21 @@ func NewPtr(elem *Type) *Type { ...@@ -516,21 +516,21 @@ func NewPtr(elem *Type) *Type {
// NewDDDField returns a new TDDDFIELD type for slice type s. // NewDDDField returns a new TDDDFIELD type for slice type s.
func NewDDDField(s *Type) *Type { func NewDDDField(s *Type) *Type {
t := New(TDDDFIELD) t := New(TDDDFIELD)
t.Extra = DDDFieldType{T: s} t.Extra = DDDField{T: s}
return t return t
} }
// NewChanArgs returns a new TCHANARGS type for channel type c. // NewChanArgs returns a new TCHANARGS type for channel type c.
func NewChanArgs(c *Type) *Type { func NewChanArgs(c *Type) *Type {
t := New(TCHANARGS) t := New(TCHANARGS)
t.Extra = ChanArgsType{T: c} t.Extra = ChanArgs{T: c}
return t return t
} }
// NewFuncArgs returns a new TFUNCARGS type for func type f. // NewFuncArgs returns a new TFUNCARGS type for func type f.
func NewFuncArgs(f *Type) *Type { func NewFuncArgs(f *Type) *Type {
t := New(TFUNCARGS) t := New(TFUNCARGS)
t.Extra = FuncArgsType{T: f} t.Extra = FuncArgs{T: f}
return t return t
} }
...@@ -562,28 +562,28 @@ func SubstAny(t *Type, types *[]*Type) *Type { ...@@ -562,28 +562,28 @@ func SubstAny(t *Type, types *[]*Type) *Type {
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.Copy()
t.Extra = PtrType{Elem: elem} t.Extra = Ptr{Elem: elem}
} }
case TARRAY: case TARRAY:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.Copy()
t.Extra.(*ArrayType).Elem = elem t.Extra.(*Array).Elem = elem
} }
case TSLICE: case TSLICE:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.Copy()
t.Extra = SliceType{Elem: elem} t.Extra = Slice{Elem: elem}
} }
case TCHAN: case TCHAN:
elem := SubstAny(t.Elem(), types) elem := SubstAny(t.Elem(), types)
if elem != t.Elem() { if elem != t.Elem() {
t = t.Copy() t = t.Copy()
t.Extra.(*ChanType).Elem = elem t.Extra.(*Chan).Elem = elem
} }
case TMAP: case TMAP:
...@@ -591,8 +591,8 @@ func SubstAny(t *Type, types *[]*Type) *Type { ...@@ -591,8 +591,8 @@ func SubstAny(t *Type, types *[]*Type) *Type {
val := SubstAny(t.Val(), types) val := SubstAny(t.Val(), types)
if key != t.Key() || val != t.Val() { if key != t.Key() || val != t.Val() {
t = t.Copy() t = t.Copy()
t.Extra.(*MapType).Key = key t.Extra.(*Map).Key = key
t.Extra.(*MapType).Val = val t.Extra.(*Map).Val = val
} }
case TFUNC: case TFUNC:
...@@ -638,25 +638,25 @@ func (t *Type) Copy() *Type { ...@@ -638,25 +638,25 @@ func (t *Type) Copy() *Type {
// copy any *T Extra fields, to avoid aliasing // copy any *T Extra fields, to avoid aliasing
switch t.Etype { switch t.Etype {
case TMAP: case TMAP:
x := *t.Extra.(*MapType) x := *t.Extra.(*Map)
nt.Extra = &x nt.Extra = &x
case TFORW: case TFORW:
x := *t.Extra.(*ForwardType) x := *t.Extra.(*Forward)
nt.Extra = &x nt.Extra = &x
case TFUNC: case TFUNC:
x := *t.Extra.(*FuncType) x := *t.Extra.(*Func)
nt.Extra = &x nt.Extra = &x
case TSTRUCT: case TSTRUCT:
x := *t.Extra.(*StructType) x := *t.Extra.(*Struct)
nt.Extra = &x nt.Extra = &x
case TINTER: case TINTER:
x := *t.Extra.(*InterType) x := *t.Extra.(*Interface)
nt.Extra = &x nt.Extra = &x
case TCHAN: case TCHAN:
x := *t.Extra.(*ChanType) x := *t.Extra.(*Chan)
nt.Extra = &x nt.Extra = &x
case TARRAY: case TARRAY:
x := *t.Extra.(*ArrayType) x := *t.Extra.(*Array)
nt.Extra = &x nt.Extra = &x
} }
// TODO(mdempsky): Find out why this is necessary and explain. // TODO(mdempsky): Find out why this is necessary and explain.
...@@ -736,13 +736,13 @@ var ParamsResults = [2]func(*Type) *Type{ ...@@ -736,13 +736,13 @@ var ParamsResults = [2]func(*Type) *Type{
// Key returns the key type of map type t. // Key returns the key type of map type t.
func (t *Type) Key() *Type { func (t *Type) Key() *Type {
t.wantEtype(TMAP) t.wantEtype(TMAP)
return t.Extra.(*MapType).Key return t.Extra.(*Map).Key
} }
// Val returns the value type of map type t. // Val returns the value type of map type t.
func (t *Type) Val() *Type { func (t *Type) Val() *Type {
t.wantEtype(TMAP) t.wantEtype(TMAP)
return t.Extra.(*MapType).Val return t.Extra.(*Map).Val
} }
// Elem returns the type of elements of t. // Elem returns the type of elements of t.
...@@ -750,13 +750,13 @@ func (t *Type) Val() *Type { ...@@ -750,13 +750,13 @@ func (t *Type) Val() *Type {
func (t *Type) Elem() *Type { func (t *Type) Elem() *Type {
switch t.Etype { switch t.Etype {
case TPTR32, TPTR64: case TPTR32, TPTR64:
return t.Extra.(PtrType).Elem return t.Extra.(Ptr).Elem
case TARRAY: case TARRAY:
return t.Extra.(*ArrayType).Elem return t.Extra.(*Array).Elem
case TSLICE: case TSLICE:
return t.Extra.(SliceType).Elem return t.Extra.(Slice).Elem
case TCHAN: case TCHAN:
return t.Extra.(*ChanType).Elem return t.Extra.(*Chan).Elem
} }
Fatalf("Type.Elem %s", t.Etype) Fatalf("Type.Elem %s", t.Etype)
return nil return nil
...@@ -765,26 +765,26 @@ func (t *Type) Elem() *Type { ...@@ -765,26 +765,26 @@ func (t *Type) Elem() *Type {
// DDDField returns the slice ... type for TDDDFIELD type t. // DDDField returns the slice ... type for TDDDFIELD type t.
func (t *Type) DDDField() *Type { func (t *Type) DDDField() *Type {
t.wantEtype(TDDDFIELD) t.wantEtype(TDDDFIELD)
return t.Extra.(DDDFieldType).T return t.Extra.(DDDField).T
} }
// ChanArgs returns the channel type for TCHANARGS type t. // ChanArgs returns the channel type for TCHANARGS type t.
func (t *Type) ChanArgs() *Type { func (t *Type) ChanArgs() *Type {
t.wantEtype(TCHANARGS) t.wantEtype(TCHANARGS)
return t.Extra.(ChanArgsType).T return t.Extra.(ChanArgs).T
} }
// FuncArgs returns the channel type for TFUNCARGS type t. // FuncArgs returns the channel type for TFUNCARGS type t.
func (t *Type) FuncArgs() *Type { func (t *Type) FuncArgs() *Type {
t.wantEtype(TFUNCARGS) t.wantEtype(TFUNCARGS)
return t.Extra.(FuncArgsType).T return t.Extra.(FuncArgs).T
} }
// Nname returns the associated function's nname. // Nname returns the associated function's nname.
func (t *Type) Nname() *Node { func (t *Type) Nname() *Node {
switch t.Etype { switch t.Etype {
case TFUNC: case TFUNC:
return t.Extra.(*FuncType).Nname return t.Extra.(*Func).Nname
} }
Fatalf("Type.Nname %v %v", t.Etype, t) Fatalf("Type.Nname %v %v", t.Etype, t)
return nil return nil
...@@ -794,7 +794,7 @@ func (t *Type) Nname() *Node { ...@@ -794,7 +794,7 @@ func (t *Type) Nname() *Node {
func (t *Type) SetNname(n *Node) { func (t *Type) SetNname(n *Node) {
switch t.Etype { switch t.Etype {
case TFUNC: case TFUNC:
t.Extra.(*FuncType).Nname = n t.Extra.(*Func).Nname = n
default: default:
Fatalf("Type.SetNname %v %v", t.Etype, t) Fatalf("Type.SetNname %v %v", t.Etype, t)
} }
...@@ -802,7 +802,7 @@ func (t *Type) SetNname(n *Node) { ...@@ -802,7 +802,7 @@ func (t *Type) SetNname(n *Node) {
// IsFuncArgStruct reports whether t is a struct representing function parameters. // IsFuncArgStruct reports whether t is a struct representing function parameters.
func (t *Type) IsFuncArgStruct() bool { func (t *Type) IsFuncArgStruct() bool {
return t.Etype == TSTRUCT && t.Extra.(*StructType).Funarg != FunargNone return t.Etype == TSTRUCT && t.Extra.(*Struct).Funarg != FunargNone
} }
func (t *Type) Methods() *Fields { func (t *Type) Methods() *Fields {
...@@ -818,10 +818,10 @@ func (t *Type) AllMethods() *Fields { ...@@ -818,10 +818,10 @@ func (t *Type) AllMethods() *Fields {
func (t *Type) Fields() *Fields { func (t *Type) Fields() *Fields {
switch t.Etype { switch t.Etype {
case TSTRUCT: case TSTRUCT:
return &t.Extra.(*StructType).fields return &t.Extra.(*Struct).fields
case TINTER: case TINTER:
Dowidth(t) Dowidth(t)
return &t.Extra.(*InterType).Fields return &t.Extra.(*Interface).Fields
} }
Fatalf("Fields: type %v does not have fields", t) Fatalf("Fields: type %v does not have fields", t)
return nil return nil
...@@ -873,7 +873,7 @@ func (t *Type) IsDDDArray() bool { ...@@ -873,7 +873,7 @@ func (t *Type) IsDDDArray() bool {
if t.Etype != TARRAY { if t.Etype != TARRAY {
return false return false
} }
return t.Extra.(*ArrayType).Bound < 0 return t.Extra.(*Array).Bound < 0
} }
func (t *Type) WidthCalculated() bool { func (t *Type) WidthCalculated() bool {
...@@ -884,7 +884,7 @@ func (t *Type) WidthCalculated() bool { ...@@ -884,7 +884,7 @@ func (t *Type) WidthCalculated() bool {
// It includes the receiver, parameters, and results. // It includes the receiver, parameters, and results.
func (t *Type) ArgWidth() int64 { func (t *Type) ArgWidth() int64 {
t.wantEtype(TFUNC) t.wantEtype(TFUNC)
return t.Extra.(*FuncType).Argwid return t.Extra.(*Func).Argwid
} }
func (t *Type) Size() int64 { func (t *Type) Size() int64 {
...@@ -1255,7 +1255,7 @@ func (t *Type) FieldName(i int) string { ...@@ -1255,7 +1255,7 @@ func (t *Type) FieldName(i int) string {
func (t *Type) NumElem() int64 { func (t *Type) NumElem() int64 {
t.wantEtype(TARRAY) t.wantEtype(TARRAY)
at := t.Extra.(*ArrayType) at := t.Extra.(*Array)
if at.Bound < 0 { if at.Bound < 0 {
Fatalf("NumElem array %v does not have bound yet", t) Fatalf("NumElem array %v does not have bound yet", t)
} }
...@@ -1267,7 +1267,7 @@ func (t *Type) NumElem() int64 { ...@@ -1267,7 +1267,7 @@ func (t *Type) NumElem() int64 {
// For other uses, create a new array with NewArray instead. // For other uses, create a new array with NewArray instead.
func (t *Type) SetNumElem(n int64) { func (t *Type) SetNumElem(n int64) {
t.wantEtype(TARRAY) t.wantEtype(TARRAY)
at := t.Extra.(*ArrayType) at := t.Extra.(*Array)
if at.Bound >= 0 { if at.Bound >= 0 {
Fatalf("SetNumElem array %v already has bound %d", t, at.Bound) Fatalf("SetNumElem array %v already has bound %d", t, at.Bound)
} }
...@@ -1278,7 +1278,7 @@ func (t *Type) SetNumElem(n int64) { ...@@ -1278,7 +1278,7 @@ func (t *Type) SetNumElem(n int64) {
// The direction will be one of Crecv, Csend, or Cboth. // The direction will be one of Crecv, Csend, or Cboth.
func (t *Type) ChanDir() ChanDir { func (t *Type) ChanDir() ChanDir {
t.wantEtype(TCHAN) t.wantEtype(TCHAN)
return t.Extra.(*ChanType).Dir return t.Extra.(*Chan).Dir
} }
func (t *Type) IsMemory() bool { return false } func (t *Type) IsMemory() bool { return false }
......
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