Граф коммитов

5845 Коммитов

Автор SHA1 Сообщение Дата
Andrew Gerrand 32acd2b372 go.tools/cmd/godoc: redirect old pkg/cmd paths
fixes golang/go#5317.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12869046
2013-08-16 13:44:52 +10:00
Andrew Gerrand 562e4faeca cmd/godoc: bake templates and scripts into godoc binary
Add godoc/vfs/mapfs package for serving baked files.

Fixes golang/go#6010.

R=golang-dev, bradfitz, r, arnehormann, rsc
CC=golang-dev
https://golang.org/cl/12978043
2013-08-16 11:44:27 +10:00
Chris Manghane dfa65ded17 go.tools: add go/vcs
go/vcs exposes cmd/go/vcs.go from the `go get` command.

- Exported global variables `Verbose` and `ShowCmd` to replace `buildV` and `buildX` from cmd/go/main.go.
- Moved environment building code (envForDir, mergeEnvLists)from cmd/go/main.go to env.go
- Exported Cmd and its methods: Create, Download, Ping, TagSync, and Tags
- Exported ByCmd and FromDir functions for constructing Cmd
- Exported TagCmd
- Exported RepoRoot
- Exported RepoRootForImport* functions for constructing RepoRoot

R=golang-dev, adg, cmang, bradfitz
CC=golang-dev
https://golang.org/cl/12058054
2013-08-15 09:00:02 -07:00
Robert Griesemer ae874abc7a go.tools/go/types: *interface types have no methods
Fixes golang/go#5918.

R=adonovan
CC=golang-dev
https://golang.org/cl/12909043
2013-08-14 11:02:10 -07:00
Robert Griesemer 0b3996b1d3 go.tools/ssa/interp: add missing "external" (fix build)
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12898043
2013-08-13 15:00:07 -07:00
David Symonds c0b6badc83 cmd/vet: flag redundant invocations of String and Error methods in printf calls.
R=r
CC=golang-dev
https://golang.org/cl/12811043
2013-08-13 13:47:58 +10:00
Robert Griesemer d13d94afe7 go.tools/go/types: do rounding in constant numeric conversions
- cleaned up surrounding code
- adjusted error message positions for too few/many argument errors
- added more conversion tests
- added all tests under test/ken to std tests

R=adonovan, r
TBR=adonovan
CC=golang-dev
https://golang.org/cl/12711043
2013-08-12 14:57:08 -07:00
Robert Griesemer 508ae115ae go.tools/go/types: added missing test for file scopes
R=adonovan, r
CC=golang-dev
https://golang.org/cl/12671044
2013-08-08 20:54:28 -07:00
Rob Pike 28fe5aa8d3 go.tools/cmd/cover: s/ParseInt/Atoi/
So people stop asking me to do this.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12691044
2013-08-09 13:48:46 +10:00
Robert Griesemer 2449594308 go.tools/go.types: retain ast.Node links on demand only
- support Info.Scopes mapping that maps ast.Nodes
  to the respective *Scope
- remove old node link from *Scope
- added corresponding API test

Also: re-enable debug mode (the faster version was
only important for the go api tool, which  has its
own version now).

R=adonovan, r
CC=golang-dev
https://golang.org/cl/12552047
2013-08-08 20:27:15 -07:00
Rob Pike 4622486b62 go.tools/cmd/cover: add -func mode to print per-function coverage
fmt/format.go:	init			100.0%
fmt/format.go:	clearflags		100.0%
fmt/format.go:	init			100.0%
fmt/format.go:	computePadding		84.6%
fmt/format.go:	writePadding		83.3%
...
total:		(statements)		91.3%

Fixes golang/go#5985.

R=golang-dev, dave, gri
CC=golang-dev
https://golang.org/cl/12454043
2013-08-09 12:55:21 +10:00
Robert Griesemer 875ff2496f go.tools/go/types: support for fake imports of package "C"
Also:
- cleaner method set printing
- disable debug mode internally (50% faster)

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12578043
2013-08-07 14:09:50 -07:00
Robert Griesemer 56b9e46247 go.tools/go/types: fewer guarantees in case of type errors
Provide fewer guarantees regarding the collected result
type information in types.Info if there are type errors.

Specifically, don't record nil objects in the Objects map
in case of a declaration error; instead, simply omit them.

R=adonovan
TBR=adonovan
CC=golang-dev
https://golang.org/cl/12553043
2013-08-06 11:27:05 -07:00
Rob Pike 75920173e4 go.tools/go/types: don't put an interface nil into the Objects map
If a method cannot type check, we end up with the interface variable
m to hold <*Func, nil>. Don't put that in the map because it defeats
the usual != nil check.

R=gri, dsymonds
CC=golang-dev
https://golang.org/cl/12506043
2013-08-06 16:19:10 +10:00
Robert Griesemer 45e3d57f32 go.tools/cmd/vet: enable test (fix build)
R=r
TBR=r
CC=golang-dev
https://golang.org/cl/12482043
2013-08-05 14:02:52 -07:00
Robert Griesemer b956928b06 go.tools/go/types: Fix for broken IsAssignableTo.
Was broken by CL 12378043.

- factored out some error checking code
- adjusted error positions

R=adonovan
TBR=adonovan
CC=golang-dev
https://golang.org/cl/12401043
2013-08-05 13:54:22 -07:00
David Symonds 1dce9cc7c7 go/types: exclude a couple of files from the stdlib test that don't parse on Windows.
They use stuff in syscall that doesn't exist on Windows, and this test does not
parse build tags (not that we make that easy) to automatically skip them.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/12453043
2013-08-05 13:54:22 +10:00
Rob Pike c333e7a7b6 go.tools/cmd/vet: fix go.tools build
TBR: gri

I cannot create an issue on the tracker for some reason, so here it is:
go vet contains this snippet:

        if types.IsAssignableTo(typ, errorType) || types.IsAssignableTo(typ, stringerType) {

It's getting the wrong answer: It claims

interface {
        f()
}

or even

interface {
        f() float64
}

matches the Error and Stringer interfaces. Both of them.  This causes a test failure:
$ go test code.google.com/p/go.tools/cmd/vet
BUG: errchk: testdata/print.go:124: missing expected error: '"for printf verb %s of wrong type"'
$
This worked until very recently.

R=gri
CC=golang-dev
https://golang.org/cl/12398043
2013-08-03 15:56:56 +10:00
Rob Pike aecec2f502 go.tools/cmd/vet: the composite test is about keys, not tags
Fix the confusion.
No semantic change, just some renamings.

Fixes golang/go#6017.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12394043
2013-08-03 12:19:59 +10:00
Robert Griesemer 3209d6ad73 go.tools/go/types: fix interface vs interface type assertion
R=adonovan
CC=golang-dev
https://golang.org/cl/12378043
2013-08-02 14:37:19 -07:00
Robert Griesemer e06b897351 go.tools/go/types: mark imported named types as 'complete'
Fixes "illegal cycle" error for: go tool vet -v pkg/unicode.

R=adonovan
CC=golang-dev
https://golang.org/cl/12355043
2013-08-02 09:33:37 -07:00
Rob Pike 797431e1a3 go.tools/cmd/vet: fix printf analysis for structs.
The old code only got it right for Stringers (etc.) and a few other simple cases.
But the rule used by fmt.Printf for non-Stringers is that pointers to structs
print as pointers, the rest must satisfy the format verb element-wise.
Thus for example
        struct {a int, b []byte}
prints with %d and %q (sic) but not %g.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12340043
2013-08-02 22:52:38 +10:00
Alex Brainman 4ff367ac3c go.tools/ssa: fix windows build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12320043
2013-08-02 16:25:49 +10:00
Robert Griesemer 4ceda807d5 go.tools/go/types: add mode to typecheck pkg-level decls only
This is useful for situations where one only cares about
exports, for instance (as in the goapi checker).

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12292043
2013-08-01 16:37:56 -07:00
Alan Donovan 61a33ecd43 go.tools/go/types: fix: the type of a method value should not have a reciever
e.g.
type T int
func (T) f() {}
var t T
_ = t.f  // method value: should have signature "func()", no receiver

Also:
- ssa: add sanity check that helped diagnose this.

R=gri
CC=golang-dev
https://golang.org/cl/12283043
2013-08-01 15:38:41 -04:00
Alan Donovan 5cc33ea5a7 go.tools/ssa: cosmetic changes to ssa.Alloc.
Remove its 'name' field and treat it just like any other
ssa.Register: it gets a temp name like "t1".

Instead, give it a comment field holding its purpose, e.g, "x"
for a source-level vare, or "new", "slicelit", "complit" or
"varargs".

This improves usability of tools whose UI needs to refer to a
particular allocation site.

R=gri
CC=golang-dev
https://golang.org/cl/12273043
2013-08-01 14:06:10 -04:00
Andrew Gerrand 8d55039560 go.tools/cmd/godoc: fix typo
R=golang-dev
CC=golang-dev
https://golang.org/cl/12238043
2013-08-01 17:43:31 +10:00
Andrew Gerrand 37c18cdcf3 go.tools/cmd/godoc: start indexer in app engine mode
R=golang-dev
CC=golang-dev
https://golang.org/cl/12237044
2013-08-01 17:37:20 +10:00
Andrew Gerrand 0830cbddc9 go.talks/cmd/godoc: add jquery.js and style.css
Somehow missed these.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12233043
2013-08-01 17:36:56 +10:00
Andrew Gerrand 0afeff2d4b go.tools/cmd/godoc: add godocs.js and playground.js from core repo
The originals will be removed.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12219043
2013-08-01 15:08:46 +10:00
Chris Manghane a705311956 go.tools: add dashboard
Moving misc/dashboard to its new home. It will be deleted
(except for misc/dashboard/codereview) from its current home
if this is approved.

R=golang-dev, bradfitz, cmang, adg
CC=golang-dev
https://golang.org/cl/12180043
2013-08-01 13:23:51 +10:00
Robert Griesemer caf3fc90ed go.tools/go/types: test against test/fixedbugs
Fixed several bugs:
- lhs blank identifier may be parenthesized: (_) = 0 is ok
- constant shift counts in non-constant shifts must be >= 0
- init functions must have a body

Classified currently failing tests:
- 10 classes of errors not checked at the moment

R=adonovan, r
CC=golang-dev
https://golang.org/cl/11952046
2013-07-31 20:08:18 -07:00
Folke Behrens 976d735966 go.tools/godoc: Fix jump-to-line in source view.
Remove the empty anchor element and add the line ID (Lnnn)
to the span element that contains the line number.
Fixes golang/go#5903.
Fixes golang/go#5977.

R=adg
CC=bradfitz, golang-dev
https://golang.org/cl/12189043
2013-08-01 11:52:25 +10:00
Alan Donovan e7016436a6 go.tools/ssa: accommodate go/types changes to value,ok-mode inferred types.
The required changes were surprisingly minimal (I was hoping for a net
code deletion) because ssa is essentially doing its own type inference
for the three value,ok operators---and it continues to have to do so.
To see why, consider:

  var i interface{}; var ok bool
  i, ok := (map[string]string)(nil)[""]

Before, go/types inferred interface{} for the RHS of the assignment,
and now it infers (interface{}, bool), yet neither of these is what
ssa needs: it needs to know that the map values were strings so
that it can emit a lookup of the right type followed by a conversion
from string to interface{}.

TBR=gri
CC=golang-dev
https://golang.org/cl/11988044
2013-07-31 21:31:46 -04:00
Andrew Gerrand 508186a765 go.tools/cmd/godoc: copy templates from $GOROOT/lib/godoc
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12209043
2013-08-01 11:01:10 +10:00
Robert Griesemer ae07aa6055 go.tools/go/types: return typed bool for comma-ok expressions
Also: determine default types for assignments of the form: _ = x .

R=adonovan
CC=golang-dev
https://golang.org/cl/12186043
2013-07-31 12:49:34 -07:00
Alan Donovan 323b856f4d go.tools/ssa: oops, missing file from CL 12147043.
(Should fix build; ssa tests remain broken from CL 12024046)

R=gri
TBR=gri
CC=golang-dev
https://golang.org/cl/12002046
2013-07-31 13:30:59 -04:00
Alan Donovan c28bf6e069 go.tools/ssa: extend debug information to arbitrary ast.Exprs.
CanonicalPos was inadequate since many pairs of instruction share the same pos (e.g. Allocs and Phis).  Instead, we generalize the DebugRef instruction to associate not just Idents but Exprs with ssa.Values.

We no longer store any DebugRefs for constant expressions, to save space.  (The type and value of such expressions can be obtained by other means, at a cost in complexity.)

Function.ValueForExpr queries the DebugRef info to return the ssa.Value of a given Expr.

Added tests.

Also:
- the DebugInfo flag is now per package, not global.
   It must be set between Create and Build phases if desired.
- {Value,Instruction}.Pos() documentation updated: we still maintain
  this information in the instruction stream even in non-debug mode,
  but we make fewer claims about its invariants.
- Go and Defer instructions can now use their respective go/defer
   token positions (not the call's lparen), so they do.
- SelectState:
     Posn token.Pos indicates the <- position
     DebugNode ast.Expr is the send stmt or receive expr.
- In building SelectStmt, we introduce extra temporaries in debug
   mode to hold the result of the receive in 'case <-ch' even though
   this value isn't ordinarily needed.
- Use *SelectState (indirectly) since the struct is getting bigger.
- Document some missing instructions in doc.go.

R=gri
CC=golang-dev
https://golang.org/cl/12147043
2013-07-31 13:13:05 -04:00
Robert Griesemer e5cfd92deb go.tools/go/types: record comma-ok results as tuples
- added corresponding api tests
- support tuple comparison with IsIdentical

This CL will require some adjustments to SSA.

R=adonovan
CC=golang-dev
https://golang.org/cl/12024046
2013-07-31 09:33:46 -07:00
Robert Griesemer eae0511b70 go.tools/ssa/interp: fix build
fallthrough's are now checked - adjust
now illegal test.

TBR: adonovan

R=adonovan
CC=golang-dev
https://golang.org/cl/12041052
2013-07-30 20:28:18 -07:00
Robert Griesemer 1e79a68ff5 go.tools/go/types: check fallthrough statements
R=adonovan
CC=golang-dev
https://golang.org/cl/12041049
2013-07-30 16:00:57 -07:00
Brad Fitzpatrick 143d18d6c5 cmd/godoc: fix build
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12127043
2013-07-30 13:42:50 -07:00
Alan Donovan 2f6855ad75 go.tools/ssa: avoid calling go/types.NewSelection, and eliminate it.
Also: s/LookupMethod/Method/

R=gri
CC=golang-dev
https://golang.org/cl/12058052
2013-07-30 16:36:58 -04:00
Robert Griesemer 4ae33302a4 go.tools/go/types: map keys must be comparable
R=adonovan
CC=golang-dev
https://golang.org/cl/12102044
2013-07-30 13:15:28 -07:00
Robert Griesemer 33d57bf48f go.tools/go/types: report identifier for methods with blank names
R=adonovan
CC=golang-dev
https://golang.org/cl/12123045
2013-07-30 12:47:40 -07:00
Alan Donovan 2a3a12930b go.tools/ssa: add test of SSA construction on $GOROOT/src/pkg/...
stdlib_test runs the builder (in sanity-checking mode) over
the Go standard library.  It also prints some stats about
the time and memory usage.

Also:
- importer.LoadPackage too (not just doImport) must consult
  the cache to avoid creating duplicate Package instances for
  the same import path when called serially from a test.
- importer: skip empty directories without an error.
- importer: print all errors, not just the first.
- visit.go: added AllFunctions utility for enumerating all
  Functions in a Program.
- ssa.MethodSet is not safe to expose from the package since
  it must be accessed under an (inaccessible) lock.  (!!!)
  This CL makes it unexported and restricts its use to the
  single function Program.LookupMethod().
- Program.MethodSet() has gone.
  Clients should instead iterate over the types.MethodSet
  and call LookupMethod.
- Package.DumpTo(): improved efficiency of methodset printing
  (by not creating wrappers) and accuracy (by showing * on
  receiver type only when necessary).
- Program.CreatePackage: documented precondition and added
  assertion.

R=gri
CC=golang-dev
https://golang.org/cl/12058048
2013-07-30 14:28:14 -04:00
Robert Griesemer e7c7afbb1a go.tools/go/types: enable (previously broken) shift tests
R=adonovan
CC=golang-dev
https://golang.org/cl/12109044
2013-07-30 11:10:28 -07:00
Robert Griesemer 7a1a18283b go.tools/go/types: constant shifts always produce integers (bug fix)
R=adonovan
CC=golang-dev
https://golang.org/cl/12025044
2013-07-30 10:28:57 -07:00
Robert Griesemer 30c6d6350d go.tools/go/types: check type-checker against $GOROOT/test
R=adonovan
CC=golang-dev
https://golang.org/cl/12070044
2013-07-30 09:00:25 -07:00
Rob Pike 2a8b9debdd go.tools/cmd/vet: don't complain about empty interface values in printf
R=dsymonds
CC=golang-dev
https://golang.org/cl/12005047
2013-07-30 15:51:35 +10:00