Better types #15

Merged
alex-eg merged 27 commits from better-types into main 2025-10-30 16:05:44 +01:00
2 changed files with 24 additions and 3 deletions
Showing only changes of commit 59337f71ab - Show all commits

View File

@@ -145,9 +145,9 @@
(if (atom? type) (atom-to-fmt-c type) (if (atom? type) (atom-to-fmt-c type)
(flatten (flatten
(tree-map atom-to-fmt-c (tree-map atom-to-fmt-c
(fold-right append (list) (flatten
(list-join (reverse (list-split type '*)) (list-join (reverse (list-split type '*))
'(*))))))) '(*)))))))
(define (walk-fn-def form) (define (walk-fn-def form)
(match form (match form

View File

@@ -47,6 +47,27 @@
'(%fun void ((int) (%array float) (%array (struct what * const)))) '(%fun void ((int) (%array float) (%array (struct what * const))))
(walk-type '(fn ((int) (¤ float) (¤ (const * struct what))) void))) (walk-type '(fn ((int) (¤ float) (¤ (const * struct what))) void)))
(test
'(%array (%fun void ((int) (%array float) (%array (struct what * const)))))
(walk-type '(¤ (fn ((int) (¤ float) (¤ (const * struct what))) void))))
;; Type convert to C
(test
'(int)
(type-convert-to-c '(int)))
(test
'(* int)
(type-convert-to-c '(int *)))
(test
'(* const int)
(type-convert-to-c '(const int *)))
(test
'(const * const char)
(type-convert-to-c '(const char * const)))
;;; Variable defs ;;; Variable defs
(test (test
'(%var (%array float 8) a) '(%var (%array float 8) a)