Skip to content

cmd/asm: allow methods implemented in assembly #25274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cmd/asm/internal/lex/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,16 @@ func Make(token ScanToken, text string) Token {
if token == scanner.Ident && strings.HasPrefix(text, "\u00B7") {
text = `""` + text
}
// Substitute the substitutes for . and /.
// If the symbol starts with type··x, rewrite it as type·""·x
if token == scanner.Ident && strings.HasPrefix(text, "type\u00B7\u00B7") {
text = "type\u00B7" + `""` + text[len("type\u00B7"):]
}
// Substitute the substitutes for '.', '/', '*', '(' and ')'.
text = strings.Replace(text, "\u00B7", ".", -1)
text = strings.Replace(text, "\u2215", "/", -1)
text = strings.Replace(text, "\u2217", "*", -1)
text = strings.Replace(text, "\uFF08", "(", -1)
text = strings.Replace(text, "\uFF09", ")", -1)
return Token{ScanToken: token, text: text}
}

Expand Down
6 changes: 6 additions & 0 deletions src/cmd/asm/internal/lex/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ func isIdentRune(ch rune, i int) bool {
return true
case '\u2215': // Represents the slash in runtime/debug.setGCPercent. U+2215 '∕' division slash
return true
case '\u2217': // Represents the asterisk in main.(*SomeType).method. U+2217 '∗' asterisk
return true
case '\uFF08': // Represents the left parentheses in main.(*SomeType).method. U+FF08 '(' left parentheses
return true
case '\uFF09': // Represents the right parentheses in main.(*SomeType).method. U+FF09 ')' right parentheses
return true
}
// Digits are OK only after the first character.
return i > 0 && unicode.IsDigit(ch)
Expand Down