@@ -652,10 +652,44 @@ pub fn step(prim: Prim) -> Step {
652652 Prim :: BoolEq => const_step ! ( [ x: Bool , y: Bool ] => Const :: Bool ( x == y) ) ,
653653 Prim :: BoolNeq => const_step ! ( [ x: Bool , y: Bool ] => Const :: Bool ( x != y) ) ,
654654 Prim :: BoolNot => const_step ! ( [ x: Bool ] => Const :: Bool ( bool :: not( * x) ) ) ,
655- Prim :: BoolAnd => const_step ! ( [ x: Bool , y: Bool ] => Const :: Bool ( * x && * y) ) ,
656- Prim :: BoolOr => const_step ! ( [ x: Bool , y: Bool ] => Const :: Bool ( * x || * y) ) ,
657655 Prim :: BoolXor => const_step ! ( [ x: Bool , y: Bool ] => Const :: Bool ( * x ^ * y) ) ,
658656
657+ Prim :: BoolAnd => |env : & ElimEnv , spine : & [ Elim ] | match spine {
658+ [ Elim :: FunApp ( _, x) , Elim :: FunApp ( _, y) ] => {
659+ let x = env. force_lazy ( x) ;
660+ match x. as_ref ( ) {
661+ Value :: ConstLit ( Const :: Bool ( false ) ) => Some ( x) ,
662+ Value :: ConstLit ( Const :: Bool ( true ) ) => {
663+ let y = env. force_lazy ( y) ;
664+ match y. as_ref ( ) {
665+ Value :: ConstLit ( Const :: Bool ( _) ) => Some ( y) ,
666+ _ => None ,
667+ }
668+ }
669+ _ => None ,
670+ }
671+ }
672+ _ => None ,
673+ } ,
674+
675+ Prim :: BoolOr => |env : & ElimEnv , spine : & [ Elim ] | match spine {
676+ [ Elim :: FunApp ( _, x) , Elim :: FunApp ( _, y) ] => {
677+ let x = env. force_lazy ( x) ;
678+ match x. as_ref ( ) {
679+ Value :: ConstLit ( Const :: Bool ( true ) ) => Some ( x) ,
680+ Value :: ConstLit ( Const :: Bool ( false ) ) => {
681+ let y = env. force_lazy ( y) ;
682+ match y. as_ref ( ) {
683+ Value :: ConstLit ( Const :: Bool ( _) ) => Some ( y) ,
684+ _ => None ,
685+ }
686+ }
687+ _ => None ,
688+ }
689+ }
690+ _ => None ,
691+ } ,
692+
659693 Prim :: U8Eq => const_step ! ( [ x: U8 , y: U8 ] => Const :: Bool ( x == y) ) ,
660694 Prim :: U8Neq => const_step ! ( [ x: U8 , y: U8 ] => Const :: Bool ( x != y) ) ,
661695 Prim :: U8Gt => const_step ! ( [ x: U8 , y: U8 ] => Const :: Bool ( x > y) ) ,
0 commit comments