aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-files_operations.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-02-18 20:25:15 +0100
committerTristan Gingold <tgingold@free.fr>2020-02-18 20:25:15 +0100
commit5abd825112fcddd8a61407a422a38a6bdd3f94a8 (patch)
treeb1ce1a4a0b1e2f5aff9a03ac3ce7266b5461e81d /src/synth/synth-files_operations.adb
parent96716ed59e3ffd00511e462122abd67aac1de4cc (diff)
downloadghdl-5abd825112fcddd8a61407a422a38a6bdd3f94a8.tar.gz
ghdl-5abd825112fcddd8a61407a422a38a6bdd3f94a8.tar.bz2
ghdl-5abd825112fcddd8a61407a422a38a6bdd3f94a8.zip
synth: handle file_open.
Diffstat (limited to 'src/synth/synth-files_operations.adb')
-rw-r--r--src/synth/synth-files_operations.adb42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/synth/synth-files_operations.adb b/src/synth/synth-files_operations.adb
index 782908913..3fa075468 100644
--- a/src/synth/synth-files_operations.adb
+++ b/src/synth/synth-files_operations.adb
@@ -173,6 +173,48 @@ package body Synth.Files_Operations is
end if;
end Endfile;
+ -- Declaration
+ -- 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)
+ is
+ Inters : constant Node := Get_Interface_Declaration_Chain (Imp);
+ F : constant File_Index := Get_Value (Syn_Inst, Inters).File;
+ Param2 : constant Node := Get_Chain (Inters);
+ File_Name : constant Value_Acc := Get_Value (Syn_Inst, Param2);
+ Param3 : constant Node := Get_Chain (Param2);
+ Open_Kind : constant Value_Acc := Get_Value (Syn_Inst, Param3);
+ C_Name : C_File_Name;
+ C_Name_Len : Natural;
+ File_Mode : Ghdl_I32;
+ Status : Op_Status;
+ begin
+ Convert_File_Name (File_Name, C_Name, C_Name_Len, Status);
+ if Status = Op_Ok then
+ File_Mode := Ghdl_I32 (Open_Kind.Scal);
+ if Get_Text_File_Flag (Get_Type (Inters)) then
+ Ghdl_Text_File_Open
+ (F, File_Mode, To_Ghdl_C_String (C_Name'Address), Status);
+ else
+ Ghdl_File_Open
+ (F, File_Mode, To_Ghdl_C_String (C_Name'Address), Status);
+ end if;
+ end if;
+
+ if Status /= Op_Ok then
+ if Status = Op_Name_Error then
+ Error_Msg_Synth
+ (+Loc, "cannot open file: " & C_Name (1 .. C_Name_Len));
+ raise File_Execution_Error;
+ else
+ File_Error (Loc, Status);
+ end if;
+ end if;
+ end Synth_File_Open;
+
-- Declaration:
-- procedure untruncated_text_read --!V87
-- (file f : text; str : out string; len : out natural); --!V87