diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-02-27 18:28:51 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-02-27 18:28:51 +0100 |
commit | fe5524a0d34fc0fc97a5b3f571581ca5ec2827c4 (patch) | |
tree | 41c7bdca82c9074a881ff077ec1bbd9dd8fec7ea | |
parent | a07173e47e33a4b03ab3415d40438135d04b23c6 (diff) | |
download | ghdl-fe5524a0d34fc0fc97a5b3f571581ca5ec2827c4.tar.gz ghdl-fe5524a0d34fc0fc97a5b3f571581ca5ec2827c4.tar.bz2 ghdl-fe5524a0d34fc0fc97a5b3f571581ca5ec2827c4.zip |
synth: handle file_close.
-rw-r--r-- | src/synth/synth-files_operations.adb | 27 | ||||
-rw-r--r-- | src/synth/synth-files_operations.ads | 12 | ||||
-rw-r--r-- | src/synth/synth-static_proc.adb | 2 |
3 files changed, 31 insertions, 10 deletions
diff --git a/src/synth/synth-files_operations.adb b/src/synth/synth-files_operations.adb index 3fa075468..29c70d98d 100644 --- a/src/synth/synth-files_operations.adb +++ b/src/synth/synth-files_operations.adb @@ -174,12 +174,11 @@ package body Synth.Files_Operations is end Endfile; -- Declaration - -- procedure FILE_OPEN (file F : FT: + -- procedure FILE_OPEN (file F : FT; -- External_Name : String; -- Open_Kind : File_Open_Kind); - procedure Synth_File_Open (Syn_Inst : Synth_Instance_Acc; - Imp : Node; - Loc : Node) + procedure Synth_File_Open + (Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node) is Inters : constant Node := Get_Interface_Declaration_Chain (Imp); F : constant File_Index := Get_Value (Syn_Inst, Inters).File; @@ -215,6 +214,26 @@ package body Synth.Files_Operations is end if; end Synth_File_Open; + -- Declaration + -- procedure FILE_CLOSE (file F : FT); + procedure Synth_File_Close + (Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node) + is + Inters : constant Node := Get_Interface_Declaration_Chain (Imp); + F : constant File_Index := Get_Value (Syn_Inst, Inters).File; + Status : Op_Status; + begin + if Get_Text_File_Flag (Get_Type (Inters)) then + Ghdl_Text_File_Close (F, Status); + else + Ghdl_File_Close (F, Status); + end if; + + if Status /= Op_Ok then + File_Error (Loc, Status); + end if; + end Synth_File_Close; + -- Declaration: -- procedure untruncated_text_read --!V87 -- (file f : text; str : out string; len : out natural); --!V87 diff --git a/src/synth/synth-files_operations.ads b/src/synth/synth-files_operations.ads index 35a92dbb0..69be99ff9 100644 --- a/src/synth/synth-files_operations.ads +++ b/src/synth/synth-files_operations.ads @@ -33,11 +33,11 @@ package Synth.Files_Operations is function Endfile (F : File_Index; Loc : Syn_Src) return Boolean; - procedure Synth_File_Open (Syn_Inst : Synth_Instance_Acc; - Imp : Node; - Loc : Node); + procedure Synth_File_Open + (Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node); + procedure Synth_File_Close + (Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node); - procedure Synth_Untruncated_Text_Read (Syn_Inst : Synth_Instance_Acc; - Imp : Node; - Loc : Node); + procedure Synth_Untruncated_Text_Read + (Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node); end Synth.Files_Operations; diff --git a/src/synth/synth-static_proc.adb b/src/synth/synth-static_proc.adb index cc92b9ee7..f0a09a172 100644 --- a/src/synth/synth-static_proc.adb +++ b/src/synth/synth-static_proc.adb @@ -43,6 +43,8 @@ package body Synth.Static_Proc is case Get_Implicit_Definition (Imp) is when Iir_Predefined_File_Open => Synth_File_Open (Syn_Inst, Imp, Loc); + when Iir_Predefined_File_Close => + Synth_File_Close (Syn_Inst, Imp, Loc); when Iir_Predefined_Foreign_Untruncated_Text_Read => Synth_Untruncated_Text_Read (Syn_Inst, Imp, Loc); when Iir_Predefined_Deallocate => |