
These two passes are related, but can definitely work independently. Which is what this change does: it splits the two passes. This should make it easier to change these two new passes in the future. This change now also enables slightly better testing by testing these two passes independently. In particular, the reflect lowering pass got some actual tests: it was barely unit-tested before. I have verified that this doesn't really change code size, at least not on the microbit target. Two tests do change, but in a very minor way (and in opposite direction).
23 строки
412 Б
Go
23 строки
412 Б
Go
package transform_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tinygo-org/tinygo/transform"
|
|
"tinygo.org/x/go-llvm"
|
|
)
|
|
|
|
func TestInterfaceLowering(t *testing.T) {
|
|
t.Parallel()
|
|
testTransform(t, "testdata/interface", func(mod llvm.Module) {
|
|
err := transform.LowerInterfaces(mod, 0)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
pm := llvm.NewPassManager()
|
|
defer pm.Dispose()
|
|
pm.AddGlobalDCEPass()
|
|
pm.Run(mod)
|
|
})
|
|
}
|