@@ -562,23 +562,7 @@ func (o *Order) stmt(n *Node) {
562
562
o .mapAssign (n )
563
563
o .cleanTemp (t )
564
564
565
- // Special: make sure key is addressable if needed,
566
- // and make sure OINDEXMAP is not copied out.
567
- case OAS2MAPR :
568
- t := o .markTemp ()
569
- o .exprList (n .List )
570
- r := n .Right
571
- r .Left = o .expr (r .Left , nil )
572
- r .Right = o .expr (r .Right , nil )
573
-
574
- // See similar conversion for OINDEXMAP below.
575
- _ = mapKeyReplaceStrConv (r .Right )
576
-
577
- r .Right = o .mapKeyTemp (r .Left .Type , r .Right )
578
- o .okAs2 (n )
579
- o .cleanTemp (t )
580
-
581
- // Special: avoid copy of func call n.Rlist.First().
565
+ // Special: avoid copy of func call n.Right
582
566
case OAS2FUNC :
583
567
t := o .markTemp ()
584
568
o .exprList (n .List )
@@ -588,32 +572,29 @@ func (o *Order) stmt(n *Node) {
588
572
o .cleanTemp (t )
589
573
590
574
// Special: use temporary variables to hold result,
591
- // so that assertI2Tetc can take address of temporary.
575
+ // so that runtime can take address of temporary.
592
576
// No temporary for blank assignment.
593
- case OAS2DOTTYPE :
577
+ //
578
+ // OAS2MAPR: make sure key is addressable if needed,
579
+ // and make sure OINDEXMAP is not copied out.
580
+ case OAS2DOTTYPE , OAS2RECV , OAS2MAPR :
594
581
t := o .markTemp ()
595
582
o .exprList (n .List )
596
- n .Right .Left = o .expr (n .Right .Left , nil ) // i in i.(T)
597
- o .okAs2 (n )
598
- o .cleanTemp (t )
599
583
600
- // Special: use temporary variables to hold result,
601
- // so that chanrecv can take address of temporary.
602
- case OAS2RECV :
603
- t := o .markTemp ()
604
- o .exprList (n .List )
605
- n .Right .Left = o .expr (n .Right .Left , nil ) // arg to recv
606
- ch := n .Right .Left .Type
607
- tmp1 := o .newTemp (ch .Elem (), types .Haspointers (ch .Elem ()))
608
- tmp2 := o .newTemp (types .Types [TBOOL ], false )
609
- o .out = append (o .out , n )
610
- r := nod (OAS , n .List .First (), tmp1 )
611
- r = typecheck (r , ctxStmt )
612
- o .mapAssign (r )
613
- r = okas (n .List .Second (), tmp2 )
614
- r = typecheck (r , ctxStmt )
615
- o .mapAssign (r )
616
- n .List .Set2 (tmp1 , tmp2 )
584
+ switch r := n .Right ; r .Op {
585
+ case ODOTTYPE2 , ORECV :
586
+ r .Left = o .expr (r .Left , nil )
587
+ case OINDEXMAP :
588
+ r .Left = o .expr (r .Left , nil )
589
+ r .Right = o .expr (r .Right , nil )
590
+ // See similar conversion for OINDEXMAP below.
591
+ _ = mapKeyReplaceStrConv (r .Right )
592
+ r .Right = o .mapKeyTemp (r .Left .Type , r .Right )
593
+ default :
594
+ Fatalf ("order.stmt: %v" , r .Op )
595
+ }
596
+
597
+ o .okAs2 (n )
617
598
o .cleanTemp (t )
618
599
619
600
// Special: does not save n onto out.
@@ -1310,7 +1291,7 @@ func okas(ok, val *Node) *Node {
1310
1291
}
1311
1292
1312
1293
// as2 orders OAS2XXXX nodes. It creates temporaries to ensure left-to-right assignment.
1313
- // The caller should order the right-hand side of the assignment before calling orderas2 .
1294
+ // The caller should order the right-hand side of the assignment before calling order.as2 .
1314
1295
// It rewrites,
1315
1296
// a, b, a = ...
1316
1297
// as
@@ -1338,7 +1319,7 @@ func (o *Order) as2(n *Node) {
1338
1319
o .stmt (as )
1339
1320
}
1340
1321
1341
- // okAs2 orders OAS2 with ok.
1322
+ // okAs2 orders OAS2XXX with ok.
1342
1323
// Just like as2, this also adds temporaries to ensure left-to-right assignment.
1343
1324
func (o * Order ) okAs2 (n * Node ) {
1344
1325
var tmp1 , tmp2 * Node
0 commit comments