Permalink
Browse files

!(a?b:c) ==> !a?c:b

  • Loading branch information...
mishoo committed Feb 3, 2011
1 parent 5954d87 commit 559540d8e60a244df9a04924ec2d2b3220cb77a4
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/squeeze.lisp
View
@@ -93,15 +93,17 @@
(:seq (_ two)
(boolean-expr two))))
-(defun negate (c)
+(defun negate (c &optional bool-context)
(flet ((not-c ()
`(:unary-prefix :! ,c)))
(or (ast-case c
(:unary-prefix (op expr)
- (when (and (eq op :!) (boolean-expr expr))
+ (when (and (eq op :!) (or bool-context (boolean-expr expr)))
expr))
(:seq (one two)
`(:seq ,one ,(negate two)))
+ (:conditional (cond left right)
+ `(:conditional ,(negate cond t) ,right ,left))
(:binary (op left right)
(case op
(:< `(:binary :>= ,left ,right))

0 comments on commit 559540d

Please sign in to comment.