let compute_assignation_list
rhs_term_value_list lhs_variables_string_id
lhs_session_id rhs_session_id =
if (!debug_level >= 2) then
(prerr_string "% compute_assignation_list: lhs_session_id=";
prerr_int lhs_session_id;
prerr_string " rhs_session_id=";
prerr_int rhs_session_id; prerr_newline();
prerr_string " variables:");
let lhs_global_var_id =
List.map
(fun x ->
if (!debug_level >= 2) then
prerr_string (" "^(Globals.string_id#get_name x));
Globals.global_var_id#get_id_of lhs_session_id x)
lhs_variables_string_id
in
if (!debug_level >= 2) then
(prerr_string "\n values:";
List.iter
(fun x -> prerr_string " "; Interface.prerr_term x)
rhs_term_value_list;
prerr_newline());
(*
For the assignation, we are computing a fix-point..
*)
let assignment_list =
List.combine lhs_global_var_id rhs_term_value_list
in
(*
We want to use the next function as less as possible. It permits to register variables
in the [memory_map] table.
*)
(*
We are doing a fix point computation. In the worst case, the number of iterations is
the length of the list.
*)
let length = List.length assignment_list in
let i = ref 0 in
let was_not_assigned (x,_) = x in
let complete_assignment_list =
List.map (fun x -> (true,x)) assignment_list
in
let not_already_assigned_list = ref complete_assignment_list in
(*
First, we register once and for all the variables in the [memory_map] table.
*)
List.iter memory_map#check_map_var lhs_global_var_id;
(*
Second, we compute the fix point of the assignation list.
*)
(* version with sem. error when variable not instantiated:
(try
while (!not_already_assigned_list <> []) do
not_already_assigned_list :=
List.find_all
was_not_assigned
(compute_assignment_list
rhs_session_id
!not_already_assigned_list);
incr i;
if (!i > length) then
raise Not_found
done
with Not_found ->
(handleSemanticError
(20,
"
^"
^(list_to_string (fun (_,(_,t)) -> term_to_string t) " !not_already_assigned_list),
",",",");
if (!debug_level >= 5) then
Utils_debug.dump ();
exit 0));
*)
while ((!not_already_assigned_list <> []) && (!i <= length)) do
not_already_assigned_list :=
List.find_all
was_not_assigned
(compute_assignment_list
rhs_session_id
!not_already_assigned_list);
incr i;
done;
if (!i > length) then
(not_already_assigned_list :=
List.filter
(fun (_,(x,_)) ->
not_excluded_type
(Globals.type_table#get_type (snd (Globals.global_var_id#get_variable x))))
!not_already_assigned_list;
if (!not_already_assigned_list <> []) then
displayWarning 10
("incomplete instantiation of a role call.\n"
^"%% The following variables have no value: "
^(list_to_string
(fun (_,(_,t)) ->
term_to_string t)
", " !not_already_assigned_list)));
(*
In the return value, we just give the association list between a key in the [global_var_id]
table and its value in the [term] type.
*)
if (!debug_level >= 3) then
Utils_debug.affiche_debug assignment_list;
assignment_list