impc:ir:compiler:heap-alloc-without-size   scheme


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

Implementation

(define impc:ir:compiler:heap-alloc-without-size
  (lambda (ast types hint?)
    (let* ((os (make-string 0)))
      (let* ;;((t (impc:ir:convert-from-pretty-types (cadr ast))))
          ((t (impc:ir:pointer-- (car hint?))))
        (emit  (impc:ir:gname "dat" "i8*") " = call i8* @malloc(" *impc:ir:size_t_str* " " (number->string (impc:ir:get-type-size t)) ")\n" os)
        (emit "call i8* @memset(i8* " (car (impc:ir:gname "dat")) ", i32 0, " *impc:ir:size_t_str* " " (number->string (impc:ir:get-type-size t)) ")\n" os)
        (emit (impc:ir:gname "val" (string-append (impc:ir:get-type-str t) "*"))
              " = bitcast i8* " (car (impc:ir:gname "dat"))
              " to " (impc:ir:get-type-str t) "*\n" os)
        (impc:ir:strip-space os)))))


Back to Index