forked from gopherjs/gopherjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:gopherjs/gopherjs into dceIntegra…
…tionTests
- Loading branch information
Showing
5 changed files
with
130 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dce | ||
|
||
import ( | ||
"go/types" | ||
|
||
"github.com/gopherjs/gopherjs/compiler/typesutil" | ||
) | ||
|
||
// getFilters determines the DCE filters for the given object. | ||
// This will return an object filter and optionally return a method filter. | ||
func getFilters(o types.Object) (objectFilter, methodFilter string) { | ||
importPath := o.Pkg().Path() | ||
if typesutil.IsMethod(o) { | ||
recv := typesutil.RecvType(o.Type().(*types.Signature)).Obj() | ||
objectFilter = importPath + `.` + recv.Name() | ||
if !o.Exported() { | ||
methodFilter = importPath + `.` + o.Name() + `~` | ||
} | ||
} else { | ||
objectFilter = importPath + `.` + o.Name() | ||
} | ||
return | ||
} | ||
|
||
// getDepFilter returns the filter for the given object to be used as a dependency. | ||
func getDepFilter(o types.Object) string { | ||
qualifiedName := o.Pkg().Path() + "." + o.Name() | ||
if typesutil.IsMethod(o) { | ||
qualifiedName += "~" | ||
} | ||
return qualifiedName | ||
} |
Oops, something went wrong.