]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use one format for exporting calls of builtin functions
authorRobert Griesemer <gri@golang.org>
Wed, 11 May 2016 20:39:36 +0000 (13:39 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 11 May 2016 22:57:12 +0000 (22:57 +0000)
Minor cleanup. Each of these cases appears both during export and
import when running all.bash and thus is tested by all.bash.

Change-Id: Iaa4a5a5b163cefe33e43d08d396e02a02e5c22a5
Reviewed-on: https://go-review.googlesource.com/23060
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/bimport.go

index 48b2b201562cabbea7433991175f980f2736ea6b..2e5731e2b8c5805d693e44a365b1055d85100fff 100644 (file)
@@ -1256,26 +1256,35 @@ func (p *exporter) expr(n *Node) {
                p.expr(max)
 
        case OCOPY, OCOMPLEX:
+               // treated like other builtin calls (see e.g., OREAL)
                p.op(op)
                p.expr(n.Left)
                p.expr(n.Right)
+               p.op(OEND)
 
        case OCONV, OCONVIFACE, OCONVNOP, OARRAYBYTESTR, OARRAYRUNESTR, OSTRARRAYBYTE, OSTRARRAYRUNE, ORUNESTR:
                p.op(OCONV)
                p.typ(n.Type)
-               if p.bool(n.Left != nil) {
+               if n.Left != nil {
                        p.expr(n.Left)
+                       p.op(OEND)
                } else {
-                       p.exprList(n.List)
+                       p.exprList(n.List) // emits terminating OEND
                }
 
        case OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN:
                p.op(op)
-               if p.bool(n.Left != nil) {
+               if n.Left != nil {
                        p.expr(n.Left)
+                       p.op(OEND)
                } else {
-                       p.exprList(n.List)
+                       p.exprList(n.List) // emits terminating OEND
+               }
+               // only append() calls may contain '...' arguments
+               if op == OAPPEND {
                        p.bool(n.Isddd)
+               } else if n.Isddd {
+                       Fatalf("exporter: unexpected '...' with %s call", opnames[op])
                }
 
        case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OGETG:
index 1bc184f7a430709f7a8665c5698b21a11f7f9307..51847538961eecc60b99a9b7aaa18b23a81b9a7e 100644 (file)
@@ -884,29 +884,18 @@ func (p *importer) node() *Node {
                n.SetSliceBounds(low, high, max)
                return n
 
-       case OCOPY, OCOMPLEX:
-               n := builtinCall(op)
-               n.List.Set([]*Node{p.expr(), p.expr()})
-               return n
-
        // case OCONV, OCONVIFACE, OCONVNOP, OARRAYBYTESTR, OARRAYRUNESTR, OSTRARRAYBYTE, OSTRARRAYRUNE, ORUNESTR:
        //      unreachable - mapped to OCONV case below by exporter
 
        case OCONV:
                n := Nod(OCALL, typenod(p.typ()), nil)
-               if p.bool() {
-                       n.List.Set1(p.expr())
-               } else {
-                       n.List.Set(p.exprList())
-               }
+               n.List.Set(p.exprList())
                return n
 
-       case OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN:
+       case OCOPY, OCOMPLEX, OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN:
                n := builtinCall(op)
-               if p.bool() {
-                       n.List.Set1(p.expr())
-               } else {
-                       n.List.Set(p.exprList())
+               n.List.Set(p.exprList())
+               if op == OAPPEND {
                        n.Isddd = p.bool()
                }
                return n