mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: encapsulate OSLICE* representation
As a nice side-effect, this allows us to unify several code paths. The terminology (low, high, max, simple slice expr, full slice expr) is taken from the spec and the examples in the spec. This is a trial run. The plan, probably for Go 1.8, is to change slice expressions to use Node.List instead of OKEY, and to do some similar tree structure changes for other ops. Passes toolstash -cmp. No performance change. all.bash passes with GO_GCFLAGS=-newexport. Updates #15350 Change-Id: Ic1efdc36e79cdb95ae1636e9817a3ac8f83ab1ac Reviewed-on: https://go-review.googlesource.com/22425 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
2bf7034d87
commit
f12bd8a5a8
13 changed files with 204 additions and 198 deletions
|
|
@ -727,7 +727,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
|
|||
arraylit(ctxt, 2, n, vstat, init)
|
||||
|
||||
// copy static to slice
|
||||
a := Nod(OSLICE, vstat, Nod(OKEY, nil, nil))
|
||||
a := Nod(OSLICE, vstat, nil)
|
||||
|
||||
a = Nod(OAS, var_, a)
|
||||
a = typecheck(a, Etop)
|
||||
|
|
@ -851,7 +851,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
|
|||
}
|
||||
|
||||
// make slice out of heap (6)
|
||||
a = Nod(OAS, var_, Nod(OSLICE, vauto, Nod(OKEY, nil, nil)))
|
||||
a = Nod(OAS, var_, Nod(OSLICE, vauto, nil))
|
||||
|
||||
a = typecheck(a, Etop)
|
||||
a = orderstmtinplace(a)
|
||||
|
|
@ -1391,7 +1391,8 @@ func genAsInitNoCheck(n *Node, reportOnly bool) bool {
|
|||
fallthrough
|
||||
|
||||
case OSLICEARR:
|
||||
if nr.Right.Op != OKEY || nr.Right.Left != nil || nr.Right.Right != nil {
|
||||
low, high, _ := nr.SliceBounds()
|
||||
if low != nil || high != nil {
|
||||
return false
|
||||
}
|
||||
nr = nr.Left
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue