impc:ti:compile-type-dataconstructors   scheme


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

Implementation

(define impc:ti:compile-type-dataconstructors
  (lambda (name type generic printer? copy? constructor?)
    (if (or (not (string? type)) ;; if not already a pretty type
            (regex:match? type "^\\s*{"))
        (set! type (impc:ir:pretty-print-type type)))
    ;; (println 'DataConstructor: 'name: name 'type type 'gen generic 'print: printer? 'const: constructor?)
    ;; (println 'impc:ti:compile-type-dataconstructors name type generic)
    (let* ((tsplit (car (regex:type-split (symbol->string name) "_poly_")))
           (a (map (lambda (x)
                     (if (and (string=? tsplit (impc:ir:get-base-type x))
                              (= 1 (impc:ir:get-ptr-depth x)))
                         (string-append (symbol->string name) "*")
                         x))
                   (impc:ir:get-pretty-tuple-arg-strings type)))
           (arglst1 (make-list-with-proc (length a) (lambda (i) (string->symbol (string-append "arg_" (atom->string i))))))
           (arglst2 (range (length a)))
           (namestr (symbol->string name))
           ;;(namestrup (impc:ti:word-upcase (symbol->string name)))
           ;;(namestrdown (impc:ti:word-downcase (symbol->string name)))
           (ctype (string-append "["
                                 (if generic
                                     ;(apply string-append namestr ":" type "*"
                                     (apply string-append namestr
                                            "{"
                                            (string-join
                                             (map (lambda (x) (symbol->string x))
                                                  (impc:ti:gather-all-gvars (impc:ir:get-type-from-pretty-str type)))
                                             ",")
                                            "}*"


Back to Index