ComparableType *Type
// Types to represent untyped string and boolean constants.
- UntypedString = New(TSTRING)
- UntypedBool = New(TBOOL)
+ UntypedString = newType(TSTRING)
+ UntypedBool = newType(TBOOL)
// Types to represent untyped numeric constants.
- UntypedInt = New(TIDEAL)
- UntypedRune = New(TIDEAL)
- UntypedFloat = New(TIDEAL)
- UntypedComplex = New(TIDEAL)
+ UntypedInt = newType(TIDEAL)
+ UntypedRune = newType(TIDEAL)
+ UntypedFloat = newType(TIDEAL)
+ UntypedComplex = newType(TIDEAL)
)
// A Type represents a Go type.
}
// New returns a new Type of the specified kind.
-func New(et Kind) *Type {
+func newType(et Kind) *Type {
t := &Type{
kind: et,
width: BADWIDTH,
if bound < 0 {
base.Fatalf("NewArray: invalid bound %v", bound)
}
- t := New(TARRAY)
+ t := newType(TARRAY)
t.extra = &Array{Elem: elem, Bound: bound}
t.SetNotInHeap(elem.NotInHeap())
if elem.HasTParam() {
return t
}
- t := New(TSLICE)
+ t := newType(TSLICE)
t.extra = Slice{Elem: elem}
elem.cache.slice = t
if elem.HasTParam() {
// NewChan returns a new chan Type with direction dir.
func NewChan(elem *Type, dir ChanDir) *Type {
- t := New(TCHAN)
+ t := newType(TCHAN)
ct := t.ChanType()
ct.Elem = elem
ct.Dir = dir
}
func NewTuple(t1, t2 *Type) *Type {
- t := New(TTUPLE)
+ t := newType(TTUPLE)
t.extra.(*Tuple).first = t1
t.extra.(*Tuple).second = t2
if t1.HasTParam() || t2.HasTParam() {
}
func newResults(types []*Type) *Type {
- t := New(TRESULTS)
+ t := newType(TRESULTS)
t.extra.(*Results).Types = types
return t
}
}
func newSSA(name string) *Type {
- t := New(TSSA)
+ t := newType(TSSA)
t.extra = name
return t
}
// NewMap returns a new map Type with key type k and element (aka value) type v.
func NewMap(k, v *Type) *Type {
- t := New(TMAP)
+ t := newType(TMAP)
mt := t.MapType()
mt.Key = k
mt.Elem = v
return t
}
- t := New(TPTR)
+ t := newType(TPTR)
t.extra = Ptr{Elem: elem}
t.width = int64(PtrSize)
t.align = uint8(PtrSize)
// NewChanArgs returns a new TCHANARGS type for channel type c.
func NewChanArgs(c *Type) *Type {
- t := New(TCHANARGS)
+ t := newType(TCHANARGS)
t.extra = ChanArgs{T: c}
return t
}
// NewFuncArgs returns a new TFUNCARGS type for func type f.
func NewFuncArgs(f *Type) *Type {
- t := New(TFUNCARGS)
+ t := newType(TFUNCARGS)
t.extra = FuncArgs{T: f}
return t
}
// FakeRecvType returns the singleton type used for interface method receivers.
func FakeRecvType() *Type {
if recvType == nil {
- recvType = NewPtr(New(TSTRUCT))
+ recvType = NewPtr(newType(TSTRUCT))
}
return recvType
}
// maintained until the type is filled in, so those references can be updated when
// the type is complete.
func NewNamed(obj Object) *Type {
- t := New(TFORW)
+ t := newType(TFORW)
t.sym = obj.Sym()
t.nod = obj
return t
}
// NewBasic returns a new basic type of the given kind.
-func NewBasic(kind Kind, obj Object) *Type {
- t := New(kind)
+func newBasic(kind Kind, obj Object) *Type {
+ t := newType(kind)
t.sym = obj.Sym()
t.nod = obj
return t
// NewInterface returns a new interface for the given methods and
// embedded types. Embedded types are specified as fields with no Sym.
func NewInterface(pkg *Pkg, methods []*Field) *Type {
- t := New(TINTER)
+ t := newType(TINTER)
t.SetInterface(methods)
for _, f := range methods {
// f.Type could be nil for a broken interface declaration
// NewTypeParam returns a new type param with the specified sym (package and name)
// and specified index within the typeparam list.
func NewTypeParam(sym *Sym, index int) *Type {
- t := New(TTYPEPARAM)
+ t := newType(TTYPEPARAM)
t.sym = sym
t.extra.(*Typeparam).index = index
t.SetHasTParam(true)
// NewUnion returns a new union with the specified set of terms (types). If
// tildes[i] is true, then terms[i] represents ~T, rather than just T.
func NewUnion(terms []*Type, tildes []bool) *Type {
- t := New(TUNION)
+ t := newType(TUNION)
if len(terms) != len(tildes) {
base.Fatalf("Mismatched terms and tildes for NewUnion")
}
recvs = []*Field{recv}
}
- t := New(TFUNC)
+ t := newType(TFUNC)
ft := t.FuncType()
funargs := func(fields []*Field, funarg Funarg) *Type {
// NewStruct returns a new struct with the given fields.
func NewStruct(pkg *Pkg, fields []*Field) *Type {
- t := New(TSTRUCT)
+ t := newType(TSTRUCT)
t.SetFields(fields)
if anyBroke(fields) {
t.SetBroke(true)