diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-03-12 23:54:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-03-12 23:54:42 -0700 |
commit | d317297ce46d3ce070919afe0fa5846cc19ea729 (patch) | |
tree | 44c1556555e1513f4c8e56b05ec35a4c3a5761d4 | |
parent | c960bf4e9adf9dbb0946d23512c044af8a9604e4 (diff) | |
download | txr-d317297ce46d3ce070919afe0fa5846cc19ea729.tar.gz txr-d317297ce46d3ce070919afe0fa5846cc19ea729.tar.bz2 txr-d317297ce46d3ce070919afe0fa5846cc19ea729.zip |
asm: support gensym labels.
Remove restriction that labels are keywords; a compiler
cannot pollute the keyword space to generate labels.
We allow them to be uninterned symbols also.
* share/txr/stdlib/asm.tl (assembler parse-args, assembler
asm-one): Use is-label instead of keywordp.
(is-label): New function.
(op-label): Use is-label test.
-rw-r--r-- | share/txr/stdlib/asm.tl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/share/txr/stdlib/asm.tl b/share/txr/stdlib/asm.tl index 4871dd4f..be83a0e3 100644 --- a/share/txr/stdlib/asm.tl +++ b/share/txr/stdlib/asm.tl @@ -116,7 +116,7 @@ (when me.(immediate-fits-type arg type) arg)) (l (cond - ((keywordp arg) me.(lookup-label arg oc)) + ((is-label arg) me.(lookup-label arg oc)) ((integerp arg) arg))) (n (if (integerp arg) arg)) (o arg) @@ -142,7 +142,7 @@ (:method asm-one (me syntax) (let ((oc (cond - ((keywordp syntax) [%oc-hash% 'label]) + ((is-label syntax) [%oc-hash% 'label]) ((consp syntax) [%oc-hash% (car syntax)])))) (unless oc (error "assembler: invalid instruction ~s" syntax)) @@ -196,6 +196,11 @@ (set [%oc-hash% oc.symbol] oc) (set [%oc-hash% oc.code] oc)) +(defun is-label (obj) + (or (keywordp obj) + (and (symbolp obj) + (not (symbol-package obj))))) + (defun parse-operand (str) (cond ((r^$ #/t[0-9A-Fa-f][0-9A-Fa-f]?/ str) @@ -242,8 +247,8 @@ (defopcode op-label label nil (:method asm (me asm syntax) - (unless (keywordp syntax) - asm.(synerr "label must be keyword")) + (unless (is-label syntax) + asm.(synerr "label must be keyword or gensym")) asm.(define-label syntax)) (:method dis (me asm extension operand))) |