1
0
mirror of https://github.com/golang/go synced 2024-10-01 07:38:32 -06:00
Commit Graph

672 Commits

Author SHA1 Message Date
Alan Donovan
4dcb74e810 go.tools/go/ssa/interp: implement reflection over callstack (now that we have access to it).
+ tests.

Fixes golang/go#6041

Also: move global var _sizes to a field of interpreter.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/56530046
2014-01-27 15:39:17 -05:00
Alan Donovan
fbb3d81367 go.tools/ssa/interp: add intrinsics for (*sync.Pool).{Get,Put}.
Since Put() makes a dynamic function call, this CL includes a long-overdue change to supply a *frame (and thus the call
stack and the interpreter) to intrinsics too.

This fixes the tests that were broken by (sound) revision e4a4cb47c141.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/57350043
2014-01-27 13:11:16 -05:00
Brad Fitzpatrick
eda00ba4ec imports: bake in the standard library again
Fast path for the common case. Avoids scanning GOPATH usually.

LGTM=r, crawshaw
R=david.crawshaw, adg, r, crawshaw
CC=golang-codereviews
https://golang.org/cl/56820043
2014-01-26 09:47:31 -08:00
Andrew Gerrand
3b2989e9ea go.tools/dashboard: update CL on build failure
Only send mail to golang-dev if updating the CL fails.

R=golang-codereviews, dvyukov, minux.ma, rsc
CC=golang-codereviews
https://golang.org/cl/43760043
2014-01-24 14:52:23 +11:00
Andrew Gerrand
3342856161 go.tools/dashboard/app: sort builder columns in a more useful manner
Supported operating systems first, then race builders, then the rest.

R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/56190043
2014-01-24 09:13:34 +11:00
Alan Donovan
87b29f65dc go.tools/go/ssa/interp: fix broken import paths.
Fixes golang/go#7166

R=gri
CC=golang-codereviews
https://golang.org/cl/55710045
2014-01-22 17:19:25 -05:00
Alan Donovan
0dcaae1610 go.tools/go/loader: permit Create* methods to specify the ad-hoc package's path
CL 49530047 made the (over-)simplifying assumption that the
Path of an ad-hoc (Created) package should default to its
Name, i.e. package declaration.

With this change, the Name is still always computed from the
package declaration (by go/types) but the Path may be
specified by the loader.Config.  If "", the value of the Name
is used, which is not globally unique.

R=gri, axwalk
CC=golang-codereviews
https://golang.org/cl/55180043
2014-01-22 09:59:19 -05:00
Robert Griesemer
074bd4ac9c go.tools/go/types: cleanup: remove unnecessary receiver
R=adonovan
CC=golang-codereviews
https://golang.org/cl/53810044
2014-01-17 11:17:43 -08:00
Alan Donovan
2845638157 go.tools/go/ssa: simplify builder.exprN now that go/types emits correct types.
(Follow-up to fix of issue 7060.)

Also: comment fixes.

R=gri
CC=golang-codereviews
https://golang.org/cl/47670043
2014-01-17 09:38:25 -05:00
Robert Griesemer
2d6b34a0f5 go.tools/go/types: report rhs type for comma-ok expressions
Fixes golang/go#7060.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/53520043
2014-01-16 19:33:51 -08:00
Robert Griesemer
0b4b877c72 go.tools/go/types: remove size from Basic
More localized computation of sizes.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/53460043
2014-01-16 14:47:26 -08:00
Robert Griesemer
9b91992c8c go.tools/go/loader: add missing argument to fmt.Errorf call
R=adonovan
CC=golang-codereviews
https://golang.org/cl/53360043
2014-01-16 13:20:02 -08:00
Robert Griesemer
184bc0cc8c go.tools/go/gccgoimporter: remove dead code
R=adonovan
CC=golang-codereviews
https://golang.org/cl/53340043
2014-01-16 13:19:39 -08:00
Robert Griesemer
e4a00b5ce3 go.tools/go/importer: fix format string
R=adonovan
CC=golang-codereviews
https://golang.org/cl/52360045
2014-01-16 13:17:46 -08:00
Alan Donovan
9cfde22948 go.tools/ssa/interp: rewrite initorder test.
Correct, this time.

R=gri
CC=golang-codereviews
https://golang.org/cl/52930043
2014-01-16 14:08:04 -05:00
Alan Donovan
b856247075 go.tools/call: rename package to go/callgraph
Was:		Now:
call.Graph	callgraph.Graph
call.GraphNode	callgraph.Node
call.Edge	callgraph.Edge

Though call.Graph was cute, the original naming was a mistake:
'call' is too useful a var name to waste on a package.

R=gri, crawshaw
CC=golang-codereviews
https://golang.org/cl/53190043
2014-01-16 14:04:19 -05:00
Alan Donovan
3fc0fc1310 go.tools: rename packages.
Was:		Now:
ssa		go/ssa
importer	go/loader
pointer		go/pointer

Next CL: call -> go/callgraph (requires more care)

R=gri, crawshaw
CC=golang-codereviews
https://golang.org/cl/52960043
2014-01-16 09:33:58 -05:00
Alan Donovan
d20cbc12f1 go.tools/oracle: eliminate reliance on undefined map iteration order.
(Unmasked by recent randomization of small (<8) map iteration.)

R=gri, crawshaw, bradfitz
CC=golang-codereviews
https://golang.org/cl/51170044
2014-01-15 22:55:52 -05:00
Alan Donovan
e8afbfad8c go.tools/importer: API rethink.
The Importer type has been replaced with Config and Program.

Clients populate a Config, directly or more usually via
convenience functions.  They then call its Load() method to do
all of the typechecking and transitive-closure computation.

ssa.NewProgram and ssa.CreatePackages have been fused into
ssa.Create, which now cannot fail, since (*Config).Load()
reports all type errors.

Also:
- The addition of an ssa.GlobalDebug builder mode flag
  eliminates a loop-over-packages repeated in many clients.
- PackageInfo.Err flag unexported.  Clients never see bad infos now.
- cmd/ssadump: now only looks for func "main" in package "main".
- importsOf deleted, was dead code.

STILL TODO:
- ParseFile seems like API creep (though it's convenient)
  and CreateFromFiles is dangerous (w.r.t. FileSet identity).
  Need to think more...
- the need for clients to rely on elementwise correspondence
  of Config.CreatePkgs and Program.Created is a little sad.
- The command-line interface has not changed.
  That will happen in a follow-up.
  r recommends using a repeated flag: -package p -package q ...

R=gri
CC=axwalk, frederik.zipp, golang-codereviews
https://golang.org/cl/49530047
2014-01-15 21:37:55 -05:00
Robert Griesemer
d71b7746ee go.tools/oracle: disable broken test (fix build)
R=adonovan
TBR=adonovan
CC=golang-codereviews
https://golang.org/cl/52920043
2014-01-15 16:25:40 -08:00
Robert Griesemer
981e35990f go.tools/ssa/interp: fix init order test (partial build fix)
R=adonovan
TBR=adonovan
CC=golang-codereviews
https://golang.org/cl/52600044
2014-01-15 16:16:49 -08:00
Robert Griesemer
e1c6a8ff95 go.tools/go/types: init order depends on source order
Apply sorting consistently to object->decl maps.

Fixes golang/go#7131.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/52890043
2014-01-15 15:15:32 -08:00
Alan Donovan
b75a5a4b65 go.tools/ssa: skip redundant identifier qualification in package dump.
(Reduces ssadump -build=P verbosity by 25%.)

R=gri
CC=golang-codereviews
https://golang.org/cl/52730044
2014-01-15 13:51:50 -05:00
Alan Donovan
8dabab4124 go.tools/ssa/interp: remove irrelevent parts of test, improve comments.
(Discovered during diagnosis of bug 7131.)

R=gri
CC=golang-codereviews
https://golang.org/cl/52780043
2014-01-15 13:50:11 -05:00
Robert Griesemer
5d7773006a go.tools/go/types: minor cleanups
- remove TODO in exact.go
- use testing.Verbose() rather than local verbose flag

R=adonovan
CC=golang-codereviews
https://golang.org/cl/52500043
2014-01-14 21:04:35 -08:00
Alan Donovan
39fe7e6f8e go.tools/ssa/interp: fix windows build.
- Add missing import.
- platform-specific files syswrite() wrapper presents
  standard API to syscall.Write, even on Windows where
  first arg is a Handle.

Fixes golang/go#7100

R=gri, minux.ma, alex.brainman
CC=golang-codereviews
https://golang.org/cl/52250043
2014-01-14 21:47:31 -05:00
Peter Collingbourne
a0cc29953e go.tools/go/types: introduce Func.Scope()
The goal is to allow clients to distinguish function-local objects
from package-local objects and identify the specific function by
examining its scope. For example, a compiler may need to mangle
object names according to the outer function name.

R=gri
CC=golang-codereviews, golang-dev
https://golang.org/cl/52280043
2014-01-14 14:47:27 -08:00
Peter Collingbourne
0c15485ecc go.tools/go/types: use WordSize as function pointer size
Both gc and gccgo appear to use this size, so it seems appropriate
to use it here.

R=gri
CC=golang-codereviews, golang-dev, iant, rsc
https://golang.org/cl/52290043
2014-01-14 14:10:09 -08:00
Alan Donovan
f3eb05bcef go.tools/ssa: eliminate (non-nil) slice constants.
go/types no longer reports a constant value for a slice,
e.g. []byte("foo").

ssa.Const no longer support slice constants, only
bool/string/numeric and nil.

emitConv emits a Convert instruction for string->[]byte
conversions.

Added regression test for bug 6949.

R=gri
CC=golang-codereviews
https://golang.org/cl/50590043
2014-01-13 16:45:46 -05:00
Robert Griesemer
29ac1365f4 go.tools/oracle: adjust golden output to new names
R=adonovan
TBR=adonovan
CC=golang-codereviews
https://golang.org/cl/49530049
2014-01-10 16:05:14 -08:00
Robert Griesemer
179e0b3699 go.tools/go/types: only report constants with constant types
The issue is addressed with the change in conversions.go.

Also:
- added corresponding API test
- made names for untyped ints, bools consistent with others
- use *Basic with names byte/rune instead of uint8/int32 for better output
- minor cleanups

Fixes golang/go#6949.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/50520043
2014-01-10 15:21:51 -08:00
Alan Donovan
d2fe54b33c go.tools/ssa: fix bug: lifting pass invalidated Referrers info for DebugRef's X operand.
Tested: by enabling debug info globally in stdlib_test,
the existing sanity checks catch it.

R=gri
CC=golang-codereviews
https://golang.org/cl/50570043
2014-01-10 17:10:12 -05:00
Alan Donovan
3d82e7e94a go.tools/ssa: fix crash in SSA builder when using GCImporter to satisfy imports (ssadump -build=G).
Packages were not being created for all types.Packages,
specifically, indirectly imported packages were missing.
(*Program).CreatePackages now iterates over the type-checker's
package map too.

Also: removed all concurrency from importer.  I think it was
incorrect (and hard to fix).

Also: change LoadInitialPackages so that all named packages
are loaded from source.  This happens regardless of whether
GCImporter is used to satisfy imports.

Details:
- importer.Config.SourceImports flag determines whether to
  load all packages from *.go source.
  (Before, this was indicated by Config.Build != nil.)
- importer.Config.Build field effectively defaults to
  &go/build.Default.  A zero importer.Config is now usable.
- importer.Importer.Config field is now exported.
- LoadPackage renamed to ImportPackage since the resulting
  packages may come from GCImporter (and be incomplete).
- doImport and ImportPackage fused.

Fixes golang/go#7028

R=gri, axwalk
CC=golang-codereviews
https://golang.org/cl/48770043
2014-01-09 14:11:54 -05:00
Robert Griesemer
df3357d07f go.tools/go/types: simplify variable usage error detection
Now that inner functions are processed "in line", usage errors
can be detected immediately after each function is processed.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/49900044
2014-01-09 10:45:42 -08:00
Robert Griesemer
4e620158a2 go.tools/go/types: use correct outer scope state for inner functions
Inner function bodies must be type-checked "in-place" for
them to see the correct state of the surrounding scopes.

Fixes golang/go#7035.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/49350043
2014-01-09 08:40:32 -08:00
Peter Collingbourne
d0b88d2206 cmd/gotype: add -gccgo flag
R=gri
CC=golang-codereviews, golang-dev
https://golang.org/cl/39050043
2014-01-08 15:25:17 -08:00
Alan Donovan
18b807c7ac go.tools/ssa: doc: Builtin is not an Instruction.
Fixes golang/go#7026.

R=gri
CC=golang-codereviews
https://golang.org/cl/48630045
2014-01-08 14:50:52 -05:00
Alan Donovan
5612f0615f go.tools/ssa: use correct word size for GOARCH during type checking, interpretation.
Also report an error for "cross-interpretation": not supported
due to the interpreter's assumption that host and target
{int,uint,uintptr} are the same.  (Too tedious and messy to fix.)

Tested manually:

% cat d.go
package main
const m = ^uintptr(0)
const w = m>>8&1 + m>>16&1 + m>>32&1
func main() { println(m, w) }

% ./ssadump -build=P -run d.go
package main:
  const m          m = 18446744073709551615:uintptr
  const w          w = 3:uintptr
18446744073709551615 3

% GOARCH=386 ./ssadump -build=P -run d.go
package main:
  const m          m = 4294967295:uintptr
  const w          w = 2:uintptr
Error: Cross-interpretation is not yet supported (target has GOARCH 386, interpreter has amd64).

Fixes golang/go#7080

R=gri
CC=golang-codereviews
https://golang.org/cl/49070043
2014-01-08 14:46:17 -05:00
Peter Collingbourne
893253274d go.tools/go/gccgoimporter: importer for gccgo export data
This can import all of the standard library, and has been tested
by using gotype to type check libgo with gccgo's export data (this
would be nice to automate, but I can't see a good way to do it,
not least because system-specific source files cause errors which
I needed to identify manually).

It includes a builtin export locator. Unfortunately I can't see a
more reliable way to locate the builtin export files than to parse
the output of 'gccgo -###'.

R=gri, iant, gri
CC=golang-codereviews, golang-dev
https://golang.org/cl/31860043
2014-01-08 09:00:50 -08:00
Robert Griesemer
a9b6519df8 go.tools/go.types: cleanups
- if a named type was imported before, read it again
  and throw it away in favor of the existing type
  (the old code did the same, but more circuitously)

- better tag name for int64 values

R=adonovan
CC=golang-codereviews
https://golang.org/cl/47650044
2014-01-08 08:58:00 -08:00
Robert Griesemer
ff72a95f05 go.tools/go/gcimporter: correct package for imported methods
R=adonovan
CC=golang-codereviews
https://golang.org/cl/48630044
2014-01-07 14:46:10 -08:00
Alan Donovan
d6eb8982f6 go.tools/ssa: two fixes to CallCommon.
(*CallCommon).Signature() now returns non-nil even for
built-ins.  Builtins are now created with specialized types for
each use.  Added sanity-check.

CallCommon.HasEllipsis field eliminated.  It was an incorrect
memoization of Signature().IsVariadic() used only for
printing.

Also: introduce and use newTypeVar utility.

R=gri
CC=golang-codereviews
https://golang.org/cl/46880044
2014-01-07 13:31:05 -05:00
Robert Griesemer
b6eef48120 go.tools/go/types: adjust comments for godoc
R=adonovan
CC=golang-codereviews
https://golang.org/cl/38560045
2014-01-07 10:03:15 -08:00
Brad Garcia
26542a8bc5 godoc: Update identifier indexing tests.
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/48170043
2014-01-06 14:53:03 -05:00
Brad Garcia
27d851fc2c godoc: Add package identifiers to documentation indexing.
This allows us to show package synopsis in search results.
Fix skipping of test files (prefix changed from "test/" to "/test/").

R=bradfitz, bradfitz
CC=golang-codereviews
https://golang.org/cl/44790044
2014-01-06 13:26:25 -05:00
Brad Garcia
a28efa5d8c godoc: add ability to change or disable the display of search results.
The display of search results can now be changed. A slice of functions for displaying the results can now be provided.  By default, three functions are provided to display documentation, source code, and textual results.
This makes it possible to replace them with equivalents that, say,
obtain search results from alternative source code search engines.

R=bradfitz, adg
CC=golang-codereviews
https://golang.org/cl/43470043
2014-01-06 09:51:01 -05:00
Francesc Campoy
5f5d42a466 go.tools/present: links with the prefix "javascript:" should be executed in the same window.
Using url.Parse instead of more ad hoc solution.

R=r
CC=golang-codereviews
https://golang.org/cl/47320043
2014-01-03 14:51:34 -08:00
Robert Griesemer
822669c658 go.tools/importer: fix field package for anonymous fields
Anonymous field names are emitted as "" in the export data
since the actual name can be reconstructed easily from the
field's type name. But "" names are not exported names and
thus the respective qualified name emits complete package
information even if the actual field name is exported. Fix
the package upon import.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/42090044
2014-01-03 14:08:12 -08:00
Robert Griesemer
df08273253 go.tools/gcimporter: use imported package info for anonymous fields
The package of a struct field is independent of the type of the
struct field - the old code was technically not correct. That said,
it does not seem possible (or very difficult) to create a test case
because for exported anonymous fields that field package doesn't matter
(it's not needed for name identity), and non-exported anonymous fields
cannot be accessed from an imported package.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/47560043
2014-01-03 11:37:20 -08:00
Robert Griesemer
6770b5cdca go.tools/go/importer: more cleanups
R=adonovan
CC=golang-codereviews
https://golang.org/cl/34660046
2014-01-03 09:12:32 -08:00