Commit 0165be43 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Use big int (well, num actually) to represent integers internally and avoid overflows.

nb : this break luckyDrawC.
parent dc565b9b
......@@ -179,3 +179,7 @@ install/Makefile.lurette
install/autom4te.cache/
install/configure
i*86-linux*
cross-win32
doc/lutin-man/touch.tex
linux
mymakefile
......@@ -5,9 +5,9 @@ LIB=../../../$(HOSTTYPE)/lib
MAIN=rabbit
NEW_LURETTETOP=$(LTOP) --precision 2 \
--test-length 500 --thick-draw 1 \
--test-length 5000 --thick-draw 1 \
--draw-inside 0 --draw-edges 0 --draw-vertices 0 --draw-all-vertices \
--step-mode Inside --local-var --no-sim2chro --seed 3 \
--step-mode Inside --local-var --no-sim2chro \
--do-not-show-step
......@@ -22,7 +22,7 @@ clean:
test: rabbit.cmxs
rm -f test.rif0 .lurette_rc
$(NEW_LURETTETOP) -go --output test.rif0 \
$(NEW_LURETTETOP) -go --output test.rif0 \
-rp "sut:ocaml:rabbit.cmxs:" \
-rp 'env:lutin:rabbit.lut:-main:rabbit:-L:libm.so:-loc' && \
grep -v "lurette chronogram" test.rif0 | \
......
......@@ -8,4 +8,5 @@
#step 3
#outs -77141518 49170124 -177856997 -97639089 -94952018
#step 4
#end. Simulation ended normally)
#end. Simulation ended normally.
......@@ -8,4 +8,5 @@
#step 3
#outs t f t f t
#step 4
#end. Simulation ended normally)
#end. Simulation ended normally.
......@@ -8,4 +8,5 @@
#step 3
#outs f f f t t
#step 4
#end. Simulation ended normally)
#end. Simulation ended normally.
......@@ -8,4 +8,5 @@
#step 3
#outs f f f f f t
#step 4
#end. Simulation ended normally)
#end. Simulation ended normally.
......@@ -8,4 +8,5 @@
#step 3
#outs f t f t
#step 4
#end. Simulation ended normally)
#end. Simulation ended normally.
......@@ -2,4 +2,5 @@
#inputs "a":bool "b":bool
#outputs "c":bool
#step 1
0 1#end. Simulation ended normally)
0 1
#end. Simulation ended normally.
......@@ -120,4 +120,5 @@
#step 59
9 3 #outs f f
#step 60
0 9 #end. Simulation ended normally)
0 9
#end. Simulation ended normally.
......@@ -24,4 +24,5 @@
#step 11
#outs t f
#step 12
#end. Simulation ended normally)
#end. Simulation ended normally.
......@@ -12,4 +12,5 @@ F T #outs t f
#step 5
F F #outs t t
#step 6
F T #end. Simulation ended normally)
F T
#end. Simulation ended normally.
......@@ -8,14 +8,11 @@ LURETTETOP=$(LTOP) \
--do-not-show-step
# -rp "sut:ec_exe:heater_control.ec:" \
# -rp "sut:v4:heater_control.lus:heater_control" \
test:heater_control.ec heater_control$(EXE)
rm -f test.rif0 .lurette_rc
$(LURETTETOP) -go --output test.rif0 \
-rp "sut:ec_exe:heater_control.ec:" \
$(LURETTETOP) -go --output test.rif0 \
-rp "sut:ec_exe:./heater_control.ec:" \
-rp "oracle:v4:heater_control.lus:not_a_sauna" \
-rp "oracle:v6:heater_control.lus:not_a_fridge" \
-rp "env:lutin:env.lut:-m:main" && \
......
......@@ -308,7 +308,7 @@ let (get_output_int : lucky_process -> string -> int) =
match get_outval_val lp name with
| B(b) -> failwith ("luc4c: "^name^" is not a bool")
| N(F(f)) -> failwith ("luc4c: "^name^" is not a float")
| N(I(i)) -> Num.int_of_num i
| N(I(i)) -> Util.int_of_num i
let (get_output_float : lucky_process -> string -> float) =
......
......@@ -96,7 +96,7 @@ let (num2value : Value.t -> value) =
fun v ->
match v with
Value.B(x) -> B(x)
| Value.N(Value.I(x)) -> I(Num.int_of_num x)
| Value.N(Value.I(x)) -> I(Util.int_of_num x)
| Value.N(Value.F(x)) -> F(x)
......
......@@ -209,7 +209,7 @@ let rec (main_loop : int -> unit) =
let continue = Cmd.read (fun _ -> (input_line args.icr)) in
if continue then main_loop (cpt+1)
let lurettetop_quit _ =
let lurettetop_quit msg () =
let tmp_file = (Filename.temp_file "lurette" "") in
if Filename.dirname tmp_file = Filename.dirname args.tmp_dir
&& not (args.direct_mode)
......@@ -219,8 +219,8 @@ let lurettetop_quit _ =
Sys.remove tmp_file ;
Unix.chdir args.sut_dir;
output_string args.ecr "lurettetop: bye!\n";
flush args.ocr;
output_string args.ecr (msg^"\nlurettetop: bye!\n");
flush args.ecr;
ExtTools.quit_gnuplot ()
......@@ -233,7 +233,7 @@ let main_loop_start () =
if (res) <> 0 then (
Printf.fprintf args.ocr "\nLurette launched a process that failed (exit %d).\n \n" res;
flush args.ocr;
lurettetop_quit ();
lurettetop_quit "" ();
exit 2
);
)
......@@ -241,7 +241,7 @@ let main_loop_start () =
(
output_string args.ocr "Can not build lurette, sorry\n \n \n";
flush args.ocr;
lurettetop_quit ();
lurettetop_quit "" ();
exit 2
)
)
......@@ -249,12 +249,12 @@ let main_loop_start () =
let _ =
Sys.catch_break true;
at_exit lurettetop_quit;
at_exit (lurettetop_quit "break signal catched\n");
if args.verbose > 0 then output_string args.ocr "lurettetop: starting...\n";
flush args.ocr;
try main_loop_start ()
with e ->
print_string ("*** lurettetop: " ^ (Printexc.to_string e) ^ "\n");
flush stdout;
lurettetop_quit ()
lurettetop_quit "" ()
;;
......@@ -12,7 +12,7 @@ let bval b = if b then True else False
let exp_to_ezdl_arg e = (
match e with
| Numer (Ival i) -> Ezdl.Int_carg (Num.int_of_num i)
| Numer (Ival i) -> Ezdl.Int_carg (Util.int_of_num i)
| Numer (Fval f) -> Ezdl.Double_carg f
| Formu (True) -> Ezdl.Int_carg 1
| Formu (False) -> Ezdl.Int_carg 0
......@@ -49,22 +49,22 @@ let rec simp_num it = (
) with Not_found -> it
)
| Gcont (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Num.int_of_num i1, Num.int_of_num i2,Num.int_of_num i3) in
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.gauss_continue i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Gstop (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Num.int_of_num i1, Num.int_of_num i2,Num.int_of_num i3) in
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.gauss_stop i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Icont (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Num.int_of_num i1, Num.int_of_num i2,Num.int_of_num i3) in
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.interval_continue i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Istop (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Num.int_of_num i1, Num.int_of_num i2,Num.int_of_num i3) in
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.interval_stop i1 i2 i3 in
Ival (Num.num_of_int i)
)
......
......@@ -49,7 +49,7 @@ exception No_simp
let val2exp = function
| B true -> CoAlgExp.of_true
| B false -> CoAlgExp.of_false
| N (I i) -> CoAlgExp.of_ival (Num.int_of_num i)
| N (I i) -> CoAlgExp.of_ival (Util.int_of_num i)
| N (F f) -> CoAlgExp.of_rval f
......
......@@ -493,7 +493,7 @@ let try_compute_exp (it:t) data e = (
(** i.e. but must be int *)
let compute_int (it:t) data e = (
match (compute_exp it data e) with
| Value.N ( Value.I i) -> Num.int_of_num i
| Value.N ( Value.I i) -> Util.int_of_num i
| _ -> assert false
)
......
......@@ -529,7 +529,7 @@ let lut_get_wtl (zelut:t) (input:Var.env_in) (st:Prog.state) (ctrlst:Prog.ctrl_s
let we = lucky_numexp_of (compil_id2exp zelut) e in
Utils.time_C "treat_gtree (weight)";
let res = match we with
| Exp.Ival i -> Prog.V (Num.int_of_num i)
| Exp.Ival i -> Prog.V (Util.int_of_num i)
| _ -> Prog.compute_weight (Exp.Wexpr we) input st
in
(* let res = Prog.compute_weight (Exp.Wexpr we) input st in *)
......
......@@ -261,7 +261,7 @@ let to_exe oc infile mnode opt = (
let bg = LutExe.get_behavior_gen exe ins pres ctrl in
match bg () with
| LutExe.NoMoreBehavior -> (
Rif.write oc "# Simulation ended with uncaught Deadlock\n";
Rif.write oc "#end.\n# Simulation ended with uncaught Deadlock\n";
Rif.flush oc;
exit 2
)
......@@ -283,8 +283,8 @@ let to_exe oc infile mnode opt = (
if noo then Rif.write oc " #outs ";
Rif.write_outputs oc out_vars outs ;
if noo && MainArg.show_locals opt then (
Rif.write oc "\n#locs ";
Rif.write_outputs oc loc_vars locs
Rif.write oc "\n#locs ";
Rif.write_outputs oc loc_vars locs
);
Rif.write oc "\n";
Rif.flush oc;
......@@ -305,12 +305,12 @@ let to_exe oc infile mnode opt = (
)
)
| LutExe.Raise x -> (
Rif.write oc ("#end. Simulation ended with uncaught user exception \""^x^"\"\n");
Rif.write oc ("\n#end. Simulation ended with uncaught user exception \""^x^"\"\n");
Rif.flush oc;
exit 2
)
| LutExe.Vanish -> (
Rif.write oc "#end. Simulation ended normally)\n";
Rif.write oc "\n#end. Simulation ended normally.\n";
Rif.flush oc;
exit 0
)
......@@ -347,88 +347,112 @@ let to_exe oc infile mnode opt = (
)
let main () = (
(try
let opt = MainArg.parse Sys.argv in
let infile = MainArg.infile opt in
let mnode = MainArg.main_node opt in
let _ =
if (infile = []) then
if MainArg.see_all_options opt then
(MainArg.full_usage stderr opt; exit 0)
else
(
MainArg.usage stderr opt;
raise (Global_error "no input file")
)
in
let oc =
match (MainArg.riffile opt) with
| None -> stdout
| Some file -> open_out file
in
match MainArg.gen_mode opt with
| Simu ->
if (MainArg.test_exe opt)
then to_exe oc infile mnode opt
else to_simu oc infile mnode opt
| Cstubs -> (
Luc2c.option.Luc2c.output <- MainArg.outfile (opt) ;
Luc2c.option.Luc2c.seed <- (Some(MainArg.seed (opt)));
Luc2c.option.Luc2c.step_mode <- (
match (MainArg.step_mode (opt)) with
| Lucky.StepInside -> Luc2c.Inside
| Lucky.StepEdges -> Luc2c.Edges
| Lucky.StepVertices -> Luc2c.Vertices)
;
Luc2c.option.Luc2c.env <- (MainArg.infile(opt));
Luc2c.main ()
)
| GenLuc -> (
let mainprg = Parsers.read_lut infile in
let tlenv = CheckType.check_pack (MainArg.libs (opt)) mainprg in
(* type/binding check *)
if MainArg.test_lex opt then (
List.iter (Parsers.lexemize_lut) infile
) else if (MainArg.test_parse opt) then (
(* analyse syntaxique *)
SyntaxeDump.dump_pack mainprg;
) else if (MainArg.test_check opt) then (
CheckEnv.dbg_dump tlenv;
) else (
to_luc mainprg tlenv opt
)
let opt = MainArg.parse Sys.argv in
let oc =
match (MainArg.riffile opt) with
| None -> stdout
| Some file -> open_out file
in
(try
let infile = MainArg.infile opt in
let mnode = MainArg.main_node opt in
let _ =
if (infile = []) then
if MainArg.see_all_options opt then
(MainArg.full_usage stderr opt; exit 0)
else
(
MainArg.usage stderr opt;
raise (Global_error "no input file")
)
in
match MainArg.gen_mode opt with
| Simu ->
if (MainArg.test_exe opt)
then to_exe oc infile mnode opt
else to_simu oc infile mnode opt
| Cstubs -> (
Luc2c.option.Luc2c.output <- MainArg.outfile (opt) ;
Luc2c.option.Luc2c.seed <- (Some(MainArg.seed (opt)));
Luc2c.option.Luc2c.step_mode <- (
match (MainArg.step_mode (opt)) with
| Lucky.StepInside -> Luc2c.Inside
| Lucky.StepEdges -> Luc2c.Edges
| Lucky.StepVertices -> Luc2c.Vertices)
;
Luc2c.option.Luc2c.env <- (MainArg.infile(opt));
Luc2c.main ()
)
| GenLuc -> (
let mainprg = Parsers.read_lut infile in
let tlenv = CheckType.check_pack (MainArg.libs (opt)) mainprg in
(* type/binding check *)
if MainArg.test_lex opt then (
List.iter (Parsers.lexemize_lut) infile
) else if (MainArg.test_parse opt) then (
(* analyse syntaxique *)
SyntaxeDump.dump_pack mainprg;
) else if (MainArg.test_check opt) then (
CheckEnv.dbg_dump tlenv;
) else (
to_luc mainprg tlenv opt
)
)
with
| Rif_base.Bye
| Stop -> (
(* OK *)
Rif.write oc ("\n#end. \n");
Rif.flush oc;
)
with
| Rif_base.Bye
| Stop ->
(* OK *)
( )
| Sys_error(s) -> (
prerr_string (s^"\n") ; exit 1
)
| Sys_error(s) -> (
prerr_string (s^"\n") ;
Rif.write oc ("\n#end.\n# "^s^"\n");
Rif.flush oc;
exit 1
)
| Global_error s -> (
print_global_error s ; exit 1
)
| Parsing.Parse_error -> (
print_compile_error (Lexeme.last_made ()) "syntax error";
exit 1
)
| Compile_error(lxm,msg) -> (
print_compile_error lxm msg ; exit 1
)
| Internal_error (fname,msg) -> (
print_internal_error fname msg ; exit 1
)
| End_of_file -> (
)
)
| Global_error s -> (
print_global_error s;
Rif.write oc ("\n#end.\n# "^s^"\n");
Rif.flush oc;
exit 1
)
| Parsing.Parse_error -> (
let str = Printf.sprintf "%s\n"
(compile_error_string (Lexeme.last_made ()) "syntax error")
in
Printf.eprintf "%s" str;
flush stderr;
Rif.write oc ("\n#end.\n# "^str^"\n");
Rif.flush oc;
exit 1
)
| Compile_error(lxm,msg) -> (
let str = Printf.sprintf "%s\n" (compile_error_string lxm msg) in
Printf.eprintf "%s" str;
flush stderr;
Rif.write oc ("\n#end.\n# "^str^"\n");
Rif.flush oc;
exit 1
)
| Internal_error (fname,msg) -> (
print_internal_error fname msg ;
Rif.write oc ("#\nend.\n# Internal error in "^fname^": "^msg^"\n");
Rif.flush oc;
exit 1
)
| End_of_file -> (
Rif.write oc ("\n#end.\n# End of file\n");
Rif.flush oc
)
)
)
let _ = (
Utils.time_C "main";
main () ;
Utils.time_R "main";
Utils.time_P ();
Utils.time_C "main";
main () ;
Utils.time_R "main";
Utils.time_P ();
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment