definec   macro


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmti.xtm

Implementation

(define-macro (definec symname poly . args)
  (let ((zone-size *impc:default-zone-size*))
    (if (number? (car args))
        (begin (set! zone-size (car args))
               (set! args (cdr args))))
    (let ((types (cdr (reverse args)))
          (expr (car (reverse args)))
          (aot_sexpr '()))
      (if (regex:match? (symbol->string symname) ":")
          (let ((sres (regex:type-split (symbol->string symname) ":")))
            (set! symname (string->symbol (car sres)))
            (set! types (cons (cons symname (string->symbol (cadr sres))) types))))
      ;; (print-full symname 'types: types 'e: expr 'args: args)
      `(let* ((newname (impc:ti:run ',symname
                                    '(let ((,symname ,expr)) ,symname)
                                    ,zone-size
                                    ,poly
                                    #f
                                    ,@(if (null? types)
                                          '()
                                          (map (lambda (k) (list 'quote k)) types)))))
         ;; (impc:ti:initialize-closure-with-new-zone (symbol->string ',symname)
         ;;                                           *impc:default-zone-size*)
         ;; (impc:ti:create-scheme-wrapper (symbol->string ',symname)))))))
         (impc:ti:initialize-closure-with-new-zone newname *impc:default-zone-size*)
         (impc:ti:create-scheme-wrapper newname)))))


Back to Index