This commit is contained in:
@@ -71,6 +71,18 @@
|
||||
(list)
|
||||
raw-forms)))
|
||||
|
||||
(define (public-fn-interface form)
|
||||
;; (pub fn name args ret . body) -> prototype, keeping a docstring so
|
||||
;; the importer can emit it above the declaration
|
||||
(let ((header (take form 5)))
|
||||
(let loop ((body (drop form 5)))
|
||||
(cond
|
||||
((null? body) header)
|
||||
((and (pair? (car body)) (eq? (caar body) 'comment))
|
||||
(loop (cdr body)))
|
||||
((string? (car body)) (append header (list (car body))))
|
||||
(else header)))))
|
||||
|
||||
;;; TODO: use semen facilities to analyze modules
|
||||
(define (process-public-interface-form form acc)
|
||||
(case (car form)
|
||||
@@ -79,7 +91,7 @@
|
||||
;; A function is reduced to a prototype and keeps its `pub', so
|
||||
;; the importing unit declares it with external linkage
|
||||
((fn)
|
||||
(cons (copy-form-source! form (take form 5)) acc))
|
||||
(cons (copy-form-source! form (public-fn-interface form)) acc))
|
||||
;; A variable becomes an `extern' declaration
|
||||
((var)
|
||||
(cons (copy-form-source! form (cons 'extern (take (cdr form) 3))) acc))
|
||||
|
||||
Reference in New Issue
Block a user