2015-10-30 22:07:00 +00:00
|
|
|
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
|
2016-04-26 00:18:04 +00:00
|
|
|
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}}
|
2015-10-30 22:07:00 +00:00
|
|
|
var {{var "c"}} bool {{/* // changed */}}
|
2016-04-26 00:18:04 +00:00
|
|
|
_ = {{var "c"}}{{end}}
|
2015-10-30 22:07:00 +00:00
|
|
|
if {{var "l"}} == 0 {
|
|
|
|
{{if isSlice }}if {{var "v"}} == nil {
|
|
|
|
{{var "v"}} = []{{ .Typ }}{}
|
|
|
|
{{var "c"}} = true
|
|
|
|
} else if len({{var "v"}}) != 0 {
|
|
|
|
{{var "v"}} = {{var "v"}}[:0]
|
|
|
|
{{var "c"}} = true
|
|
|
|
} {{end}} {{if isChan }}if {{var "v"}} == nil {
|
|
|
|
{{var "v"}} = make({{ .CTyp }}, 0)
|
|
|
|
{{var "c"}} = true
|
|
|
|
} {{end}}
|
2015-06-29 21:50:55 +00:00
|
|
|
} else if {{var "l"}} > 0 {
|
2015-10-30 22:07:00 +00:00
|
|
|
{{if isChan }}if {{var "v"}} == nil {
|
|
|
|
{{var "rl"}}, _ = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
|
|
|
|
{{var "v"}} = make({{ .CTyp }}, {{var "rl"}})
|
|
|
|
{{var "c"}} = true
|
|
|
|
}
|
2015-06-29 21:50:55 +00:00
|
|
|
for {{var "r"}} := 0; {{var "r"}} < {{var "l"}}; {{var "r"}}++ {
|
2015-10-30 22:07:00 +00:00
|
|
|
{{var "h"}}.ElemContainerState({{var "r"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
var {{var "t"}} {{ .Typ }}
|
|
|
|
{{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{var "v"}} <- {{var "t"}}
|
|
|
|
}
|
|
|
|
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
|
|
|
|
var {{var "rt"}} bool {{/* truncated */}}
|
2016-04-26 00:18:04 +00:00
|
|
|
_, _ = {{var "rl"}}, {{var "rt"}}
|
|
|
|
{{var "rr"}} = {{var "l"}} // len({{var "v"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
if {{var "l"}} > cap({{var "v"}}) {
|
2015-10-30 22:07:00 +00:00
|
|
|
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
|
|
|
|
{{ else }}{{if not .Immutable }}
|
|
|
|
{{var "rg"}} := len({{var "v"}}) > 0
|
|
|
|
{{var "v2"}} := {{var "v"}} {{end}}
|
|
|
|
{{var "rl"}}, {{var "rt"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
|
|
|
|
if {{var "rt"}} {
|
|
|
|
if {{var "rl"}} <= cap({{var "v"}}) {
|
|
|
|
{{var "v"}} = {{var "v"}}[:{{var "rl"}}]
|
|
|
|
} else {
|
|
|
|
{{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
{{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{var "c"}} = true
|
|
|
|
{{var "rr"}} = len({{var "v"}}) {{if not .Immutable }}
|
|
|
|
if {{var "rg"}} { copy({{var "v"}}, {{var "v2"}}) } {{end}} {{end}}{{/* end not Immutable, isArray */}}
|
|
|
|
} {{if isSlice }} else if {{var "l"}} != len({{var "v"}}) {
|
|
|
|
{{var "v"}} = {{var "v"}}[:{{var "l"}}]
|
|
|
|
{{var "c"}} = true
|
|
|
|
} {{end}} {{/* end isSlice:47 */}}
|
2015-06-29 21:50:55 +00:00
|
|
|
{{var "j"}} := 0
|
2015-10-07 20:10:00 +00:00
|
|
|
for ; {{var "j"}} < {{var "rr"}} ; {{var "j"}}++ {
|
2015-10-30 22:07:00 +00:00
|
|
|
{{var "h"}}.ElemContainerState({{var "j"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
{{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
|
2015-10-07 20:10:00 +00:00
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{if isArray }}for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ {
|
|
|
|
{{var "h"}}.ElemContainerState({{var "j"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
z.DecSwallow()
|
2015-10-07 20:10:00 +00:00
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{ else }}if {{var "rt"}} {
|
2015-10-07 20:10:00 +00:00
|
|
|
for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ {
|
|
|
|
{{var "v"}} = append({{var "v"}}, {{ zero}})
|
2015-10-30 22:07:00 +00:00
|
|
|
{{var "h"}}.ElemContainerState({{var "j"}})
|
2015-10-07 20:10:00 +00:00
|
|
|
{{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
|
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
} {{end}} {{/* end isArray:56 */}}
|
|
|
|
{{end}} {{/* end isChan:16 */}}
|
|
|
|
} else { {{/* len < 0 */}}
|
|
|
|
{{var "j"}} := 0
|
|
|
|
for ; !r.CheckBreak(); {{var "j"}}++ {
|
|
|
|
{{if isChan }}
|
|
|
|
{{var "h"}}.ElemContainerState({{var "j"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
var {{var "t"}} {{ .Typ }}
|
|
|
|
{{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }}
|
|
|
|
{{var "v"}} <- {{var "t"}}
|
|
|
|
{{ else }}
|
2015-10-30 22:07:00 +00:00
|
|
|
if {{var "j"}} >= len({{var "v"}}) {
|
|
|
|
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "j"}}+1)
|
|
|
|
{{ else }}{{var "v"}} = append({{var "v"}}, {{zero}})// var {{var "z"}} {{ .Typ }}
|
|
|
|
{{var "c"}} = true {{end}}
|
|
|
|
}
|
|
|
|
{{var "h"}}.ElemContainerState({{var "j"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
if {{var "j"}} < len({{var "v"}}) {
|
|
|
|
{{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
|
|
|
|
} else {
|
|
|
|
z.DecSwallow()
|
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{end}}
|
2015-06-29 21:50:55 +00:00
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{if isSlice }}if {{var "j"}} < len({{var "v"}}) {
|
|
|
|
{{var "v"}} = {{var "v"}}[:{{var "j"}}]
|
|
|
|
{{var "c"}} = true
|
|
|
|
} else if {{var "j"}} == 0 && {{var "v"}} == nil {
|
|
|
|
{{var "v"}} = []{{ .Typ }}{}
|
|
|
|
{{var "c"}} = true
|
|
|
|
}{{end}}
|
2015-06-29 21:50:55 +00:00
|
|
|
}
|
2015-10-30 22:07:00 +00:00
|
|
|
{{var "h"}}.End()
|
|
|
|
{{if not isArray }}if {{var "c"}} {
|
2015-06-29 21:50:55 +00:00
|
|
|
*{{ .Varname }} = {{var "v"}}
|
2015-10-30 22:07:00 +00:00
|
|
|
}{{end}}
|