mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
compiler: refactor method names
This commit includes two changes:
* It makes unexported interface methods package-private, so that it's
not possible to type-assert on an unexported method in a different
package.
* It makes the globals used to identify interface methods defined
globals, so that they can (eventually) be left in the program for an
eventual non-LTO build mode.
This commit is contained in:
committed by
Ron Evans
parent
52d640967b
commit
f2e8d7112c
@@ -54,10 +54,14 @@ type signatureInfo struct {
|
||||
// methodName takes a method name like "func String()" and returns only the
|
||||
// name, which is "String" in this case.
|
||||
func (s *signatureInfo) methodName() string {
|
||||
if !strings.HasPrefix(s.name, "func ") {
|
||||
panic("signature must start with \"func \"")
|
||||
var methodName string
|
||||
if strings.HasPrefix(s.name, "reflect/methods.") {
|
||||
methodName = s.name[len("reflect/methods."):]
|
||||
} else if idx := strings.LastIndex(s.name, ".$methods."); idx >= 0 {
|
||||
methodName = s.name[idx+len(".$methods."):]
|
||||
} else {
|
||||
panic("could not find method name")
|
||||
}
|
||||
methodName := s.name[len("func "):]
|
||||
if openingParen := strings.IndexByte(methodName, '('); openingParen < 0 {
|
||||
panic("no opening paren in signature name")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user