mirror of
https://github.com/golang/go
synced 2024-09-29 03:24:29 -06:00
[dev.unified] cmd/compile: visit LHS before RHS/X in assign/for statement
Unified IR used to visit RHS/X before LHS in assign/for statements for satisfying toolstash in quirksmode. After CL 385998, unified IR quirks mode was gone, the constraint to visit RHS/X first is no longer necessary. Change-Id: I1c3825168b67fb094928f5aa21748a3c81b118ce Reviewed-on: https://go-review.googlesource.com/c/go/+/410343 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
46ddf0873e
commit
9e5c968021
@ -1224,10 +1224,8 @@ func (r *reader) stmt1(tag codeStmt, out *ir.Nodes) ir.Node {
|
||||
case stmtAssign:
|
||||
pos := r.pos()
|
||||
|
||||
// TODO(mdempsky): After quirks mode is gone, swap these
|
||||
// statements so we visit LHS before RHS again.
|
||||
rhs := r.exprList()
|
||||
names, lhs := r.assignList()
|
||||
rhs := r.exprList()
|
||||
|
||||
if len(rhs) == 0 {
|
||||
for _, name := range names {
|
||||
@ -1368,10 +1366,8 @@ func (r *reader) forStmt(label *types.Sym) ir.Node {
|
||||
if r.Bool() {
|
||||
pos := r.pos()
|
||||
|
||||
// TODO(mdempsky): After quirks mode is gone, swap these
|
||||
// statements so we read LHS before X again.
|
||||
x := r.expr()
|
||||
names, lhs := r.assignList()
|
||||
x := r.expr()
|
||||
|
||||
body := r.blockStmt()
|
||||
r.closeAnotherScope()
|
||||
|
@ -954,8 +954,8 @@ func (w *writer) stmt1(stmt syntax.Stmt) {
|
||||
default:
|
||||
w.Code(stmtAssign)
|
||||
w.pos(stmt)
|
||||
w.exprList(stmt.Rhs)
|
||||
w.assignList(stmt.Lhs)
|
||||
w.exprList(stmt.Rhs)
|
||||
}
|
||||
|
||||
case *syntax.BlockStmt:
|
||||
@ -1065,8 +1065,8 @@ func (w *writer) declStmt(decl syntax.Decl) {
|
||||
case *syntax.VarDecl:
|
||||
w.Code(stmtAssign)
|
||||
w.pos(decl)
|
||||
w.exprList(decl.Values)
|
||||
w.assignList(namesAsExpr(decl.NameList))
|
||||
w.exprList(decl.Values)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1083,8 +1083,8 @@ func (w *writer) forStmt(stmt *syntax.ForStmt) {
|
||||
|
||||
if rang, ok := stmt.Init.(*syntax.RangeClause); w.Bool(ok) {
|
||||
w.pos(rang)
|
||||
w.expr(rang.X)
|
||||
w.assignList(rang.Lhs)
|
||||
w.expr(rang.X)
|
||||
} else {
|
||||
w.pos(stmt)
|
||||
w.stmt(stmt.Init)
|
||||
|
Loading…
Reference in New Issue
Block a user