Skip to content

Commit 8d52a6e

Browse files
committed
cmd/asm: allow methods implemented in assembly
1. allow methods implemented in assembly, identifier name support "main.(*SomeType).method" format 2. if the symbol starts with type··x, rewrite it as type·""·x fixes #4978
1 parent 4ebc67d commit 8d52a6e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/cmd/asm/internal/lex/lex.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,16 @@ func Make(token ScanToken, text string) Token {
107107
if token == scanner.Ident && strings.HasPrefix(text, "\u00B7") {
108108
text = `""` + text
109109
}
110-
// Substitute the substitutes for . and /.
110+
// If the symbol starts with type··x, rewrite it as type·""·x
111+
if token == scanner.Ident && strings.HasPrefix(text, "type\u00B7\u00B7") {
112+
text = "type\u00B7" + `""` + text[len("type\u00B7"):]
113+
}
114+
// Substitute the substitutes for '.', '/', '*', '(' and ')'.
111115
text = strings.Replace(text, "\u00B7", ".", -1)
112116
text = strings.Replace(text, "\u2215", "/", -1)
117+
text = strings.Replace(text, "\u2217", "*", -1)
118+
text = strings.Replace(text, "\uFF08", "(", -1)
119+
text = strings.Replace(text, "\uFF09", ")", -1)
113120
return Token{ScanToken: token, text: text}
114121
}
115122

src/cmd/asm/internal/lex/tokenizer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ func isIdentRune(ch rune, i int) bool {
6161
return true
6262
case '\u2215': // Represents the slash in runtime/debug.setGCPercent. U+2215 '∕' division slash
6363
return true
64+
case '\u2217': // Represents the asterisk in main.(*SomeType).method. U+2217 '∗' asterisk
65+
return true
66+
case '\uFF08': // Represents the left parentheses in main.(*SomeType).method. U+FF08 '(' left parentheses
67+
return true
68+
case '\uFF09': // Represents the right parentheses in main.(*SomeType).method. U+FF09 ')' right parentheses
69+
return true
6470
}
6571
// Digits are OK only after the first character.
6672
return i > 0 && unicode.IsDigit(ch)

0 commit comments

Comments
 (0)