1------------------------------------------------------------------------------ 2-- -- 3-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- 4-- -- 5-- A 4 G . A S I S _ T A B L E S -- 6-- -- 7-- S p e c -- 8-- -- 9-- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- 10-- -- 11-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- 12-- under terms of the GNU General Public License as published by the Free -- 13-- Software Foundation; either version 2, or (at your option) any later -- 14-- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- 15-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- 16-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- 17-- Public License for more details. You should have received a copy of the -- 18-- GNU General Public License distributed with ASIS-for-GNAT; see file -- 19-- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- 20-- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- 21-- -- 22-- -- 23-- -- 24-- -- 25-- -- 26-- -- 27-- -- 28-- -- 29-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- 30-- Software Engineering Laboratory of the Swiss Federal Institute of -- 31-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- 32-- Scientific Research Computer Center of Moscow State University (SRCC -- 33-- MSU), Russia, with funding partially provided by grants from the Swiss -- 34-- National Science Foundation and the Swiss Academy of Engineering -- 35-- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- 36-- (http://www.adacore.com). -- 37-- -- 38------------------------------------------------------------------------------ 39 40-- This package contains definitions of tables and related auxilary resources 41-- needed in more than one ASIS implementation package 42 43with Asis; 44 45with Sinfo; use Sinfo; 46with Table; 47with Types; use Types; 48 49package A4G.Asis_Tables is 50 51 package Internal_Asis_Element_Table is new Table.Table ( 52 Table_Component_Type => Asis.Element, 53 Table_Index_Type => Asis.ASIS_Natural, 54 Table_Low_Bound => 1, 55 Table_Initial => 10, 56 Table_Increment => 100, 57 Table_Name => "Internal Element_List"); 58 59 -- This table contains ASIS Elements. It is supposed to be used only for 60 -- creating the result Element lists in ASIS structural queries. Note that 61 -- many ASIS queries use instantiations of Traverse_Elements to create 62 -- result lists, so we have to make sure that ASIS structural queries 63 -- used in the implementation of Traverse_Element use another table to 64 -- create result lists 65 66 package Asis_Element_Table is new Table.Table ( 67 Table_Component_Type => Asis.Element, 68 Table_Index_Type => Asis.ASIS_Natural, 69 Table_Low_Bound => 1, 70 Table_Initial => 10, 71 Table_Increment => 100, 72 Table_Name => "Element_List"); 73 -- This table contains ASIS Elements. It is supposed to be used for any 74 -- purpose except creating the result Element lists in ASIS structural 75 -- queries. 76 77 procedure Add_New_Element (Element : Asis.Element); 78 -- Differs from Asis_Element_Table.Append that checks if the argument 79 -- Element already is in the table, and appends the new element only if the 80 -- check fails. Note that the implementation is based on a simple array 81 -- search, so it can result in performance penalties if there are too 82 -- many elements in the table. 83 84 type Node_Trace_Rec is record 85 Kind : Node_Kind; 86 Node_Line : Physical_Line_Number; 87 Node_Col : Column_Number; 88 end record; 89 -- This record represents a Node in the node trace used to find the same 90 -- construct in another tree 91 92 package Node_Trace is new Table.Table ( 93 Table_Component_Type => Node_Trace_Rec, 94 Table_Index_Type => Int, 95 Table_Low_Bound => 0, 96 Table_Initial => 10, 97 Table_Increment => 100, 98 Table_Name => "Node_Trace"); 99 -- This table is used to create the node trace needed to compare elements 100 -- from nested instances 101 102 function Is_Equal 103 (N : Node_Id; 104 Trace_Rec : Node_Trace_Rec) 105 return Boolean; 106 -- Checks if N (in the currently accessed tree corresponds to the node 107 -- for which Trace_Rec was created 108 109 procedure Create_Node_Trace (N : Node_Id); 110 -- Creates the Node trace which is supposed to be used to find the node 111 -- representing the same construct in another tree. The trace is also used 112 -- to check is two nodes from different trees, each belonging to expanded 113 -- generics both denote the same thing. This trace contains the record 114 -- about N itself and all the enclosing constructs such as package bodies 115 -- and package specs. For the package which is an expanded generic, the 116 -- next element in the trace is the corresponding instantiation node. 117 118 function Enclosing_Scope (N : Node_Id) return Node_Id; 119 -- Given a node somewhere from expanded generic, returnes its enclosing 120 -- "scope" which can be N_Package_Declaration, N_Package_Body or 121 -- N_Generic_Declaration node. The idea is to use this function to create 122 -- the node trace either for storing it in the Note Trace table or for 123 -- creating the trace on the fly to compare it with the stored trace. 124 125end A4G.Asis_Tables; 126