go.tools/ssa: un-export Function.FullName. Use String.
R=gri CC=golang-dev https://golang.org/cl/10604044
This commit is contained in:
parent
22b7915ff5
commit
b68a029040
|
@ -2240,8 +2240,7 @@ func (b *builder) buildFunction(fn *Function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if fn.Prog.mode&LogSource != 0 {
|
if fn.Prog.mode&LogSource != 0 {
|
||||||
defer logStack("build function %s @ %s",
|
defer logStack("build function %s @ %s", fn, fn.Prog.Files.Position(fn.pos))()
|
||||||
fn.FullName(), fn.Prog.Files.Position(fn.pos))()
|
|
||||||
}
|
}
|
||||||
fn.startBody()
|
fn.startBody()
|
||||||
fn.createSyntacticParams()
|
fn.createSyntacticParams()
|
||||||
|
|
|
@ -258,7 +258,7 @@ func sanityCheckDomTree(f *Function) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ok {
|
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
|
// printDomTreeDot prints the dominator tree of f in AT&T GraphViz
|
||||||
// (.dot) format.
|
// (.dot) format.
|
||||||
func printDomTreeDot(w io.Writer, f *Function) {
|
func printDomTreeDot(w io.Writer, f *Function) {
|
||||||
fmt.Fprintln(w, "//", f.FullName())
|
fmt.Fprintln(w, "//", f)
|
||||||
fmt.Fprintln(w, "digraph domtree {")
|
fmt.Fprintln(w, "digraph domtree {")
|
||||||
for i, b := range f.Blocks {
|
for i, b := range f.Blocks {
|
||||||
v := b.dom
|
v := b.dom
|
||||||
|
|
|
@ -448,11 +448,7 @@ func (f *Function) emit(instr Instruction) Value {
|
||||||
// "func@5.32" // an anonymous function
|
// "func@5.32" // an anonymous function
|
||||||
// "bound$(*T).f" // a bound method wrapper
|
// "bound$(*T).f" // a bound method wrapper
|
||||||
//
|
//
|
||||||
func (f *Function) FullName() string {
|
// If from==f.Pkg, suppress package qualification.
|
||||||
return f.fullName(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Like FullName, but if from==f.Pkg, suppress package qualification.
|
|
||||||
func (f *Function) fullName(from *Package) string {
|
func (f *Function) fullName(from *Package) string {
|
||||||
// TODO(adonovan): expose less fragile case discrimination.
|
// 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.
|
// all basic blocks of function f.
|
||||||
//
|
//
|
||||||
func (f *Function) DumpTo(w io.Writer) {
|
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() {
|
if pos := f.Pos(); pos.IsValid() {
|
||||||
fmt.Fprintf(w, "# Declared at %s\n", f.Prog.Files.Position(pos))
|
fmt.Fprintf(w, "# Declared at %s\n", f.Prog.Files.Position(pos))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -436,15 +436,15 @@ func callSSA(i *interpreter, caller *frame, callpos token.Pos, fn *ssa.Function,
|
||||||
if i.mode&EnableTracing != 0 {
|
if i.mode&EnableTracing != 0 {
|
||||||
fset := fn.Prog.Files
|
fset := fn.Prog.Files
|
||||||
// TODO(adonovan): fix: loc() lies for external functions.
|
// 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 := ""
|
suffix := ""
|
||||||
if caller != nil {
|
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 {
|
if fn.Enclosing == nil {
|
||||||
name := fn.FullName()
|
name := fn.String()
|
||||||
if ext := externals[name]; ext != nil {
|
if ext := externals[name]; ext != nil {
|
||||||
if i.mode&EnableTracing != 0 {
|
if i.mode&EnableTracing != 0 {
|
||||||
fmt.Fprintln(os.Stderr, "\t(external)")
|
fmt.Fprintln(os.Stderr, "\t(external)")
|
||||||
|
|
|
@ -68,7 +68,7 @@ func (v *Builtin) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Function) String() string {
|
func (v *Function) String() string {
|
||||||
return v.FullName()
|
return v.fullName(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullName returns g's package-qualified name.
|
// FullName returns g's package-qualified name.
|
||||||
|
|
|
@ -443,7 +443,7 @@ func boundMethodWrapper(meth *Function) *Function {
|
||||||
}
|
}
|
||||||
s := meth.Signature
|
s := meth.Signature
|
||||||
fn = &Function{
|
fn = &Function{
|
||||||
name: "bound$" + meth.FullName(),
|
name: "bound$" + meth.String(),
|
||||||
Signature: types.NewSignature(nil, s.Params(), s.Results(), s.IsVariadic()), // drop recv
|
Signature: types.NewSignature(nil, s.Params(), s.Results(), s.IsVariadic()), // drop recv
|
||||||
Prog: prog,
|
Prog: prog,
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ func TestEnclosingFunction(t *testing.T) {
|
||||||
name := "(none)"
|
name := "(none)"
|
||||||
fn := ssa.EnclosingFunction(pkg, path)
|
fn := ssa.EnclosingFunction(pkg, path)
|
||||||
if fn != nil {
|
if fn != nil {
|
||||||
name = fn.FullName()
|
name = fn.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if name != test.fn {
|
if name != test.fn {
|
||||||
|
|
|
@ -1230,8 +1230,10 @@ func (c *CallCommon) Pos() token.Pos { return c.pos }
|
||||||
// Signature returns the signature of the called function.
|
// Signature returns the signature of the called function.
|
||||||
//
|
//
|
||||||
// For an "invoke"-mode call, the signature of the interface method is
|
// For an "invoke"-mode call, the signature of the interface method is
|
||||||
// returned; the receiver is represented by sig.Recv, not
|
// returned.
|
||||||
// sig.Params().At(0).
|
//
|
||||||
|
// 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 {
|
func (c *CallCommon) Signature() *types.Signature {
|
||||||
if c.Recv != nil {
|
if c.Recv != nil {
|
||||||
|
|
Loading…
Reference in New Issue