diff options
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 7 | ||||
-rw-r--r-- | src/vhdl/vhdl-post_sems.adb | 8 | ||||
-rw-r--r-- | src/vhdl/vhdl-std_env.adb | 59 | ||||
-rw-r--r-- | src/vhdl/vhdl-std_env.ads | 24 |
4 files changed, 98 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index bbf411fd5..8e939ad45 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -5612,6 +5612,13 @@ package Vhdl.Nodes is Iir_Predefined_Foreign_Textio_Read_Real, Iir_Predefined_Foreign_Textio_Write_Real, + -- Defined in package std.env + Iir_Predefined_Std_Env_Stop_Status, + Iir_Predefined_Std_Env_Stop, + Iir_Predefined_Std_Env_Finish_Status, + Iir_Predefined_Std_Env_Finish, + Iir_Predefined_Std_Env_Resolution_Limit, + -- Defined in package ieee.std_logic_1164 -- Std_Ulogic operations. diff --git a/src/vhdl/vhdl-post_sems.adb b/src/vhdl/vhdl-post_sems.adb index ba5a35419..d4748354d 100644 --- a/src/vhdl/vhdl-post_sems.adb +++ b/src/vhdl/vhdl-post_sems.adb @@ -16,6 +16,7 @@ with Types; use Types; with Std_Names; use Std_Names; with Vhdl.Sem_Specs; +with Vhdl.Std_Env; with Vhdl.Ieee.Std_Logic_1164; with Vhdl.Ieee.Vital_Timing; with Vhdl.Ieee.Numeric; @@ -80,6 +81,13 @@ package body Vhdl.Post_Sems is null; end case; end if; + elsif Get_Identifier (Lib) = Name_Std then + -- This is a unit of Std. + if Get_Kind (Lib_Unit) = Iir_Kind_Package_Declaration + and then Id = Name_Env + then + Vhdl.Std_Env.Extract_Declarations (Lib_Unit); + end if; end if; -- Look for VITAL attributes. diff --git a/src/vhdl/vhdl-std_env.adb b/src/vhdl/vhdl-std_env.adb new file mode 100644 index 000000000..03b3c364f --- /dev/null +++ b/src/vhdl/vhdl-std_env.adb @@ -0,0 +1,59 @@ +-- Nodes recognizer for ieee.math_real. +-- Copyright (C) 2019 Tristan Gingold +-- +-- This program 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 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see <gnu.org/licenses>. + +with Types; use Types; +with Std_Names; use Std_Names; + +package body Vhdl.Std_Env is + procedure Extract_Declarations (Pkg : Iir_Package_Declaration) + is + Decl : Iir; + Predef : Iir_Predefined_Functions; + Inter : Iir; + begin + Std_Env_Pkg := Pkg; + + Decl := Get_Declaration_Chain (Pkg); + + while Decl /= Null_Iir loop + pragma Assert (Get_Kind (Decl) in Iir_Kinds_Subprogram_Declaration); + Inter := Get_Interface_Declaration_Chain (Decl); + case Get_Identifier (Decl) is + when Name_Stop => + if Inter = Null_Iir then + Predef := Iir_Predefined_Std_Env_Stop; + else + Predef := Iir_Predefined_Std_Env_Stop_Status; + pragma Assert (Get_Chain (Inter) = Null_Iir); + end if; + when Name_Finish => + if Inter = Null_Iir then + Predef := Iir_Predefined_Std_Env_Finish; + else + Predef := Iir_Predefined_Std_Env_Finish_Status; + pragma Assert (Get_Chain (Inter) = Null_Iir); + end if; + when Name_Resolution_Limit => + pragma Assert (Inter = Null_Iir); + Predef := Iir_Predefined_Std_Env_Resolution_Limit; + when others => + raise Internal_Error; + end case; + Set_Implicit_Definition (Decl, Predef); + Decl := Get_Chain (Decl); + end loop; + end Extract_Declarations; +end Vhdl.Std_Env; diff --git a/src/vhdl/vhdl-std_env.ads b/src/vhdl/vhdl-std_env.ads new file mode 100644 index 000000000..4a0c3416b --- /dev/null +++ b/src/vhdl/vhdl-std_env.ads @@ -0,0 +1,24 @@ +-- Nodes recognizer for std.env. +-- Copyright (C) 2022 Tristan Gingold +-- +-- This program 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 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see <gnu.org/licenses>. + +with Vhdl.Nodes; use Vhdl.Nodes; + +package Vhdl.Std_Env is + Std_Env_Pkg : Iir_Package_Declaration := Null_Iir; + + -- Extract declarations from PKG (std_env). + procedure Extract_Declarations (Pkg : Iir_Package_Declaration); +end Vhdl.Std_Env; |