Skip to content

Commit 1711624

Browse files
committed
wire: 修正 Set 指令未“并行赋值”的问题
1 parent c516079 commit 1711624

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

internal/wire/function.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -337,22 +337,6 @@ func rc_stmt(s Stmt, inloop bool, d *Block) {
337337
s.Rhs[i] = rc_expr(s.Rhs[i], inloop, false, false, d, &pre)
338338
}
339339

340-
//rhNeedRetain := make([]bool, len(s.Lhs))
341-
//if len(s.Lhs) == len(s.Rhs) {
342-
// for i := range s.Rhs {
343-
// rc_expr(s.Rhs[i], inloop, false, false, d, &pre)
344-
// if rtimp.hasChunk(s.Rhs[i].Type()) && !s.Rhs[i].retained() {
345-
// rhNeedRetain[i] = true
346-
// }
347-
// }
348-
//} else {
349-
// // rh 是元组
350-
// notRetained := rtimp.hasChunk(s.Rhs[0].Type()) && !s.Rhs[0].retained()
351-
// for i := range rhNeedRetain {
352-
// rhNeedRetain[i] = notRetained
353-
// }
354-
//}
355-
356340
d.Stmts = append(d.Stmts, pre...)
357341

358342
allLhsAssignable := true
@@ -396,7 +380,6 @@ func rc_stmt(s Stmt, inloop bool, d *Block) {
396380

397381
if allLhsAssignable {
398382
assign := newAssignN(lhs, s.Rhs, s.pos)
399-
//copy(assign.needRetain, rhNeedRetain)
400383
d.emit(assign)
401384
} else {
402385
rhs := make([]Expr, len(s.Lhs))
@@ -414,7 +397,15 @@ func rc_stmt(s Stmt, inloop bool, d *Block) {
414397
rhs[i] = newExtract(tuple, i, s.pos)
415398
}
416399
} else {
417-
copy(rhs, s.Rhs)
400+
if len(s.Rhs) == 1 {
401+
copy(rhs, s.Rhs)
402+
} else {
403+
for i := range s.Rhs {
404+
imv := newImv(d.newTempVarName(), s.Rhs[i], s.pos)
405+
d.emit(imv)
406+
rhs[i] = imv
407+
}
408+
}
418409
}
419410

420411
for i := range lhs {
@@ -423,14 +414,12 @@ func rc_stmt(s Stmt, inloop bool, d *Block) {
423414

424415
if lhAssignable[i] {
425416
assign := newAssign(loc, rh, s.pos)
426-
//assign.needRetain[0] = rhNeedRetain[i]
427417
d.emit(assign)
428418
continue
429419
}
430420

431421
if c, ok := rh.(*Const); ok {
432422
store := newStore(loc, c, s.pos)
433-
//store.needRetain = false
434423
d.emit(store)
435424
continue
436425
}
@@ -440,15 +429,13 @@ func rc_stmt(s Stmt, inloop bool, d *Block) {
440429
panic(fmt.Sprintf("rh: %s is not a Register", v.Name()))
441430
}
442431
store := newStore(loc, v, s.pos)
443-
//store.needRetain = rhNeedRetain[i]
444432
d.emit(store)
445433
continue
446434
}
447435

448436
imv := newImv(d.newTempVarName(), rh, s.pos)
449437
d.emit(imv)
450438
store := newStore(loc, imv, s.pos)
451-
//store.needRetain = rhNeedRetain[i]
452439
d.emit(store)
453440
}
454441
}

0 commit comments

Comments
 (0)