spell an array bound as an expression
It went to fmt-c unwalked, so a bound named CHUNK-AREA kept its dash while the same name in an expression became CHUNK_AREA. Fixes #50.
This commit is contained in:
@@ -316,7 +316,7 @@ forms, and what remains."
|
|||||||
(match form
|
(match form
|
||||||
(('¤ . array-type)
|
(('¤ . array-type)
|
||||||
(if (array-bound? form)
|
(if (array-bound? form)
|
||||||
`(%array ,(walk-type (array-element-type form)) ,(last array-type))
|
`(%array ,(walk-type (array-element-type form)) ,(walk-expr (last array-type)))
|
||||||
;; sugar for pointer... Do we really need it? Guess why not,
|
;; sugar for pointer... Do we really need it? Guess why not,
|
||||||
;; it's a strong semantic cue
|
;; it's a strong semantic cue
|
||||||
`(%array ,(walk-type (array-element-type form)))))
|
`(%array ,(walk-type (array-element-type form)))))
|
||||||
|
|||||||
@@ -678,6 +678,11 @@ compiles."
|
|||||||
(emits? "(define N 4) (struct s ((a (¤ char (* 2 N)))))" "char a[2 * N]"))
|
(emits? "(define N 4) (struct s ((a (¤ char (* 2 N)))))" "char a[2 * N]"))
|
||||||
(test-assert "an integer bound still works"
|
(test-assert "an integer bound still works"
|
||||||
(emits? "(struct s ((a (¤ int 4))))" "int a[4]"))
|
(emits? "(struct s ((a (¤ int 4))))" "int a[4]"))
|
||||||
|
;; ...and it is spelled the way the same name is in an expression
|
||||||
|
(test-assert "a bound's name is converted"
|
||||||
|
(emits? (in-fn "(var xs (¤ u16 CHUNK-AREA))") "u16 xs[CHUNK_AREA]"))
|
||||||
|
(test-assert "so is one inside an expression bound"
|
||||||
|
(emits? (in-fn "(var xs (¤ u16 (* 2 CHUNK-AREA)))") "u16 xs[2 * CHUNK_AREA]"))
|
||||||
;; a multi-word type is keywords all the way down, so a trailing
|
;; a multi-word type is keywords all the way down, so a trailing
|
||||||
;; keyword belongs to the type and leaves the array unsized
|
;; keyword belongs to the type and leaves the array unsized
|
||||||
(test-assert "a multi-word type is not a bound"
|
(test-assert "a multi-word type is not a bound"
|
||||||
|
|||||||
Reference in New Issue
Block a user