Browse files

[cl-backend] added simple arithmetic ops

  • Loading branch information...
1 parent 710ffd7 commit e735b8712fb217576a41299231bfb0f749cad55a @pmurias pmurias committed Feb 11, 2011
Showing with 14 additions and 1 deletion.
  1. +14 −1 cl-backend/backend.lisp
@@ -207,7 +207,7 @@
`(,(method-name (to-string method-name)) (FETCH ,(first args)) ,@(rest args))))
-(defun nam-obj_getbool (obj) (if (numberp obj) (not (equal obj 0)) t))
+(defun nam-obj_getbool (obj) (if (numberp obj) (not (equal obj 0)) obj))
(nam-op ternary (cond if then) `(if ,cond ,if ,then))
(defun nam-null (type) nil)
@@ -278,6 +278,19 @@
(defun p6-say (&rest things) (mapcar #'print-thing things) (format t "~%"))
(defun p6-concat (&rest things) (apply 'concatenate 'string (mapcar #'FETCH things)))
+; BIF
+(defun nam-bif_plus (a b) (+ (FETCH a) (FETCH b)))
+(defun nam-bif_minus (a b) (- (FETCH a) (FETCH b)))
+(defun nam-bif_mul (a b) (* (FETCH a) (FETCH b)))
+(defun nam-bif_numgt (a b) (> (FETCH a) (FETCH b)))
+(defun nam-bif_numeq (a b) (= (FETCH a) (FETCH b)))
(defun wrap-for-eval (compiled-unit)
`(let ((|&infix:<~>| #'p6-concat)
(|&say| #'p6-say)

0 comments on commit e735b87

Please sign in to comment.