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
This commit is contained in:
Alan Donovan 2014-01-16 09:33:58 -05:00
parent d20cbc12f1
commit 3fc0fc1310
106 changed files with 120 additions and 121 deletions

View File

@ -54,7 +54,7 @@ import (
//
// Precondition: [start, end) both lie within the same file as root.
// TODO(adonovan): return (nil, false) in this case and remove precond.
// Requires FileSet; see importer.tokenFileContainsPos.
// Requires FileSet; see loader.tokenFileContainsPos.
//
// Postcondition: path is never nil; it always contains at least 'root'.
//

View File

@ -58,7 +58,7 @@ language.
*/
package call
import "code.google.com/p/go.tools/ssa"
import "code.google.com/p/go.tools/go/ssa"
// A Graph represents a call graph.
//

View File

@ -23,7 +23,7 @@ import (
"runtime"
"runtime/pprof"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/oracle"
)
@ -74,7 +74,7 @@ Describe the syntax at offset 530 in this file (an import spec):
Print the callgraph of the trivial web-server in JSON format:
% oracle -format=json src/pkg/net/http/triv.go callgraph
` + importer.FromArgsUsage
` + loader.FromArgsUsage
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

View File

@ -14,10 +14,10 @@ import (
"runtime"
"runtime/pprof"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/ssa/interp"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/ssa/interp"
)
var buildFlag = flag.String("build", "", `Options controlling the SSA builder.
@ -48,7 +48,7 @@ Examples:
% ssadump -build=FPG hello.go # quickly dump SSA form of a single package
% ssadump -run -interp=T hello.go # interpret a program, with tracing
% ssadump -run unicode -- -test.v # interpret the unicode package's tests, verbosely
` + importer.FromArgsUsage +
` + loader.FromArgsUsage +
`
When -run is specified, ssadump will find the first package that
defines a main function and run it in the interpreter.
@ -73,7 +73,7 @@ func main() {
flag.Parse()
args := flag.Args()
conf := importer.Config{
conf := loader.Config{
Build: &build.Default,
SourceImports: true,
}

View File

@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package importer_test
package loader_test
import (
"fmt"
"sort"
"testing"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/go/loader"
)
func loadFromArgs(args []string) (prog *importer.Program, rest []string, err error) {
conf := &importer.Config{}
func loadFromArgs(args []string) (prog *loader.Program, rest []string, err error) {
conf := &loader.Config{}
rest, err = conf.FromArgs(args)
if err == nil {
prog, err = conf.Load()

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package importer loads, parses and type-checks packages of Go code
// Package loader loads, parses and type-checks packages of Go code
// plus their transitive closure, and retains both the ASTs and the
// derived facts.
//
@ -18,7 +18,7 @@
// be called any number of times. Finally, these are followed by a
// call to Load() to actually load and type-check the program.
//
// var conf importer.Config
// var conf loader.Config
//
// // Use the command-line arguments to specify
// // a set of initial packages to load from source.
@ -70,7 +70,7 @@
// An external test package may depend upon members of the augmented
// package that are not in the unaugmented package, such as functions
// that expose internals. (See bufio/export_test.go for an example.)
// So, the importer must ensure that for each external test package
// So, the loader must ensure that for each external test package
// it loads, it also augments the corresponding non-test package.
//
// The import graph over n unaugmented packages must be acyclic; the
@ -78,17 +78,16 @@
// package must also be acyclic. ('go test' relies on this.) But the
// import graph over n augmented packages may contain cycles, and
// currently, go/types is incapable of handling such inputs, so the
// Importer will only augment (and create an external test package
// loader will only augment (and create an external test package
// for) the first import path specified on the command-line.
//
// The INITIAL packages are those specified in the configuration. A
// DEPENDENCY is a package loaded to satisfy an import in an initial
// package or another dependency.
//
package importer
package loader
// TODO(adonovan):
// - Rename this package go.tools/go/loader.
// - (*Config).ParseFile is very handy, but feels like feature creep.
// (*Config).CreateFromFiles has a nasty precondition.
// - Ideally some of this logic would move under the umbrella of

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package importer
package loader
import (
"fmt"

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package importer_test
package loader_test
// This file defines tests of source utilities.
@ -14,8 +14,8 @@ import (
"testing"
"code.google.com/p/go.tools/astutil"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
)
// findInterval parses input and returns the [start, end) positions of
@ -82,7 +82,7 @@ func TestEnclosingFunction(t *testing.T) {
"900", "func@2.27"},
}
for _, test := range tests {
conf := importer.Config{Fset: token.NewFileSet()}
conf := loader.Config{Fset: token.NewFileSet()}
f, start, end := findInterval(t, conf.Fset, test.input, test.substr)
if f == nil {
continue

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package importer
package loader
// This file defines various utility functions exposed by the package
// and used by it.

View File

@ -13,9 +13,9 @@ import (
"os"
"reflect"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/go/types/typemap"
"code.google.com/p/go.tools/ssa"
)
// object.flags bitmask values.

View File

@ -11,8 +11,8 @@ import (
"io"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types/typemap"
"code.google.com/p/go.tools/ssa"
)
// A Config formulates a pointer analysis problem for Analyze().

View File

@ -11,7 +11,7 @@ import (
"go/token"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/go/ssa"
)
// cgraph implements call.Graph.

View File

@ -9,9 +9,9 @@ import (
"sort"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/pointer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/pointer"
"code.google.com/p/go.tools/go/ssa"
)
// This program demonstrates how to use the pointer analysis to
@ -38,8 +38,8 @@ func main() {
i.f() // dynamic method call
}
`
// Construct an importer.
conf := importer.Config{SourceImports: true}
// Construct a loader.
conf := loader.Config{SourceImports: true}
// Parse the input file.
file, err := conf.ParseFile("myprog.go", myprog, 0)

View File

@ -14,8 +14,8 @@ import (
"fmt"
"go/token"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
var (

View File

@ -18,8 +18,8 @@ package pointer
import (
"fmt"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
// Instances of 'intrinsic' generate analysis constraints for calls to

View File

@ -10,8 +10,8 @@ import (
"strings"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
// A Label is an entity that may be pointed to by a pointer, map,

View File

@ -22,11 +22,11 @@ import (
"testing"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/pointer"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/go/types/typemap"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/pointer"
"code.google.com/p/go.tools/ssa"
)
var inputs = []string{
@ -151,7 +151,7 @@ func findProbe(prog *ssa.Program, probes map[*ssa.CallCommon]pointer.Pointer, e
}
func doOneInput(input, filename string) bool {
conf := importer.Config{SourceImports: true}
conf := loader.Config{SourceImports: true}
// Parsing.
f, err := conf.ParseFile(filename, input, 0)

View File

@ -28,8 +28,8 @@ import (
"reflect"
"code.google.com/p/go.tools/go/exact"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
// -------------------- (reflect.Value) --------------------

View File

@ -10,9 +10,9 @@ import (
"strings"
"testing"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
)
func isEmpty(f *ssa.Function) bool { return f.Blocks == nil }
@ -41,7 +41,7 @@ func main() {
`
// Create a single-file main package.
var conf importer.Config
var conf loader.Config
f, err := conf.ParseFile("<input>", test, 0)
if err != nil {
t.Error(err)
@ -206,7 +206,7 @@ func TestTypesWithMethodSets(t *testing.T) {
}
for i, test := range tests {
// Create a single-file main package.
var conf importer.Config
var conf loader.Config
f, err := conf.ParseFile("<input>", test.input, 0)
if err != nil {
t.Errorf("test %d: %s", i, err)

View File

@ -12,8 +12,8 @@ import (
"go/token"
"os"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/importer"
)
// BuilderMode is a bitmask of options for diagnostics and checking.
@ -37,7 +37,7 @@ const (
//
// mode controls diagnostics and checking during SSA construction.
//
func Create(iprog *importer.Program, mode BuilderMode) *Program {
func Create(iprog *loader.Program, mode BuilderMode) *Program {
prog := &Program{
Fset: iprog.Fset,
imported: make(map[string]*Package),
@ -170,7 +170,7 @@ func membersFromDecl(pkg *Package, decl ast.Decl) {
// The real work of building SSA form for each function is not done
// until a subsequent call to Package.Build().
//
func (prog *Program) CreatePackage(info *importer.PackageInfo) *Package {
func (prog *Program) CreatePackage(info *loader.PackageInfo) *Package {
if p := prog.packages[info.Pkg]; p != nil {
return p // already loaded
}

View File

@ -23,8 +23,8 @@
// primitives in the future to facilitate constant-time dispatch of
// switch statements, for example.
//
// To construct an SSA-form program, call ssa.Create on an
// importer.Program, a set of type-checked packages created from
// To construct an SSA-form program, call ssa.Create on a
// loader.Program, a set of type-checked packages created from
// parsed Go source files. The resulting ssa.Program contains all the
// packages and their members, but SSA code is not created for
// function bodies until a subsequent call to (*Package).Build.

View File

@ -8,8 +8,8 @@ import (
"fmt"
"os"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
)
// This program demonstrates how to run the SSA builder on a "Hello,
@ -40,7 +40,7 @@ func main() {
fmt.Println(message)
}
`
var conf importer.Config
var conf loader.Config
// Parse the input file.
file, err := conf.ParseFile("hello.go", hello, 0)

View File

@ -14,7 +14,7 @@ import (
"syscall"
"time"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/go/ssa"
)
type externalFn func(fn *ssa.Function, args []value) value

View File

@ -9,7 +9,7 @@ package interp
import (
"syscall"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/go/ssa"
)
func fillStat(st *syscall.Stat_t, stat structure) {

View File

@ -51,8 +51,8 @@ import (
"reflect"
"runtime"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
type continuation int

View File

@ -16,10 +16,10 @@ import (
"testing"
"time"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/ssa/interp"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/ssa/interp"
)
// Each line contains a space-separated list of $GOROOT/test/
@ -168,7 +168,7 @@ func run(t *testing.T, dir, input string, success successPredicate) bool {
inputs = append(inputs, dir+i)
}
conf := importer.Config{SourceImports: true}
conf := loader.Config{SourceImports: true}
// TODO(adonovan): add the following packages' tests, which pass:
// "flag", "unicode", "unicode/utf8", "testing", "log", "path".
if err := conf.CreateFromFilenames(inputs...); err != nil {
@ -318,7 +318,7 @@ func TestTestmainPackage(t *testing.T) {
// CreateTestMainPackage should return nil if there were no tests.
func TestNullTestmainPackage(t *testing.T) {
var conf importer.Config
var conf loader.Config
if err := conf.CreateFromFilenames("testdata/b_test.go"); err != nil {
t.Fatalf("ParseFile failed: %s", err)
}

View File

@ -13,8 +13,8 @@ import (
"unsafe"
"code.google.com/p/go.tools/go/exact"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
// If the target program panics, the interpreter panics with this type.

View File

@ -16,8 +16,8 @@ import (
"reflect"
"unsafe"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
type opaqueType struct {

View File

@ -42,9 +42,9 @@ import (
"sync"
"unsafe"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/go/types/typemap"
"code.google.com/p/go.tools/ssa"
)
type value interface{}

View File

@ -140,7 +140,7 @@ func findNamedFunc(pkg *Package, pos token.Pos) *Function {
// - f was not built with debug information; or
// - e is a constant expression. (For efficiency, no debug
// information is stored for constants. Use
// importer.PackageInfo.ValueOf(e) instead.)
// loader.PackageInfo.ValueOf(e) instead.)
// - e is a reference to nil or a built-in function.
// - the value was optimised away.
//

View File

@ -18,13 +18,13 @@ import (
"code.google.com/p/go.tools/astutil"
"code.google.com/p/go.tools/go/exact"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
)
func TestObjValueLookup(t *testing.T) {
var conf importer.Config
var conf loader.Config
f, err := conf.ParseFile("testdata/objlookup.go", nil, parser.ParseComments)
if err != nil {
t.Error(err)
@ -188,7 +188,7 @@ func checkVarValue(t *testing.T, prog *ssa.Program, pkg *ssa.Package, ref []ast.
// Ensure that, in debug mode, we can determine the ssa.Value
// corresponding to every ast.Expr.
func TestValueForExpr(t *testing.T) {
var conf importer.Config
var conf loader.Config
f, err := conf.ParseFile("testdata/valueforexpr.go", nil, parser.ParseComments)
if err != nil {
t.Error(err)

View File

@ -14,9 +14,9 @@ import (
"sync"
"code.google.com/p/go.tools/go/exact"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/go/types/typemap"
"code.google.com/p/go.tools/importer"
)
// A Program is a partial or complete Go program converted to SSA form.
@ -49,10 +49,10 @@ type Package struct {
// The following fields are set transiently, then cleared
// after building.
started int32 // atomically tested and set at start of build phase
ninit int32 // number of init functions
info *importer.PackageInfo // package ASTs and type information
needRTTI typemap.M // types for which runtime type info is needed
started int32 // atomically tested and set at start of build phase
ninit int32 // number of init functions
info *loader.PackageInfo // package ASTs and type information
needRTTI typemap.M // types for which runtime type info is needed
}
// A Member is a member of a Go package, implemented by *NamedConst,

View File

@ -23,8 +23,8 @@ import (
"fmt"
"go/token"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/ssa"
)
// A ConstCase represents a single constant comparison.

View File

@ -9,13 +9,13 @@ import (
"strings"
"testing"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/ssa/ssautil"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/ssa/ssautil"
)
func TestSwitches(t *testing.T) {
var conf importer.Config
var conf loader.Config
f, err := conf.ParseFile("testdata/switches.go", nil, parser.ParseComments)
if err != nil {
t.Error(err)

View File

@ -4,7 +4,7 @@
package ssautil
import "code.google.com/p/go.tools/ssa"
import "code.google.com/p/go.tools/go/ssa"
// This file defines utilities for visiting the SSA representation of
// a Program.

View File

@ -18,9 +18,9 @@ import (
"testing"
"time"
"code.google.com/p/go.tools/importer"
"code.google.com/p/go.tools/ssa"
"code.google.com/p/go.tools/ssa/ssautil"
"code.google.com/p/go.tools/go/loader"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/ssa/ssautil"
)
func allPackages() []string {
@ -52,7 +52,7 @@ func TestStdlib(t *testing.T) {
// Load, parse and type-check the program.
t0 := time.Now()
var conf importer.Config
var conf loader.Config
if _, err := conf.FromArgs(allPackages()); err != nil {
t.Errorf("FromArgs failed: %s", err)
return

View File

@ -10,9 +10,9 @@ import (
"go/token"
"sort"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/oracle/serial"
"code.google.com/p/go.tools/ssa"
)
// Callees reports the possible callees of the function call site

View File

@ -9,8 +9,8 @@ import (
"go/token"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/oracle/serial"
"code.google.com/p/go.tools/ssa"
)
// Callers reports the possible callers of the function

View File

@ -9,8 +9,8 @@ import (
"sort"
"code.google.com/p/go.tools/call"
"code.google.com/p/go.tools/go/ssa"
"code.google.com/p/go.tools/oracle/serial"
"code.google.com/p/go.tools/ssa"
)
// callgraph displays the entire callgraph of the current program.

Some files were not shown because too many files have changed in this diff Show More