[dev.typeparams] cmd/compile: add types2.Sizes implementation

This CL adds an implementation of types2.Sizes that calculates sizes
using the same sizing algorithm as cmd/compile. In particular, it
matches how cmd/compile pads structures and includes padding in size
calculations.

Change-Id: I4dd8e51f95c90f9d7bd1e7463e40edcd3955a219
Reviewed-on: https://go-review.googlesource.com/c/go/+/282915
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2021-01-08 19:27:51 -08:00
parent 44d1a8523a
commit 2e8f29b79d
2 changed files with 151 additions and 0 deletions

View file

@ -133,6 +133,7 @@ func ParseFiles(filenames []string) (lines uint) {
return os.Open(file)
},
},
Sizes: &gcSizes{},
}
info := types2.Info{
Types: make(map[syntax.Expr]types2.TypeAndValue),