impc:ir:get-type-size   scheme


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

Implementation

(define impc:ir:get-type-size
  (lambda (type)
    (if (string? type)
        ;; if this is a named type string
        (if (impc:ti:namedtype-exists? type)
            (if (impc:ir:pointer? type)
                (/ (sys:pointer-size) 8) ;; in bytes not bits
                (impc:ir:get-type-size (impc:ti:get-namedtype-type type)))
            (impc:ir:get-type-size (impc:ir:get-type-from-str type)))
        (let ((t (impc:ir:str-list-check type)))
          (if (impc:ir:pointer? t) (/ (sys:pointer-size) 8) ;; in bytes not bits
              (cond ((member t (list *impc:ir:fp64* *impc:ir:si64* *impc:ir:ui64*)) 8) ; 8 byte stuff
                    ((member t (list *impc:ir:fp32* *impc:ir:si32* *impc:ir:ui32*)) 4) ; 4 byte stuff
                    ((member t (list *impc:ir:si16* *impc:ir:ui16*)) 2) ; 2 byte stuff
                    ((member t (list *impc:ir:char* *impc:ir:si8* *impc:ir:ui8* *impc:ir:i1*)) 1) ; 1 bytes stuff
                    ((= t *impc:ir:closure*) (* (impc:ir:get-type-size "i8*") 3))
                    ((= t *impc:ir:array*) (* (impc:ir:get-type-size (caddr type)) (cadr type)))
                    ((= t *impc:ir:vector*) (* (impc:ir:get-type-size (caddr type)) (cadr type)))
                    ((= t *impc:ir:tuple*)
                     (impc:ir:get-tuple-type-size type)
                     ;; (llvm:get-struct-size (impc:ir:get-type-str type))
                     )
                    (else (impc:compiler:print-bad-type-error type "bad type in get-size"))))))))


Back to Index