Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
be5deb93
Commit
be5deb93
authored
Feb 12, 2013
by
Alan Donovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exp/ssa: omit Function's package name when printing intra-package references.
R=iant CC=golang-dev
https://golang.org/cl/7307105
parent
83da2014
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
src/pkg/exp/ssa/func.go
src/pkg/exp/ssa/func.go
+19
-5
src/pkg/exp/ssa/print.go
src/pkg/exp/ssa/print.go
+4
-7
src/pkg/exp/ssa/ssa.go
src/pkg/exp/ssa/ssa.go
+1
-1
No files found.
src/pkg/exp/ssa/func.go
View file @
be5deb93
...
...
@@ -344,6 +344,11 @@ func (f *Function) emit(instr Instruction) Value {
// "func@5.32" // an anonymous function
//
func
(
f
*
Function
)
FullName
()
string
{
return
f
.
fullName
(
nil
)
}
// Like FullName, but if from==f.Pkg, suppress package qualification.
func
(
f
*
Function
)
fullName
(
from
*
Package
)
string
{
// Anonymous?
if
f
.
Enclosing
!=
nil
{
return
f
.
Name_
...
...
@@ -353,11 +358,20 @@ func (f *Function) FullName() string {
// Synthetic?
if
f
.
Pkg
==
nil
{
var
recvType
types
.
Type
if
recv
!=
nil
{
recvType
=
recv
.
Type
// bridge method
}
else
{
recvType
=
f
.
Params
[
0
]
.
Type
()
// interface method thunk
}
// TODO(adonovan): print type package-qualified, if NamedType.
return
fmt
.
Sprintf
(
"(%s).%s"
,
recv
.
Type
,
f
.
Name_
)
// bridge method
return
fmt
.
Sprintf
(
"(%s).%s"
,
recvType
,
f
.
Name_
)
}
return
fmt
.
Sprintf
(
"(%s).%s"
,
f
.
Params
[
0
]
.
Type
(),
f
.
Name_
)
// interface method thunk
// "pkg." prefix for cross-package references only.
var
pkgQual
string
if
from
!=
f
.
Pkg
{
pkgQual
=
f
.
Pkg
.
ImportPath
+
"."
}
// Declared method?
...
...
@@ -366,11 +380,11 @@ func (f *Function) FullName() string {
if
isPointer
(
recv
.
Type
)
{
star
=
"*"
}
return
fmt
.
Sprintf
(
"(%s%s
.%s).%s"
,
star
,
f
.
Pkg
.
ImportPath
,
deref
(
recv
.
Type
),
f
.
Name_
)
return
fmt
.
Sprintf
(
"(%s%s
%s).%s"
,
star
,
pkgQual
,
deref
(
recv
.
Type
),
f
.
Name_
)
}
// Package-level function.
return
fmt
.
Sprintf
(
"%s.%s"
,
f
.
Pkg
.
ImportPath
,
f
.
Name_
)
return
pkgQual
+
f
.
Name_
}
// DumpTo prints to w a human readable "disassembly" of the SSA code of
...
...
src/pkg/exp/ssa/print.go
View file @
be5deb93
...
...
@@ -20,9 +20,9 @@ func (id Id) String() string {
}
// relName returns the name of v relative to i.
// In most cases, this is identical to v.Name(), but for
cross-package
//
references to Functions (including methods) and Globals, the
//
package-qualified FullName is used instead
.
// In most cases, this is identical to v.Name(), but for
references to
//
Functions (including methods) and Globals, the FullName is used
//
instead, explicitly package-qualified for cross-package references
.
//
func
relName
(
v
Value
,
i
Instruction
)
string
{
switch
v
:=
v
.
(
type
)
{
...
...
@@ -32,10 +32,7 @@ func relName(v Value, i Instruction) string {
}
return
v
.
FullName
()
case
*
Function
:
if
v
.
Pkg
==
nil
||
v
.
Pkg
==
i
.
Block
()
.
Func
.
Pkg
{
return
v
.
Name
()
}
return
v
.
FullName
()
return
v
.
fullName
(
i
.
Block
()
.
Func
.
Pkg
)
}
return
v
.
Name
()
}
...
...
src/pkg/exp/ssa/ssa.go
View file @
be5deb93
...
...
@@ -204,7 +204,7 @@ type Function struct {
Pos
token
.
Pos
// location of the definition
Enclosing
*
Function
// enclosing function if anon; nil if global
Pkg
*
Package
// enclosing package
; nil for some synthetic methods
Pkg
*
Package
// enclosing package
for Go source functions; otherwise nil
Prog
*
Program
// enclosing program
Params
[]
*
Parameter
FreeVars
[]
*
Capture
// free variables whose values must be supplied by closure
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment