1
0
forked from alex-eg/sex

add type database and compile-time reflection

This commit is contained in:
2026-09-14 23:52:44 +03:00
parent c976378363
commit 1e435f7fdf
13 changed files with 425 additions and 14 deletions

View File

@@ -11,11 +11,23 @@
(define (cat sym-1 sym-2)
(string->symbol (cat-syms sym-1 sym-2)))
;;; The reader keeps `;' comments as (comment "...") forms so they can
;;; be re-emitted into the generated C. In a macro body a comment
;;; should be a call which does nothing, hence this one
(define (comment . _)
(void))
(define (register-macro name arglist body)
(put! name 'sex-macro
`(lambda ,arglist
;; A macro body is ordinary Scheme, evaluated at compile
;; time. It gets `cat' for building names, and read access to
;; the type database
(import scheme
(only sex-macros cat))
(scheme base)
(only sex-macros cat comment)
(only types get-type-info get-fields get-underlying-type
type-match map-fields))
,@body)))
(define (get-macro name)