aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-12-05 18:44:23 +0100
committerTristan Gingold <tgingold@free.fr>2018-12-05 18:44:23 +0100
commita4379194ab883f522a2fedc5802a7bb2f51e42ce (patch)
tree408336ed5ec4bed3b125acaef1b9128c9b23a566
parenta39717aa310c4a70ff134a8f960b3ccd551159cd (diff)
downloadghdl-a4379194ab883f522a2fedc5802a7bb2f51e42ce.tar.gz
ghdl-a4379194ab883f522a2fedc5802a7bb2f51e42ce.tar.bz2
ghdl-a4379194ab883f522a2fedc5802a7bb2f51e42ce.zip
nodes_gc: use logging instead of Text_IO.
-rw-r--r--src/vhdl/nodes_gc.adb21
-rw-r--r--src/vhdl/nodes_gc.adb.in159
2 files changed, 8 insertions, 172 deletions
diff --git a/src/vhdl/nodes_gc.adb b/src/vhdl/nodes_gc.adb
index f3c9299b9..55b39e324 100644
--- a/src/vhdl/nodes_gc.adb
+++ b/src/vhdl/nodes_gc.adb
@@ -16,9 +16,9 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
-with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Types; use Types;
+with Logging; use Logging;
with Nodes;
with Nodes_Meta; use Nodes_Meta;
with Errorout; use Errorout;
@@ -38,22 +38,18 @@ package body Nodes_GC is
procedure Free is new Ada.Unchecked_Deallocation
(Marker_Array, Marker_Array_Acc);
- procedure Report_Early_Reference (N : Iir; F : Nodes_Meta.Fields_Enum)
- is
- use Ada.Text_IO;
+ procedure Report_Early_Reference (N : Iir; F : Nodes_Meta.Fields_Enum) is
begin
- Put ("early reference to ");
- Put (Nodes_Meta.Get_Field_Image (F));
- Put (" in ");
+ Log ("early reference to ");
+ Log (Nodes_Meta.Get_Field_Image (F));
+ Log (" in ");
Disp_Tree.Disp_Tree (N, True);
Has_Error := True;
end Report_Early_Reference;
- procedure Report_Already_Marked (N : Iir)
- is
- use Ada.Text_IO;
+ procedure Report_Already_Marked (N : Iir) is
begin
- Put ("Already marked ");
+ Log ("Already marked ");
Disp_Tree.Disp_Tree (N, True);
Has_Error := True;
end Report_Already_Marked;
@@ -488,7 +484,6 @@ package body Nodes_GC is
procedure Report_Unreferenced
is
- use Ada.Text_IO;
use Std_Package;
El : Iir;
Nbr_Unreferenced : Natural;
@@ -503,7 +498,7 @@ package body Nodes_GC is
while El in Markers'Range loop
if not Markers (El) and then Get_Kind (El) /= Iir_Kind_Unused then
if Nbr_Unreferenced = 0 then
- Put_Line ("** unreferenced nodes:");
+ Log_Line ("** unreferenced nodes:");
end if;
Nbr_Unreferenced := Nbr_Unreferenced + 1;
Report_Unreferenced_Node (El);
diff --git a/src/vhdl/nodes_gc.adb.in b/src/vhdl/nodes_gc.adb.in
deleted file mode 100644
index 7c4303bc5..000000000
--- a/src/vhdl/nodes_gc.adb.in
+++ /dev/null
@@ -1,159 +0,0 @@
--- Node garbage collector (for debugging).
--- Copyright (C) 2014 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 GHDL; see the file COPYING. If not, write to the Free
--- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
--- 02111-1307, USA.
-
-with Ada.Text_IO;
-with Types; use Types;
-with Nodes;
-with Iirs; use Iirs;
-with Libraries;
-with Disp_Tree;
-with Std_Package;
-
-package body Nodes_GC is
-
- type Marker_Array is array (Iir range <>) of Boolean;
- type Marker_Array_Acc is access Marker_Array;
-
- Markers : Marker_Array_Acc;
-
- procedure Mark_Iir (N : Iir);
-
- procedure Mark_Iir_List (N : Iir_List)
- is
- El : Iir;
- begin
- case N is
- when Null_Iir_List
- | Iir_List_All
- | Iir_List_Others =>
- null;
- when others =>
- for I in Natural loop
- El := Get_Nth_Element (N, I);
- exit when El = Null_Iir;
- Mark_Iir (El);
- end loop;
- end case;
- end Mark_Iir_List;
-
- procedure Mark_PSL_Node (N : PSL_Node) is
- begin
- null;
- end Mark_PSL_Node;
-
- procedure Mark_PSL_NFA (N : PSL_NFA) is
- begin
- null;
- end Mark_PSL_NFA;
-
- procedure Report_Already_Marked (N : Iir)
- is
- use Ada.Text_IO;
- begin
- Disp_Tree.Disp_Tree (N, True);
- return;
- end Report_Already_Marked;
-
- procedure Already_Marked (N : Iir) is
- begin
- -- An unused node mustn't be referenced.
- if Get_Kind (N) = Iir_Kind_Unused then
- raise Internal_Error;
- end if;
-
- if not Flag_Disp_Multiref then
- return;
- end if;
-
- case Get_Kind (N) is
- when Iir_Kind_Constant_Interface_Declaration =>
- if Get_Identifier (N) = Null_Identifier then
- -- Anonymous interfaces are shared by predefined functions.
- return;
- end if;
- when Iir_Kind_Enumeration_Literal =>
- if Get_Enum_Pos (N) = 0
- or else N = Get_Right_Limit (Get_Range_Constraint
- (Get_Type (N)))
- then
- return;
- end if;
- when others =>
- null;
- end case;
-
- Report_Already_Marked (N);
- end Already_Marked;
-
- procedure Mark_Chain (Head : Iir)
- is
- El : Iir;
- begin
- El := Head;
- while El /= Null_Iir loop
- Mark_Iir (El);
- El := Get_Chain (El);
- end loop;
- end Mark_Chain;
-
- procedure Report_Unreferenced_Node (N : Iir) is
- begin
- Disp_Tree.Disp_Tree (N, True);
- end Report_Unreferenced_Node;
-
- -- Subprograms
-
- procedure Report_Unreferenced
- is
- use Ada.Text_IO;
- use Std_Package;
- El : Iir;
- Nbr_Unreferenced : Natural;
- begin
- Markers := new Marker_Array'(Null_Iir .. Iirs.Get_Last_Node => False);
-
- if Flag_Disp_Multiref then
- Put_Line ("** nodes already marked:");
- end if;
-
- Mark_Chain (Libraries.Get_Libraries_Chain);
- Mark_Chain (Libraries.Obsoleted_Design_Units);
- Mark_Iir (Convertible_Integer_Type_Declaration);
- Mark_Iir (Convertible_Integer_Subtype_Declaration);
- Mark_Iir (Convertible_Real_Type_Declaration);
- Mark_Iir (Universal_Integer_One);
- Mark_Iir (Error_Mark);
-
- El := Error_Mark;
- Nbr_Unreferenced := 0;
- while El in Markers'Range loop
- if not Markers (El) and then Get_Kind (El) /= Iir_Kind_Unused then
- if Nbr_Unreferenced = 0 then
- Put_Line ("** unreferenced nodes:");
- end if;
- Nbr_Unreferenced := Nbr_Unreferenced + 1;
- Report_Unreferenced_Node (El);
- end if;
- El := Iir (Nodes.Next_Node (Nodes.Node_Type (El)));
- end loop;
-
- if Nbr_Unreferenced /= 0 then
- raise Internal_Error;
- end if;
- end Report_Unreferenced;
-end Nodes_GC;