(push x comp-limple))
(defun comp-emit-set-call (call)
- "Emit CALL assigning the result the the current slot frame.."
+ "Emit CALL assigning the result the the current slot frame.
+If the calle function is known to have a return type propagate it."
(cl-assert call)
(setf (comp-slot)
(make-comp-mvar :slot (comp-sp)
- :type (alist-get (cadr call)
- comp-known-ret-types)))
+ :type (when (> comp-speed 0)
+ (alist-get (cadr call)
+ comp-known-ret-types))))
(comp-emit (list 'set (comp-slot) call)))
(defun comp-push-call (call)
"Limplify LAP instruction INST accumulating in `comp-limple'."
(let ((op (car inst)))
(pcase op
+ ('byte-discard
+ (comp-pop 1))
('byte-dup
(comp-push-slot-n (comp-sp)))
('byte-varref
('byte-plus
(comp-pop 1)
(comp-emit-set-call `(callref Fplus 2 ,(comp-sp))))
+ ('byte-aref
+ (comp-pop 1)
+ (comp-emit-set-call `(call Faref
+ ,(comp-slot)
+ ,(comp-slot-next))))
+ ('byte-aset
+ (comp-pop 2)
+ (comp-emit-set-call `(call Faset
+ ,(comp-slot)
+ ,(comp-slot-next)
+ ,(comp-slot-n (+ 2 (comp-sp))))))
('byte-cons
(comp-pop 1)
(comp-emit-set-call `(call Fcons ,(comp-slot) ,(comp-slot-next))))
(should (= (comp-tests-length-f) 3)))
-;; (ert-deftest comp-tests-aref-aset ()
-;; "Testing aref and aset."
-;; (defun comp-tests-aref-aset-f ()
-;; (let ((vec [1 2 3]))
-;; (aset vec 2 100)
-;; (aref vec 2)))
-;; (native-compile #'comp-tests-aref-aset-f)
-
-;; (should (= (comp-tests-aref-aset-f) 100)))
+(ert-deftest comp-tests-aref-aset ()
+ "Testing aref and aset."
+ (defun comp-tests-aref-aset-f ()
+ (let ((vec [1 2 3]))
+ (aset vec 2 100)
+ (aref vec 2)))
+ (native-compile #'comp-tests-aref-aset-f)
+
+ (should (= (comp-tests-aref-aset-f) 100)))
;; (ert-deftest comp-tests-symbol-value ()
;; "Testing aref and aset."