bind-data-type-constructor   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/base/adt.xtm

Implementation

(define (bind-data-type-constructor n name)
  (let* ((type (impc:ir:get-type-from-pretty-str (symbol->string name)))
         (gentypes (if (and (list? type)
                            (= (length type) 4))
                       (cdddr type)
                       '())))
    `(bind-func ,(string->symbol
                  (string-append (symbol->string n) "_Make:["
                                 (symbol->string name) "*,i64,i8*]*"))
       (lambda (a0 a1)
         (let ((obj (alloc 2)))
           ,(if (null? gentypes)
                `(tfill! obj a0 a1)
                `(tfill! obj a0 a1 ,@(map (lambda (t) `(convert null)) gentypes)))
           obj)))))


Back to Index