func (v *Value) size(name string) string {
	if v.isFixed() {
		if v.t == TypeContainer {
			return v.sizeContainer(name, false)
		}
		if v.n == 1 {
			return name + "++"
		}
		return name + " += " + strconv.Itoa(int(v.n))
	}
	switch v.t {
	case TypeContainer, TypeReference:
		return v.sizeContainer(name, false)
	case TypeBitList:
		fallthrough
	case TypeBytes:
		return fmt.Sprintf(name+" += len(::.%s)", v.name)
	case TypeList:
		fallthrough
	case TypeVector:
		if v.e.isFixed() {
			return fmt.Sprintf("%s += len(::.%s) * %d", name, v.name, v.e.n)
		}
		v.e.name = v.name + "[ii]"
		tmpl := `for ii := 0; ii < len(::.{{.name}}); ii++ {
			{{.size}} += 4
			{{.dynamic}}
		}`
		return execTmpl(tmpl, map[string]interface{}{
			"name":    v.name,
			"size":    name,
			"dynamic": v.e.size(name),
		})
	default:
		panic(fmt.Errorf("size not implemented for type %s", v.t.String()))
	}
}
'name' is the name of target variable we assign the size too. We also use this function
during marshalling to figure out the size of the offset
package main
import (
	"fmt"
	"strconv"
	"strings"
)
func (e *env) size(name string, v *Value) string {
	tmpl := ` 
	func (:: *{{.name}}) SizeSSZ() (size int) {
		size = {{.fixed}}{{if .dynamic}}
		{{.dynamic}}
		{{end}}
		return
	}`
	str := execTmpl(tmpl, map[string]interface{}{
		"name":    name,
		"fixed":   v.n,
		"dynamic": v.sizeContainer("size", true),
	})
	return appendObjSignature(str, v)
}
func (v *Value) sizeContainer(name string, start bool) string {
	if !start {
		tmpl := `{{if .check}} if ::.{{.name}} == nil {
			::.{{.name}} = new({{.obj}})
		}
		{{end}} {{ .dst }} += ::.{{.name}}.SizeSSZ()`
		check := true
		if v.isListElem() {
			check = false
		}
		if v.noPtr {
			check = false
		}
		return execTmpl(tmpl, map[string]interface{}{
			"name":  v.name,
			"dst":   name,
			"obj":   v.objRef(),
			"check": check,
		})
	}
	out := []string{}
	for indx, v := range v.o {
		if !v.isFixed() {
			out = append(out, fmt.Sprintf("// Field (%d) '%s'\n%s", indx, v.name, v.size(name)))
		}
	}
	return strings.Join(out, "\n\n")
}