impc:ti:register-new-globalvar   scheme


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

Implementation

(define impc:ti:register-new-globalvar
  (lambda (globalvar-name type docstring)
    (if (impc:ti:globalvar-exists? globalvar-name)
        (impc:compiler:print-already-bound-error (string->symbol globalvar-name) (impc:ir:pretty-print-type (impc:ir:pointer-- (impc:ti:get-globalvar-type globalvar-name))))
        ;; check arg types
        (if (not (and (or (string? globalvar-name) (begin (println 'bad 'globalvar-name: globalvar-name) #f))
                      (or (list? type)
                          (integer? type)
                          (impc:ti:namedtype-exists? type)
                          (begin (println 'bad 'type: type) #f))
                      (or (string? docstring) (begin (println 'bad 'docstring: docstring) #f))))
            (impc:compiler:print-compiler-error "couldn't register new globalvar")
            (begin
              ;; add the bind-poly form to the AOT-header if we're precompiling
              (set! *impc:ti:globalvar-cache*
                    ;; the old llvm:get-global-variable-type returned
                    ;; an extra level of pointerness from the bind-val
                    ;; declaration (e.g. (bind-val mytype i64) would
                    ;; return type "i64*"), so we increment the
                    ;; "pointerlyness" by one level here to mimic this
                    ;; behaviour
                    (cons (cons globalvar-name (vector (impc:ir:pointer++ type) docstring))
                          *impc:ti:globalvar-cache*))
              (car *impc:ti:globalvar-cache*))))))


Back to Index