summaryrefslogtreecommitdiff
path: root/gcc/ada/g-comlin.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-13 10:23:29 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-13 10:23:29 +0000
commit453c24fb4dcaabaa2ef129d61468fc1e8733dcaa (patch)
tree740c5aba3c0949b0af4ce8a5af9213a4c4837b5f /gcc/ada/g-comlin.adb
parent7b17e51b9ad5916b8df45cf5bedaf1ba81aaa0a2 (diff)
downloadgcc-453c24fb4dcaabaa2ef129d61468fc1e8733dcaa.tar.gz
2007-12-06 Bob Duff <duff@adacore.com>
* clean.adb (Usage): Add line for -aP (Check_Version_And_Help): Change Check_Version_And_Help to be generic, with a parameter "procedure Usage", instead of passing a pointer to a procedure. This is to eliminate trampolines (since the Usage procedure is often nested in a main procedure, and it would be inconvenient to unnest it). * g-comlin.adb (For_Each_Simple_Switch): Change For_Each_Simple_Switch to be generic, with a parameter "procedure Callback (...)", instead of passing a pointer to a procedure. This is to eliminate trampolines (since the Callback procedure is usually nested). * gnatfind.adb, switch.adb, switch.ads, gnatlink.adb, gnatls.adb, gnatname.adb, gnatxref.adb, gnatchop.adb, gprep.adb, gnatbind.adb (Check_Version_And_Help): Change Check_Version_And_Help to be generic. * g-pehage.adb (Compute_Edges_And_Vertices, Build_Identical_Key_Sets): Use the generic Heap_Sort_G instead of Heap_Sort_A. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130824 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-comlin.adb')
-rw-r--r--gcc/ada/g-comlin.adb46
1 files changed, 25 insertions, 21 deletions
diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb
index 95b1fbe2367..d661978bd59 100644
--- a/gcc/ada/g-comlin.adb
+++ b/gcc/ada/g-comlin.adb
@@ -114,11 +114,11 @@ package body GNAT.Command_Line is
function Args_From_Expanded (Args : Boolean_Chars) return String;
-- Return the string made of all characters with True in Args
- type Callback_Procedure is access procedure (Simple_Switch : String);
+ generic
+ with procedure Callback (Simple_Switch : String);
procedure For_Each_Simple_Switch
- (Cmd : Command_Line;
- Switch : String;
- Callback : Callback_Procedure);
+ (Cmd : Command_Line;
+ Switch : String);
-- Breaks Switch into as simple switches as possible (expanding aliases and
-- ungrouping common prefixes when possible), and call Callback for each of
-- these.
@@ -1185,9 +1185,8 @@ package body GNAT.Command_Line is
----------------------------
procedure For_Each_Simple_Switch
- (Cmd : Command_Line;
- Switch : String;
- Callback : Callback_Procedure)
+ (Cmd : Command_Line;
+ Switch : String)
is
begin
-- Are we adding a switch that can in fact be expanded through aliases ?
@@ -1204,7 +1203,7 @@ package body GNAT.Command_Line is
for A in Cmd.Config.Aliases'Range loop
if Cmd.Config.Aliases (A).all = Switch then
For_Each_Simple_Switch
- (Cmd, Cmd.Config.Expansions (A).all, Callback);
+ (Cmd, Cmd.Config.Expansions (A).all);
return;
end if;
end loop;
@@ -1227,7 +1226,7 @@ package body GNAT.Command_Line is
.. Switch'Last
loop
For_Each_Simple_Switch
- (Cmd, Cmd.Config.Prefixes (P).all & Switch (S), Callback);
+ (Cmd, Cmd.Config.Prefixes (P).all & Switch (S));
end loop;
return;
end if;
@@ -1291,11 +1290,13 @@ package body GNAT.Command_Line is
end if;
end Add_Simple_Switch;
+ procedure Add_Simple_Switches is
+ new For_Each_Simple_Switch (Add_Simple_Switch);
+
-- Start of processing for Add_Switch
begin
- For_Each_Simple_Switch
- (Cmd, Switch, Add_Simple_Switch'Unrestricted_Access);
+ Add_Simple_Switches (Cmd, Switch);
Free (Cmd.Coalesce);
end Add_Switch;
@@ -1381,11 +1382,13 @@ package body GNAT.Command_Line is
end if;
end Remove_Simple_Switch;
+ procedure Remove_Simple_Switches is
+ new For_Each_Simple_Switch (Remove_Simple_Switch);
+
-- Start of processing for Remove_Switch
begin
- For_Each_Simple_Switch
- (Cmd, Switch, Remove_Simple_Switch'Unrestricted_Access);
+ Remove_Simple_Switches (Cmd, Switch);
Free (Cmd.Coalesce);
end Remove_Switch;
@@ -1440,11 +1443,13 @@ package body GNAT.Command_Line is
end if;
end Remove_Simple_Switch;
+ procedure Remove_Simple_Switches is
+ new For_Each_Simple_Switch (Remove_Simple_Switch);
+
-- Start of processing for Remove_Switch
begin
- For_Each_Simple_Switch
- (Cmd, Switch, Remove_Simple_Switch'Unrestricted_Access);
+ Remove_Simple_Switches (Cmd, Switch);
Free (Cmd.Coalesce);
end Remove_Switch;
@@ -1566,6 +1571,9 @@ package body GNAT.Command_Line is
end loop;
end Remove_Cb;
+ procedure Check_All is new For_Each_Simple_Switch (Check_Cb);
+ procedure Remove_All is new For_Each_Simple_Switch (Remove_Cb);
+
-- Start of processing for Alias_Switches
begin
@@ -1582,15 +1590,11 @@ package body GNAT.Command_Line is
-- then check whether the expanded command line has all of them.
Found := True;
- For_Each_Simple_Switch
- (Cmd, Cmd.Config.Expansions (A).all,
- Check_Cb'Unrestricted_Access);
+ Check_All (Cmd, Cmd.Config.Expansions (A).all);
if Found then
First := Integer'Last;
- For_Each_Simple_Switch
- (Cmd, Cmd.Config.Expansions (A).all,
- Remove_Cb'Unrestricted_Access);
+ Remove_All (Cmd, Cmd.Config.Expansions (A).all);
Result (First) := new String'(Cmd.Config.Aliases (A).all);
end if;
end loop;