impc:ir:compiler:set!   scheme


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

Implementation

(define impc:ir:compiler:set!
  (lambda (ast types)
    (let* ((os (make-string 0))
           (global? (impc:ti:globalvar-exists? (symbol->string (cadr ast)))) ;; are we are setting a global variable?
           (gtype (if global? (impc:ir:pointer-- (impc:ti:get-globalvar-type (symbol->string (cadr ast)))) #f))
           (t (if global? gtype
                  (if (assoc-strcmp (cadr ast) types)
                      (cdr (assoc-strcmp (cadr ast) types))
                      #f)))
           (s2 (if t
                   (impc:ir:compiler (caddr ast) types t)
                   (impc:ir:compiler (caddr ast) types)))
           (vv (impc:ir:gname))
           (type (impc:ir:get-type-from-str (cadr vv))))
      (emit "; do set!\n" os)
      (emit s2 os)
      (if global? ;; (impc:ti:globalvar-exists? (symbol->string (cadr ast))) ;; are we are setting a global variable?
          (emit (string-append "store " (cadr vv) " " (car vv) ", " (cadr vv) "* @"
                               (symbol->string (cadr ast)) "\n") os)
          (if (member (cadr ast) *impc:ir:sym-name-stack*)
              (emit (string-append "store " (cadr vv) " " (car vv) ", " (cadr vv) "* %"
                                   (symbol->string (cadr ast)) "Ptr\n") os)
              (impc:compiler:print-missing-identifier-error (cadr ast) 'variable)))
      ;; ir:gname should be vv
      (impc:ir:strip-space os))))


Back to Index

Similar Entries