]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: add OFUNCINST/OTYPEINST nodes for generic func/type...
authorDan Scales <danscales@google.com>
Tue, 2 Feb 2021 20:17:57 +0000 (12:17 -0800)
committerDan Scales <danscales@google.com>
Wed, 3 Feb 2021 01:18:23 +0000 (01:18 +0000)
Expresses things more clearly, especially in cases like 'f := min[int]'
where we create a xsgeneric function instantiation, but don't immediately
call it.

min[int](2, 3) now looks like:

.   CALLFUNC tc(1) Use:1 int # min1.go:11 int
.   .   FUNCINST tc(1) FUNC-func(int, int) int # min1.go:11 FUNC-func(int, int) int
.   .   .   NAME-main.min tc(1) Class:PFUNC Offset:0 Used FUNC-func[T](T, T) T # min1.go:3
.   .   FUNCINST-Targs
.   .   .   TYPE .int Offset:0 type int
.   CALLFUNC-Args
.   .   LITERAL-2 tc(1) int # min1.go:11
.   .   LITERAL-3 tc(1) int # min1.go:11

Remove the targs parameter from ir.NewCallExpr(), not needed anymore,
since type arguments are included in the FUNCINST.

Change-Id: I23438b75288330475294d7ace239ba64acfa641e
Reviewed-on: https://go-review.googlesource.com/c/go/+/288951
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
19 files changed:
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/node_gen.go
src/cmd/compile/internal/ir/op_string.go
src/cmd/compile/internal/noder/expr.go
src/cmd/compile/internal/noder/helpers.go
src/cmd/compile/internal/noder/noder.go
src/cmd/compile/internal/reflectdata/alg.go
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/ssagen/abi.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/walk/builtin.go
src/cmd/compile/internal/walk/compare.go
src/cmd/compile/internal/walk/complit.go
src/cmd/compile/internal/walk/convert.go
src/cmd/compile/internal/walk/expr.go
src/cmd/compile/internal/walk/stmt.go
src/cmd/compile/internal/walk/walk.go

index 7c60334c049badf273d1bdb0747d335479e2f548..d68bcfe60c45d1ddf055dcefc9e7abef7fe13f1d 100644 (file)
@@ -153,12 +153,11 @@ const (
        CallUseStmt // results not used - call is a statement
 )
 
-// A CallExpr is a function call X[Targs](Args).
+// A CallExpr is a function call X(Args).
 type CallExpr struct {
        miniExpr
        origNode
        X         Node
-       Targs     Nodes
        Args      Nodes
        KeepAlive []*Name // vars to be kept alive until call returns
        IsDDD     bool
@@ -166,12 +165,11 @@ type CallExpr struct {
        NoInline  bool
 }
 
-func NewCallExpr(pos src.XPos, op Op, fun Node, targs, args []Node) *CallExpr {
+func NewCallExpr(pos src.XPos, op Op, fun Node, args []Node) *CallExpr {
        n := &CallExpr{X: fun}
        n.pos = pos
        n.orig = n
        n.SetOp(op)
-       n.Targs = targs
        n.Args = args
        return n
 }
@@ -307,20 +305,6 @@ func (n *IndexExpr) SetOp(op Op) {
        }
 }
 
-// A ListExpr is list of expressions
-type ListExpr struct {
-       miniExpr
-       List Nodes
-}
-
-func NewListExpr(pos src.XPos, list []Node) *ListExpr {
-       n := &ListExpr{}
-       n.pos = pos
-       n.op = OLIST
-       n.List = list
-       return n
-}
-
 // A KeyExpr is a Key: Value composite literal key.
 type KeyExpr struct {
        miniExpr
@@ -686,6 +670,20 @@ func (n *UnaryExpr) SetOp(op Op) {
        }
 }
 
+// An InstExpr is a generic function or type instantiation.
+type InstExpr struct {
+       miniExpr
+       X     Node
+       Targs []Node
+}
+
+func NewInstExpr(pos src.XPos, op Op, x Node, targs []Node) *InstExpr {
+       n := &InstExpr{X: x, Targs: targs}
+       n.pos = pos
+       n.op = op
+       return n
+}
+
 func IsZero(n Node) bool {
        switch n.Op() {
        case ONIL:
index 590c428ac5fea2bb3878cbf2c76e1d32f7ed3aa2..59643713fa690a021541d94cb39a42e71532013e 100644 (file)
@@ -190,7 +190,6 @@ const (
        OGT            // Left > Right
        ODEREF         // *Left
        OINDEX         // Left[Right] (index of array or slice)
-       OLIST          // list of expressions
        OINDEXMAP      // Left[Right] (index of map)
        OKEY           // Left:Right (key:value in struct/array/map literal)
        OSTRUCTKEY     // Sym:Left (key:value in struct literal, after type checking)
@@ -279,6 +278,8 @@ const (
        // OTYPESW:  Left := Right.(type) (appears as .Left of OSWITCH)
        //   Left is nil if there is no type-switch variable
        OTYPESW
+       OFUNCINST // instantiation of a generic function
+       OTYPEINST // instantiation of a generic type
 
        // types
        OTCHAN   // chan int
index 6f5eceb86de7f336d9753d58b8ccbb7970405d24..22855d7163f44a6e9d51586c60cabc3c397dccff 100644 (file)
@@ -249,7 +249,6 @@ func (n *CallExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
 func (n *CallExpr) copy() Node {
        c := *n
        c.init = copyNodes(c.init)
-       c.Targs = copyNodes(c.Targs)
        c.Args = copyNodes(c.Args)
        c.KeepAlive = copyNames(c.KeepAlive)
        return &c
@@ -261,9 +260,6 @@ func (n *CallExpr) doChildren(do func(Node) bool) bool {
        if n.X != nil && do(n.X) {
                return true
        }
-       if doNodes(n.Targs, do) {
-               return true
-       }
        if doNodes(n.Args, do) {
                return true
        }
@@ -277,7 +273,6 @@ func (n *CallExpr) editChildren(edit func(Node) Node) {
        if n.X != nil {
                n.X = edit(n.X).(Node)
        }
-       editNodes(n.Targs, edit)
        editNodes(n.Args, edit)
        editNames(n.KeepAlive, edit)
 }
@@ -674,6 +669,33 @@ func (n *InlinedCallExpr) editChildren(edit func(Node) Node) {
        editNodes(n.ReturnVars, edit)
 }
 
+func (n *InstExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
+func (n *InstExpr) copy() Node {
+       c := *n
+       c.init = copyNodes(c.init)
+       c.Targs = copyNodes(c.Targs)
+       return &c
+}
+func (n *InstExpr) doChildren(do func(Node) bool) bool {
+       if doNodes(n.init, do) {
+               return true
+       }
+       if n.X != nil && do(n.X) {
+               return true
+       }
+       if doNodes(n.Targs, do) {
+               return true
+       }
+       return false
+}
+func (n *InstExpr) editChildren(edit func(Node) Node) {
+       editNodes(n.init, edit)
+       if n.X != nil {
+               n.X = edit(n.X).(Node)
+       }
+       editNodes(n.Targs, edit)
+}
+
 func (n *InterfaceType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
 func (n *InterfaceType) copy() Node {
        c := *n
@@ -750,27 +772,6 @@ func (n *LinksymOffsetExpr) editChildren(edit func(Node) Node) {
        editNodes(n.init, edit)
 }
 
-func (n *ListExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
-func (n *ListExpr) copy() Node {
-       c := *n
-       c.init = copyNodes(c.init)
-       c.List = copyNodes(c.List)
-       return &c
-}
-func (n *ListExpr) doChildren(do func(Node) bool) bool {
-       if doNodes(n.init, do) {
-               return true
-       }
-       if doNodes(n.List, do) {
-               return true
-       }
-       return false
-}
-func (n *ListExpr) editChildren(edit func(Node) Node) {
-       editNodes(n.init, edit)
-       editNodes(n.List, edit)
-}
-
 func (n *LogicalExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }
 func (n *LogicalExpr) copy() Node {
        c := *n
index 390b0eecfeac771793a0faf32b565efc81892ed6..65456df356dd3d523f3a815b53068d49fdc92596 100644 (file)
@@ -74,98 +74,99 @@ func _() {
        _ = x[OGT-63]
        _ = x[ODEREF-64]
        _ = x[OINDEX-65]
-       _ = x[OLIST-66]
-       _ = x[OINDEXMAP-67]
-       _ = x[OKEY-68]
-       _ = x[OSTRUCTKEY-69]
-       _ = x[OLEN-70]
-       _ = x[OMAKE-71]
-       _ = x[OMAKECHAN-72]
-       _ = x[OMAKEMAP-73]
-       _ = x[OMAKESLICE-74]
-       _ = x[OMAKESLICECOPY-75]
-       _ = x[OMUL-76]
-       _ = x[ODIV-77]
-       _ = x[OMOD-78]
-       _ = x[OLSH-79]
-       _ = x[ORSH-80]
-       _ = x[OAND-81]
-       _ = x[OANDNOT-82]
-       _ = x[ONEW-83]
-       _ = x[ONOT-84]
-       _ = x[OBITNOT-85]
-       _ = x[OPLUS-86]
-       _ = x[ONEG-87]
-       _ = x[OOROR-88]
-       _ = x[OPANIC-89]
-       _ = x[OPRINT-90]
-       _ = x[OPRINTN-91]
-       _ = x[OPAREN-92]
-       _ = x[OSEND-93]
-       _ = x[OSLICE-94]
-       _ = x[OSLICEARR-95]
-       _ = x[OSLICESTR-96]
-       _ = x[OSLICE3-97]
-       _ = x[OSLICE3ARR-98]
-       _ = x[OSLICEHEADER-99]
-       _ = x[ORECOVER-100]
-       _ = x[ORECV-101]
-       _ = x[ORUNESTR-102]
-       _ = x[OSELRECV2-103]
-       _ = x[OIOTA-104]
-       _ = x[OREAL-105]
-       _ = x[OIMAG-106]
-       _ = x[OCOMPLEX-107]
-       _ = x[OALIGNOF-108]
-       _ = x[OOFFSETOF-109]
-       _ = x[OSIZEOF-110]
-       _ = x[OMETHEXPR-111]
-       _ = x[OSTMTEXPR-112]
-       _ = x[OBLOCK-113]
-       _ = x[OBREAK-114]
-       _ = x[OCASE-115]
-       _ = x[OCONTINUE-116]
-       _ = x[ODEFER-117]
-       _ = x[OFALL-118]
-       _ = x[OFOR-119]
-       _ = x[OFORUNTIL-120]
-       _ = x[OGOTO-121]
-       _ = x[OIF-122]
-       _ = x[OLABEL-123]
-       _ = x[OGO-124]
-       _ = x[ORANGE-125]
-       _ = x[ORETURN-126]
-       _ = x[OSELECT-127]
-       _ = x[OSWITCH-128]
-       _ = x[OTYPESW-129]
-       _ = x[OTCHAN-130]
-       _ = x[OTMAP-131]
-       _ = x[OTSTRUCT-132]
-       _ = x[OTINTER-133]
-       _ = x[OTFUNC-134]
-       _ = x[OTARRAY-135]
-       _ = x[OTSLICE-136]
-       _ = x[OINLCALL-137]
-       _ = x[OEFACE-138]
-       _ = x[OITAB-139]
-       _ = x[OIDATA-140]
-       _ = x[OSPTR-141]
-       _ = x[OCFUNC-142]
-       _ = x[OCHECKNIL-143]
-       _ = x[OVARDEF-144]
-       _ = x[OVARKILL-145]
-       _ = x[OVARLIVE-146]
-       _ = x[ORESULT-147]
-       _ = x[OINLMARK-148]
-       _ = x[OLINKSYMOFFSET-149]
-       _ = x[OTAILCALL-150]
-       _ = x[OGETG-151]
-       _ = x[OEND-152]
+       _ = x[OINDEXMAP-66]
+       _ = x[OKEY-67]
+       _ = x[OSTRUCTKEY-68]
+       _ = x[OLEN-69]
+       _ = x[OMAKE-70]
+       _ = x[OMAKECHAN-71]
+       _ = x[OMAKEMAP-72]
+       _ = x[OMAKESLICE-73]
+       _ = x[OMAKESLICECOPY-74]
+       _ = x[OMUL-75]
+       _ = x[ODIV-76]
+       _ = x[OMOD-77]
+       _ = x[OLSH-78]
+       _ = x[ORSH-79]
+       _ = x[OAND-80]
+       _ = x[OANDNOT-81]
+       _ = x[ONEW-82]
+       _ = x[ONOT-83]
+       _ = x[OBITNOT-84]
+       _ = x[OPLUS-85]
+       _ = x[ONEG-86]
+       _ = x[OOROR-87]
+       _ = x[OPANIC-88]
+       _ = x[OPRINT-89]
+       _ = x[OPRINTN-90]
+       _ = x[OPAREN-91]
+       _ = x[OSEND-92]
+       _ = x[OSLICE-93]
+       _ = x[OSLICEARR-94]
+       _ = x[OSLICESTR-95]
+       _ = x[OSLICE3-96]
+       _ = x[OSLICE3ARR-97]
+       _ = x[OSLICEHEADER-98]
+       _ = x[ORECOVER-99]
+       _ = x[ORECV-100]
+       _ = x[ORUNESTR-101]
+       _ = x[OSELRECV2-102]
+       _ = x[OIOTA-103]
+       _ = x[OREAL-104]
+       _ = x[OIMAG-105]
+       _ = x[OCOMPLEX-106]
+       _ = x[OALIGNOF-107]
+       _ = x[OOFFSETOF-108]
+       _ = x[OSIZEOF-109]
+       _ = x[OMETHEXPR-110]
+       _ = x[OSTMTEXPR-111]
+       _ = x[OBLOCK-112]
+       _ = x[OBREAK-113]
+       _ = x[OCASE-114]
+       _ = x[OCONTINUE-115]
+       _ = x[ODEFER-116]
+       _ = x[OFALL-117]
+       _ = x[OFOR-118]
+       _ = x[OFORUNTIL-119]
+       _ = x[OGOTO-120]
+       _ = x[OIF-121]
+       _ = x[OLABEL-122]
+       _ = x[OGO-123]
+       _ = x[ORANGE-124]
+       _ = x[ORETURN-125]
+       _ = x[OSELECT-126]
+       _ = x[OSWITCH-127]
+       _ = x[OTYPESW-128]
+       _ = x[OFUNCINST-129]
+       _ = x[OTYPEINST-130]
+       _ = x[OTCHAN-131]
+       _ = x[OTMAP-132]
+       _ = x[OTSTRUCT-133]
+       _ = x[OTINTER-134]
+       _ = x[OTFUNC-135]
+       _ = x[OTARRAY-136]
+       _ = x[OTSLICE-137]
+       _ = x[OINLCALL-138]
+       _ = x[OEFACE-139]
+       _ = x[OITAB-140]
+       _ = x[OIDATA-141]
+       _ = x[OSPTR-142]
+       _ = x[OCFUNC-143]
+       _ = x[OCHECKNIL-144]
+       _ = x[OVARDEF-145]
+       _ = x[OVARKILL-146]
+       _ = x[OVARLIVE-147]
+       _ = x[ORESULT-148]
+       _ = x[OINLMARK-149]
+       _ = x[OLINKSYMOFFSET-150]
+       _ = x[OTAILCALL-151]
+       _ = x[OGETG-152]
+       _ = x[OEND-153]
 }
 
-const _Op_name = "XXXNAMENONAMETYPEPACKLITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXLISTINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFMETHEXPRSTMTEXPRBLOCKBREAKCASECONTINUEDEFERFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWTCHANTMAPTSTRUCTTINTERTFUNCTARRAYTSLICEINLCALLEFACEITABIDATASPTRCFUNCCHECKNILVARDEFVARKILLVARLIVERESULTINLMARKLINKSYMOFFSETTAILCALLGETGEND"
+const _Op_name = "XXXNAMENONAMETYPEPACKLITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFMETHEXPRSTMTEXPRBLOCKBREAKCASECONTINUEDEFERFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWFUNCINSTTYPEINSTTCHANTMAPTSTRUCTTINTERTFUNCTARRAYTSLICEINLCALLEFACEITABIDATASPTRCFUNCCHECKNILVARDEFVARKILLVARLIVERESULTINLMARKLINKSYMOFFSETTAILCALLGETGEND"
 
-var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 37, 39, 42, 48, 52, 58, 64, 73, 85, 94, 103, 115, 124, 126, 129, 139, 146, 153, 160, 164, 168, 176, 184, 193, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 280, 284, 287, 294, 302, 309, 315, 318, 324, 331, 339, 343, 350, 358, 360, 362, 364, 366, 368, 370, 375, 380, 384, 392, 395, 404, 407, 411, 419, 426, 435, 448, 451, 454, 457, 460, 463, 466, 472, 475, 478, 484, 488, 491, 495, 500, 505, 511, 516, 520, 525, 533, 541, 547, 556, 567, 574, 578, 585, 593, 597, 601, 605, 612, 619, 627, 633, 641, 649, 654, 659, 663, 671, 676, 680, 683, 691, 695, 697, 702, 704, 709, 715, 721, 727, 733, 738, 742, 749, 755, 760, 766, 772, 779, 784, 788, 793, 797, 802, 810, 816, 823, 830, 836, 843, 856, 864, 868, 871}
+var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 37, 39, 42, 48, 52, 58, 64, 73, 85, 94, 103, 115, 124, 126, 129, 139, 146, 153, 160, 164, 168, 176, 184, 193, 201, 204, 209, 216, 223, 229, 238, 246, 254, 260, 264, 273, 280, 284, 287, 294, 302, 309, 315, 318, 324, 331, 339, 343, 350, 358, 360, 362, 364, 366, 368, 370, 375, 380, 388, 391, 400, 403, 407, 415, 422, 431, 444, 447, 450, 453, 456, 459, 462, 468, 471, 474, 480, 484, 487, 491, 496, 501, 507, 512, 516, 521, 529, 537, 543, 552, 563, 570, 574, 581, 589, 593, 597, 601, 608, 615, 623, 629, 637, 645, 650, 655, 659, 667, 672, 676, 679, 687, 691, 693, 698, 700, 705, 711, 717, 723, 729, 737, 745, 750, 754, 761, 767, 772, 778, 784, 791, 796, 800, 805, 809, 814, 822, 828, 835, 842, 848, 855, 868, 876, 880, 883}
 
 func (i Op) String() string {
        if i >= Op(len(_Op_index)-1) {
index 41d54441d4ce32c2ef02f3ff4a1f24d3b8a4a27b..3c18bdcc2428f5e46fb12dbb5521044af6c5ecb3 100644 (file)
@@ -99,23 +99,28 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
                }
                return Call(pos, g.typ(typ), g.expr(expr.Fun), g.exprs(expr.ArgList), expr.HasDots)
        case *syntax.IndexExpr:
-               var index ir.Node
-
-               // We are using IndexExpr in two ways, as an standard index
-               // operation (with expression) and as a function/type
-               // instantiation (with a type list). We will soon make this
-               // clearer by having separate function/type instantiation nodes.
+               var targs []ir.Node
                if _, ok := expr.Index.(*syntax.ListExpr); ok {
-                       // List of types for a generic function call or type instantiation
-                       index = ir.NewListExpr(pos, g.exprList(expr.Index))
+                       targs = g.exprList(expr.Index)
                } else {
-                       index = g.expr(expr.Index)
-                       if index.Op() == ir.OTYPE {
-                               // Single type for a generic function call or type instantiation
-                               index = ir.NewListExpr(pos, []ir.Node{index})
+                       index := g.expr(expr.Index)
+                       if index.Op() != ir.OTYPE {
+                               // This is just a normal index expression
+                               return Index(pos, g.expr(expr.X), index)
                        }
+                       // This is generic function instantiation with a single type
+                       targs = []ir.Node{index}
+               }
+               // This is a generic function instantiation
+               x := g.expr(expr.X)
+               if x.Op() != ir.ONAME || x.Type().Kind() != types.TFUNC {
+                       panic("Incorrect argument for generic func instantiation")
                }
-               return Index(pos, g.typ(typ), g.expr(expr.X), index)
+               // This could also be an OTYPEINST once we can handle those examples.
+               n := ir.NewInstExpr(pos, ir.OFUNCINST, x, targs)
+               typed(g.typ(typ), n)
+               return n
+
        case *syntax.ParenExpr:
                return g.expr(expr.X) // skip parens; unneeded after parse+typecheck
        case *syntax.SelectorExpr:
index d97dacfc8b5dd8701dfca266299cf36277df1a2c..fcbb3a6ce5ee7e2e087219a94a04a4da9c0bc973 100644 (file)
@@ -83,13 +83,13 @@ func Call(pos src.XPos, typ *types.Type, fun ir.Node, args []ir.Node, dots bool)
        // TODO(mdempsky): This should not be so difficult.
        if fun.Op() == ir.OTYPE {
                // Actually a type conversion, not a function call.
-               n := ir.NewCallExpr(pos, ir.OCALL, fun, nil, args)
+               n := ir.NewCallExpr(pos, ir.OCALL, fun, args)
                return typecheck.Expr(n)
        }
 
        if fun, ok := fun.(*ir.Name); ok && fun.BuiltinOp != 0 {
                // Call to a builtin function.
-               n := ir.NewCallExpr(pos, ir.OCALL, fun, nil, args)
+               n := ir.NewCallExpr(pos, ir.OCALL, fun, args)
                n.IsDDD = dots
                switch fun.BuiltinOp {
                case ir.OCLOSE, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTN:
@@ -116,20 +116,10 @@ func Call(pos src.XPos, typ *types.Type, fun ir.Node, args []ir.Node, dots bool)
                }
        }
 
-       var targs []ir.Node
-       if indexExpr, ok := fun.(*ir.IndexExpr); ok {
-               if indexExpr.Index.Op() == ir.OLIST {
-                       // Called function is an instantiated generic function
-                       fun = indexExpr.X
-                       // Don't need to copy, since the node list was just created
-                       targs = indexExpr.Index.(*ir.ListExpr).List
-               }
-       }
-
-       n := ir.NewCallExpr(pos, ir.OCALL, fun, targs, args)
+       n := ir.NewCallExpr(pos, ir.OCALL, fun, args)
        n.IsDDD = dots
 
-       if targs == nil {
+       if n.X.Op() != ir.OFUNCINST {
                // If no type params, still do normal typechecking, since we're
                // still missing some things done by tcCall below (mainly
                // typecheckargs and typecheckaste).
@@ -233,12 +223,7 @@ func method(typ *types.Type, index int) *types.Field {
        return types.ReceiverBaseType(typ).Methods().Index(index)
 }
 
-func Index(pos src.XPos, typ *types.Type, x, index ir.Node) ir.Node {
-       if index.Op() == ir.OLIST {
-               n := ir.NewIndexExpr(pos, x, index)
-               typed(typ, n)
-               return n
-       }
+func Index(pos src.XPos, x, index ir.Node) ir.Node {
        // TODO(mdempsky): Avoid typecheck.Expr (which will call tcIndex)
        return typecheck.Expr(ir.NewIndexExpr(pos, x, index))
 }
index 492c2c242a090106fdc479b81280af6c46538722..1c38f1a934d0b71c3256bfb7f45a72fde9cfbac5 100644 (file)
@@ -755,7 +755,7 @@ func (p *noder) expr(expr syntax.Expr) ir.Node {
                }
                return ir.NewBinaryExpr(pos, op, x, y)
        case *syntax.CallExpr:
-               n := ir.NewCallExpr(p.pos(expr), ir.OCALL, p.expr(expr.Fun), nil, p.exprs(expr.ArgList))
+               n := ir.NewCallExpr(p.pos(expr), ir.OCALL, p.expr(expr.Fun), p.exprs(expr.ArgList))
                n.IsDDD = expr.HasDots
                return n
 
index 3d8729069ae7343f26a7ce203ed7aa062ca31564..faa431a9d194434f279ab45a283ed4a61d2d1336 100644 (file)
@@ -176,7 +176,7 @@ func genhash(t *types.Type) *obj.LSym {
                loop.PtrInit().Append(init)
 
                // h = hashel(&p[i], h)
-               call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil, nil)
+               call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil)
 
                nx := ir.NewIndexExpr(base.Pos, np, ni)
                nx.SetBounded(true)
@@ -202,7 +202,7 @@ func genhash(t *types.Type) *obj.LSym {
                        // Hash non-memory fields with appropriate hash function.
                        if !isRegularMemory(f.Type) {
                                hashel := hashfor(f.Type)
-                               call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil, nil)
+                               call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil)
                                nx := ir.NewSelectorExpr(base.Pos, ir.OXDOT, np, f.Sym) // TODO: fields from other packages?
                                na := typecheck.NodAddr(nx)
                                call.Args.Append(na)
@@ -217,7 +217,7 @@ func genhash(t *types.Type) *obj.LSym {
 
                        // h = hashel(&p.first, size, h)
                        hashel := hashmem(f.Type)
-                       call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil, nil)
+                       call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil)
                        nx := ir.NewSelectorExpr(base.Pos, ir.OXDOT, np, f.Sym) // TODO: fields from other packages?
                        na := typecheck.NodAddr(nx)
                        call.Args.Append(na)
@@ -672,7 +672,7 @@ func EqString(s, t ir.Node) (eqlen *ir.BinaryExpr, eqmem *ir.CallExpr) {
 
        fn := typecheck.LookupRuntime("memequal")
        fn = typecheck.SubstArgTypes(fn, types.Types[types.TUINT8], types.Types[types.TUINT8])
-       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, []ir.Node{sptr, tptr, ir.Copy(slen)})
+       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, []ir.Node{sptr, tptr, ir.Copy(slen)})
        typecheck.Call(call)
 
        cmp := ir.NewBinaryExpr(base.Pos, ir.OEQ, slen, tlen)
@@ -709,7 +709,7 @@ func EqInterface(s, t ir.Node) (eqtab *ir.BinaryExpr, eqdata *ir.CallExpr) {
        sdata.SetTypecheck(1)
        tdata.SetTypecheck(1)
 
-       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, []ir.Node{stab, sdata, tdata})
+       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, []ir.Node{stab, sdata, tdata})
        typecheck.Call(call)
 
        cmp := ir.NewBinaryExpr(base.Pos, ir.OEQ, stab, ttab)
@@ -725,7 +725,7 @@ func eqmem(p ir.Node, q ir.Node, field *types.Sym, size int64) ir.Node {
        ny := typecheck.Expr(typecheck.NodAddr(ir.NewSelectorExpr(base.Pos, ir.OXDOT, q, field)))
 
        fn, needsize := eqmemfunc(size, nx.Type().Elem())
-       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, nil)
+       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil)
        call.Args.Append(nx)
        call.Args.Append(ny)
        if needsize {
index c1385e6dab310083e9e1b0d8030b9a2bfdf17587..632e0f48d4f56d38bd450bfdde8ec1d086b4536a 100644 (file)
@@ -1747,7 +1747,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field) *obj.LSym {
                // generating wrapper from *T to T.
                n := ir.NewIfStmt(base.Pos, nil, nil, nil)
                n.Cond = ir.NewBinaryExpr(base.Pos, ir.OEQ, nthis, typecheck.NodNil())
-               call := ir.NewCallExpr(base.Pos, ir.OCALL, typecheck.LookupRuntime("panicwrap"), nil, nil)
+               call := ir.NewCallExpr(base.Pos, ir.OCALL, typecheck.LookupRuntime("panicwrap"), nil)
                n.Body = []ir.Node{call}
                fn.Body.Append(n)
        }
@@ -1772,7 +1772,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field) *obj.LSym {
                fn.Body.Append(ir.NewTailCallStmt(base.Pos, method.Nname.(*ir.Name)))
        } else {
                fn.SetWrapper(true) // ignore frame for panic+recover matching
-               call := ir.NewCallExpr(base.Pos, ir.OCALL, dot, nil, nil)
+               call := ir.NewCallExpr(base.Pos, ir.OCALL, dot, nil)
                call.Args = ir.ParamNames(tfn.Type())
                call.IsDDD = tfn.Type().IsVariadic()
                if method.Type.NumResults() > 0 {
index b22a5ef2bef8784405483a2bf186dbc71ed84a19..5bebce1db58df057faa7c4133cf21134b1e1cb68 100644 (file)
@@ -305,7 +305,7 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
 
                tail = ir.NewTailCallStmt(base.Pos, f.Nname)
        } else {
-               call := ir.NewCallExpr(base.Pos, ir.OCALL, f.Nname, nil, nil)
+               call := ir.NewCallExpr(base.Pos, ir.OCALL, f.Nname, nil)
                call.Args = ir.ParamNames(tfn.Type())
                call.IsDDD = tfn.Type().IsVariadic()
                tail = call
index a44af10bbb6faa3c6637537ce6ace86685925aca..7ab5f68ce301b40a4f3325ff5d7e8a015cadd902 100644 (file)
@@ -254,7 +254,7 @@ func MethodValueWrapper(dot *ir.SelectorExpr) *ir.Func {
        ptr.SetByval(true)
        fn.ClosureVars = append(fn.ClosureVars, ptr)
 
-       call := ir.NewCallExpr(base.Pos, ir.OCALL, ir.NewSelectorExpr(base.Pos, ir.OXDOT, ptr, meth), nil, nil)
+       call := ir.NewCallExpr(base.Pos, ir.OCALL, ir.NewSelectorExpr(base.Pos, ir.OXDOT, ptr, meth), nil)
        call.Args = ir.ParamNames(tfn.Type())
        call.IsDDD = tfn.Type().IsVariadic()
 
index 201b217e8ec87767b84d4e49450fda88efc76206..7b5b113b158d20abea4599b4479ef31169faac75 100644 (file)
@@ -1068,7 +1068,7 @@ func (r *importReader) node() ir.Node {
        case ir.OCALL:
                pos := r.pos()
                init := r.stmtList()
-               n := ir.NewCallExpr(pos, ir.OCALL, r.expr(), nil, r.exprList())
+               n := ir.NewCallExpr(pos, ir.OCALL, r.expr(), r.exprList())
                *n.PtrInit() = init
                n.IsDDD = r.bool()
                return n
@@ -1236,5 +1236,5 @@ func (r *importReader) exprsOrNil() (a, b ir.Node) {
 }
 
 func builtinCall(pos src.XPos, op ir.Op) *ir.CallExpr {
-       return ir.NewCallExpr(pos, ir.OCALL, ir.NewIdent(base.Pos, types.BuiltinPkg.Lookup(ir.OpNames[op])), nil, nil)
+       return ir.NewCallExpr(pos, ir.OCALL, ir.NewIdent(base.Pos, types.BuiltinPkg.Lookup(ir.OpNames[op])), nil)
 }
index 60cbd66370c607eb71328910b6a2140826cbded3..97f9de9c1df332e3222f94a48e322bf460ad7f9a 100644 (file)
@@ -631,7 +631,7 @@ func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node {
                        continue
                }
 
-               r := ir.NewCallExpr(base.Pos, ir.OCALL, on, nil, nil)
+               r := ir.NewCallExpr(base.Pos, ir.OCALL, on, nil)
                if params := on.Type().Params().FieldSlice(); len(params) > 0 {
                        t := params[0].Type
                        if !types.Identical(t, n.Type()) {
index a076cdbe1a6d780c56d9d1b3674650e1dd1998cf..f4b5387c061dab12449425c67f4f338b542665f1 100644 (file)
@@ -160,7 +160,7 @@ func walkCompare(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
                }
 
                fn, needsize := eqFor(t)
-               call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, nil)
+               call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil)
                call.Args.Append(typecheck.NodAddr(cmpl))
                call.Args.Append(typecheck.NodAddr(cmpr))
                if needsize {
index 95f9d18f8cb75e6c7d0300a4cad61d5ca344f60e..73442dc404cf6988e599b8fb6ef8c60458567546 100644 (file)
@@ -416,7 +416,7 @@ func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes)
 
 func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) {
        // make the map var
-       a := ir.NewCallExpr(base.Pos, ir.OMAKE, nil, nil, nil)
+       a := ir.NewCallExpr(base.Pos, ir.OMAKE, nil, nil)
        a.SetEsc(n.Esc())
        a.Args = []ir.Node{ir.TypeNode(n.Type()), ir.NewInt(int64(len(n.List)))}
        litas(m, a, init)
index 30bac5462fa5fbc1baa0f88def6f628bd23b5de1..fa8e2c0bb8db485d88d280e1f9b1c9eb43facfd4 100644 (file)
@@ -145,7 +145,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
                types.CalcSize(fromType)
                fn = typecheck.SubstArgTypes(fn, fromType)
                types.CalcSize(fn.Type())
-               call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, nil)
+               call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil)
                call.Args = []ir.Node{n.X}
                e := ir.NewBinaryExpr(base.Pos, ir.OEFACE, typeword(), safeExpr(walkExpr(typecheck.Expr(call), init), init))
                e.SetType(toType)
@@ -180,7 +180,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
        fn := typecheck.LookupRuntime(fnname)
        fn = typecheck.SubstArgTypes(fn, fromType, toType)
        types.CalcSize(fn.Type())
-       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, nil)
+       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil)
        call.Args = []ir.Node{tab, v}
        return walkExpr(typecheck.Expr(call), init)
 }
index b7aeb53e436a4d53350c0507d2d218eb77029ba5..d7a20206c89f0aa8950cfd5b9aea4b7949a0537c 100644 (file)
@@ -469,7 +469,7 @@ func walkAddString(n *ir.AddStringExpr, init *ir.Nodes) ir.Node {
        }
 
        cat := typecheck.LookupRuntime(fn)
-       r := ir.NewCallExpr(base.Pos, ir.OCALL, cat, nil, nil)
+       r := ir.NewCallExpr(base.Pos, ir.OCALL, cat, nil)
        r.Args = args
        r1 := typecheck.Expr(r)
        r1 = walkExpr(r1, init)
index 8a076ca558ee12d641ea16bfccb1e6dac0d6cfd6..46a621c2ba74d9aa6b236e8d1316af82ab87dce0 100644 (file)
@@ -278,7 +278,7 @@ func wrapCall(n *ir.CallExpr, init *ir.Nodes) ir.Node {
                }
                args[i] = ir.NewConvExpr(base.Pos, origArg.Op(), origArg.Type(), args[i])
        }
-       call := ir.NewCallExpr(base.Pos, n.Op(), n.X, nil, args)
+       call := ir.NewCallExpr(base.Pos, n.Op(), n.X, args)
        if !isBuiltinCall {
                call.SetOp(ir.OCALL)
                call.IsDDD = n.IsDDD
@@ -291,6 +291,6 @@ func wrapCall(n *ir.CallExpr, init *ir.Nodes) ir.Node {
        typecheck.Stmts(fn.Body)
        typecheck.Target.Decls = append(typecheck.Target.Decls, fn)
 
-       call = ir.NewCallExpr(base.Pos, ir.OCALL, fn.Nname, nil, n.Args)
+       call = ir.NewCallExpr(base.Pos, ir.OCALL, fn.Nname, n.Args)
        return walkExpr(typecheck.Stmt(call), init)
 }
index 91b7e34d54aafab12356a5466c54fc23cb08b6fd..b47d96dc4c933db6022f9bffc20334b69313edba 100644 (file)
@@ -113,7 +113,7 @@ func vmkcall(fn ir.Node, t *types.Type, init *ir.Nodes, va []ir.Node) *ir.CallEx
                base.Fatalf("vmkcall %v needs %v args got %v", fn, n, len(va))
        }
 
-       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil, va)
+       call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, va)
        typecheck.Call(call)
        call.SetType(t)
        return walkExpr(call, init).(*ir.CallExpr)