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
diff --git a/ssa/ssa.go b/ssa/ssa.go
index 7c2c722..111af69 100644
--- a/ssa/ssa.go
+++ b/ssa/ssa.go
@@ -1170,7 +1170,8 @@
// For non-Ident expressions, Object() returns nil.
//
// DebugRefs are generated only for functions built with debugging
-// enabled; see Package.SetDebugMode().
+// enabled; see Package.SetDebugMode() and the GlobalDebug builder
+// mode flag.
//
// DebugRefs are not emitted for ast.Idents referring to constants or
// predeclared identifiers, since they are trivial and numerous.
@@ -1240,7 +1241,7 @@
// (b) a *MakeClosure, indicating an immediately applied
// function literal with free variables.
// (c) a *Builtin, indicating a statically dispatched call
-// to a built-in function. StaticCallee returns nil.
+// to a built-in function.
// (d) any other value, indicating a dynamically dispatched
// function call.
// StaticCallee returns the identity of the callee in cases