1----------------------------------------------------------------------
2--  Framework.Symbol_Table - Package specification                  --
3--                                                                  --
4--  This software  is (c) Adalog  2004-2007. The Ada  Controller is --
5--  free software;  you can redistribute it and/or  modify it under --
6--  terms of  the GNU  General Public License  as published  by the --
7--  Free Software Foundation; either version 2, or (at your option) --
8--  any later version.   This unit is distributed in  the hope that --
9--  it will be  useful, but WITHOUT ANY WARRANTY;  without even the --
10--  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR --
11--  PURPOSE.  See the GNU  General Public License for more details. --
12--  You  should have  received a  copy  of the  GNU General  Public --
13--  License distributed  with this  program; see file  COPYING.  If --
14--  not, write to  the Free Software Foundation, 59  Temple Place - --
15--  Suite 330, Boston, MA 02111-1307, USA.                          --
16--                                                                  --
17--  As  a special  exception, if  other files  instantiate generics --
18--  from the units  of this program, or if you  link this unit with --
19--  other files  to produce  an executable, this  unit does  not by --
20--  itself cause the resulting executable  to be covered by the GNU --
21--  General  Public  License.   This  exception  does  not  however --
22--  invalidate any  other reasons why the executable  file might be --
23--  covered by the GNU Public License.                              --
24--                                                                  --
25--  This  software is  distributed  in  the hope  that  it will  be --
26--  useful,  but WITHOUT  ANY  WARRANTY; without  even the  implied --
27--  warranty  of  MERCHANTABILITY   or  FITNESS  FOR  A  PARTICULAR --
28--  PURPOSE.                                                        --
29----------------------------------------------------------------------
30
31-- ASIS
32with
33  Asis;
34
35package Framework.Symbol_Table is
36
37   type Root_Content is tagged limited null record;
38   -- This declaration is here for use in the private part of the generic,
39   -- no use for the user
40
41   Max_Instances : constant := 5;
42   -- Max allowed number of instantiations of Data_Access.
43   -- Exceeding this number will immediately result in Failure
44   -- If necessary, just increase the above constant, no other change required.
45
46
47   --
48   -- Declarations common to all instantiations
49   --
50   type Scope_Kinds is (Declaration, Visibility);
51   -- The Declaration scope is the scope where the entity is declared
52   -- The Visibility scope is the outermost scope where the entity is visible
53   -- They are different for entities declared in package specs and formal parameters
54   -- The global scope (where library elements are declared) is represented by Nil_Element
55
56   Not_In_Table   : exception;
57   Delete_Current : exception;
58   -- Works like Binary_Map.Delete_Current
59
60
61   -- Instantiate this generic to allow to associate any data with any declared element.
62   -- Data associated to an element are automatically freed when the (visibility) scope of
63   -- the element is exited. Note that this happens *after* calling Framework.Plugs.Exit_Scope,
64   -- therefore rules that need to inspect how an entity has been used can do so by plugging
65   -- some processing into Exit_Scope.
66   generic
67      type Content is private;
68   package Data_Access is
69      procedure Store (Element : Asis.Element; Content_Value : Content);
70      function  Fetch (Element : Asis.Element) return Content;
71      -- Raises Not_In_Table if not present
72      function  Fetch (Element : Asis.Element; Default : Content) return Content;
73      -- Returns Default if not present
74
75      function Is_Present (Element : Asis.Element) return Boolean;
76      function Scope_Of   (Element : Asis.Element) return Asis.Element;
77      -- Raises Not_In_Table if not present
78
79      procedure Clear;
80      -- Remove all data stored by this package
81
82      -- Apply Action to all entities whose declaration or visibility scope is the current scope
83      generic
84         with procedure Action (Entity : Asis.Defining_Name; Content_Value : in out Content);
85      procedure On_Every_Entity_From_Scope (Scope_Kind : Scope_Kinds);
86   private
87      type Content_Hook is new Root_Content with
88         record
89            The_Content : Content;
90         end record;
91   end Data_Access;
92
93   ----------------------------------------------------------------------------------------
94   --
95   --  Declarations below this line are for the use of the framework
96   --
97
98   procedure Exit_Scope (Element : in Asis.Element);
99   -- Clean-up elements from current scope
100
101end Framework.Symbol_Table;
102