From aa7f7514d35a8195226ce30ccb3ea90c71cb7b85 Mon Sep 17 00:00:00 2001 From: Arnaud DABY-SEESARAM Date: Sun, 18 Dec 2022 17:36:10 +0100 Subject: [PATCH] [Lustre -> intermediate] fix for the [pre] construct --- src/ast_to_c.ml | 7 +++++-- src/test.node | 5 +---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ast_to_c.ml b/src/ast_to_c.ml index 9edace9..bca0ea2 100644 --- a/src/ast_to_c.ml +++ b/src/ast_to_c.ml @@ -14,11 +14,14 @@ let ast_to_intermediate_ast (nodes: t_nodelist) (h: node_states): i_nodelist = let ast_to_intermediate_ast_varlist vl = snd vl in let rec ast_to_intermediate_ast_expr hloc = function | EVar (_, v) -> - begin + begin match Hashtbl.find_opt hloc (Utils.name_of_var v, false) with | None -> IEVar (CVInput (name_of_var v)) | Some (s, i) -> IEVar (CVStored (s, i)) - end + end + | EMonOp (_, MOp_pre, EVar (_, v)) -> + let s, i = Hashtbl.find hloc (Utils.name_of_var v, true) in + IEVar (CVStored (s, i)) | EMonOp (_, op, e) -> IEMonOp (op, ast_to_intermediate_ast_expr hloc e) | EBinOp (_, op, e, e') -> IEBinOp (op, ast_to_intermediate_ast_expr hloc e, ast_to_intermediate_ast_expr hloc e') diff --git a/src/test.node b/src/test.node index f6054ee..5fb4a8f 100644 --- a/src/test.node +++ b/src/test.node @@ -1,9 +1,6 @@ node n (i: int) returns (o: int); -var v, t: int; a, b: bool; +var v: int; let - a = true -> false; - b = a and not (pre a); o = 1; v = pre o; - t = o + pre i; tel