Skip to content
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

Improve converted names for arithmetic operators #156

Open
pdarragh opened this issue Dec 16, 2023 · 0 comments
Open

Improve converted names for arithmetic operators #156

pdarragh opened this issue Dec 16, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@pdarragh
Copy link
Contributor

If symbol->label is used on names like +, you end up with label___12345, which is very unhelpful. Maybe we could incorporate special-case names for certain common symbols, depending on what the nasm specification allows.

www/langs/a86/ast.rkt

Lines 400 to 421 in 7f55e4f

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Symbol to Label
;; Symbol -> Label
;; Produce a symbol that is a valid Nasm label
;; Guarantees that (eq? s1 s2) <=> (eq? (symbol->label s1) (symbol->label s1))
(provide symbol->label)
(define (symbol->label s)
(string->symbol
(string-append
"label_"
(list->string
(map (λ (c)
(if (or (char<=? #\a c #\z)
(char<=? #\A c #\Z)
(char<=? #\0 c #\9)
(memq c '(#\_ #\$ #\# #\@ #\~ #\. #\?)))
c
#\_))
(string->list (symbol->string s))))
"_"
(number->string (eq-hash-code s) 16))))

@pdarragh pdarragh added the enhancement New feature or request label Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant