mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use typecheck.InitUniverse in unit tests
Rather than ad hoc setting up the universe, just initialize it properly. Change-Id: I18484b952321f55eb3e1e48fd383068a4ee75f66 Reviewed-on: https://go-review.googlesource.com/c/go/+/345475 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
967a8017f7
commit
f153b6739b
1 changed files with 8 additions and 27 deletions
|
|
@ -5,14 +5,16 @@
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"cmd/compile/internal/ir"
|
"cmd/compile/internal/ir"
|
||||||
|
"cmd/compile/internal/typecheck"
|
||||||
"cmd/compile/internal/types"
|
"cmd/compile/internal/types"
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
"cmd/internal/obj/arm64"
|
"cmd/internal/obj/arm64"
|
||||||
"cmd/internal/obj/s390x"
|
"cmd/internal/obj/s390x"
|
||||||
"cmd/internal/obj/x86"
|
"cmd/internal/obj/x86"
|
||||||
"cmd/internal/src"
|
"cmd/internal/src"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var CheckFunc = checkFunc
|
var CheckFunc = checkFunc
|
||||||
|
|
@ -104,33 +106,12 @@ func (d TestFrontend) MyImportPath() string {
|
||||||
var testTypes Types
|
var testTypes Types
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Initialize just enough of the universe and the types package to make our tests function.
|
// TODO(mdempsky): Push into types.InitUniverse or typecheck.InitUniverse.
|
||||||
// TODO(josharian): move universe initialization to the types package,
|
types.PtrSize = 8
|
||||||
// so this test setup can share it.
|
types.RegSize = 8
|
||||||
|
types.MaxWidth = 1 << 50
|
||||||
|
|
||||||
for _, typ := range [...]struct {
|
typecheck.InitUniverse()
|
||||||
width int64
|
|
||||||
et types.Kind
|
|
||||||
}{
|
|
||||||
{1, types.TINT8},
|
|
||||||
{1, types.TUINT8},
|
|
||||||
{1, types.TBOOL},
|
|
||||||
{2, types.TINT16},
|
|
||||||
{2, types.TUINT16},
|
|
||||||
{4, types.TINT32},
|
|
||||||
{4, types.TUINT32},
|
|
||||||
{4, types.TFLOAT32},
|
|
||||||
{4, types.TFLOAT64},
|
|
||||||
{8, types.TUINT64},
|
|
||||||
{8, types.TINT64},
|
|
||||||
{8, types.TINT},
|
|
||||||
{8, types.TUINTPTR},
|
|
||||||
} {
|
|
||||||
t := types.New(typ.et)
|
|
||||||
t.Width = typ.width
|
|
||||||
t.Align = uint8(typ.width)
|
|
||||||
types.Types[typ.et] = t
|
|
||||||
}
|
|
||||||
testTypes.SetTypPtrs()
|
testTypes.SetTypPtrs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue