call-as-xtlang   macro


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

Implementation

(define-macro (call-as-xtlang . expr)
  (if (not (impc:aot:currently-compiling?))
      (sys:with-quiet-compiler
       (begin
         (set! *impc:ir:sym-name-stack* '())
         (set! *impc:ir:ls_var* '())
         (set! *impc:ti:bound-lambdas* '())
         (set! *impc:ti:generic-type-mappings* '())
         (set! *impc:ti:nativef-generics-recurse-test* 0)
         (let ((type (impc:ti:get-expression-type (car (reverse expr)))))
           (eval `(bind-func xtlang_expression
                    (lambda ()
                      ,(if (equal? type -1)
                           `(let ((s:i8* (halloc 2)))
                              ,@expr
                              s)
                           `(letz ((res (begin ,@expr))
                                   (s:String* (toString res))
                                   (lgth (+ 1 (tref s 0)))
                                   (oldcs (tref s 1))
                                   (newcs:i8* (halloc lgth)))
                              (strcpy newcs oldcs)
                              newcs))))
                 (interaction-environment))
           (quote (string->atom (cptr->string (xtlang_expression)))))))))


Back to Index

Similar Entries