go.tools/go.types: cleanups
Per feedback for CL 37250044. R=adonovan CC=golang-codereviews https://golang.org/cl/47150043
This commit is contained in:
parent
3d2d158b9d
commit
10f0067eb1
|
|
@ -218,6 +218,8 @@ func (p *exporter) fraction(x exact.Value) {
|
|||
p.ufloat(exact.Denom(x))
|
||||
}
|
||||
|
||||
// ufloat writes abs(x) in form of a binary exponent
|
||||
// followed by its mantissa bytes; x must be != 0.
|
||||
func (p *exporter) ufloat(x exact.Value) {
|
||||
mant := exact.Bytes(x)
|
||||
exp8 := -1
|
||||
|
|
@ -288,6 +290,13 @@ func (p *exporter) typ(typ types.Type) {
|
|||
case *types.Interface:
|
||||
p.int(interfaceTag)
|
||||
|
||||
// write embedded interfaces
|
||||
m := t.NumEmbeddeds()
|
||||
p.int(m)
|
||||
for i := 0; i < m; i++ {
|
||||
p.typ(t.Embedded(i))
|
||||
}
|
||||
|
||||
// write methods
|
||||
n := t.NumExplicitMethods()
|
||||
p.int(n)
|
||||
|
|
@ -297,13 +306,6 @@ func (p *exporter) typ(typ types.Type) {
|
|||
p.typ(m.Type())
|
||||
}
|
||||
|
||||
// write embedded interfaces
|
||||
m := t.NumEmbeddeds()
|
||||
p.int(m)
|
||||
for i := 0; i < m; i++ {
|
||||
p.typ(t.Embedded(i))
|
||||
}
|
||||
|
||||
case *types.Map:
|
||||
p.int(mapTag)
|
||||
p.typ(t.Key())
|
||||
|
|
|
|||
|
|
@ -253,16 +253,19 @@ func (p *importer) typ() types.Type {
|
|||
t := new(types.Interface)
|
||||
p.record(t)
|
||||
|
||||
// read embedded interfaces
|
||||
embeddeds := make([]*types.Named, p.int())
|
||||
for i := range embeddeds {
|
||||
embeddeds[i] = p.typ().(*types.Named)
|
||||
}
|
||||
|
||||
// read methods
|
||||
methods := make([]*types.Func, p.int())
|
||||
for i := range methods {
|
||||
pkg, name := p.qualifiedName()
|
||||
methods[i] = types.NewFunc(token.NoPos, pkg, name, p.typ().(*types.Signature))
|
||||
}
|
||||
|
||||
embeddeds := make([]*types.Named, p.int())
|
||||
for i := range embeddeds {
|
||||
embeddeds[i] = p.typ().(*types.Named)
|
||||
}
|
||||
*t = *types.NewInterface(methods, embeddeds)
|
||||
return t
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ package importer
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/build"
|
||||
|
|
@ -24,8 +23,6 @@ import (
|
|||
"code.google.com/p/go.tools/go/types"
|
||||
)
|
||||
|
||||
var verbose = flag.Bool("importer.v", false, "verbose mode")
|
||||
|
||||
var tests = []string{
|
||||
`package p`,
|
||||
|
||||
|
|
@ -108,7 +105,7 @@ func TestImportStdLib(t *testing.T) {
|
|||
// can be compared reasonably well
|
||||
types.GcCompatibilityMode = true
|
||||
|
||||
var totSize, totGcsize, n int
|
||||
var totSize, totGcsize int
|
||||
for _, lib := range libs {
|
||||
// limit run time for short tests
|
||||
if testing.Short() && time.Since(start) >= 750*time.Millisecond {
|
||||
|
|
@ -128,15 +125,14 @@ func TestImportStdLib(t *testing.T) {
|
|||
}
|
||||
|
||||
size, gcsize := testExportImport(t, pkg, lib)
|
||||
if *verbose {
|
||||
if testing.Verbose() {
|
||||
fmt.Printf("%s\t%d\t%d\t%d%%\n", lib, size, gcsize, int(float64(size)*100/float64(gcsize)))
|
||||
}
|
||||
totSize += size
|
||||
totGcsize += gcsize
|
||||
n++
|
||||
}
|
||||
|
||||
if *verbose {
|
||||
if testing.Verbose() {
|
||||
fmt.Printf("\n%d\t%d\t%d%%\n", totSize, totGcsize, int(float64(totSize)*100/float64(totGcsize)))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue