forked from alex-eg/sex
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:
@@ -315,7 +315,7 @@ forms, and what remains."
|
||||
(match form
|
||||
(('¤ . array-type)
|
||||
(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,
|
||||
;; it's a strong semantic cue
|
||||
`(%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]"))
|
||||
(test-assert "an integer bound still works"
|
||||
(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
|
||||
;; keyword belongs to the type and leaves the array unsized
|
||||
(test-assert "a multi-word type is not a bound"
|
||||
|
||||
Reference in New Issue
Block a user