File: dictionary-writeoperatorrenamingdeclaration.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 (141 lines) | stat: -rw-r--r-- 6,086 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
-------------------------------------------------------------------------------
-- (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.
--
--=============================================================================

separate (Dictionary)
procedure WriteOperatorRenamingDeclaration (The_Operator : in RawDict.Operator_Info_Ref;
                                            Scope        : in Scopes) is

   procedure Write_Operator_Name (File : in SPARK_IO.File_Type;
                                  Name : in SP_Symbols.SP_Symbol)
   --# global in out SPARK_IO.File_Sys;
   --# derives SPARK_IO.File_Sys from *,
   --#                                File,
   --#                                Name;
   is
   begin
      case Name is
         when SP_Symbols.RWand =>
            Write_String (File, "and");
         when SP_Symbols.RWor =>
            Write_String (File, "or");
         when SP_Symbols.RWxor =>
            Write_String (File, "xor");
         when SP_Symbols.plus =>
            Write_String (File, "+");
         when SP_Symbols.minus =>
            Write_String (File, "-");
         when SP_Symbols.RWmod =>
            Write_String (File, "mod");
         when SP_Symbols.equals =>
            Write_String (File, "=");
         when SP_Symbols.less_than =>
            Write_String (File, "<");
         when SP_Symbols.less_or_equal =>
            Write_String (File, "<=");
         when SP_Symbols.greater_than =>
            Write_String (File, ">");
         when SP_Symbols.greater_or_equal =>
            Write_String (File, ">=");
         when SP_Symbols.multiply =>
            Write_String (File, "*");
         when SP_Symbols.divide =>
            Write_String (File, "/");
         when SP_Symbols.double_star =>
            Write_String (File, "**");
         when SP_Symbols.RWabs =>
            Write_String (File, "abs");
         when others =>
            Write_String (File, "not");
      end case;
   end Write_Operator_Name;

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

   procedure Write_Unary_Operator_Renaming_Declaration
     (Name    : in SP_Symbols.SP_Symbol;
      Operand : in RawDict.Type_Info_Ref;
      Scope   : in Scopes)
   --# global in     Dict;
   --#        in     LexTokenManager.State;
   --#        in out SPARK_IO.File_Sys;
   --# derives SPARK_IO.File_Sys from *,
   --#                                Dict,
   --#                                LexTokenManager.State,
   --#                                Name,
   --#                                Operand,
   --#                                Scope;
   is
   begin
      Write_String (Dict.TemporaryFile, "unary operator ");
      Write_Operator_Name (File => Dict.TemporaryFile,
                           Name => Name);
      Write_String (Dict.TemporaryFile, " ");
      Write_Name (File => Dict.TemporaryFile,
                  Item => RawDict.Get_Type_Symbol (Operand));
      Write_String (Dict.TemporaryFile, " is renamed in ");
      Write_Scope (Dict.TemporaryFile, Scope);
      Write_Line (Dict.TemporaryFile, " ;");
   end Write_Unary_Operator_Renaming_Declaration;

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

   procedure Write_Binary_Operator_Renaming_Declaration
     (Name  : in SP_Symbols.SP_Symbol;
      Left  : in RawDict.Type_Info_Ref;
      Right : in RawDict.Type_Info_Ref;
      Scope : in Scopes)
   --# global in     Dict;
   --#        in     LexTokenManager.State;
   --#        in out SPARK_IO.File_Sys;
   --# derives SPARK_IO.File_Sys from *,
   --#                                Dict,
   --#                                Left,
   --#                                LexTokenManager.State,
   --#                                Name,
   --#                                Right,
   --#                                Scope;
   is
   begin
      Write_String (Dict.TemporaryFile, "binary operator ");
      Write_Name (File => Dict.TemporaryFile,
                  Item => RawDict.Get_Type_Symbol (Left));
      Write_String (Dict.TemporaryFile, " ");
      Write_Operator_Name (File => Dict.TemporaryFile,
                           Name => Name);
      Write_String (Dict.TemporaryFile, " ");
      Write_Name (File => Dict.TemporaryFile,
                  Item => RawDict.Get_Type_Symbol (Right));
      Write_String (Dict.TemporaryFile, " is renamed in ");
      Write_Scope (Dict.TemporaryFile, Scope);
      Write_Line (Dict.TemporaryFile, " ;");
   end Write_Binary_Operator_Renaming_Declaration;

begin -- WriteOperatorRenamingDeclaration
   case RawDict.Get_Operator_Is_Binary (The_Operator => The_Operator) is
      when False =>
         Write_Unary_Operator_Renaming_Declaration
           (Name    => RawDict.Get_Operator_Name (The_Operator => The_Operator),
            Operand => RawDict.Get_Operator_Operand (The_Operator => The_Operator),
            Scope   => Scope);
      when True =>
         Write_Binary_Operator_Renaming_Declaration
           (Name  => RawDict.Get_Operator_Name (The_Operator => The_Operator),
            Left  => RawDict.Get_Operator_Left_Operand (The_Operator => The_Operator),
            Right => RawDict.Get_Operator_Right_Operand (The_Operator => The_Operator),
            Scope => Scope);
   end case;
end WriteOperatorRenamingDeclaration;