Skip to content
Snippets Groups Projects
Commit 01ab2ccb authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Fix a bug in the -esa mode: all program using constants were crashing.

parent 3fa6378d
No related branches found
No related tags found
No related merge requests found
(** Time-stamp: <modified the 03/02/2009 (at 11:14) by Erwan Jahier> *)
(** Time-stamp: <modified the 05/02/2009 (at 16:24) by Erwan Jahier> *)
(* Replace structures and arrays by as many variables as necessary.
Since structures can be recursive, it migth be a lot of new variables...
......@@ -289,25 +289,26 @@ and (var_trees_of_val_exp : Eff.local_env -> Eff.id_solver -> acc -> Eff.val_exp
acc, A l
| _, (S _ | L _) -> assert false
)
| IDENT idref ->
let vi =
try id_solver.id2var idref lxm
with _ ->
raise (Errors.Compile_error(
lxm,
("\n*** '"^(Ident.string_of_idref idref)^
"': Unknown variable.\n*** Current variables are: " ^
(Hashtbl.fold
(fun id vi_eff acc ->
acc ^ (Format.sprintf
"\n\t%s" (LicDump.string_of_var_info_eff4msg vi_eff))
)
nenv.lenv_vars
""
))))
in
acc, gen_var_trees (make_val_exp nenv lxm vi) "" vi.var_type_eff
| IDENT idref -> (
try
let vi = id_solver.id2var idref lxm in
(acc,
gen_var_trees (make_val_exp nenv lxm vi) "" vi.var_type_eff)
with _ ->
try let _const = id_solver.id2const idref lxm in
(acc, L ve)
with _ ->
let msg =
"\n*** during Array expansion: '"^
(Ident.string_of_idref idref)^
"': Unknown variable.\n*** Current variables are: " ^
(Hashtbl.fold
(fun id vi_eff acc -> acc ^ (Format.sprintf "\n\t%s"
(LicDump.string_of_var_info_eff4msg vi_eff)))
nenv.lenv_vars "")
in
raise (Errors.Compile_error(lxm, msg))
)
| WITH(_) | HAT(_) | CONCAT | ARRAY(_)
| Predef _ | CALL _ | MERGE _ | CONST _
| PRE | ARROW | FBY | CURRENT | WHEN _ | TUPLE
......@@ -455,35 +456,9 @@ let (node : Eff.id_solver -> Eff.local_env -> Eff.node_exp -> Eff.node_exp) =
let inlist = n.inlist_eff in
let outlist = n.outlist_eff in
let acc = ([],[],[]) in
(* let _ = *)
(* print_string *)
(* ("\n*** nenv.lenv_vars (avant) = " ^ *)
(* (Hashtbl.fold *)
(* (fun id vi_eff acc -> *)
(* acc ^ (Format.sprintf *)
(* "\n\t%s" (LicDump.string_of_var_info_eff4msg vi_eff)) *)
(* ) *)
(* n_env.lenv_vars *)
(* "" *)
(* )); *)
(* flush stdout *)
(* in *)
let inlist, acc = List.fold_left (expand_var_info n_env is) ([],acc) inlist in
let outlist, acc = List.fold_left (expand_var_info n_env is) ([],acc) outlist in
let loclist, acc = List.fold_left (expand_var_info n_env is) ([],acc) loclist in
(* let _ = *)
(* print_string ("\n*** nenv.lenv_vars (avant) = "^ *)
(* (Hashtbl.fold *)
(* (fun id vi_eff acc -> *)
(* acc ^ (Format.sprintf *)
(* "\n\t%s" (LicDump.string_of_var_info_eff4msg vi_eff)) *)
(* ) *)
(* n_env.lenv_vars *)
(* "" *)
(* )); *)
(* flush stdout *)
(* in *)
let acc = List.fold_left (expand_eq n_env is) acc b.eqs_eff in
let acc = List.fold_left (expand_assert n_env is) acc b.asserts_eff in
let (asserts,neqs, nv) = acc in
......
......@@ -96,7 +96,7 @@ test_ec:
echo -e "\n$(NL)====> $(LC) -ec $$d -o /tmp/xx.ec" >> test_ec.res; \
$(LC0) -ec $$d -o /tmp/xx.ec >> test_ec.res 2>&1 ;\
echo -e "ec2c /tmp/xx.ec" >> test_ec.res; \
ec2c /tmp/xx.ec >> test_ec.res 2>&1 ;\
(ec2c /tmp/xx.ec >> test_ec.res 2>&1 && echo -n "ok ") || echo " KO!";\
done; \
diff -u test_ec.res.exp test_ec.res > test_ec.diff || \
(cat test.diff ; echo "cf test.diff"; exit 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment