aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/prj-ext.ads
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-08-03 11:21:55 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-03 11:21:55 +0200
commitc0e538ad8071a46fc28634e622faa5a51bf81807 (patch)
tree3725855258e586f8b68daed8cfdfe5efa06f8cf7 /gcc/ada/prj-ext.ads
parentc4d67e2d730f6a8e45182a384b5b674f5134bc64 (diff)
downloadgcc-c0e538ad8071a46fc28634e622faa5a51bf81807.zip
gcc-c0e538ad8071a46fc28634e622faa5a51bf81807.tar.gz
gcc-c0e538ad8071a46fc28634e622faa5a51bf81807.tar.bz2
[multiple changes]
2011-08-03 Emmanuel Briot <briot@adacore.com> * prj-part.adb, prj-part.ads, prj-makr.adb, prj-pars.adb, prj-conf.adb, prj-env.adb (Prj.Part.Parse): change parameter Always_Errout_Finalize to Errout_Handling. 2011-08-03 Emmanuel Briot <briot@adacore.com> * prj-dect.adb (Parse_Attribute_Declaration): make sure we can use "external" as an attribute name in aggregate projects. 2011-08-03 Jose Ruiz <ruiz@adacore.com> * s-taprop-vxworks.adb: (Create_Task, Initialize): Ada 2012 pragma CPU uses CPU numbers starting 1, while VxWorks uses CPU numbers starting from 0, so we need to adjust. 2011-08-03 Emmanuel Briot <briot@adacore.com> * prj-proc.adb, prj-ext.adb, prj-ext.ads, makeutl.adb, prj-tree.adb, prj-tree.ads, gnatcmd.adb, clean.adb (External_References): new type. From-SVN: r177244
Diffstat (limited to 'gcc/ada/prj-ext.ads')
-rw-r--r--gcc/ada/prj-ext.ads69
1 files changed, 63 insertions, 6 deletions
diff --git a/gcc/ada/prj-ext.ads b/gcc/ada/prj-ext.ads
index 1fb389c..26ad219 100644
--- a/gcc/ada/prj-ext.ads
+++ b/gcc/ada/prj-ext.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 2000-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 2000-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -26,7 +26,7 @@
-- Subprograms to set, get and cache external references, to be used as
-- External functions in project files.
-with Prj.Tree;
+with GNAT.Dynamic_HTables;
package Prj.Ext is
@@ -42,27 +42,84 @@ package Prj.Ext is
-- trees are loaded in parallel we can have different scenarios (or even
-- load the same tree twice and see different views of it).
+ type External_References is private;
+ No_External_Refs : constant External_References;
+
+ procedure Initialize
+ (Self : out External_References;
+ Copy_From : External_References := No_External_Refs);
+ -- Initialize Self, and copy all values from Copy_From if needed.
+ -- This has no effect if Self was already initialized.
+
+ procedure Free (Self : in out External_References);
+ -- Free memory used by Self
+
procedure Add
- (Tree : Prj.Tree.Project_Node_Tree_Ref;
+ (Self : External_References;
External_Name : String;
Value : String);
-- Add an external reference (or modify an existing one)
function Value_Of
- (Tree : Prj.Tree.Project_Node_Tree_Ref;
+ (Self : External_References;
External_Name : Name_Id;
With_Default : Name_Id := No_Name)
return Name_Id;
-- Get the value of an external reference, and cache it for future uses
function Check
- (Tree : Prj.Tree.Project_Node_Tree_Ref;
+ (Self : External_References;
Declaration : String) return Boolean;
-- Check that an external declaration <external>=<value> is correct.
-- If it is correct, the external reference is Added.
- procedure Reset (Tree : Prj.Tree.Project_Node_Tree_Ref);
+ procedure Reset (Self : External_References);
-- Clear the internal data structure that stores the external references
-- and free any allocated memory.
+private
+
+ -- Use a Static_HTable, not a Simple_HTable.
+ -- The issue is that we need to be able to copy the contents of the table
+ -- (in Initialize), but this isn't doable for Simple_HTable for which
+ -- iterators do not return the key.
+
+ type Name_To_Name;
+ type Name_To_Name_Ptr is access all Name_To_Name;
+ type Name_To_Name is record
+ Key : Name_Id;
+ Value : Name_Id;
+ Next : Name_To_Name_Ptr;
+ end record;
+
+ procedure Set_Next (E : Name_To_Name_Ptr; Next : Name_To_Name_Ptr);
+ function Next (E : Name_To_Name_Ptr) return Name_To_Name_Ptr;
+ function Get_Key (E : Name_To_Name_Ptr) return Name_Id;
+
+ package Name_To_Name_HTable is new GNAT.Dynamic_HTables.Static_HTable
+ (Header_Num => Header_Num,
+ Element => Name_To_Name,
+ Elmt_Ptr => Name_To_Name_Ptr,
+ Null_Ptr => null,
+ Set_Next => Set_Next,
+ Next => Next,
+ Key => Name_Id,
+ Get_Key => Get_Key,
+ Hash => Hash,
+ Equal => "=");
+ -- General type for htables associating name_id to name_id. This is in
+ -- particular used to store the values of external references.
+
+ type Instance_Access is access all Name_To_Name_HTable.Instance;
+
+ type External_References is record
+ Refs : Instance_Access;
+ -- External references are stored in this hash table (and manipulated
+ -- through subprogrames in prj-ext.ads). External references are
+ -- project-tree specific so that one can load the same tree twice but
+ -- have two views of it, for instance.
+ end record;
+
+ No_External_Refs : constant External_References := (Refs => null);
+
end Prj.Ext;