From d1699c1daac94729f4c9de5ebbdcca94eddeecac Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Thu, 7 Feb 2013 09:57:47 +0100
Subject: [PATCH] Remove the dependence on Global from Lic.

Indeed, part of licDump was done in lic, but that part should
not depend in the compil option.
---
 src/lic.ml         | 14 ++------
 src/licDump.ml     | 83 ++++++++++++++++++++++++++++++++++++++++++----
 src/unifyClock.mli |  2 +-
 test/lus2lic.sum   |  2 +-
 test/lus2lic.time  |  4 +--
 todo.org           |  9 -----
 todo.org_archive   | 27 +++++++++++++++
 7 files changed, 109 insertions(+), 32 deletions(-)

diff --git a/src/lic.ml b/src/lic.ml
index 29b43281..99ca2cca 100644
--- a/src/lic.ml
+++ b/src/lic.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2013 (at 17:55) by Erwan Jahier> *)
+(* Time-stamp: <modified the 07/02/2013 (at 09:48) by Erwan Jahier> *)
 
 (** Define the Data Structure representing Compiled programs. *)
 
@@ -645,17 +645,7 @@ let (clock_of_left: left -> clock) =
     snd (var_info_of_left left).var_clock_eff
 
 
-(* utils N.B peut etre different de LicDump ! *)
-let string_of_ident x =
-   if !Global.no_prefix
-(* XXX Ce genre de test n'a VRAIMENT rien a faire ici. Dans licDump, ok, mais 
-   pas ici.
-
-   Bon, ca oblige à dupliquer un peu le code, mais tant pis !
- *)
-   then Ident.no_pack_string_of_long x
-
-   else Ident.string_of_long2 x
+let string_of_ident = Ident.string_of_long2
 
 let rec string_of_type = function
   | Bool_type_eff -> "bool"
diff --git a/src/licDump.ml b/src/licDump.ml
index 4d69271f..f746982d 100644
--- a/src/licDump.ml
+++ b/src/licDump.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 06/02/2013 (at 17:56) by Erwan Jahier> *)
+(* Time-stamp: <modified the 07/02/2013 (at 09:57) by Erwan Jahier> *)
 
 open Errors
 open Printf
@@ -39,6 +39,10 @@ let rec is_a_tuple (e:Lic.val_exp) : bool =
     | _ -> false
 
 (******************************************************************************)    
+let string_of_ident x =
+   if !Global.no_prefix
+   then Ident.no_pack_string_of_long x
+   else Ident.string_of_long2 x
 
 let rec string_of_const_eff =
   function
@@ -151,7 +155,77 @@ and string_def_of_type_eff = function
 (* exported *)
 
 (* On prend le meme que Lic *)
-and string_of_type_eff = Lic.string_of_type
+and string_of_type_eff  = function
+  | Bool_type_eff -> "bool"
+  | Int_type_eff  -> "int"
+  | Real_type_eff -> "real"
+  | External_type_eff (name) -> (string_of_ident name)
+  | Abstract_type_eff (name, t) -> (string_of_ident name)
+  | Enum_type_eff (name, _) -> (string_of_ident name)
+  | Array_type_eff (ty, sz) ->
+    Printf.sprintf "%s^%d" (string_of_type_eff ty) sz
+  | Struct_type_eff (name, _) -> (string_of_ident name)
+  | TypeVar Any -> "any"
+  | (TypeVar AnyNum) -> "anynum"
+
+and string_of_type_list = function
+  | []  -> ""
+  | [x] -> string_of_type_eff x
+  | l   -> String.concat " * " (List.map string_of_type_eff l)
+
+and string_of_type_profile (i, o) =
+  (string_of_type_list i)^" -> "^(string_of_type_list o)
+
+and string_of_const = function
+  | Bool_const_eff true -> "true"
+  | Bool_const_eff false -> "false"
+  | Int_const_eff i -> (sprintf "%d" i)
+  | Real_const_eff r -> r
+  | Extern_const_eff (s,_) -> (string_of_ident s)
+  | Abstract_const_eff (s,t,v,_) -> (string_of_ident s)
+  | Enum_const_eff   (s,_) -> (string_of_ident s)
+  | Struct_const_eff (fl, t) -> 
+    let string_of_field (id, veff) =
+      (Ident.to_string id)^" = "^ (string_of_const veff)
+    in
+    Printf.sprintf "%s{%s}"
+      (string_of_type_eff t)
+      (String.concat "; " (List.map string_of_field fl))
+  | Array_const_eff (ctab, t) ->
+    Printf.sprintf "[%s]"
+      (String.concat ", " (List.map string_of_const ctab))
+  | Tuple_const_eff   cl ->
+    Printf.sprintf "(%s)"
+      (String.concat ", " (List.map string_of_const cl))
+
+and string_of_var_info x =
+  (AstCore.string_of_var_nature x.var_nature_eff) ^ " " ^
+    (Ident.to_string x.var_name_eff) ^ ":"^(string_of_type_eff x.var_type_eff)^
+    (string_of_clock (snd x.var_clock_eff)^"("^ (Ident.to_string (fst x.var_clock_eff)) ^","^
+    (string_of_int x.var_number_eff)^")")
+
+and string_of_var_list vl = String.concat " ; " (List.map string_of_var_info vl)
+
+and string_of_node_key = function
+  | (ik, []) ->
+    (string_of_ident ik)
+  | (ik, sargs)  -> Printf.sprintf "%s<<%s>>"
+    (string_of_ident ik)
+    (String.concat ", " (List.map string_of_static_arg sargs))
+
+and string_of_static_arg = function
+  | ConstStaticArgLic(id, ceff) -> Printf.sprintf "const %s = %s" id (string_of_const ceff)
+  | TypeStaticArgLic (id, teff) -> Printf.sprintf "type %s = %s" id (string_of_type_eff teff)
+  (* | NodeStaticArgLic (id, ((long,sargs), _, _), _) -> *)
+  | NodeStaticArgLic (id, nk) ->
+    Printf.sprintf "node %s = %s" id (string_of_node_key nk)
+
+and string_of_type_var tv = string_of_type_eff (TypeVar tv)
+and string_of_type_matches pm =
+  let sotm (tv,t) = Printf.sprintf "%s <- %s"
+    (string_of_type_var tv) (string_of_type_eff t)
+  in
+  String.concat ", " (List.map sotm pm)
 
 (* for printing recursive node *)
 and string_of_node_key_rec (nkey: node_key) = 
@@ -177,11 +251,6 @@ and string_of_node_key_def (nkey: node_key) =
     | (ik, salst) ->
       let astrings = List.map (string_of_static_arg) salst in
       sprintf "%s<<%s>>" (Ident.string_of_long ik) (String.concat ", " astrings)
-and string_of_static_arg (sa : Lic.static_arg) =
-  match sa with
-    | ConstStaticArgLic (id, ceff) -> sprintf "%s" (string_of_const_eff ceff)
-    | TypeStaticArgLic  (id, teff) -> sprintf "%s" (string_of_type_eff teff)
-    | NodeStaticArgLic  (id, nk) -> string_of_node_key_rec nk
 
 (* for inventing a name to parametrized nodes *)
 and static_arg2string_bis (sa : Lic.static_arg) =
diff --git a/src/unifyClock.mli b/src/unifyClock.mli
index 07afd0b4..44794cac 100644
--- a/src/unifyClock.mli
+++ b/src/unifyClock.mli
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 18/01/2013 (at 08:32) by Erwan Jahier> *)
+(* Time-stamp: <modified the 07/02/2013 (at 09:41) by Erwan Jahier> *)
 
 (** Sub module of EvalClock that defines clock-checking utilities.
 
diff --git a/test/lus2lic.sum b/test/lus2lic.sum
index 1ee9be6f..48e6204b 100644
--- a/test/lus2lic.sum
+++ b/test/lus2lic.sum
@@ -1,4 +1,4 @@
-Test Run By jahier on Wed Feb  6 18:01:32 2013
+Test Run By jahier on Thu Feb  7 09:53:07 2013
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic tests ===
diff --git a/test/lus2lic.time b/test/lus2lic.time
index 4ac89b10..76997001 100644
--- a/test/lus2lic.time
+++ b/test/lus2lic.time
@@ -1,2 +1,2 @@
-testcase ./lus2lic.tests/non-reg.exp completed in 23 seconds
-testcase ./lus2lic.tests/progression.exp completed in 1 seconds
+testcase ./lus2lic.tests/non-reg.exp completed in 24 seconds
+testcase ./lus2lic.tests/progression.exp completed in 0 seconds
diff --git a/todo.org b/todo.org
index c5ecf9b9..a7816e26 100644
--- a/todo.org
+++ b/todo.org
@@ -75,15 +75,6 @@ du with ?
 comment fait caml ?
   - State "TODO"       from ""           [2012-10-26 Fri 14:59]
 
-** TODO const_to_val_eff n'a vraiment rien à faire dans UnifyClock !!!
-
-   - State "TODO"       from ""           [2013-01-29 Tue 14:26]
-file:src/unifyClock.ml::271
-
-** TODO aucune fonction dans Lic.*_to_string ne devrait dependre des options de compil
-   - State "TODO"       from ""           [2013-02-01 Fri 17:54]
-cf le XXX  file:src/lic.ml::655
-
 
 * Languages issues
 ** TODO Verifier les boucles combinatoires meme quand on ne genere pas de ec
diff --git a/todo.org_archive b/todo.org_archive
index d014b851..d2b53f84 100644
--- a/todo.org_archive
+++ b/todo.org_archive
@@ -404,6 +404,33 @@ cf file:./src/lic.ml::206
 y virer !!
   - State "TODO"       from ""           [2012-10-26 Fri 14:59]
 
+* TODO const_to_val_eff n'a vraiment rien à faire dans UnifyClock !!!
+
+   - State "TODO"       from ""           [2013-01-29 Tue 14:26]
+  :PROPERTIES:
+  :ARCHIVE_TIME: 2013-02-07 Thu 09:42
+  :ARCHIVE_FILE: ~/lus2lic/todo.org
+  :ARCHIVE_OLPATH: Aesthetes issues
+  :ARCHIVE_CATEGORY: lv6
+  :ARCHIVE_TODO: TODO
+  :END:
+file:src/unifyClock.ml::271
+
+mouarf, pourquoi pas en fait.
+
+* TODO aucune fonction dans Lic.*_to_string ne devrait dependre des options de compil
+   - State "TODO"       from ""           [2013-02-01 Fri 17:54]
+  :PROPERTIES:
+  :ARCHIVE_TIME: 2013-02-07 Thu 09:54
+  :ARCHIVE_FILE: ~/lus2lic/todo.org
+  :ARCHIVE_OLPATH: Aesthetes issues
+  :ARCHIVE_CATEGORY: lv6
+  :ARCHIVE_TODO: TODO
+  :END:
+cf le XXX  file:src/lic.ml::655
+
+
+
 
 
 
-- 
GitLab