}
case ir.OSLICELIT:
+ r := r.(*ir.CompLitExpr)
// copy slice
- slicesym(l, loff, s.inittemps[r], ir.Int64Val(r.Right()))
+ slicesym(l, loff, s.inittemps[r], r.Len)
return true
case ir.OARRAYLIT, ir.OSTRUCTLIT:
}
case ir.OSLICELIT:
+ r := r.(*ir.CompLitExpr)
s.initplan(r)
// Init slice.
- bound := ir.Int64Val(r.Right())
- ta := types.NewArray(r.Type().Elem(), bound)
+ ta := types.NewArray(r.Type().Elem(), r.Len)
ta.SetNoalg(true)
a := staticname(ta)
s.inittemps[r] = a
- slicesym(l, loff, a, bound)
+ slicesym(l, loff, a, r.Len)
// Fall through to init underlying array.
l = a
loff = 0
return initDynamic
case ir.OSLICELIT:
+ n := n.(*ir.CompLitExpr)
if !top {
return initDynamic
}
- if ir.Int64Val(n.Right())/4 > int64(n.List().Len()) {
+ if n.Len/4 > int64(n.List().Len()) {
// <25% of entries have explicit values.
// Very rough estimation, it takes 4 bytes of instructions
// to initialize 1 byte of result. So don't use a static
return false
}
- r := n.Right()
-
- return smallintconst(r) && (n.Type().Elem().Width == 0 || ir.Int64Val(r) <= smallArrayBytes/n.Type().Elem().Width)
+ return n.Type().Elem().Width == 0 || n.Len <= smallArrayBytes/n.Type().Elem().Width
}
func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes) {
// make an array type corresponding the number of elements we have
- t := types.NewArray(n.Type().Elem(), ir.Int64Val(n.Right()))
+ t := types.NewArray(n.Type().Elem(), n.Len)
dowidth(t)
if ctxt == inNonInitFunction {