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

5045 Commits

Author SHA1 Message Date
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
Alan Donovan
da051f41cc go.tools/ssa: fixes required by go/types CL 11317043: the last
parameter of a variadic signature is now a slice type.

R=gri
CC=golang-dev
https://golang.org/cl/11347043
2013-07-16 12:22:22 -04:00
Robert Griesemer
0117ba266d go.tools/go/types: cleanup parameter passing
- now represent ...T parameter type as []T (rather than T)
- simplified call checking
- added missing check and test for x... arguments (x must be slice)

This CL will temporarily break ssa and ssa/interp.

R=adonovan, axwalk
CC=golang-dev
https://golang.org/cl/11317043
2013-07-16 09:12:33 -07:00
Alan Donovan
25f3e0fbde go.tools/cmd/vet: improvements to static checking of printf calls.
Details:
- added support for complex numbers as distinct from floats:
  %[efg] allows complex; %b does not.
- %p: only Signature, Map, Chan, Slice, unsafe.Pointer allowed.
- %s: allow []byte.
- allow a verb to match map[K]V and []T if it matches K/V/T,
  e.g. %d now matches []int.  i.e. matching is recursive.
- use go/types' constant folding.  literal() is gone.
- group cases together.

Added tests.

R=gri, r
CC=golang-dev
https://golang.org/cl/10895043
2013-07-15 18:37:49 -04:00
Alan Donovan
da3a30b5e1 go.tools/ssa: move pure-AST functions to importer package.
This slightly simplifies the PathEnclosingInterval spec (and
some uncommitted client code of mine).

R=gri
CC=golang-dev
https://golang.org/cl/11305043
2013-07-15 18:09:18 -04:00
Alan Donovan
a399e26e0e go.tools/ssa: remove position info from Literals.
R=gri
CC=golang-dev
https://golang.org/cl/11292043
2013-07-15 16:10:08 -04:00
Alan Donovan
55d678e697 go.tools/ssa: add debug information for all ast.Idents.
This CL adds three new functions to determine the SSA Value
for a given syntactic var, func or const object:
  Program.{Const,Func,Var}Value.
Since constants and functions are immutable, the first
two only need a types.Object; but each distinct
reference to a var may return a distinct Value, so the third
requires an ast.Ident parameter too.

Debug information for local vars is encoded in the
instruction stream in the form of DebugRef instructions,
which are a no-op but relate their operand to a particular
ident in the AST.  The beauty of this approach is that it
naturally stays consistent during optimisation passes
(e.g. lifting) without additional bookkeeping.

DebugRef instructions are only generated if the DebugMode
builder flag is set; I plan to make the policy more fine-
grained (per function).

DebugRef instructions are inserted for:
- expr(Ident) for rvalue idents
- address.store() for idents that update an lvalue
- address.address() for idents that take address of lvalue
  (this new method replaces all uses of lval.(address).addr)
- expr() for all constant expressions
- local ValueSpecs with implicit zero initialization (no RHS)
  (this case doesn't call store() or address())

To ensure we don't forget to emit debug info for uses of Idents,
we must use the lvalue mechanism consistently.  (Previously,
many simple cases had effectively inlined these functions.)
Similarly setCallFunc no longer inlines expr(Ident).

Also:
- Program.Value() has been inlined & specialized.
- Program.Package() has moved nearer the new lookup functions.
- refactoring: funcSyntax has lost paramFields, resultFields;
  gained funcType, which provides access to both.
- add package-level constants to Package.values map.
- opt: don't call localValueSpec for constants.
  (The resulting code is always optimised away.)

There are a number of comments asking whether Literals
should have positions.  Will address in a follow-up.

Added tests of all interesting cases.

R=gri
CC=golang-dev
https://golang.org/cl/11259044
2013-07-15 13:56:46 -04:00
Robert Griesemer
f1a889124d go.tools/go/types: cleanups
Objects:
- provide IsExported, SameName, uniqueName methods
- clean up a lot of dependent code

Scopes:
- don't add children to Universe scope (!)
- document Node, WriteTo

Types:
- remove Deref in favor of internal function deref

ssa, ssa/interp:
- introduced local deref, adjusted code
- fixed some "Underlying" bugs (pun intended)

R=adonovan
CC=golang-dev
https://golang.org/cl/11232043
2013-07-12 21:09:33 -07:00
Rob Pike
b042505490 go.tools/cmd/vet: use types.Eval to simplify some checking.
Depends on CL 10748044

R=gri
CC=golang-dev
https://golang.org/cl/11206043
2013-07-13 07:52:00 +10:00
Robert Griesemer
a3301d1bc6 go.tools/go/types: more test cases for types.Eval
R=adonovan
CC=golang-dev
https://golang.org/cl/11229043
2013-07-12 13:51:24 -07:00
Robert Griesemer
32ed9615b3 go.tools/go/types: implement New, Eval and EvalNode
Eval and EvalNode permit the evaluation of an expression
or type literal string (or AST node in case of EvalNode)
within a given context (package and scope).

Also:
- track nested (children) scopes for all scopes
- provide a mechanism to iterate over nested scopes
- permit recursive printing of scopes

TODO: more tests

R=adonovan
CC=golang-dev
https://golang.org/cl/10748044
2013-07-12 11:03:34 -07:00
Robert Griesemer
5ec27f6da9 go.tools/go/types: export IsAssignableTo
Tested implictly since its simply calling the
internal isAssignableTo which is used in every
assignment when testing the std library.

R=adonovan
CC=golang-dev
https://golang.org/cl/11189043
2013-07-11 14:23:23 -07:00
Robert Griesemer
424b1fda00 go.tools/go/types: only print underlying type in Object.String for type objects
R=adonovan
CC=golang-dev
https://golang.org/cl/11161045
2013-07-11 13:19:12 -07:00
Robert Griesemer
ed5ac0e6f1 go.tools/go/types: provide Object.String method
R=adonovan
CC=golang-dev
https://golang.org/cl/11178043
2013-07-11 12:57:56 -07:00
Alan Donovan
bc1f724aa4 go.tools/ssa: Member.Object() returns typechecker object for package members.
Also:
- {Must,}SanityCheck un-exported.  Added sanityCheckPackage.

R=gri
CC=golang-dev
https://golang.org/cl/11174043
2013-07-11 14:12:30 -04:00
Robert Griesemer
1f28df4b6c go.tools/go/types: reuse code for m:n assignments
- more test cases

R=adonovan
CC=golang-dev
https://golang.org/cl/10952044
2013-07-11 10:54:52 -07:00
Robert Griesemer
59f09dcb8c go.tools/go/types: report test errors immediately in -list mode
This way, errors reported before a crash are visible.

R=adonovan, r
CC=golang-dev
https://golang.org/cl/10802044
2013-07-10 22:19:43 -07:00
Robert Griesemer
71e1c68445 go.tools/ssa: fix build
Caused by https://golang.org/cl/11093044/ .

R=adonovan
CC=golang-dev
https://golang.org/cl/11149043
2013-07-10 22:14:40 -07:00
Robert Griesemer
3a75f78acd go.tools/go/types: cleanup init expr checks
- factored our arity checks
- started more systematic tests for const/var decls
- better error messages
- fixed several corner case errors

R=adonovan
CC=golang-dev
https://golang.org/cl/11137043
2013-07-10 20:10:24 -07:00
Alan Donovan
32f601bfbe go.types/ssa: unexport Package.Init; clients should use pkg.Func("init").
R=gri
CC=golang-dev
https://golang.org/cl/11093044
2013-07-10 18:37:52 -04:00
Alan Donovan
e783d2d666 go.tools/ssa: added test of loading of partial programs (via gcimporter).
This exposed a bug: we weren't creating Functions for methods
of imported named types.

Also:
- simplification: 'candidate' no longer contains 'concrete *Function'.
  We look this up on demand.

NB: this CL contains a copy of CL 10935047 (use of typemap);
will submit/sync/resolve soon.

R=gri
CC=golang-dev
https://golang.org/cl/11051043
2013-07-10 18:08:42 -04:00
Alan Donovan
4df74776da go.tools/ssa: de-dup the creation of method sets, using typemap.
Yields a ~20% improvement in SSA construction time.

Also: better names for promotion wrapper functions.

R=gri
CC=golang-dev
https://golang.org/cl/11050043
2013-07-10 18:01:11 -04:00
Alan Donovan
26d93d2e47 go.tools/go.types/typemap: a map whose keys are types.
go/types.Type has an equivalence relation (IsIdentical) that
is not consistent with the equivalence relation implemented by
Go's == operator for Types.  Therefore extra work is required
to build a map whose keys are types.  This package does that
work.

Has simple unit test.  More tests might be good.

R=gri
CC=golang-dev
https://golang.org/cl/9649044
2013-07-10 17:57:07 -04:00
Rob Pike
1c382c95b2 go.tools/cmd/cover: get cover counters on if conditions
This requires a little more tree rewriting to put a block around the if of an "else if".
More tests too.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11042045
2013-07-10 15:20:52 +10:00
Robert Griesemer
8cd6c3be05 go.tools/go/types: check for non-func init declarations
R=adonovan
CC=golang-dev
https://golang.org/cl/11075043
2013-07-09 21:13:37 -07:00
Andrew Gerrand
5b27bc1db9 go.talks/cmd/cover: show simpler legend for "set" mode
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10738044
2013-07-10 14:03:35 +10:00
Andrew Gerrand
c659fcb7c8 go.tools/cmd/cover: add floating bar with file selector and legend
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11076043
2013-07-10 13:22:04 +10:00
Robert Griesemer
b8f13c4c9b go.tools/go/types: assignment checking cleanup (round 2)
- consolited remainign assignment check routines
- removed more dead code
- fixed incorrect scope hierarchy in case of errors for some statements
- fixed scope of key iteration variable for range clauses

R=adonovan
CC=golang-dev
https://golang.org/cl/10694044
2013-07-09 09:45:09 -07:00
Alan Donovan
06a43b8a0c go.tools/ssa: fix regression in x<<y logic from CL 11011043
Details:
- reintroduce interp.asUint64: it's not sound to use only the
  low 32 bits of y, which is what asInt gives us, when GOARCH=386.
- instead, emit a uint64 conversion when y is not unsigned
  (i.e. a signed var, or an untyped constant).

Tested on 386 & x86-64.

R=gri
CC=golang-dev
https://golang.org/cl/11023043
2013-07-09 10:21:25 -04:00
Andrew Gerrand
2b6515094c go.talks/cmd/cover: better color scheme and fonts
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11032043
2013-07-09 16:58:15 +10:00
Alan Donovan
5da7e5a1a8 go.tools/ssa: give consistent positions for CanonicalPos(Literal).
(There are only seven ast.Expr types that can be constant.)

R=gri
CC=golang-dev
https://golang.org/cl/10766044
2013-07-08 18:02:50 -04:00
Alan Donovan
8846992823 go.tools/ssa: avoid redundant uint64 conversion of right operand of <<, >>.
Also: add sanity check that no Instruction yields a Value of 'untyped' type.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/11011043
2013-07-08 17:33:51 -04:00
Robert Griesemer
1aa0484f4b go.tools/go/types: report correct type for untyped conversion arguments
Fixes golang/go#5849.

R=adonovan
CC=golang-dev
https://golang.org/cl/11007043
2013-07-08 13:51:20 -07:00
Robert Griesemer
cc52b8b7f8 go.tools/go/types: clean up assignment checks (round 1)
Various bug fixes:
- don't allow := to redeclare non-variables
- don't permit a comma-ok expression as a two-value function return

Lots of dead code removed.

Fixes golang/go#5500.

R=adonovan
CC=golang-dev
https://golang.org/cl/10792044
2013-07-08 09:40:30 -07:00
Andrew Gerrand
a82eaff6b7 go.tools/cmd/cover: change color scheme and add legend
R=r, dsymonds
CC=golang-dev
https://golang.org/cl/10991043
2013-07-08 15:24:34 +10:00