From d4e15b648f503c4bd5208f4cef7f888dfca7c398 Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Fri, 28 Nov 2008 15:54:51 +0100
Subject: [PATCH] Translate diese and nor into boolred in the Inline module.

---
 src/inline.ml  | 34 +++++++++++++++++++++++++++++++++-
 src/licDump.ml |  8 ++++----
 src/split.ml   |  6 +++---
 3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/src/inline.ml b/src/inline.ml
index 64495b1a..e6761c12 100644
--- a/src/inline.ml
+++ b/src/inline.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 28/11/2008 (at 10:28) by Erwan Jahier> *)
+(** Time-stamp: <modified the 28/11/2008 (at 15:51) by Erwan Jahier> *)
 
 
 open Lxm
@@ -208,6 +208,38 @@ let rec (inline_eq: Eff.local_env ->
             in
               (List.rev_append neqs eqs, List.append acc_vars locs)
                 
+        | CallByPosEff({src=lxm_ve;it=Eff.Predef(Predef.DIESE_n,_)}, OperEff args) ->
+            (* a diese is a particular kind of boolred:
+               #(A,...,an) = boolred(1,1,n)([a1,...,an])
+            *)
+            let n = List.length args in
+            let sargs = [ConstStaticArgEff(Ident.of_string "i",Int_const_eff 1);
+                         ConstStaticArgEff(Ident.of_string "j",Int_const_eff 1);
+                         ConstStaticArgEff(Ident.of_string "k",Int_const_eff n)
+                        ] 
+            in
+            let boolred_op = Eff.Predef(Predef.BoolRed,sargs) in
+            let arg = CallByPosEff({src=lxm_ve;it=ARRAY args}, OperEff []) in 
+            let rhs = CallByPosEff({src=lxm_ve;it=boolred_op}, OperEff [arg])  in
+            let eq = { src = lxm_eq ; it = (lhs, rhs) } in
+
+              inline_eq node_env id_solver (eqs, locs) eq
+        | CallByPosEff({src=lxm_ve;it=Eff.Predef(Predef.NOR_n,_)}, OperEff args) ->
+            (* a nor is a particular kind of boolred too:
+               #(A,...,an) = boolred(0,0,n)([a1,...,an])
+            *)
+            let n = List.length args in
+            let sargs = [ConstStaticArgEff(Ident.of_string "i",Int_const_eff 0);
+                         ConstStaticArgEff(Ident.of_string "j",Int_const_eff 0);
+                         ConstStaticArgEff(Ident.of_string "k",Int_const_eff n)
+                        ] 
+            in
+            let boolred_op = Eff.Predef(Predef.BoolRed,sargs) in
+            let arg = CallByPosEff({src=lxm_ve;it=ARRAY args}, OperEff []) in 
+            let rhs = CallByPosEff({src=lxm_ve;it=boolred_op}, OperEff [arg])  in
+            let eq = { src = lxm_eq ; it = (lhs, rhs) } in
+              inline_eq node_env id_solver (eqs, locs) eq
+
         | CallByPosEff({src=lxm_ve;it=Eff.Predef(Predef.BoolRed,sargs)}, OperEff args) -> 
             (* Given 
                - 3 integers i, j, k
diff --git a/src/licDump.ml b/src/licDump.ml
index 4d726e6d..162ecb7c 100644
--- a/src/licDump.ml
+++ b/src/licDump.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 26/11/2008 (at 11:15) by Erwan Jahier> *)
+(** Time-stamp: <modified the 28/11/2008 (at 15:17) by Erwan Jahier> *)
 
 open Printf
 open Lxm
@@ -171,12 +171,12 @@ and string_of_type_eff = function
     
     Indeed instead of printing:
 
-    node toto(x: int ^ 4) ... 
+       node toto(x: int ^ 4) ... 
 
     we want to print something like :
 
-    type int4 = int ^ 4;
-    node toto(x: int4) ... 
+       type int4 = int ^ 4;
+       node toto(x: int4) ... 
     
     That may occur only for array actually.
 
diff --git a/src/split.ml b/src/split.ml
index 9af3533a..350740a6 100644
--- a/src/split.ml
+++ b/src/split.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 27/11/2008 (at 10:16) by Erwan Jahier> *)
+(** Time-stamp: <modified the 28/11/2008 (at 15:20) by Erwan Jahier> *)
 
 
 open Lxm
@@ -195,7 +195,7 @@ and (split_val_exp : bool -> Eff.local_env -> Eff.val_exp -> Eff.val_exp * split
                   let rhs = CallByPosEff(by_pos_op_eff, OperEff vel) in
                     rhs, (eql, vl)
                   
-              | Eff.ARRAY vel ->  
+              | Eff.ARRAY vel ->
                   let vel, (eql, vl) = split_val_exp_list false node_env vel in
                   let by_pos_op_eff = Lxm.flagit (Eff.ARRAY(vel)) lxm in
                   let rhs = CallByPosEff(by_pos_op_eff, OperEff []) in
@@ -205,7 +205,7 @@ and (split_val_exp : bool -> Eff.local_env -> Eff.val_exp -> Eff.val_exp * split
                   let rhs = CallByPosEff(by_pos_op_eff, OperEff vel) in
                     rhs, (eql, vl)
           in
-            if top_level || by_pos_op_eff.it = TUPLE then 
+           if top_level || by_pos_op_eff.it = TUPLE then 
               rhs, (eql, vl) 
             else
               (* create the var for the current call *)
-- 
GitLab