diff options
author | Alex Auvolat <alex.auvolat@ansys.com> | 2014-07-04 09:37:22 +0200 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ansys.com> | 2014-07-04 09:37:22 +0200 |
commit | 8c8765721b5cb2907182a63c562677447df8caea (patch) | |
tree | 5d917e0e941c39307618704c95f82ee880b5572c /frontend | |
parent | f808eeaf3016f828d71b0f87afb89bb79a869035 (diff) | |
download | scade-analyzer-8c8765721b5cb2907182a63c562677447df8caea.tar.gz scade-analyzer-8c8765721b5cb2907182a63c562677447df8caea.zip |
Simplifications && preparation for restart.
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/ast.ml | 4 | ||||
-rw-r--r-- | frontend/parser.mly | 1 | ||||
-rw-r--r-- | frontend/typing.ml | 17 |
3 files changed, 21 insertions, 1 deletions
diff --git a/frontend/ast.ml b/frontend/ast.ml index d55626d..c561cef 100644 --- a/frontend/ast.ml +++ b/frontend/ast.ml @@ -69,6 +69,10 @@ and state = { st_locals : var_def list; body : eqn ext list; until : transition list; + (* these two rst info are determined after parsing, in typing.ml when + the variable list is extracted *) + mutable i_rst : bool; (* resettable by S -> S transition *) + mutable o_rst : bool; (* resettable by S' -> S transition *) } and transition = (expr ext) * (id ext) * bool (* bool : does it reset ? *) diff --git a/frontend/parser.mly b/frontend/parser.mly index e8a6ecf..672bb9a 100644 --- a/frontend/parser.mly +++ b/frontend/parser.mly @@ -126,6 +126,7 @@ state: st_locals = v; body = b; until = until; + i_rst = false; o_rst = false; (* calculated later *) } } trans(TT): diff --git a/frontend/typing.ml b/frontend/typing.ml index 46458f2..2859230 100644 --- a/frontend/typing.ml +++ b/frontend/typing.ml @@ -186,6 +186,18 @@ let rec extract_all_vars rp (node, prefix, eqs) n_vars = vars_of_expr c @ do_branch a @ do_branch b in do_branch b | AST_automaton (aid, states, ret) -> + (* Determine which states can be reset *) + let rst_trans = List.flatten + (List.map (fun (st, _) -> + List.map (fun (_, (id, _), _) -> (st.st_name, id)) + (List.filter (fun (_, _, rst) -> rst) st.until)) + states) + in + List.iter (fun (st, _) -> + st.i_rst <- List.mem (st.st_name, st.st_name) rst_trans; + st.o_rst <- List.exists (fun (a, b) -> b = st.st_name && a <> b) rst_trans) + states; + let do_state (st, _) = let tvars = List.flatten @@ -193,7 +205,10 @@ let rec extract_all_vars rp (node, prefix, eqs) n_vars = in let st_scope = (node, aid^"."^st.st_name^".", st.body) in let svars = vars_in_node node st.st_locals in - svars @ tvars @ clock_vars rp st_scope @ + (if st.i_rst || st.o_rst then + [false, node^"/"^aid^"."^st.st_name^".next_reset", bool_type] + else []) + @ svars @ tvars @ clock_vars rp st_scope @ extract_all_vars rp st_scope (tvars@n_vars) in let st_ids = List.map (fun (st, _) -> st.st_name) states in |