1---------------------------------------------------------------------- 2-- Framework.Language.Shared_Keys - Package specification -- 3-- -- 4-- This software is (c) The European Organisation for the Safety -- 5-- of Air Navigation (EUROCONTROL) and Adalog 2004-2005. The Ada -- 6-- Controller is free software; you can redistribute it and/or -- 7-- modify it under terms of the GNU General Public License as -- 8-- published by the Free Software Foundation; either version 2, or -- 9-- (at your option) any later version. This unit is distributed -- 10-- in the hope that it will be useful, but WITHOUT ANY WARRANTY; -- 11-- without even the implied warranty of MERCHANTABILITY or FITNESS -- 12-- FOR A PARTICULAR PURPOSE. See the GNU General Public License -- 13-- for more details. You should have received a copy of the GNU -- 14-- General Public License distributed with this program; see file -- 15-- COPYING. If not, write to the Free Software Foundation, 59 -- 16-- Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- 17-- -- 18-- As a special exception, if other files instantiate generics -- 19-- from the units of this program, or if you link this unit with -- 20-- other files to produce an executable, this unit does not by -- 21-- itself cause the resulting executable to be covered by the GNU -- 22-- General Public License. This exception does not however -- 23-- invalidate any other reasons why the executable file might be -- 24-- covered by the GNU Public License. -- 25-- -- 26-- This software is distributed in the hope that it will be -- 27-- useful, but WITHOUT ANY WARRANTY; without even the implied -- 28-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- 29-- PURPOSE. -- 30---------------------------------------------------------------------- 31 32-- Adalog 33with 34 Thick_Queries; 35 36-- Adacontrol 37with 38 Framework.Language; 39pragma Elaborate (Framework.Language); 40-- We must "with" our parent, because the pragma Elaborate is required 41-- here, as for any unit that instantiates a generic from Framework.Language 42package Framework.Language.Shared_Keys is 43 44 ----------------------------------------------------------------------------------- 45 -- Scope_Places 46 ----------------------------------------------------------------------------------- 47 48 type Scope_Places is (S_All, S_Block, S_Library, S_Local, 49 S_Own, S_Private, S_Public, S_In_Generic, S_Task_Body); 50 package Scope_Places_Utilities is new Modifier_Utilities (Scope_Places, "S_"); 51 52 type Places_Set is private; 53 Everywhere : constant Places_Set; 54 No_Places : constant Places_Set; 55 function Get_Places_Set_Modifiers (Allow_All : Boolean := True) return Places_Set; 56 function Is_Applicable (Expected_Places : Places_Set) return Boolean; 57 -- Checks if Current_Scope matches all Scope_Places in Expected_Places 58 59 function Image (Set : Places_Set; 60 Default : Places_Set := No_Places) return Wide_String; 61 62 procedure Help_On_Scope_Places (Header : Wide_String := ""; 63 Expected : Scope_Places_Utilities.Modifier_Set := Scope_Places_Utilities.Full_Set); 64 65 ----------------------------------------------------------------------------------- 66 -- Min_Max 67 ----------------------------------------------------------------------------------- 68 69 type Bounds_Values is 70 record 71 Min : Thick_Queries.Biggest_Int; 72 Max : Thick_Queries.Biggest_Int; 73 end record; 74 Unlimited_Bounds : constant Bounds_Values := (Min => Thick_Queries.Biggest_Int'First, 75 Max => Thick_Queries.Biggest_Int'Last); 76 function Get_Bounds_Parameters (Rule_Id : Wide_String; 77 Bound_Min : Thick_Queries.Biggest_Int := 0; 78 Bound_Max : Thick_Queries.Biggest_Int := Thick_Queries.Biggest_Natural'Last; 79 Allow_Single : Boolean := False) 80 return Bounds_Values; 81 -- Gets Min and Max parameters in the form min <val>, max <val> (in any order) 82 -- or the Bound_Min (resp Bound_Max) value for unspecified bounds 83 -- If Allow_Single, a single value (without specifying Min or Max) is allowed and 84 -- returned in both Min and Max 85 86 function Is_In (Val : Thick_Queries.Biggest_Int; Bounds : Bounds_Values) return Boolean; 87 88 function Bound_Image (Bounds : Language.Shared_Keys.Bounds_Values) return Wide_String; 89 -- Basically, prints an message like "not in Min .. Max", but adjusts the message 90 -- if only one bound has been specified. 91 92 procedure Help_On_Bounds (Header : Wide_String := ""); 93 94 95 ----------------------------------------------------------------------------------- 96 -- Categories 97 ----------------------------------------------------------------------------------- 98 99 type Categories is (Cat_Any, 100 Cat_Enum, Cat_Range, Cat_Mod, Cat_Delta, Cat_Digits, 101 Cat_Array, Cat_Record, Cat_Tagged, Cat_Extension, Cat_Access, 102 Cat_New, Cat_Private, Cat_Task, Cat_Protected); 103 package Categories_Utilities is new Modifier_Utilities (Categories, 104 Prefix => "CAT_", 105 Box_Pos => 0, 106 Pars_Pos => 1); 107 subtype Categories_Set is Categories_Utilities.Modifier_Set; 108 109 subtype Discrete_Categories is Categories range Cat_Enum .. Cat_Mod; 110 subtype Integer_Categories is Categories range Cat_Range .. Cat_Mod; 111 Discrete_Set : constant Categories_Set := (Discrete_Categories => True, others => False); 112 Integer_Set : constant Categories_Set := (Integer_Categories => True, others => False); 113 114 function Value (Spec : Wide_String) return Categories; 115 function Value (Spec : Entity_Specification) return Categories; 116 -- If Spec kind is a Regular_Id that matches the image of a category (or "()"), 117 -- return that category. 118 -- Return Cat_Any otherwise. 119 120 function Matches (Elem : in Asis.Element; 121 Cat : in Categories; 122 Follow_Derived : in Boolean := False; 123 Privacy : in Thick_Queries.Privacy_Policy := Thick_Queries.Stop_At_Private; 124 Separate_Extension : in Boolean := False) 125 return Boolean; 126 -- See Thick_Queries.Type_Category for details of parameters Follow_Derived, Privacy, and Separate_Extension 127 -- 128 -- Appropriate Element_Kinds for Elem: 129 -- A_Declaration 130 -- A_Definition 131 -- A_Defining_Name 132 -- An_Expression 133 -- Appropriate Declaration_Kinds: 134 -- An_Ordinary_Type_Declaration 135 -- A_Task_Type_Declaration 136 -- A_Protected_Type_Declaration 137 -- A_Private_Type_Declaration 138 -- A_Private_Extension_Declaration 139 -- A_Subtype_Declaration 140 -- A_Formal_Type_Declaration 141 -- Appropriate Definition_Kinds: 142 -- A_Type_Definition 143 -- A_Task_Definition 144 -- A_Protected_Definition 145 146 function Matching_Category (Elem : in Asis.Element; 147 From_Cats : in Categories_Utilities.Unconstrained_Modifier_Set; 148 Follow_Derived : in Boolean := False; 149 Privacy : in Thick_Queries.Privacy_Policy := Thick_Queries.Stop_At_Private; 150 Separate_Extension : in Boolean := False) 151 return Categories; 152 -- Appropriate Element_Kinds for Elem: 153 -- Same as Matches above 154 -- 155 -- Return the category of Elem if it is in From_Cats, Cat_Any otherwise 156 157 function Image (Item : Thick_Queries.Type_Categories) return Wide_String; 158 -- Image of a type category, in upper case 159 160 161 ----------------------------------------------------------------------------------- 162 -- Aspects 163 ----------------------------------------------------------------------------------- 164 165 type Aspects is (Representation, Pack, Size, Component_Size); 166 type Aspect_Presence is (Unspecified, Present, Absent); 167 type Aspects_Set is array (Aspects) of Aspect_Presence; 168 No_Aspect : constant Aspects_Set := (others => Unspecified); 169 package Aspects_Utilities is new Flag_Utilities (Aspects); 170 171 function Get_Aspects_Parameter (Rule_Id : Wide_String; 172 Expected : Aspects_Set := (others => Present)) return Aspects_Set; 173 -- with pre => (for all E of Expected => E /= Unspecified); 174 175 function Corresponding_Aspects_Set (Elem : Asis.Element) return Aspects_Set; 176 -- with post => (for all E of Corresponding_Aspects_Set'Result => E /= Unspecified) 177 -- Return the aspects that apply (or not) to Elem 178 -- Appropriate Element_Kinds for Elem: 179 -- A_Declaration 180 -- A_Definition 181 -- An_Expression 182 -- A_Defining_Name 183 -- Appropriate Declaration_Kinds: 184 -- An_Ordinary_Type_Declaration 185 -- A_Task_Type_Declaration 186 -- A_Protected_Type_Declaration 187 -- A_Private_Type_Declaration 188 -- A_Private_Extension_Declaration 189 -- A_Subtype_Declaration 190 -- A_Formal_Type_Declaration 191 -- Appropriate Definition_Types: 192 -- A_Type_Definition 193 -- A_Task_Definition 194 -- A_Protected_Definition 195 -- Appropriate Expression_Kinds 196 -- An_Identifier 197 -- A_Selected_Name (applies to selector) 198 199private 200 type Places_Set is 201 record 202 Specified : Scope_Places_Utilities.Modifier_Set; 203 Presence : Scope_Places_Utilities.Modifier_Set; 204 end record; 205 Everywhere : constant Places_Set := (Specified => (S_All => True, others => False), 206 Presence => Scope_Places_Utilities.Full_Set); 207 No_Places : constant Places_Set := (Specified => Scope_Places_Utilities.Empty_Set, 208 Presence => Scope_Places_Utilities.Empty_Set); 209 210end Framework.Language.Shared_Keys; 211