1
0
mirror of https://github.com/golang/go synced 2024-11-06 08:36:14 -07:00
Commit Graph

1870 Commits

Author SHA1 Message Date
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
Andrew Gerrand
00268482c0 go.tools/cmd/cover: use html/template for html generation
Also includes simple JavaScript dropdown picker.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10838045
2013-07-06 16:58:50 +10:00
Andrew Gerrand
d9e6cbb135 go.tools/cmd/cover: use a gradient to colorize "count" profiles
R=r
CC=golang-dev
https://golang.org/cl/10858047
2013-07-05 13:53:09 +10:00
Robert Griesemer
4ca3d7e9da go.tools/go/types: remove defers from critical paths
Various minor cleanups.

R=adonovan
CC=golang-dev
https://golang.org/cl/10925043
2013-07-03 20:51:39 -07:00
Alan Donovan
1fa3f78146 go.tools/ssa: Function.Synthetic documents provenance of synthetic functions.
We use the new field to determine whether or not a function is
synthetic, not Pos() == 0, so synthetic functions can have
positions too.

R=gri
CC=golang-dev
https://golang.org/cl/10916044
2013-07-03 17:57:20 -04:00
Alan Donovan
3b6580d5b4 go.tools/ssa: remove workaround for missing go/types check, now fixed.
R=gri
CC=golang-dev
https://golang.org/cl/10921043
2013-07-03 17:54:55 -04:00
Alan Donovan
ea8ba6f45b go.tools/ssa: fix crash on 'select { case x, ok = <-ch: }' (= not :=).
Added test.

Also:
- abstracted Function.addLocalForIdent (9 calls).
- remove vestige of old typeswitch hack.
- specify and fix CallCommon.Signature() for calls to built-ins.

R=gri
CC=golang-dev
https://golang.org/cl/10884044
2013-07-03 15:10:49 -04:00
Alan Donovan
997111ba7d go.tools/importer: update comment (and absolve gri of blame) for non-bug.
R=gri
CC=golang-dev
https://golang.org/cl/10911044
2013-07-03 14:41:26 -04:00
Robert Griesemer
f052654314 go.tools/go/types: remove iota from all parameter lists (cleanup)
Instead of passing around iota everywhere, keep track of the
current value in the checker, and update it when entering
different declarations. This is less explicit, but the improvement
over all code is so significant that it is worth it.

R=adonovan
CC=golang-dev
https://golang.org/cl/10814044
2013-07-03 10:06:09 -07:00
Robert Griesemer
b58f98e9c2 go.tools/go/types: fix more cycle errors, lots of refactoring
- moved ident and typ expr checking into typexpr.go
- as a result, fewer parameters are needed for expr checking
- forward-chain type decls of the form type ( A B; B C; C *A) etc.
  so that cycles are getting the right types in all cases
- fixed several corner case bugs, added more test cases

R=adonovan
CC=golang-dev
https://golang.org/cl/10773043
2013-07-02 16:39:30 -07:00
Alan Donovan
6ae930a01c go.tools/ssa: some renamings.
- Prog.Files -> Fset
- Prog.Packages -> PackagesByPath
- Prog.Builtins -> builtins
- Package.Types -> Object

R=gri
CC=golang-dev
https://golang.org/cl/10748043
2013-07-01 15:24:50 -04:00
Alan Donovan
c24b2413c0 go.tools/ssa: use go/types.LookupFieldOrMethod, and simplify.
Added tests.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/10830043
2013-07-01 15:17:36 -04:00
Andrew Gerrand
98e8131132 go.tools/cmd/vet: add image.Uniform to untagged literal white list
R=nigeltao
CC=golang-dev
https://golang.org/cl/10817043
2013-07-01 12:42:08 +10:00
Rob Pike
78efac5f33 go.tools/cmd/cover: yet another attempt at a usage message (YAAAAUM) for go tool cover
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10710044
2013-06-27 14:48:27 -07:00
Robert Griesemer
69c297407f go.tools/go/types: fix nil assignment
Fixes golang/go#5800.

R=adonovan
CC=golang-dev
https://golang.org/cl/10709044
2013-06-27 13:26:13 -07:00
Robert Griesemer
a0160af20b go.tools/go/types: tests for cycles in type decls
Fixed one aspect of issue 5090. Fixing it completely
requires a bit more work around the representation of
interface types.

R=adonovan
CC=golang-dev
https://golang.org/cl/10678045
2013-06-27 12:43:20 -07:00
Rob Pike
b52f745c3a go.tools/cmd/cover: delete TODO that is NOWDONE
R=adg
CC=golang-dev
https://golang.org/cl/10505044
2013-06-27 09:20:34 -07:00
Robert Griesemer
feb0ab2b10 go.tools/go/types: -files flag for testing one-off packages
Removed special case for testdata/test.go file in favor of
a simpler, more flexible, and explicit flag for one-off test
packages.

R=adonovan
CC=golang-dev
https://golang.org/cl/10618044
2013-06-26 13:01:16 -07:00
Alan Donovan
86b0a65b65 go.tools/ssa: emit ChangeType when using method as function in f := T.meth.
Previously: typeOf(f).Signature.Recv == T
       Now: typeOf(f).Signature.Params.At(0) == T

Added test.

BUG=5781

R=gri
CC=golang-dev
https://golang.org/cl/10622043
2013-06-26 13:18:31 -04:00
Alan Donovan
b68a029040 go.tools/ssa: un-export Function.FullName. Use String.
R=gri
CC=golang-dev
https://golang.org/cl/10604044
2013-06-26 12:38:08 -04:00
Robert Griesemer
22b7915ff5 go.tools/go/types: factored out code for calls and selectors
No other changes.

R=adonovan
CC=golang-dev
https://golang.org/cl/10573043
2013-06-25 15:40:28 -07:00
Robert Griesemer
25da72adcd go.tools/go/types: initialize local x early in case of bailout panic
- added respective test case

Fixes golang/go#5770.

R=adonovan
CC=golang-dev
https://golang.org/cl/10531043
2013-06-24 21:29:47 -07:00
Robert Griesemer
124e603d87 go.tools/go/types: imported structs may contain _ fields
Don't report import errors due to (multiple) _ fields
in imported structs.

Fixes golang/go#5758.

R=adonovan
CC=golang-dev
https://golang.org/cl/10529043
2013-06-24 17:38:41 -07:00
Rob Pike
6740bb0838 go.tools/cmd/vet: delete the word "only" from a warning
No semantic change.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/10516043
2013-06-24 12:56:35 -07:00
Rob Pike
40caf1ff72 go.tools/cmd/cover: better usage message
R=adg, rsc
CC=golang-dev
https://golang.org/cl/10453044
2013-06-24 12:56:25 -07:00
Robert Griesemer
c13bb422de go.tools/go/types: fix nil-ptr deref in gcimporter
Also: Make error handling more explicit.

Possibly a fix for issue 5758.

R=adonovan
CC=golang-dev
https://golang.org/cl/10520043
2013-06-24 11:49:02 -07:00