mescc: Implement unary plus operator.

* module/mescc/compile.scm (ast->type, expr->register,
try-expr->number):): Implement unary plus operator.
This commit is contained in:
Peter De Wachter 2018-10-16 20:40:38 +02:00 committed by Jan Nieuwenhuizen
parent d96730b892
commit ab57acfa01
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -209,6 +209,7 @@
((mod ,a ,b) (ast->type a info))
((mul ,a ,b) (ast->type a info))
((not ,a) (ast->type a info))
((pos ,a) (ast->type a info))
((neg ,a) (ast->type a info))
((eq ,a ,b) (ast->type a info))
((ge ,a ,b) (ast->type a info))
@ -1218,6 +1219,9 @@
(info (append-text info (wrap-as (as info 'r-negate)))))
(append-text info (wrap-as (as info 'test-r))))) ;; hmm, use ast->info?
((pos ,expr)
(expr->register expr info))
((neg ,expr)
(let* ((info (expr->register expr info))
(info (allocate-register info))
@ -1559,6 +1563,8 @@
(pmatch o
((fixed ,a) (cstring->int a))
((p-expr ,expr) (expr->number info expr))
((pos ,a)
(expr->number info a))
((neg ,a)
(- (expr->number info a)))
((add ,a ,b)