forked from alex-eg/sex
fix (¤ int N) expanding to int N a[]
Now only C type keywords will stay as a part of type, i.e. (¤ unsigned int) -> unsigned int a[] was and is okay
This commit is contained in:
@@ -292,6 +292,27 @@ forms, and what remains."
|
||||
(list)
|
||||
(walk-expr (drop form 3)))))) ; optional init expression
|
||||
|
||||
;;; `(¤ int N)' is N of int
|
||||
;;; `(¤ unsigned int)' is an unsized array of unsigned int
|
||||
;;; An aggregate is the exception -- `(¤ struct point)' ends in a tag,
|
||||
;;; which is part of the type and not a bound.
|
||||
|
||||
(define +c-type-words+
|
||||
'(void char short int long float double signed unsigned
|
||||
bool _Bool complex _Complex _Atomic const volatile restrict))
|
||||
|
||||
(define (array-bound? array-type)
|
||||
(and (> (length array-type) 1)
|
||||
(let ((bound (last array-type))
|
||||
(preceding (last (drop-right array-type 1))))
|
||||
(cond
|
||||
((not (symbol? bound)) #t)
|
||||
((memq bound +c-type-words+) #f)
|
||||
;; a tag always follows its keyword, so `(¤ * struct tt)' ends
|
||||
;; in a name belonging to the type
|
||||
((memq preceding '(struct union enum)) #f)
|
||||
(else #t)))))
|
||||
|
||||
(define (walk-type form)
|
||||
;; int -> int
|
||||
;; (const int) -> const int
|
||||
@@ -302,7 +323,7 @@ forms, and what remains."
|
||||
;; (fn ((int) (float)) void) -> (%fun void ((int) (float)))
|
||||
(match form
|
||||
(('¤ . array-type)
|
||||
(if (integer? (last array-type))
|
||||
(if (array-bound? array-type)
|
||||
;; sized array
|
||||
(let* ((type-list (drop-right array-type 1))
|
||||
(type (maybe-unwrap-type type-list))
|
||||
|
||||
Reference in New Issue
Block a user