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

The -exec mode now supports explicit arrays expression (e.g., [4,3,r])

parent bb6b76d9
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 20/03/2013 (at 17:25) by Erwan Jahier> *)
(* Time-stamp: <modified the 20/03/2013 (at 17:57) by Erwan Jahier> *)
open SocExecValue
open Soc
......@@ -205,21 +205,37 @@ let lustre_if ctx =
in
{ ctx with s = sadd ctx.s vn vv }
let lustre_hat tl ctx =
let i = match tl with
| [_;Soc.Array(_,i)] -> i
let lustre_array tl ctx =
let t,size = match List.hd (List.rev tl) with
| Soc.Array(t,i) -> t,i
| _ -> assert false
in
let (vn,vv) =
match ([get_val "x" ctx]) with
| [B x] -> "z"::ctx.cpath,A(Array.make i (B x))
| [I x] -> "z"::ctx.cpath,A(Array.make i (I x))
| [F x] -> "z"::ctx.cpath,A(Array.make i (F x))
| [A x] -> "z"::ctx.cpath,A(Array.make i (A x))
| [U] -> "z"::ctx.cpath,U
| _ -> assert false
let inames =
let res = ref [] in
for k=size downto 1 do
res:= ("x"^(string_of_int k)) :: !res;
done;
!res
in
{ ctx with s = sadd ctx.s vn vv }
let l = List.map (fun name -> get_val name ctx) inames in
let a = Array.of_list l in
{ ctx with s = sadd ctx.s ("z"::ctx.cpath) (A a) }
let lustre_hat tl ctx =
let i = match tl with
| [_;Soc.Array(_,i)] -> i
| _ -> assert false
in
let (vn,vv) =
match ([get_val "x" ctx]) with
| [B x] -> "z"::ctx.cpath,A(Array.make i (B x))
| [I x] -> "z"::ctx.cpath,A(Array.make i (I x))
| [F x] -> "z"::ctx.cpath,A(Array.make i (F x))
| [A x] -> "z"::ctx.cpath,A(Array.make i (A x))
| [U] -> "z"::ctx.cpath,U
| _ -> assert false
in
{ ctx with s = sadd ctx.s vn vv }
(* That one is different *)
let lustre_xor ctx = assert false
......@@ -260,6 +276,7 @@ let (get: Soc.key -> (ctx -> ctx)) =
| "Lustre::if" -> lustre_if
| "Lustre::hat" -> lustre_hat tl
| "Lustre::array" -> lustre_array tl
| "Lustre::xor" -> lustre_xor
| "Lustre::diese" -> lustre_diese
......
(* Time-stamp: <modified the 19/03/2013 (at 14:39) by Erwan Jahier> *)
(* Time-stamp: <modified the 20/03/2013 (at 18:01) by Erwan Jahier> *)
(** Synchronous Object Code for Predefined operators. *)
......@@ -353,9 +353,42 @@ let make_slice_soc: Lic.slice_info -> Soc.var_type -> Soc.t =
(* init = None; *)
}
let gen_index_list n =
let rec aux acc i n =
if i<0 then acc else aux (i::acc) (i-1) n
in
aux [] (n-1) n
let _ = assert (gen_index_list 5 = [0;1;2;3;4])
let make_array_soc: int -> Soc.var_type -> Soc.t =
fun i t ->
assert false
let iprof =
let res = ref [] in
for k=i downto 1 do
res:= ("x"^(string_of_int k),t) :: !res;
done;
!res
in
let array_type = Array(t,i) in
let key_prof = (List.map snd iprof) @ [array_type] in
{
key = ("Lustre::array", key_prof, None);
profile = (iprof, ["z", array_type]);
instances = [];
step = [
{
name = "step";
lxm = Lxm.dummy "predef array soc";
idx_ins = gen_index_list i;
idx_outs = [0];
impl = None;
};
];
precedences = [];
have_mem = None;
}
let make_hat_soc: int -> Soc.var_type -> Soc.t =
fun i t ->
......@@ -506,10 +539,9 @@ let (soc_interface_of_pos_op:
(make_hat_soc i elt_type)
| Lic.ARRAY, _ ->
let concrete_type = List.nth types 0 in
let soc = of_soc_key (("Lustre::array"), types@[concrete_type], None) in
let soc = instanciate_soc soc concrete_type in
soc
let elt_type = List.nth types 0 in
let i = (List.length types) in
(make_array_soc i elt_type)
| Lic.CONCAT ,_-> finish_me lxm ; assert false
......
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