[gambit ffi in library code. atsmyles@verizon.net**20110122182423 Ignore-this: 7a35809ecbe0213bf5b7005edf9dd635 This is still a work in progress. FFI code still needs to be set in native-files. ] hunk ./compile 13 -(define encore-files (list "primitives.scm")) +(define encore-files (list "primitives.scm" "gambit-macros.scm")) hunk ./expander.scm 180 +(define ex:primitive-macro-library #f) hunk ./expander.scm 2370 - + ;registers primitive macros from underlying implementation. Theses macros are copied by the expander as is. + (define (primitive-macro-library name macros) + (ex:make-library name + ;; envs + (lambda () '()) + ;; exports + (map (lambda (macro) + (cons macro (make-binding 'macro macro '(0) #f '()))) + macros) + ;; imported-libraries + '() + ;; builds + '() + ;; visit + (lambda () + (for-each (lambda (macro) + (register-macro! macro (make-expander (lambda (exp) (syntax->datum exp))))) + macros) + (values)) + ;; invoke + (lambda () (values)) + ;; build + 'system)) + hunk ./expander.scm 2464 - + (set! ex:primitive-macro-library primitive-macro-library) + hunk ./primitives.scm 165 - (write-file (cons library-declarations (ex:expand-r6rs-sequence (list library))) file) - (compile-files-to-c file))) + ;can't get this to work for some reason. This code is to re-write special forms while evaling the library code since it needs to be evaled incase of other libraries. + ;in practice this should not cause a problem with non c-* functions. + (with-exception-catcher + (lambda (e) + (cond ((and (expression-parsing-exception? e) (eq? (expression-parsing-exception-kind e) 'unsupported-special-form)) + (display-exception e) + (pp (##source-code (expression-parsing-exception-source e))) + (let* ( (src (##vector-copy (expression-parsing-exception-source e))) + (new-src (##vector-set! src 1 (list 'list "NAF")))) + (pp new-src) + (pp (##source-code new-src)) + (##comp-app ##interaction-cte new-src #f))) ;(##comp-cst #f (##make-source #!void #f) #f)) ;(##comp-quote #f (##sourcify `(##quote ,(##desourcify (expression-parsing-exception-source e))) #f) #f)) + (else (display-exception e)))) + (lambda () + (let ((expanded (ex:expand-r6rs-sequence (list library)))) + (write-file (cons library-declarations expanded) file)))) + (compile-files-to-c file)))