From 435cc5e43a178f132cbb48b623aaada107f3717d Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Wed, 3 Nov 2010 15:16:27 +0100
Subject: [PATCH] Add a --no-prefix option, so that prevent the code generator
 to prefix ident by the module name.

---
 src/global.ml         |  3 ++-
 src/ident.ml          |  3 ++-
 src/licDump.ml        | 11 ++++++-----
 src/main.ml           |  6 +++++-
 src/test/test.res.exp |  2 ++
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/global.ml b/src/global.ml
index e2736e0c..2a4ec53a 100644
--- a/src/global.ml
+++ b/src/global.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 19/08/2010 (at 16:57) by Erwan Jahier> *)
+(** Time-stamp: <modified the 03/11/2010 (at 14:12) by Erwan Jahier> *)
 
 (** Some global variables. *)
 
@@ -16,6 +16,7 @@ let one_op_per_equation = ref true
 let inline_iterator = ref false
 let lv4 = ref false
 let ec = ref false
+let no_prefix = ref false
 let expand_nodes = ref false
 let dont_expand_nodes : string list ref = ref []
 let expand_enums = ref false
diff --git a/src/ident.ml b/src/ident.ml
index 2b130028..907a2cff 100644
--- a/src/ident.ml
+++ b/src/ident.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 29/09/2010 (at 15:23) by Erwan Jahier> *)
+(** Time-stamp: <modified the 03/11/2010 (at 15:00) by Erwan Jahier> *)
 
 (* J'ai appele ca symbol (mais ca remplace le ident) :
 c'est juste une couche qui garantit l'unicite en memoire
@@ -125,6 +125,7 @@ let (long_of_string : string -> long) =
 let string_of_idref i = (
   match i.id_pack with
       Some p ->
+        if !Global.no_prefix then i.id_id else
         if !Global.ec then p^"__"^i.id_id else
         if !Global.lv4 then  (p^"__"^i.id_id) else
           (p^"::"^i.id_id)
diff --git a/src/licDump.ml b/src/licDump.ml
index 9973d582..b113b6ac 100644
--- a/src/licDump.ml
+++ b/src/licDump.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 29/09/2010 (at 16:46) by Erwan Jahier> *)
+(** Time-stamp: <modified the 03/11/2010 (at 15:00) by Erwan Jahier> *)
 
 open Printf
 open Lxm
@@ -7,9 +7,9 @@ open List
 
 (* XXX changer le nom de cette fonction *)
 let (dump_long : Ident.long -> string) = fun x -> 
-(*   if !Global.ec then *)
-(*     Ident.no_pack_string_of_long x *)
-(*   else  *)
+  if !Global.no_prefix then
+    Ident.no_pack_string_of_long x
+  else 
     Ident.string_of_long x
 (*   fun id ->  *)
 (*     let str = Ident.string_of_long id in *)
@@ -500,7 +500,8 @@ and string_of_val_exp_eff_core ve_core =
         (match by_name_op_eff.it with
 	   | STRUCT (pn,idref) -> prefix ^ (
                match Ident.pack_of_idref idref with
-                 | Some pn -> Ident.string_of_idref idref
+                 | Some pn -> 
+                     Ident.string_of_idref idref
                  | None -> 
                      let idref = Ident.make_idref pn (Ident.of_idref idref) in
                        Ident.string_of_idref idref
diff --git a/src/main.ml b/src/main.ml
index f2c1c8d5..f866f575 100644
--- a/src/main.ml
+++ b/src/main.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 19/08/2010 (at 17:44) by Erwan Jahier> *)
+(** Time-stamp: <modified the 03/11/2010 (at 14:15) by Erwan Jahier> *)
 
 (** Here follows a description of the different modules used by this lus2lic compiler.
 
@@ -147,6 +147,10 @@ let rec arg_list = [
     "\n\t Generate ec (actually just an alias for '-en -lv4')."
   );
 
+  ( "--no-prefix", Arg.Unit
+      (fun _ -> Global.no_prefix := true),
+    "\n\t Do not prefix variable names by their module (beware: variable names may clash with this option)."
+  );
 
   ("--test-lexer",Arg.Set Global.tlex,"Internal option used to test the lexer");
   ("-tlex",Arg.Set Global.tlex,"");
diff --git a/src/test/test.res.exp b/src/test/test.res.exp
index 7142b15d..cb5acc63 100644
--- a/src/test/test.res.exp
+++ b/src/test/test.res.exp
@@ -31,6 +31,8 @@ where [options] can be:
   --expanded-code 
   -ec 
 	 Generate ec (actually just an alias for '-en -lv4').
+  --no-prefix 
+	 Do not prefix variable names by their module (beware: variable names may clash with this option).
   --test-lexer Internal option used to test the lexer
   -tlex 
   --verbose-level <int>
-- 
GitLab