zcopy   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/base/base.xtm

Implementation

;; symbols need dedicated zcopy 
;; so need to override default
(bind-func zcopy:[Symbol*,Symbol*,mzone*,mzone*]*
  (lambda (x fromz toz)
    (if (llvm_ptr_in_zone fromz (cast x i8*))
        (begin (push_zone toz)
          (let ((obj (zalloc)))
            (begin 
              (tset! obj 0 (tref x 0)))
            (if (llvm_ptr_in_zone fromz (cast (tref x 1) i8*)) 
                (let ((newptr:i8* (zalloc (+ 1 (tref x 0)))))
                  (strcpy newptr (cast (tref x 1) i8*)) ; (+ (tref x 0) 1)) 
                  (tset! obj 1 newptr))
                (tset! obj 1 (tref x 1)))
            (pop_zone)
            obj))
        x)))


Back to Index

Similar Entries