diff options
author | Dan Scales <danscales@google.com> | 2021-01-27 12:55:57 -0800 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-01-28 20:28:11 +0000 |
commit | 2440dd457a451084e4a23b1b0903953f331abea7 (patch) | |
tree | a0e842ba46d323821e2af3515485674bebe0b5f0 /src/cmd/compile/internal/types/type.go | |
parent | c0bf904ddf89b549a4a9d91a634fea1422744c33 (diff) | |
download | go-2440dd457a451084e4a23b1b0903953f331abea7.tar.gz go-2440dd457a451084e4a23b1b0903953f331abea7.zip |
[dev.typeparams] cmd/compile: start adding info needed for typeparams in types & ir
We are focusing on generic functions first, and ignoring type lists for
now.
The signatures of types.NewSignature() and ir.NewCallExpr() changed (with
addition of type args/params).
Change-Id: I57480be3d1f65690b2946e15dd74929bf42873f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/287416
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types/type.go')
-rw-r--r-- | src/cmd/compile/internal/types/type.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index 0dfbef8af1..1d6edcda47 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -72,6 +72,7 @@ const ( TANY TSTRING TUNSAFEPTR + TTYPEPARAM // pseudo-types for literals TIDEAL // untyped numeric constants @@ -150,6 +151,7 @@ type Type struct { // TARRAY: *Array // TSLICE: Slice // TSSA: string + // TTYPEPARAM: *Interface (though we may not need to store/use the Interface info) Extra interface{} // Width is the width of this Type in bytes. @@ -283,6 +285,7 @@ type Func struct { Receiver *Type // function receiver Results *Type // function results Params *Type // function params + Tparams *Type // type params of receiver (if method) or function pkg *Pkg @@ -318,6 +321,7 @@ const ( FunargRcvr // receiver FunargParams // input parameters FunargResults // output results + FunargTparams // type params ) // StructType returns t's extra struct-specific fields. @@ -1645,8 +1649,8 @@ func NewInterface(pkg *Pkg, methods []*Field) *Type { } // NewSignature returns a new function type for the given receiver, -// parameters, and results, any of which may be nil. -func NewSignature(pkg *Pkg, recv *Field, params, results []*Field) *Type { +// parametes, results, and type parameters, any of which may be nil. +func NewSignature(pkg *Pkg, recv *Field, tparams, params, results []*Field) *Type { var recvs []*Field if recv != nil { recvs = []*Field{recv} @@ -1665,6 +1669,7 @@ func NewSignature(pkg *Pkg, recv *Field, params, results []*Field) *Type { } ft.Receiver = funargs(recvs, FunargRcvr) + ft.Tparams = funargs(tparams, FunargTparams) ft.Params = funargs(params, FunargParams) ft.Results = funargs(results, FunargResults) ft.pkg = pkg |