diff options
Diffstat (limited to 'src/cmd/compile/internal/types/type.go')
-rw-r--r-- | src/cmd/compile/internal/types/type.go | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index d6d56426a5..f0211a67fb 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -110,8 +110,8 @@ var ( Errortype *Type // Types to represent untyped string and boolean constants. - UntypedString *Type - UntypedBool *Type + UntypedString = New(TSTRING) + UntypedBool = New(TBOOL) // Types to represent untyped numeric constants. UntypedInt = New(TIDEAL) @@ -184,6 +184,15 @@ 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) SetRecur(b bool) { t.flags.set(typeRecur, b) } +// Kind returns the kind of type t. +func (t *Type) Kind() EType { return t.Etype } + +// Sym returns the name of type t. +func (t *Type) GetSym() *Sym { return t.Sym } + +// Underlying returns the underlying type of type t. +func (t *Type) Underlying() *Type { return t.Orig } + // SetNod associates t with syntax node n. func (t *Type) SetNod(n IRNode) { // t.nod can be non-nil already @@ -1601,3 +1610,11 @@ func (t *Type) SetUnderlying(underlying *Type) { } } } + +// NewNamed returns a new basic type of the given kind. +func NewBasic(kind EType, obj IRNode) *Type { + t := New(kind) + t.Sym = obj.Sym() + t.nod = obj + return t +} |