From d87e8284e3dc3adced8b8aa2258e3a87097396b1 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 8 May 2019 06:33:00 +0200 Subject: vhdl: renames iirs_walk to vhdl-nodes_walk --- src/vhdl/iirs_walk.adb | 177 ---------------------------------- src/vhdl/iirs_walk.ads | 53 ---------- src/vhdl/simulate/simul-debugger.adb | 2 +- src/vhdl/translate/trans_analyzes.adb | 2 +- src/vhdl/vhdl-configuration.adb | 4 +- src/vhdl/vhdl-nodes_walk.adb | 177 ++++++++++++++++++++++++++++++++++ src/vhdl/vhdl-nodes_walk.ads | 53 ++++++++++ 7 files changed, 234 insertions(+), 234 deletions(-) delete mode 100644 src/vhdl/iirs_walk.adb delete mode 100644 src/vhdl/iirs_walk.ads create mode 100644 src/vhdl/vhdl-nodes_walk.adb create mode 100644 src/vhdl/vhdl-nodes_walk.ads (limited to 'src/vhdl') diff --git a/src/vhdl/iirs_walk.adb b/src/vhdl/iirs_walk.adb deleted file mode 100644 index c367af9e6..000000000 --- a/src/vhdl/iirs_walk.adb +++ /dev/null @@ -1,177 +0,0 @@ --- Walk in iirs nodes. --- Copyright (C) 2009 Tristan Gingold --- --- GHDL is free software; you can redistribute it and/or modify it under --- the terms of the GNU General Public License as published by the Free --- Software Foundation; either version 2, or (at your option) any later --- version. --- --- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY --- WARRANTY; without even the implied warranty of MERCHANTABILITY or --- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --- for more details. --- --- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. - -with Vhdl.Utils; use Vhdl.Utils; -with Errorout; use Errorout; - -package body Iirs_Walk is - function Walk_Chain (Chain : Iir; Cb : Walk_Cb) return Walk_Status - is - El : Iir; - Status : Walk_Status := Walk_Continue; - begin - El := Chain; - while El /= Null_Iir loop - Status := Cb.all (El); - exit when Status /= Walk_Continue; - El := Get_Chain (El); - end loop; - return Status; - end Walk_Chain; - - function Walk_Sequential_Stmt (Stmt : Iir; Cb : Walk_Cb) return Walk_Status; - - - function Walk_Sequential_Stmt_Chain (Chain : Iir; Cb : Walk_Cb) - return Walk_Status - is - El : Iir; - Status : Walk_Status := Walk_Continue; - begin - El := Chain; - while El /= Null_Iir loop - Status := Cb.all (El); - exit when Status /= Walk_Continue; - Status := Walk_Sequential_Stmt (El, Cb); - exit when Status /= Walk_Continue; - El := Get_Chain (El); - end loop; - return Status; - end Walk_Sequential_Stmt_Chain; - - function Walk_Sequential_Stmt (Stmt : Iir; Cb : Walk_Cb) return Walk_Status - is - Status : Walk_Status := Walk_Continue; - Chain : Iir; - begin - case Iir_Kinds_Sequential_Statement (Get_Kind (Stmt)) is - when Iir_Kind_Simple_Signal_Assignment_Statement - | Iir_Kind_Conditional_Signal_Assignment_Statement - | Iir_Kind_Selected_Waveform_Assignment_Statement - | Iir_Kind_Null_Statement - | Iir_Kind_Assertion_Statement - | Iir_Kind_Report_Statement - | Iir_Kind_Wait_Statement - | Iir_Kind_Return_Statement - | Iir_Kind_Procedure_Call_Statement - | Iir_Kind_Next_Statement - | Iir_Kind_Exit_Statement - | Iir_Kind_Variable_Assignment_Statement - | Iir_Kind_Conditional_Variable_Assignment_Statement => - null; - when Iir_Kind_For_Loop_Statement - | Iir_Kind_While_Loop_Statement => - Status := Walk_Sequential_Stmt_Chain - (Get_Sequential_Statement_Chain (Stmt), Cb); - when Iir_Kind_Case_Statement => - Chain := Get_Case_Statement_Alternative_Chain (Stmt); - while Chain /= Null_Iir loop - Status := Walk_Sequential_Stmt_Chain - (Get_Associated_Chain (Chain), Cb); - exit when Status /= Walk_Continue; - Chain := Get_Chain (Chain); - end loop; - when Iir_Kind_If_Statement => - Chain := Stmt; - while Chain /= Null_Iir loop - Status := Walk_Sequential_Stmt_Chain - (Get_Sequential_Statement_Chain (Chain), Cb); - exit when Status /= Walk_Continue; - Chain := Get_Else_Clause (Chain); - end loop; - end case; - return Status; - end Walk_Sequential_Stmt; - - function Walk_Assignment_Target (Target : Iir; Cb : Walk_Cb) - return Walk_Status - is - Targ : constant Iir := Strip_Reference_Name (Target); - Chain : Iir; - Status : Walk_Status := Walk_Continue; - begin - case Get_Kind (Targ) is - when Iir_Kind_Aggregate => - Chain := Get_Association_Choices_Chain (Targ); - while Chain /= Null_Iir loop - Status := - Walk_Assignment_Target (Get_Associated_Expr (Chain), Cb); - exit when Status /= Walk_Continue; - Chain := Get_Chain (Chain); - end loop; - when others => - Status := Cb.all (Targ); - end case; - return Status; - end Walk_Assignment_Target; - - function Walk_Design_Units (Parent : Iir; Cb : Walk_Cb) return Walk_Status - is - El : Iir; - Status : Walk_Status := Walk_Continue; - begin - case Get_Kind (Parent) is - when Iir_Kind_Library_Declaration => - El := Get_Design_File_Chain (Parent); - while Is_Valid (El) loop - Status := Walk_Design_Units (El, Cb); - exit when Status /= Walk_Continue; - El := Get_Chain (El); - end loop; - return Status; - when Iir_Kind_Design_File => - El := Get_First_Design_Unit (Parent); - while Is_Valid (El) loop - Status := Cb.all (El); - exit when Status /= Walk_Continue; - El := Get_Chain (El); - end loop; - return Status; - when others => - Error_Kind ("walk_library_units", Parent); - end case; - end Walk_Design_Units; - - function Walk_Concurrent_Statements_Chain (Chain : Iir; Cb : Walk_Cb) - return Walk_Status - is - Status : Walk_Status; - El : Iir; - begin - El := Chain; - while Is_Valid (El) loop - case Iir_Kinds_Concurrent_Statement (Get_Kind (El)) is - when Iir_Kinds_Simple_Concurrent_Statement - | Iir_Kind_Component_Instantiation_Statement => - return Cb.all (El); - when Iir_Kind_Block_Statement => - Status := Cb.all (El); - if Status /= Walk_Continue then - return Status; - end if; - return Walk_Concurrent_Statements_Chain - (Get_Concurrent_Statement_Chain (El), Cb); - when others => - Error_Kind ("walk_concurrent_statements_chain", El); - end case; - El := Get_Chain (El); - end loop; - - return Walk_Continue; - end Walk_Concurrent_Statements_Chain; -end Iirs_Walk; diff --git a/src/vhdl/iirs_walk.ads b/src/vhdl/iirs_walk.ads deleted file mode 100644 index ca0a9e88f..000000000 --- a/src/vhdl/iirs_walk.ads +++ /dev/null @@ -1,53 +0,0 @@ --- Walk in iirs nodes. --- Copyright (C) 2009 Tristan Gingold --- --- GHDL is free software; you can redistribute it and/or modify it under --- the terms of the GNU General Public License as published by the Free --- Software Foundation; either version 2, or (at your option) any later --- version. --- --- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY --- WARRANTY; without even the implied warranty of MERCHANTABILITY or --- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --- for more details. --- --- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. - -with Vhdl.Nodes; use Vhdl.Nodes; - -package Iirs_Walk is - type Walk_Status is - ( - -- Continue to walk. - Walk_Continue, - - -- Stop walking in the subtree, continue in the parent tree. - Walk_Up, - - -- Abort the walk. - Walk_Abort); - - type Walk_Cb is access function (El : Iir) return Walk_Status; - - -- Walk on all elements of CHAIN. - function Walk_Chain (Chain : Iir; Cb : Walk_Cb) return Walk_Status; - - - function Walk_Assignment_Target (Target : Iir; Cb : Walk_Cb) - return Walk_Status; - - -- Walk on all stmts and sub-stmts of CHAIN. - function Walk_Sequential_Stmt_Chain (Chain : Iir; Cb : Walk_Cb) - return Walk_Status; - - -- Walk on all design units of library or design file PARENT. - function Walk_Design_Units (Parent : Iir; Cb : Walk_Cb) return Walk_Status; - - -- Walk on all concurrent statements (and sub statements) of CHAIN. - function Walk_Concurrent_Statements_Chain (Chain : Iir; Cb : Walk_Cb) - return Walk_Status; - -end Iirs_Walk; diff --git a/src/vhdl/simulate/simul-debugger.adb b/src/vhdl/simulate/simul-debugger.adb index f094073e2..a50542f38 100644 --- a/src/vhdl/simulate/simul-debugger.adb +++ b/src/vhdl/simulate/simul-debugger.adb @@ -38,7 +38,7 @@ with Simul.Execution; use Simul.Execution; with Vhdl.Utils; use Vhdl.Utils; with Errorout; use Errorout; with Vhdl.Disp_Vhdl; -with Iirs_Walk; use Iirs_Walk; +with Vhdl.Nodes_Walk; use Vhdl.Nodes_Walk; with Areapools; use Areapools; with Grt.Types; use Grt.Types; with Grt.Disp; diff --git a/src/vhdl/translate/trans_analyzes.adb b/src/vhdl/translate/trans_analyzes.adb index 2d4aef0d6..b3940e398 100644 --- a/src/vhdl/translate/trans_analyzes.adb +++ b/src/vhdl/translate/trans_analyzes.adb @@ -17,7 +17,7 @@ -- 02111-1307, USA. with Vhdl.Utils; use Vhdl.Utils; -with Iirs_Walk; use Iirs_Walk; +with Vhdl.Nodes_Walk; use Vhdl.Nodes_Walk; with Vhdl.Disp_Vhdl; with Ada.Text_IO; with Errorout; diff --git a/src/vhdl/vhdl-configuration.adb b/src/vhdl/vhdl-configuration.adb index 6b371d601..e23d8e9cf 100644 --- a/src/vhdl/vhdl-configuration.adb +++ b/src/vhdl/vhdl-configuration.adb @@ -22,7 +22,7 @@ with Vhdl.Std_Package; with Name_Table; use Name_Table; with Flags; with Vhdl.Utils; use Vhdl.Utils; -with Iirs_Walk; +with Vhdl.Nodes_Walk; with Vhdl.Sem_Scopes; with Vhdl.Sem_Lib; use Vhdl.Sem_Lib; with Vhdl.Canon; @@ -787,7 +787,7 @@ package body Vhdl.Configuration is end Top; package body Top is - use Iirs_Walk; + use Nodes_Walk; function Add_Entity_Cb (Design : Iir) return Walk_Status is diff --git a/src/vhdl/vhdl-nodes_walk.adb b/src/vhdl/vhdl-nodes_walk.adb new file mode 100644 index 000000000..2ada0a225 --- /dev/null +++ b/src/vhdl/vhdl-nodes_walk.adb @@ -0,0 +1,177 @@ +-- Walk in iirs nodes. +-- Copyright (C) 2009 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. + +with Vhdl.Utils; use Vhdl.Utils; +with Errorout; use Errorout; + +package body Vhdl.Nodes_Walk is + function Walk_Chain (Chain : Iir; Cb : Walk_Cb) return Walk_Status + is + El : Iir; + Status : Walk_Status := Walk_Continue; + begin + El := Chain; + while El /= Null_Iir loop + Status := Cb.all (El); + exit when Status /= Walk_Continue; + El := Get_Chain (El); + end loop; + return Status; + end Walk_Chain; + + function Walk_Sequential_Stmt (Stmt : Iir; Cb : Walk_Cb) return Walk_Status; + + + function Walk_Sequential_Stmt_Chain (Chain : Iir; Cb : Walk_Cb) + return Walk_Status + is + El : Iir; + Status : Walk_Status := Walk_Continue; + begin + El := Chain; + while El /= Null_Iir loop + Status := Cb.all (El); + exit when Status /= Walk_Continue; + Status := Walk_Sequential_Stmt (El, Cb); + exit when Status /= Walk_Continue; + El := Get_Chain (El); + end loop; + return Status; + end Walk_Sequential_Stmt_Chain; + + function Walk_Sequential_Stmt (Stmt : Iir; Cb : Walk_Cb) return Walk_Status + is + Status : Walk_Status := Walk_Continue; + Chain : Iir; + begin + case Iir_Kinds_Sequential_Statement (Get_Kind (Stmt)) is + when Iir_Kind_Simple_Signal_Assignment_Statement + | Iir_Kind_Conditional_Signal_Assignment_Statement + | Iir_Kind_Selected_Waveform_Assignment_Statement + | Iir_Kind_Null_Statement + | Iir_Kind_Assertion_Statement + | Iir_Kind_Report_Statement + | Iir_Kind_Wait_Statement + | Iir_Kind_Return_Statement + | Iir_Kind_Procedure_Call_Statement + | Iir_Kind_Next_Statement + | Iir_Kind_Exit_Statement + | Iir_Kind_Variable_Assignment_Statement + | Iir_Kind_Conditional_Variable_Assignment_Statement => + null; + when Iir_Kind_For_Loop_Statement + | Iir_Kind_While_Loop_Statement => + Status := Walk_Sequential_Stmt_Chain + (Get_Sequential_Statement_Chain (Stmt), Cb); + when Iir_Kind_Case_Statement => + Chain := Get_Case_Statement_Alternative_Chain (Stmt); + while Chain /= Null_Iir loop + Status := Walk_Sequential_Stmt_Chain + (Get_Associated_Chain (Chain), Cb); + exit when Status /= Walk_Continue; + Chain := Get_Chain (Chain); + end loop; + when Iir_Kind_If_Statement => + Chain := Stmt; + while Chain /= Null_Iir loop + Status := Walk_Sequential_Stmt_Chain + (Get_Sequential_Statement_Chain (Chain), Cb); + exit when Status /= Walk_Continue; + Chain := Get_Else_Clause (Chain); + end loop; + end case; + return Status; + end Walk_Sequential_Stmt; + + function Walk_Assignment_Target (Target : Iir; Cb : Walk_Cb) + return Walk_Status + is + Targ : constant Iir := Strip_Reference_Name (Target); + Chain : Iir; + Status : Walk_Status := Walk_Continue; + begin + case Get_Kind (Targ) is + when Iir_Kind_Aggregate => + Chain := Get_Association_Choices_Chain (Targ); + while Chain /= Null_Iir loop + Status := + Walk_Assignment_Target (Get_Associated_Expr (Chain), Cb); + exit when Status /= Walk_Continue; + Chain := Get_Chain (Chain); + end loop; + when others => + Status := Cb.all (Targ); + end case; + return Status; + end Walk_Assignment_Target; + + function Walk_Design_Units (Parent : Iir; Cb : Walk_Cb) return Walk_Status + is + El : Iir; + Status : Walk_Status := Walk_Continue; + begin + case Get_Kind (Parent) is + when Iir_Kind_Library_Declaration => + El := Get_Design_File_Chain (Parent); + while Is_Valid (El) loop + Status := Walk_Design_Units (El, Cb); + exit when Status /= Walk_Continue; + El := Get_Chain (El); + end loop; + return Status; + when Iir_Kind_Design_File => + El := Get_First_Design_Unit (Parent); + while Is_Valid (El) loop + Status := Cb.all (El); + exit when Status /= Walk_Continue; + El := Get_Chain (El); + end loop; + return Status; + when others => + Error_Kind ("walk_library_units", Parent); + end case; + end Walk_Design_Units; + + function Walk_Concurrent_Statements_Chain (Chain : Iir; Cb : Walk_Cb) + return Walk_Status + is + Status : Walk_Status; + El : Iir; + begin + El := Chain; + while Is_Valid (El) loop + case Iir_Kinds_Concurrent_Statement (Get_Kind (El)) is + when Iir_Kinds_Simple_Concurrent_Statement + | Iir_Kind_Component_Instantiation_Statement => + return Cb.all (El); + when Iir_Kind_Block_Statement => + Status := Cb.all (El); + if Status /= Walk_Continue then + return Status; + end if; + return Walk_Concurrent_Statements_Chain + (Get_Concurrent_Statement_Chain (El), Cb); + when others => + Error_Kind ("walk_concurrent_statements_chain", El); + end case; + El := Get_Chain (El); + end loop; + + return Walk_Continue; + end Walk_Concurrent_Statements_Chain; +end Vhdl.Nodes_Walk; diff --git a/src/vhdl/vhdl-nodes_walk.ads b/src/vhdl/vhdl-nodes_walk.ads new file mode 100644 index 000000000..d93d47d46 --- /dev/null +++ b/src/vhdl/vhdl-nodes_walk.ads @@ -0,0 +1,53 @@ +-- Walk in iirs nodes. +-- Copyright (C) 2009 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. + +with Vhdl.Nodes; use Vhdl.Nodes; + +package Vhdl.Nodes_Walk is + type Walk_Status is + ( + -- Continue to walk. + Walk_Continue, + + -- Stop walking in the subtree, continue in the parent tree. + Walk_Up, + + -- Abort the walk. + Walk_Abort); + + type Walk_Cb is access function (El : Iir) return Walk_Status; + + -- Walk on all elements of CHAIN. + function Walk_Chain (Chain : Iir; Cb : Walk_Cb) return Walk_Status; + + + function Walk_Assignment_Target (Target : Iir; Cb : Walk_Cb) + return Walk_Status; + + -- Walk on all stmts and sub-stmts of CHAIN. + function Walk_Sequential_Stmt_Chain (Chain : Iir; Cb : Walk_Cb) + return Walk_Status; + + -- Walk on all design units of library or design file PARENT. + function Walk_Design_Units (Parent : Iir; Cb : Walk_Cb) return Walk_Status; + + -- Walk on all concurrent statements (and sub statements) of CHAIN. + function Walk_Concurrent_Statements_Chain (Chain : Iir; Cb : Walk_Cb) + return Walk_Status; + +end Vhdl.Nodes_Walk; -- cgit v1.2.3