return c
}
-func aindex(b *Node, t *Type) *Type {
- hasbound := false
- var bound int64
- b = typecheck(b, Erv)
- if b != nil {
- switch consttype(b) {
- default:
- yyerror("array bound must be an integer expression")
-
- case CTINT, CTRUNE:
- hasbound = true
- bound = b.Int64()
- if bound < 0 {
- yyerror("array bound must be non negative")
- }
- }
- }
-
- if !hasbound {
- return typSlice(t)
- }
- return typArray(t, bound)
-}
-
// treecopy recursively copies n, with the exception of
// ONAME, OLITERAL, OTYPE, and non-iota ONONAME leaves.
// Copies of iota ONONAME nodes are assigned the current
}
// var arr [r]T
// n = arr[:l]
- t = aindex(r, t.Elem()) // [r]T
+ t = typArray(t.Elem(), nonnegintconst(r)) // [r]T
var_ := temp(t)
a := nod(OAS, var_, nil) // zero temp
a = typecheck(a, Etop)
case ORUNESTR:
a := nodnil()
if n.Esc == EscNone {
- t := aindex(nodintconst(4), Types[TUINT8])
+ t := typArray(Types[TUINT8], 4)
var_ := temp(t)
a = nod(OADDR, var_, nil)
}
a := nodnil()
if n.Esc == EscNone {
// Create temporary buffer for string on stack.
- t := aindex(nodintconst(tmpstringbufsize), Types[TUINT8])
+ t := typArray(Types[TUINT8], tmpstringbufsize)
a = nod(OADDR, temp(t), nil)
}
if n.Esc == EscNone {
// Create temporary buffer for string on stack.
- t := aindex(nodintconst(tmpstringbufsize), Types[TUINT8])
+ t := typArray(Types[TUINT8], tmpstringbufsize)
a = nod(OADDR, temp(t), nil)
}
if n.Esc == EscNone {
// Create temporary buffer for slice on stack.
- t := aindex(nodintconst(tmpstringbufsize), Types[TUINT8])
+ t := typArray(Types[TUINT8], tmpstringbufsize)
a = nod(OADDR, temp(t), nil)
}
if n.Esc == EscNone {
// Create temporary buffer for slice on stack.
- t := aindex(nodintconst(tmpstringbufsize), Types[TINT32])
+ t := typArray(Types[TINT32], tmpstringbufsize)
a = nod(OADDR, temp(t), nil)
}
// Don't allocate the buffer if the result won't fit.
if sz < tmpstringbufsize {
// Create temporary buffer for result string on stack.
- t := aindex(nodintconst(tmpstringbufsize), Types[TUINT8])
+ t := typArray(Types[TUINT8], tmpstringbufsize)
buf = nod(OADDR, temp(t), nil)
}