File: asistant-table.ads

package info (click to toggle)
asis 2008-5
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 9,724 kB
  • ctags: 615
  • sloc: ada: 95,867; makefile: 259; xml: 19
file content (144 lines) | stat: -rw-r--r-- 5,893 bytes parent folder | download | duplicates (4)
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
------------------------------------------------------------------------------
--                                                                          --
--             ASIS Tester And iNTerpreter (ASIStant) COMPONENTS            --
--                                                                          --
--                       A S I S T A N T . T A B L E                        --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
--          Copyright (c) 1997-2005, Free Software Foundation, Inc.         --
--                                                                          --
-- ASIStant 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 2,  or  (at your option)  any later --
-- version. ASIStant is distributed  in the hope  that it will be useful,   --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MER-      --
-- CHANTABILITY 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 GNAT; see file COPYING. If   --
-- not, write to the Free Software Foundation, 59 Temple Place Suite 330,   --
-- Boston, MA 02111-1307, USA.                                              --
--                                                                          --
-- ASIStant is an evolution of ASIStint tool that was created by            --
-- Vasiliy Fofanov as part of a collaboration between Software Engineering  --
-- Laboratory of the Swiss Federal Institute of Technology in Lausanne,     --
-- Switzerland, and the Scientific Research Computer Center of the Moscow   --
-- University, Russia, supported by the Swiss National Science Foundation   --
-- grant #7SUPJ048247, "Development of ASIS for GNAT with industry quality" --
--                                                                          --
-- ASIStant is distributed as a part of the ASIS implementation for GNAT    --
-- (ASIS-for-GNAT) and is maintained by Ada Core Technologies Inc           --
-- (http://www.gnat.com).                                                   --
------------------------------------------------------------------------------

with Asis;
with Asis.Text;
with Asis.Data_Decomposition;
with ASIStant.Common; use ASIStant.Common;

package ASIStant.Table is

------------------------------------------------------------------------------
--  This package provides handling of ASIStant language variable tables
------------------------------------------------------------------------------

   package DDA renames Asis.Data_Decomposition;

   subtype Var_Name is Name_String;

   type Var_Type is
   (
      Par_Absent,

      Par_ATime,
      Par_Boolean,
      Par_Context,
      Par_CUnit,
      Par_CUnitList,
      Par_ElemList,
      Par_Element,
      Par_Integer,
      Par_Line,
      Par_Line_List,
      Par_Relationship,
      Par_String,
      Par_Span,

      Par_DDA_Array_Component,
      Par_DDA_Array_Component_List,
      Par_DDA_Record_Component,
      Par_DDA_Record_Component_List,

      Par_XXXXX --  for not implemented types
   );
   --  Type to represent variable types

   type Query_Result (RType : Var_Type := Par_Absent) is
      record
         case RType is
            when Par_Absent    => null;
            when Par_String    => S  : String_Ptr;
            when Par_Boolean   => B  : Boolean;
            when Par_CUnit     => C  : Asis.Compilation_Unit;
            when Par_CUnitList => CL : CUnitList_Ptr;
            when Par_Element   => E  : Asis.Element;
            when Par_ElemList  => EL : ElemList_Ptr;
            when Par_Context | Par_Integer
                               => I  : Integer;
            when Par_Line      => L  : Asis.Text.Line;
            when Par_Line_List => LL : LineList_Ptr;
            when Par_Relationship
                               => R  : Relship_Ptr;
            when Par_Span      => Sp : Asis.Text.Span;
            when Par_DDA_Array_Component
                               => AC : DDA.Array_Component;

            when Par_DDA_Array_Component_List
                               => ACL : DDA_ArrCList_Ptr;
            when Par_DDA_Record_Component
                               => RC : DDA.Record_Component;
            when Par_DDA_Record_Component_List
                               => RCL : DDA_RecCList_Ptr;

            when others        => null;
         end case;
      end record;
   --  Universal ASIStant expression representation

   type Var_Info is
      record
         Name   : Var_Name;
         VType  : Var_Type;
         IValue : Integer;
         SValue : String_Ptr;
      end record;

   Var_Unknown : constant Var_Info :=
      ((1 .. MAX_ID_LENGTH => ' '), Par_Absent, 0, null);

   type V_Table is array (Positive range <>) of Var_Info;
   type V_TablePtr is access all V_Table;

   type Var_Table is
      record
         Free  : Positive;
         Max   : Positive;
         Table : V_TablePtr;
      end record;

   CurTable : Var_Table :=
      (1, MAX_VARIABLES, new V_Table (1 .. MAX_VARIABLES));

   function  Get_Var (T : Var_Table; N : Wide_String) return Var_Info;
   --  Scans for the variable in table T. Returns Var_Unknown if fails.

   function Get_Var_Value (VI : Var_Info) return Query_Result;
   --  Returns variable value information

   function Store_Var_Value (QR : Query_Result) return Var_Info;
   --  Stores value information in variable

   procedure Modify_Var (T : in out Var_Table; V : Var_Info);
   --  Adds/changes variable

end ASIStant.Table;