1
0
mirror of https://github.com/golang/go synced 2024-11-18 02:54:47 -07:00
Commit Graph

5229 Commits

Author SHA1 Message Date
Robert Griesemer
c98ff05fdd go.tools/go/types: faster scopes, cleanups around method lookups
R=adonovan
CC=golang-dev
https://golang.org/cl/11787043
2013-07-24 20:02:54 -07:00
Robert Griesemer
6dbbc59ae0 go.tools/go/types: simplify handling of blank _ identifiers
Also: Fixes a couple of places where scopes instead
      of objsets were used (missed in previous CL).

R=adonovan
CC=golang-dev
https://golang.org/cl/11419047
2013-07-24 12:39:11 -07:00
Robert Griesemer
d0657ebb0d go.tools/go/types: record lhs identifier in switch lhs := rhs.(type)
Added testcase.

R=adonovan
CC=golang-dev
https://golang.org/cl/11742043
2013-07-24 12:38:51 -07:00
Alan Donovan
d4f2f2d7fa go.tools/ssa: repair treatment of typeswitch after recent go/types changes.
Now, in a "switch y := x.(type)", there is no object for the
outer y, only implicit objects, one per case (including
default).

Also: don't set obj=nil for blank idents (workaround suggested by gri).

R=gri
CC=golang-dev
https://golang.org/cl/11564046
2013-07-24 14:03:53 -04:00
Robert Griesemer
c5b1cc4227 go.tool/go/types: ignore invalid anonymous fields
Fixes go tool vet breakage when applied to files
with incomplete type information for anonymous
fields.

R=adonovan
CC=golang-dev
https://golang.org/cl/11773043
2013-07-24 10:49:44 -07:00
Robert Griesemer
407e159412 go.tools/go/types: fix typo in self test
R=adonovan
CC=golang-dev
https://golang.org/cl/11749044
2013-07-24 09:26:39 -07:00
Andrew Gerrand
7375911b0e go.tools/cmd/godoc: use playground package from go.tools
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11507044
2013-07-24 17:25:24 +10:00
Andrew Gerrand
8cc9c49348 go.tools/godoc/playground: copy playground package from go.talks
After this change is submitted the dependants on go.talks/pkg/playground
talks will be updated to use this one and the old package will be deleted.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11759043
2013-07-24 17:25:00 +10:00
Robert Griesemer
66e7552830 go.tools/go/types: simplified and faster Scope
- implemented objset for tracking duplicates of fields and methods
  which permitted a simpler and faster scope implementation in turn
- related cleanups and internal renames
- fixed a couple of identifier reporting bugs

Speed of type-checking itself increased by almost 10%
(from ~71Kloc/s to ~78Kloc/s on one machine, measured
via go test -run=Self).

R=adonovan
CC=golang-dev
https://golang.org/cl/11750043
2013-07-23 21:21:37 -07:00
Robert Griesemer
2f54663e0e go.tools/go/types: fix build: ignore self-test if it fails
R=adonovan
CC=golang-dev
https://golang.org/cl/11398045
2013-07-23 20:52:41 -07:00
Robert Griesemer
cc55bd9129 go.tools/go/types: add self test
R=adonovan
CC=golang-dev
https://golang.org/cl/11739043
2013-07-23 18:30:06 -07:00
Robert Griesemer
09d04edfcf go.tools/go/types: declare typeswitch local variable in correct scope
R=adonovan
CC=golang-dev
https://golang.org/cl/11534044
2013-07-23 14:18:38 -07:00
Robert Griesemer
7bc647b29a go.tools/go/types: internal cleanups
- more consistent naming of some internal data types and methods
- better factoring of some error reporting code
- cleanup around association of methods with receiver base types
- more tests

R=adonovan
CC=golang-dev
https://golang.org/cl/11726043
2013-07-23 13:42:04 -07:00
Alan Donovan
7eafcedc87 go.tools/ssa: opt: create elements of method sets lazily.
Reduces by 94% the number of wrappers created during the tests.
(No appreciable difference in running time, sadly.)

R=gri
CC=golang-dev
https://golang.org/cl/11619043
2013-07-23 13:38:52 -04:00
Robert Griesemer
2bff3a03e7 go.tools/go/types: clean up method type checking
- treat receivers like ordinary parameters when checking signatures;
  concentrate all respective checks in one place
- continue to type-check methods even if receiver base type does not
  satisfy receiver type criteria (comes for free)
- don't ignore blank _ methods anymore
- various related cleanups

As a consequence, the resolving needs one less internal phase.

R=adonovan
CC=golang-dev
https://golang.org/cl/11591045
2013-07-22 20:42:10 -07:00
Rob Pike
9ac8940d29 all: be more idiomatic when documenting boolean return values.
Phrases like "returns whether or not the image is opaque" could be
describing what the function does (it always returns, regardless of
the opacity) or what it returns (a boolean indicating the opacity).
Even when the "or not" is missing, the phrasing is bizarre.

Go with "reports whether", which is still clunky but at least makes
it clear we're talking about the return value.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11458046
2013-07-23 10:37:43 +10:00
David Symonds
75919c8eee cmd/vet: avoid panic if no valid inputs are found.
I'd like to make vet work as a filter, but passing /dev/stdin as a
command line argument doesn't work. This at least makes it not panic.

R=r
CC=golang-dev
https://golang.org/cl/11521045
2013-07-22 12:43:11 +10:00
Alan Donovan
d203f128e2 go.tools/ssa: drop ssa.Id in favour of types.Id function.
Also exploit fact that Recv() is now always non-nil, even for interfaces.

R=gri
CC=golang-dev
https://golang.org/cl/11613043
2013-07-19 19:38:16 -04:00
Robert Griesemer
d722d82c52 go.tools/go/type: hook up interface method receivers
Also:
- Renamed Object.SameName -> Object.SameId
- Exported Object.Id

R=adonovan
CC=golang-dev
https://golang.org/cl/11567046
2013-07-19 16:26:32 -07:00
Robert Griesemer
b0ae7702cb go.tools/go/types: record Field/Method object for f in selector expressions x.f
TODO(gri) This needs tests.

R=adonovan
CC=golang-dev
https://golang.org/cl/11519046
2013-07-19 14:46:28 -07:00
Alan Donovan
5d7d9091bb go.tools/ssa: big simplification: use new types.MethodSet to compute ssa.MethodSet.
Details:
- emitImplicitSelections now emits common code for implicit
  field selections in both method and field lookups.
  The last iteration over the LookupFieldOrMethod indices---the explicit,
  final index---is handled by the caller.
- anonFieldPath, candidate and the BFS algo in buildMethodSet are all gone.

R=gri
CC=golang-dev
https://golang.org/cl/11576045
2013-07-19 17:35:29 -04:00
Robert Griesemer
f4540b7193 go.tools/go/types: set correct Method recv type in NewMethodSet
R=adonovan
CC=golang-dev
https://golang.org/cl/11602043
2013-07-19 13:00:02 -07:00
Robert Griesemer
35f4fd1cd1 go.tools/go/types: use *Var instead of *Field for struct fields
Temporarily remove Field objects in favor of Vars for struct fields.
In forthcoming CL, Fields will play the symmetric role to Methods, and
serve as lookup results including index information.

R=adonovan
CC=golang-dev
https://golang.org/cl/11594043
2013-07-19 11:01:51 -07:00
Alan Donovan
8a9eca10cd go.tools/importer: rename Context to Config for consistency with go/types.
R=gri
CC=golang-dev
https://golang.org/cl/11485046
2013-07-19 11:02:27 -04:00
Robert Griesemer
9f26deaa1d go.tools/gotype: fix build
R=adonovan
CC=golang-dev
https://golang.org/cl/11542045
2013-07-19 07:52:43 -07:00
Brad Fitzpatrick
80d38231f7 godoc: move search from cmd to the package
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11540045
2013-07-19 14:02:03 +10:00
Brad Fitzpatrick
5b72c43fc0 godoc/util: remove FileSystem. It's in vfs now.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11555043
2013-07-19 11:54:15 +10:00
David Symonds
0160160d5e cmd/godoc: Fix reg test on Windows.
R=bradfitz, gri
CC=golang-dev
https://golang.org/cl/11551043
2013-07-19 10:31:12 +10:00
Brad Fitzpatrick
705bb7ffce godoc: remove the last of the global variables, unexport Server
The exported Server becomes handlerServer, and part of Presentation
now.  Presentation is also now an http.Handler with its own
internal mux (a detail, which might go away).

main.go becomes ever simpler.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11505043
2013-07-19 10:27:53 +10:00
Robert Griesemer
40a278e5ee go.tools/go/types: rename Context -> Config (more apt name)
Also: Various minor cleanups.

R=adonovan, r
CC=golang-dev
https://golang.org/cl/11445044
2013-07-18 17:07:44 -07:00
Robert Griesemer
9460d02473 go.tools/cmd/vet: fix error message
R=r, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/11552043
2013-07-18 16:56:01 -07:00
Alan Donovan
69ce87a6c1 go.tools/ssa: some refactorings
ssa:
- Prog.CreatePackages inlined into all callers.
- Prog.CreatePackage is now exposed; idempotent; and checks for errors.
- '*address' not 'address' now implements lvalue (since it's 6 words).
- removed types.Method case from createMemberFromObject.

importer:
- added importer.PackageInfo.String method.
- simplifed importer.PackageInfo by putting types.Info in it.
- removed obsolete precondition from IsType.

R=gri
CC=golang-dev
https://golang.org/cl/11408045
2013-07-18 16:59:06 -04:00
Robert Griesemer
6d85cc17dd go.tools/go/types: request type Info via maps instead of callbacks
Allmost all uses of go/types that wanted the type
information computed, installed callback functions
that stored the information in maps. Most of the
time this is the only thing that could be done because
there is no guarantee that types are completely set
up before the end of type-checking.

This CL removes the respective Context callbacks in favor
of corresponding maps that collect the desired information
on demand, grouped together in an optional Info struct.

R=adonovan
CC=golang-dev
https://golang.org/cl/11530044
2013-07-18 13:09:03 -07:00
Robert Griesemer
78c8226b42 go.tools/go/types: don't modify lhs untyped types in constant shifts
Also: fix TestCheck (don't fail if there are no errors in -list mode)

Fixes golang/go#5895.

R=adonovan
CC=golang-dev
https://golang.org/cl/11535043
2013-07-18 10:48:03 -07:00
Brad Fitzpatrick
66f0d6e92e godoc: more cleanup
cmd/godoc/godoc.go is now merged into main.go, which is now
only 530 lines.

App Engine mode is still broken, but should be easy to fix up.
(just needs a global *godoc.Presentation created in init)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11498044
2013-07-18 13:51:17 +10:00
Brad Fitzpatrick
5395cfe05a godoc: remove more global variables
More moves into Corpus and Presentation.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11492043
2013-07-18 13:14:09 +10:00
Brad Fitzpatrick
4fc6323385 godoc: add a Corpus and Presentation type
Start of moving globals into those types.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11484043
2013-07-18 09:52:45 +10:00
David Symonds
3af65e49c2 cmd/godoc: Add a basic regression test.
R=adg, bradfitz
CC=golang-dev
https://golang.org/cl/11419044
2013-07-17 17:32:45 +10:00
Andrew Gerrand
57f0a571b9 godoc: unexport InterfaceSlice and Comparer types
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11429043
2013-07-17 17:31:24 +10:00
Brad Fitzpatrick
cd835f01af godoc: use httptest.ResponseRecorder instead of reimplementing it
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11428043
2013-07-17 17:25:54 +10:00
Brad Fitzpatrick
ca3319fbd2 godoc: actually include files from previous CL
This stuff was deleted from cmd/godoc, and is
moving into pkg godoc.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11425043
2013-07-17 17:17:12 +10:00
Brad Fitzpatrick
e6ff53bcc8 godoc: move bulk of the code to the package
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11424043
2013-07-17 17:09:54 +10:00
Andrew Gerrand
2392be72c2 go.tools/godoc: move Throttle to package godoc/util
R=bradfitz
CC=golang-dev
https://golang.org/cl/11417043
2013-07-17 15:23:31 +10:00
Robert Griesemer
8901caa2b3 go.tools/go/types: Method sets for all types
- fixed method set computation
- lazily compute it for a type on demand
- lazy allocation of various temporary maps

Also:
- removed Interface.IsEmpty, Scope.IsEmpty
  (these convenience functions didn't carry their weight)
- cosmetic changes

Next:
- consolidate various lookup APIs
- use lazily computed method sets for various checks
  instead of individual lookups

R=adonovan
CC=golang-dev
https://golang.org/cl/11385044
2013-07-16 22:18:08 -07:00
Andrew Gerrand
2822addeae go.tools/cmd/godoc: use go.talks playground package
R=bradfitz
CC=golang-dev
https://golang.org/cl/11416043
2013-07-17 15:17:04 +10:00
Andrew Gerrand
5ff0687cc9 go.tools/godoc: move vfs code to vfs package
R=bradfitz
CC=golang-dev
https://golang.org/cl/11414043
2013-07-17 15:02:27 +10:00
Brad Fitzpatrick
7526441b70 godoc: add util package, add start of vfs package
Move some code out of cmd/godoc.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11413043
2013-07-17 14:44:18 +10:00
Andrew Gerrand
d79f4fe25b go.tools/cmd/godoc: copy godoc from core reposistory
The plan for godoc:
- Copy godoc source from the core repo to go.tools (this CL).
- Break godoc into several packages inside go.tools, leaving a package
  main that merely sets up a local file system, interprets the command
  line, and otherwise delegates the heavy-lifting to the new packages.
- Remove godoc from the core repo.
- Update cmd/go to install this godoc binary in $GOROOT/bin.
- Update misc/dist to include godoc when building binary distributions.

R=bradfitz
CC=golang-dev
https://golang.org/cl/11408043
2013-07-17 14:02:35 +10:00
Alan Donovan
732dbe9ff8 go.tools/ssa: s/Literal/Const/g, s/Constant/NamedConst/g
(Motivation: "Literal" is a syntactic property, not a semantic one.)

Also: delete a "TODO: opt" that the lifting pass already does for us.

R=gri
CC=golang-dev
https://golang.org/cl/11351043
2013-07-16 13:50:08 -04:00
Alan Donovan
80ec883f7b go.tools/ssa: several small clean-ups.
- removed a number of obsolete TODO(gri) comments.
- bring ssa.DefaultType back into sync with types.defaultType.
- re-enable types.Package.Path()!="" assertion.
- use Path() (not reflect pointer) in sort routine.
- make interp.checkInterface use types.MissingMethod.
- un-export ssa.MakeId function.
- inline pointer() into all callers, and delete.
- enable two more interp_tests: $GOROOT/test/{method3,cmp}.go
- add links to bugs to other interp_tests.
- add runtime.NumCPU to ssa/interp/externals.go

R=gri
CC=golang-dev
https://golang.org/cl/11353043
2013-07-16 12:23:55 -04:00