File: declarations-outputdeclarations.adb

package info (click to toggle)
spark 2012.0.deb-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 29,260 kB
  • ctags: 3,098
  • sloc: ada: 186,243; cpp: 13,497; makefile: 685; yacc: 440; lex: 176; ansic: 119; sh: 16
file content (169 lines) | stat: -rw-r--r-- 7,594 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
-------------------------------------------------------------------------------
-- (C) Altran Praxis Limited
-------------------------------------------------------------------------------
--
-- The SPARK toolset is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. The SPARK toolset 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 distributed with the SPARK toolset; see file
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
-- the license.
--
--=============================================================================

with SystemErrors;

separate (Declarations)
procedure OutputDeclarations
  (Heap        : in out Cells.Heap_Record;
   File        : in     SPARK_IO.File_Type;
   Rule_File   : in     SPARK_IO.File_Type;
   Scope       : in     Dictionary.Scopes;
   Write_Rules : in     Boolean;
   EndPosition : in     LexTokenManager.Token_Position)
is
   NeededSymbols : Cells.Cell;

   ---------------------------------------------------------------------

   function IsLocalOwnVariableWithRefinement (Sym   : Dictionary.Symbol;
                                              Scope : Dictionary.Scopes) return Boolean
   --# global in Dictionary.Dict;
   is
      Result : Boolean;
   begin
      if Dictionary.IsOwnVariable (Sym) then
         if Dictionary.OwnVariableHasType (Sym, Scope) then
            -- it has a concrete type so it can't be what we are looking for
            Result := False;
         else
            -- it may be what we are looking for; see if it is local to this package
            Result :=
              Dictionary.Packages_Are_Equal
              (Left_Symbol  => Dictionary.GetOwner (Sym),
               Right_Symbol => Dictionary.GetEnclosingPackage (Scope));
         end if;
      else
         Result := False;
      end if;
      return Result;
   end IsLocalOwnVariableWithRefinement;

   ---------------------------------------------------------------------

   procedure GenerateDeclarations
     (Heap          : in out Cells.Heap_Record;
      UsedSymbols   : in     Cells.Cell;
      Scope         : in     Dictionary.Scopes;
      NeededSymbols :    out Cells.Cell)
   --# global in     AttributeList;
   --#        in     Dictionary.Dict;
   --#        in     LexTokenManager.State;
   --#        in out Statistics.TableUsage;
   --# derives Heap,
   --#         Statistics.TableUsage from *,
   --#                                    AttributeList,
   --#                                    Dictionary.Dict,
   --#                                    Heap,
   --#                                    LexTokenManager.State,
   --#                                    Scope,
   --#                                    UsedSymbols &
   --#         NeededSymbols         from AttributeList,
   --#                                    Dictionary.Dict,
   --#                                    Heap,
   --#                                    LexTokenManager.State,
   --#                                    Scope,
   --#                                    UsedSymbols;
      is separate;

   ---------------------------------------------------------------------

   procedure PrintDeclarations
     (Heap           : in out Cells.Heap_Record;
      File           : in     SPARK_IO.File_Type;
      Rule_File      : in     SPARK_IO.File_Type;
      Needed_Symbols : in     Cells.Cell;
      Scope          : in     Dictionary.Scopes;
      Write_Rules    : in     Boolean;
      End_Position   : in     LexTokenManager.Token_Position)
   --# global in     AttributeList;
   --#        in     BitwiseOpList;
   --#        in     CommandLineData.Content;
   --#        in     Dictionary.Dict;
   --#        in     LexTokenManager.State;
   --#        in     ProcedureExportList;
   --#        in     ReturnSymbol;
   --#        in     RootIntegerUsed;
   --#        in out ErrorHandler.Error_Context;
   --#        in out SPARK_IO.File_Sys;
   --#        in out Statistics.TableUsage;
   --# derives ErrorHandler.Error_Context from *,
   --#                                         CommandLineData.Content,
   --#                                         Dictionary.Dict,
   --#                                         End_Position,
   --#                                         File,
   --#                                         Heap,
   --#                                         LexTokenManager.State,
   --#                                         Needed_Symbols,
   --#                                         Rule_File,
   --#                                         Scope,
   --#                                         SPARK_IO.File_Sys,
   --#                                         Write_Rules &
   --#         Heap,
   --#         Statistics.TableUsage      from *,
   --#                                         Dictionary.Dict,
   --#                                         Heap,
   --#                                         Needed_Symbols,
   --#                                         Scope,
   --#                                         Write_Rules &
   --#         SPARK_IO.File_Sys          from *,
   --#                                         AttributeList,
   --#                                         BitwiseOpList,
   --#                                         CommandLineData.Content,
   --#                                         Dictionary.Dict,
   --#                                         End_Position,
   --#                                         ErrorHandler.Error_Context,
   --#                                         File,
   --#                                         Heap,
   --#                                         LexTokenManager.State,
   --#                                         Needed_Symbols,
   --#                                         ProcedureExportList,
   --#                                         ReturnSymbol,
   --#                                         RootIntegerUsed,
   --#                                         Rule_File,
   --#                                         Scope,
   --#                                         Write_Rules;
      is separate;

begin -- OutputDeclarations

   if Pile.OrderOK (Heap, UsedSymbols) then
      --Debug.PrintMsg ("UsedSymbols order OK", True);
      null;
   else
      --Debug.PrintMsg ("Dump of UsedSymbols before GenerateDeclarations", True);
      Pile.PrintPile (Heap, UsedSymbols);
      SystemErrors.Fatal_Error
        (Sys_Err => SystemErrors.Assertion_Failure,
         Msg     => "UsedSymbols before GenerateDeclarations not in order");
   end if;

   GenerateDeclarations (Heap, UsedSymbols, Scope, NeededSymbols);

   if Pile.OrderOK (Heap, NeededSymbols) then
      --Debug.PrintMsg ("NeededSymbols order OK", True);
      null;
   else
      --Debug.PrintMsg ("Dump of NeededSymbols after GenerateDeclarations", True);
      Pile.PrintPile (Heap, NeededSymbols);
      SystemErrors.Fatal_Error
        (Sys_Err => SystemErrors.Assertion_Failure,
         Msg     => "NeededSymbols after GenerateDeclarations not in order");
   end if;

   PrintDeclarations (Heap, File, Rule_File, NeededSymbols, Scope, Write_Rules, EndPosition);
end OutputDeclarations;