1
0
mirror of https://github.com/golang/go synced 2024-11-05 21:36:12 -07:00
Commit Graph

705 Commits

Author SHA1 Message Date
David Crawshaw
0d4ee40f21 go.tools/astutil: add Imports, which returns imports grouped by spacing.
R=bradfitz
CC=golang-dev
https://golang.org/cl/23660045
2013-11-08 14:51:15 -05:00
Robert Griesemer
0f193b767d go.tools/go/types: simplified GcImportedTypes test
R=adonovan
CC=golang-dev
https://golang.org/cl/23340043
2013-11-08 08:56:55 -08:00
Robert Griesemer
7520cff8d3 go.tools/go/types: remove a workaround for 386 bug
R=adonovan
CC=golang-dev
https://golang.org/cl/23350043
2013-11-08 08:55:16 -08:00
Andrew Gerrand
50d9adec93 go.tools/blog: strip prefix when serving static content
This fix permits godoc to serve images correctly under /blog/.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/22700043
2013-11-08 13:28:32 +11:00
Kamil Kisiel
e59751ce56 oracle: Fix documentation references to importer package functions.
R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/21230043
2013-11-07 16:47:35 -05:00
Robert Griesemer
0c141425f6 go.tools/cmd/gotype: parse in parallel
Performance increase is much smaller than expected;
need to investigate. Possibly, repeatedly (for each
line) accessing file sets from multiple goroutines
(in the scanner) is a bottle neck; or perhaps i/o.

R=adonovan
CC=golang-dev
https://golang.org/cl/23090043
2013-11-07 13:32:02 -08:00
Alan Donovan
f1e5b03c6e go.tools/ssa: populate Function.Referrers(), for anon functions.
Added sanity check to ensure Operands/Referrers are complete and dual.

Also: unexport Instruction.setBlock (=> no longer user-implementable).

R=gri
CC=golang-dev
https://golang.org/cl/22150043
2013-11-07 10:08:51 -05:00
Robert Griesemer
7123ca00a8 go.tools/go/types: fix bug in init cycle detection
Initialization cycles need to reported for cycles
that contain variables, even if they don't end in
a variable.

This fixes the last known issue with the existing
std library tests.

R=adonovan, gri
CC=golang-dev
https://golang.org/cl/22200049
2013-11-06 17:47:54 -08:00
Francesc Campoy
2c650d6a84 go.tools/present: add extension name to Code
This will be used to show the "Run" button for code snippets in go.talks only for Go when running on App Engine.

R=adg, r, iant
CC=golang-dev
https://golang.org/cl/21930047
2013-11-06 13:02:20 -08:00
David Crawshaw
6df4bd0406 go.tools/astutil: make sure import blocks are marked as such (Lparen=1)
R=bradfitz
CC=golang-dev
https://golang.org/cl/22320044
2013-11-06 15:31:54 -05:00
Brad Fitzpatrick
56a1b4d0b7 godoc: index import counts, package name to path(s), and exported symbols
R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/22190047
2013-11-06 15:00:26 -05:00
Brad Fitzpatrick
42513df8b8 godoc: add IndexInterval option
This will permit deleting some forked code elsewhere.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/22010046
2013-11-06 13:31:30 -05:00
David Crawshaw
0b5928ea2a go.tools/astutil: a package for common AST utilities.
Lifts the import management utilities from gofix into
a package, so they can be used by goimports.

R=bradfitz
CC=golang-dev
https://golang.org/cl/22430043
2013-11-06 13:30:30 -05:00
Robert Griesemer
eb67edd047 go.tools/go/types: add test cases for pending issues
The gc compiler is inconsistent how it handles method
"mentions" with respect to initialization cycle detection
(see issue 6703 for details). Pending a spec clarification,
this CL assumes that for a method to be "mentioned", it
must be mentioned as a method expression rather than a
method value (closer in intent to "syntactic" mention).

R=adonovan
CC=golang-dev
https://golang.org/cl/22050044
2013-11-06 09:55:03 -08:00
Alan Donovan
2e7d5a8b6b go.tools/ssa: dump types in "pkg."-unqualified form where appropriate.
Also: types.Typ[types.UnsafePointer].String() now always prints as "unsafe.Pointer".

R=gri
CC=golang-dev
https://golang.org/cl/21820044
2013-11-05 17:32:45 -05:00
Robert Griesemer
8e64946a3a go.tools/go/types: better error messages for api tests
R=adonovan
CC=golang-dev
https://golang.org/cl/22140043
2013-11-05 13:42:31 -08:00
Robert Griesemer
8b05c30f06 go.tools/go/types: track cycles through methods
R=adonovan
CC=golang-dev
https://golang.org/cl/22070043
2013-11-05 11:47:22 -08:00
Robert Griesemer
b33df7e76a go.tools/go/types: track init cycles through closures
R=adonovan
CC=golang-dev
https://golang.org/cl/21790044
2013-11-05 10:51:13 -08:00
Alan Donovan
d84d338a42 go.tools/ssa/interp: improve print() on interfaces, and log message for panic.
R=gri
CC=golang-dev
https://golang.org/cl/21960043
2013-11-05 13:03:14 -05:00
Alan Donovan
ce321e34d0 go.tools/ssa: simplify initialization of globals using go/types.Info.InitOrder.
R=gri
CC=golang-dev
https://golang.org/cl/21950043
2013-11-05 13:02:46 -05:00
Robert Griesemer
9d1e9ed2ab go.tools/go/types: track init cycles through functions
- Info.InitOrder now provides list of Initializers
  (vars + init expr), handling n:1 decls and blank
  identifiers
- added respective API test
- cycles detected through function "mentions"

Missing: cycles through method "mentions" and via
         closures

R=adonovan
CC=golang-dev
https://golang.org/cl/21810043
2013-11-05 09:25:25 -08:00
Brad Fitzpatrick
964f0f559c godoc: feed indexer concurrently, add selective indexing hook, tests
On big corpuses, the indexer was spending most of its time waiting
for filesystem operations (especially with network filesystems)
and not actually indexing.  This keeps the filesystem busy and indexer
running in different goroutines.

Also, add a hook to let godoc hosts disable indexing of certain
directories.

And finally, start adding tests for godoc, which required
fleshing out (and testing) the mapfs code.

R=golang-dev, adg, bgarcia
CC=golang-dev
https://golang.org/cl/21520045
2013-11-05 09:35:58 -05:00
Rob Pike
2afbb1cd5f go.tools/cmd/vet: handle symbolic TEXT annotations
The symbolic names such as NOSPLIT for annotations on the TEXT
directive appeared after vet started checking .s files. This CL tweaks
the regular expression to allow CAPITALS and the symbols | and +
as well as digits in that field, and interprets NOSPLIT as equivalent
to 7 in that field. All magic.

Fixes golang/go#6695

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/18700044
2013-11-01 11:49:11 -07:00
Alan Donovan
0faac9ebe6 go.tools/ssa: include line count in stdlib_test.
R=gri
CC=golang-dev
https://golang.org/cl/20860043
2013-11-01 14:32:44 -04:00
Brad Garcia
d9d5e51406 godoc: add ability to override generation of links to source code.
R=bradfitz
CC=golang-dev
https://golang.org/cl/19850046
2013-11-01 13:20:32 -04:00
Robert Griesemer
d259ea48d1 go.tools/go/types: first cut at checking variable initialization cycles
Missing:
- dependencies via functions (incl. closures and methods)
- more tests (incl. API test)

R=adonovan
CC=golang-dev
https://golang.org/cl/20510043
2013-10-31 21:47:35 -07:00
Alex Brainman
5879669d9d go.tools/dashboard/builder: ignore GOPATH setting during build (on windows)
R=golang-dev, minux.ma, adg
CC=golang-dev
https://golang.org/cl/18920046
2013-11-01 11:28:31 +11:00
Alan Donovan
74b761d099 go.tools/ssa: clarify spec of (*builder).complit().
Added test for []*map composite literals containing nested
literal subelements.  This required implementing
(reflect.Value).Map{Keys,Index} in ssa/interp.

Plus two minor fixes in ssa/interp.

R=gri
CC=golang-dev
https://golang.org/cl/20470043
2013-10-31 17:59:52 -04:00
Robert Griesemer
fb0632eb7d go.tools/go/types: Provide explicit type checker Error.
R=adonovan
CC=golang-dev
https://golang.org/cl/20400044
2013-10-31 12:01:00 -07:00
Robert Griesemer
03e3f0cf81 go.tools/cmd/gotype: make gotype use go/build
This CL makes gotype usable again. Removed -r
(recursive) mode; use go/build to determine
the correct set of Go files when processing
a directory. The -v (verbose) mode now prints
some basic stats (duration, number of files,
lines, and lines/s).

Thoroughly restructured the code.

Applying gotype -v -a . to the go/types directory:
128.94141ms (40 files, 12008 lines, 93127 lines/s)

On a 2.8 GHz Quad-Core Intel Xeon, 800 MHz DDR2 FB-DIMM,
with go/types built with the (interal) debug flag set to
false. There's still quite a bit of room for performance
improvement in all parts of the code since no tuning has
been done.

R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/19930043
2013-10-31 10:01:58 -07:00
Alan Donovan
1518a24464 go.tools/importer: don't pass srcDir=os.Getwd to go/build.Import().
This makes imports independent of the process's working
directory.  (Perhaps this was a feature, but I haven't found a
situation in which it actually works.)

R=gri
CC=golang-dev
https://golang.org/cl/19420043
2013-10-31 10:56:33 -04:00
Alan Donovan
f4fca995ad go.tools/pointer: fix test of pts(os.Args) on Windows.
I have no way to test this.

R=crawshaw
CC=alex.brainmain, golang-dev
https://golang.org/cl/17820044
2013-10-31 10:24:00 -04:00
Brad Fitzpatrick
766a70612a godoc: add a Corpus hook to summarize a package
This lets godoc implementations provide a more efficient means
of getting this information, without reading files and parsing the
package docs.

This is especially important when the files themselves don't
actually exist and the VFS is synthesizing them on demand
(e.g. protocol buffer files -> their generated *.pb.go files).
This means corpus.Init can run quickly, without generating
every protocol file in a large corpus (or fetching it from a
cache).

In the future, this hook could also be used for caching the summaries of
regular packages.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/19440043
2013-10-30 11:34:32 -07:00
Andrew Gerrand
99890b82e7 go.tools/godoc/static: use preferred JS for Google+ buttons
R=bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/19070044
2013-10-30 13:13:42 +11:00
Alan Donovan
94c387c610 go.tools/pointer: implement (reflect.Value).Call.
The implementation follows the basic pattern of an indirect
function call (genDynamicCall).

We use the same trick as SetFinalizer so that direct calls to
(r.V).Call, which are overwhelmingly the norm, are inlined.

Bug fix (and simplification): calling untag() to unbox a
reflect.Value is wrong for reflect.Values containing interfaces
(rare).  Now, we call untag for concrete types and typeFilter
for interface types, and we can use this pattern in all cases.
It corresponds to the ssa.TypeAssert operator, so we call
it typeAssert.  Added tests to cover this.

We also specialize reflect.{In,Out} when the operand is an int
literal.

+ Tests.

Also:
- make taggedValue() panic, not return nil, eliminating many checks.
  We call isTaggedValue for the one place that cares.
- pointer_test: recover from panics in Analyze() and dump the log.

R=crawshaw
CC=golang-dev
https://golang.org/cl/14426050
2013-10-29 21:57:53 -04:00
Alan Donovan
e1b710c31e go.tools/README: minor correction.
R=gri
CC=golang-dev
https://golang.org/cl/18490043
2013-10-29 13:20:58 -04:00
Alan Donovan
bac7098173 go.tools/ssa: fix crash on (new)(T) due to missing unparen() call.
Audited codebase for other occurrences, found two more.
Added test coverage for all of them.

R=gri
CC=golang-dev
https://golang.org/cl/14698043
2013-10-29 11:07:09 -04:00
Brian Gitonga Marete
4a813e4058 blog: Fix atom feed's `updated' time when there's only one article.
When computing the time for the "updated" tag of the atom feed, the
current code checks if there is more than one article and if that is
not true, it sets the time to the zero time.Time. This means that
the feed also gets the zero time in this tag when there is exactly one
article.

This trivial patch fixes this so that when there is exactly one
article, the time is set to that article's time.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/18420044
2013-10-29 15:55:27 +09:00
Brad Fitzpatrick
452c763fc7 godoc: parallelize corpus init
Massive win for high-latency network filesystems.
Also benefits the local disk/ssd case too, though.

R=golang-dev, bgarcia
CC=golang-dev
https://golang.org/cl/18650043
2013-10-28 12:51:01 -07:00
Alan Donovan
e29626539b go.tools/ssa: clarify that DebugRef relation is a function from ast.Expr to (ssa.Value, IsAddr bool), in docs and printed form.
R=gri
CC=golang-dev
https://golang.org/cl/18410043
2013-10-28 12:05:29 -04:00
Alan Donovan
7a70c382be go.tools/pointer: fix panic in reflection.
reflect.Values may point to tagged objects with
interface type, e.g. x := reflect.ValueOf(new(interface{})).Elem().
We failed to consider this when implementing Elem.

Also, (reflect.Value).Interface() must do one "unboxing"
when it encounters such tagged objects.
i.e., x.Elem().Interface() and x.Interface() are equivalent
in that case.

Also:
- add example of tagged object with interface type.
- untabify (Label).String docstring.
- added tests.

R=crawshaw
CC=golang-dev
https://golang.org/cl/18020044
2013-10-28 10:58:46 -04:00
Brian Gitonga Marete
f3120b161e blog: Make the atom feed title configurable.
The blog code is quite generic and with the replacement of template and
static files, it can be re-used. But the atom feed title is hard-coded
into the code. This patch adds a field to set the atom feed title to
the Config structure and uses it in the code where the title was
previously hard-coded.

A CL sent separately will set this Config field in the main package in
the go.blog sub-repository. (See CL 16850043 for that other patch).

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/16830043
2013-10-28 10:17:10 +02:00
Alan Donovan
aa2386290b go.tools/ssa: new Function.Syntax() returns the declaring AST (debug mode) or just the Pos/End of the function's extent (otherwise).
R=gri
CC=golang-dev
https://golang.org/cl/16980043
2013-10-27 10:55:21 -04:00
Robert Griesemer
3eb9e504e3 go.tools/go/types: update a TODO comment (not a TODO anymore)
R=adonovan
TBR=adonovan
CC=golang-dev
https://golang.org/cl/17440043
2013-10-25 15:37:03 -07:00
Robert Griesemer
b98997fdfe go.tools/go/types: enable std lib test of map key types
R=adonovan
CC=golang-dev
https://golang.org/cl/17390043
2013-10-25 14:38:52 -07:00
Robert Griesemer
65aaa0093c go.tools/go/types: check map key type when it is fully known
Fixes golang/go#6667.

R=adonovan
CC=golang-dev
https://golang.org/cl/17360043
2013-10-25 14:32:14 -07:00
Robert Griesemer
1e05a58b11 go.tools/go/types: consistently use 'elem' instead of 'elt'
This is simply a rename of unexported struct fields.
No other changes.

R=adonovan
CC=golang-dev
https://golang.org/cl/17330043
2013-10-25 13:59:40 -07:00
Robert Griesemer
cf08eefe7f go.tools/go/types: test cases for comparisons
- better error messages
- in contrast to a long-standing TODO, comparisons
  between interface and non-interface types always
  worked correctly

R=adonovan
CC=golang-dev
https://golang.org/cl/17310043
2013-10-25 13:16:45 -07:00
Alan Donovan
d644aa1fcd go.tools/ssa/interp: enable $GOROOT/test/switch.go test
(now that go/types can handle it)

R=gri
TBR=gri
CC=golang-dev
https://golang.org/cl/16970043
2013-10-24 22:38:10 -04:00
Alan Donovan
9f640c2abb go.tools/ssa: record lvalue/rvalue distinction precisely in DebugRef.
A DebugRef associates a source expression E with an ssa.Value
V, but until now did not record whether V was the value or the
address of E.  So, we would guess from the "pointerness" of
the Value, leading to confusion in some cases, e.g.

   type N *N
   var n N
   n = &n  // lvalue and rvalue are both pointers

Now we explicitly record 'IsAddress bool' in DebugRef, and
plumb this everywhere: through (*Function).ValueForExpr and
(*Program).VarValue, all the way to forming the pointer
analysis query.

Also:
- VarValue now treats each reference to a global distinctly,
  just like it does for other vars.  So:
    var g int
    func f() {
   	g = 1     // VarValue(g) == Const(1:int), !isAddress
        print(g)  // VarValue(g) == Global(g), isAddress
    }
- DebugRefs are not emitted for references to predeclared
  identifiers (nil, built-in).
- DebugRefs no longer prevent lifting of an Alloc var into a
  register; now we update or discard the debug info.
- TestValueForExpr: improve coverage of ssa.EnclosingFunction
  by putting expectations in methods and init funcs, not just
  normal funcs.
- oracle: fix golden file broken by recent
  (*types.Var).IsField change.

R=gri
CC=golang-dev
https://golang.org/cl/16610045
2013-10-24 18:31:50 -04:00