From b68a029040f87d0f56cb346c8c5eee540ea4386f Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 26 Jun 2013 12:38:08 -0400 Subject: [PATCH] go.tools/ssa: un-export Function.FullName. Use String. R=gri CC=golang-dev https://golang.org/cl/10604044 --- ssa/builder.go | 3 +-- ssa/dom.go | 4 ++-- ssa/func.go | 8 ++------ ssa/interp/interp.go | 8 ++++---- ssa/print.go | 2 +- ssa/promote.go | 2 +- ssa/source_test.go | 2 +- ssa/ssa.go | 6 ++++-- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/ssa/builder.go b/ssa/builder.go index d7595cdb..140969ef 100644 --- a/ssa/builder.go +++ b/ssa/builder.go @@ -2240,8 +2240,7 @@ func (b *builder) buildFunction(fn *Function) { return } if fn.Prog.mode&LogSource != 0 { - defer logStack("build function %s @ %s", - fn.FullName(), fn.Prog.Files.Position(fn.pos))() + defer logStack("build function %s @ %s", fn, fn.Prog.Files.Position(fn.pos))() } fn.startBody() fn.createSyntacticParams() diff --git a/ssa/dom.go b/ssa/dom.go index 499ea9ee..2fe3098c 100644 --- a/ssa/dom.go +++ b/ssa/dom.go @@ -258,7 +258,7 @@ func sanityCheckDomTree(f *Function) { } } if !ok { - panic("sanityCheckDomTree failed for " + f.FullName()) + panic("sanityCheckDomTree failed for " + f.String()) } } @@ -275,7 +275,7 @@ func printDomTreeText(w io.Writer, v *domNode, indent int) { // printDomTreeDot prints the dominator tree of f in AT&T GraphViz // (.dot) format. func printDomTreeDot(w io.Writer, f *Function) { - fmt.Fprintln(w, "//", f.FullName()) + fmt.Fprintln(w, "//", f) fmt.Fprintln(w, "digraph domtree {") for i, b := range f.Blocks { v := b.dom diff --git a/ssa/func.go b/ssa/func.go index 8b843b1d..f73bdcea 100644 --- a/ssa/func.go +++ b/ssa/func.go @@ -448,11 +448,7 @@ func (f *Function) emit(instr Instruction) Value { // "func@5.32" // an anonymous function // "bound$(*T).f" // a bound method wrapper // -func (f *Function) FullName() string { - return f.fullName(nil) -} - -// Like FullName, but if from==f.Pkg, suppress package qualification. +// If from==f.Pkg, suppress package qualification. func (f *Function) fullName(from *Package) string { // TODO(adonovan): expose less fragile case discrimination. @@ -535,7 +531,7 @@ func writeSignature(w io.Writer, name string, sig *types.Signature, params []*Pa // all basic blocks of function f. // func (f *Function) DumpTo(w io.Writer) { - fmt.Fprintf(w, "# Name: %s\n", f.FullName()) + fmt.Fprintf(w, "# Name: %s\n", f.String()) if pos := f.Pos(); pos.IsValid() { fmt.Fprintf(w, "# Declared at %s\n", f.Prog.Files.Position(pos)) } else { diff --git a/ssa/interp/interp.go b/ssa/interp/interp.go index a2ae6d22..7f030835 100644 --- a/ssa/interp/interp.go +++ b/ssa/interp/interp.go @@ -436,15 +436,15 @@ func callSSA(i *interpreter, caller *frame, callpos token.Pos, fn *ssa.Function, if i.mode&EnableTracing != 0 { fset := fn.Prog.Files // TODO(adonovan): fix: loc() lies for external functions. - fmt.Fprintf(os.Stderr, "Entering %s%s.\n", fn.FullName(), loc(fset, fn.Pos())) + fmt.Fprintf(os.Stderr, "Entering %s%s.\n", fn, loc(fset, fn.Pos())) suffix := "" if caller != nil { - suffix = ", resuming " + caller.fn.FullName() + loc(fset, callpos) + suffix = ", resuming " + caller.fn.String() + loc(fset, callpos) } - defer fmt.Fprintf(os.Stderr, "Leaving %s%s.\n", fn.FullName(), suffix) + defer fmt.Fprintf(os.Stderr, "Leaving %s%s.\n", fn, suffix) } if fn.Enclosing == nil { - name := fn.FullName() + name := fn.String() if ext := externals[name]; ext != nil { if i.mode&EnableTracing != 0 { fmt.Fprintln(os.Stderr, "\t(external)") diff --git a/ssa/print.go b/ssa/print.go index 46189c9d..588a2f27 100644 --- a/ssa/print.go +++ b/ssa/print.go @@ -68,7 +68,7 @@ func (v *Builtin) String() string { } func (v *Function) String() string { - return v.FullName() + return v.fullName(nil) } // FullName returns g's package-qualified name. diff --git a/ssa/promote.go b/ssa/promote.go index be978328..07978d25 100644 --- a/ssa/promote.go +++ b/ssa/promote.go @@ -443,7 +443,7 @@ func boundMethodWrapper(meth *Function) *Function { } s := meth.Signature fn = &Function{ - name: "bound$" + meth.FullName(), + name: "bound$" + meth.String(), Signature: types.NewSignature(nil, s.Params(), s.Results(), s.IsVariadic()), // drop recv Prog: prog, } diff --git a/ssa/source_test.go b/ssa/source_test.go index 1eead236..dd1ef7cd 100644 --- a/ssa/source_test.go +++ b/ssa/source_test.go @@ -260,7 +260,7 @@ func TestEnclosingFunction(t *testing.T) { name := "(none)" fn := ssa.EnclosingFunction(pkg, path) if fn != nil { - name = fn.FullName() + name = fn.String() } if name != test.fn { diff --git a/ssa/ssa.go b/ssa/ssa.go index 354db2ec..14ab40ae 100644 --- a/ssa/ssa.go +++ b/ssa/ssa.go @@ -1230,8 +1230,10 @@ func (c *CallCommon) Pos() token.Pos { return c.pos } // Signature returns the signature of the called function. // // For an "invoke"-mode call, the signature of the interface method is -// returned; the receiver is represented by sig.Recv, not -// sig.Params().At(0). +// returned. +// +// In either "call" or "invoke" mode, if the callee is a method, its +// receiver is represented by sig.Recv, not sig.Params().At(0). // func (c *CallCommon) Signature() *types.Signature { if c.Recv != nil {