mirror of
https://github.com/golang/go
synced 2024-10-05 20:21:21 -06:00
[dev.ssa] cmd/compile/ssa: implement OLEN
Change-Id: Ie23b13142fd820d7071a348a8370175e58b76d64 Reviewed-on: https://go-review.googlesource.com/11878 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
6c14059e65
commit
cc3f031a31
@ -521,6 +521,16 @@ func (s *state) expr(n *Node) *ssa.Value {
|
||||
return s.newValue2(ssa.OpLoad, n.Left.Type.Type, p, s.mem())
|
||||
}
|
||||
|
||||
case OLEN:
|
||||
switch {
|
||||
case n.Left.Type.Bound < 0: // slice
|
||||
return s.newValue1(ssa.OpSliceLen, s.config.Uintptr, s.expr(n.Left))
|
||||
case n.Left.Type.IsString(): // string
|
||||
return s.newValue1(ssa.OpStringLen, s.config.Uintptr, s.expr(n.Left))
|
||||
default: // array
|
||||
return s.constInt(s.config.Uintptr, n.Left.Type.Bound)
|
||||
}
|
||||
|
||||
case OCALLFUNC:
|
||||
static := n.Left.Op == ONAME && n.Left.Class == PFUNC
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user