mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.unified] cmd/compile/internal/noder: start writing implicit conversions
This CL adds support for implicit conversions to the unified IR export data format, and starts inserting them in a few low-hanging places (send statements, index expressions). Subsequentl CLs will handle the remaining trickier cases. Change-Id: Iaea9d1c5df8432b61bd82578ab2ef02adaf26367 Reviewed-on: https://go-review.googlesource.com/c/go/+/413396 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
9cb784ac69
commit
5f5422a2dd
2 changed files with 54 additions and 11 deletions
|
|
@ -1782,6 +1782,7 @@ func (r *reader) expr() (res ir.Node) {
|
|||
return typecheck.Expr(ir.NewUnaryExpr(pos, ir.ONEW, typ))
|
||||
|
||||
case exprConvert:
|
||||
implicit := r.Bool()
|
||||
typ := r.typ()
|
||||
pos := r.pos()
|
||||
x := r.expr()
|
||||
|
|
@ -1799,7 +1800,11 @@ func (r *reader) expr() (res ir.Node) {
|
|||
base.ErrorExit() // harsh, but prevents constructing invalid IR
|
||||
}
|
||||
|
||||
return typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, typ, x))
|
||||
n := typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, typ, x))
|
||||
if implicit && n.Op() != ir.OLITERAL {
|
||||
n.(ImplicitNode).SetImplicit(true)
|
||||
}
|
||||
return n
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue