aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/a-cgaaso.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-11-04 14:45:01 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2011-11-04 14:45:01 +0100
commit8c18a165e2ebb82121a0cae15e50c0ac74bd33c3 (patch)
tree1ed84f104093c2e1fdc9849a02ea2ea880616996 /gcc/ada/a-cgaaso.adb
parent872b942a5b8626fbfa1c9692e0e9fb5a590cf333 (diff)
downloadgcc-8c18a165e2ebb82121a0cae15e50c0ac74bd33c3.zip
gcc-8c18a165e2ebb82121a0cae15e50c0ac74bd33c3.tar.gz
gcc-8c18a165e2ebb82121a0cae15e50c0ac74bd33c3.tar.bz2
[multiple changes]
2011-11-04 Yannick Moy <moy@adacore.com> * atree.adb, atree.ads (Set_Original_Node): New set procedure. * sem_ch13.adb (Analyze_Aspect_Specifications/Pre_Post_Aspects): In ASIS mode, no splitting of aspects between conjuncts. (Analyze_Aspect_Specifications/Aspect_Test_Case): Make pragma expressions refer to the original aspect expressions through the Original_Node link. This is used in semantic analysis for ASIS mode, so that the original expression also gets analyzed. * sem_prag.adb (Preanalyze_TC_Args, Check_Precondition_Postcondition, Analyze_Pragma/Pragma_Test_Case): In ASIS mode, for a pragma generated from a source aspect, also analyze the original aspect expression. (Check_Expr_Is_Static_Expression): New procedure similar to existing procedure Check_Arg_Is_Static_Expression, except called on expression inside pragma. 2011-11-04 Tristan Gingold <gingold@adacore.com> * prj-env.adb, prj-env.ads (Find_Name_In_Path): New function, from Find_Project.Try_Path_Name. (Find_Project): Use Find_Name_In_Path to implement Try_Path_Name. 2011-11-04 Eric Botcazou <ebotcazou@adacore.com> * s-atocou.ads (Atomic_Counter): Remove redundant pragma Volatile. 2011-11-04 Pascal Obry <obry@adacore.com> * projects.texi: Add short description for qualifiers aggregate and aggregate library. 2011-11-04 Matthew Heaney <heaney@adacore.com> * Makefile.rtl, impunit.adb: Added a-cogeso.ad[sb] * a-cgaaso.adb: Replaced implementation with instantiation of Generic_Sort. * a-cogeso.ad[sb] This is the new Ada 2012 unit Ada.Containers.Generic_Sort From-SVN: r180948
Diffstat (limited to 'gcc/ada/a-cgaaso.adb')
-rw-r--r--gcc/ada/a-cgaaso.adb104
1 files changed, 11 insertions, 93 deletions
diff --git a/gcc/ada/a-cgaaso.adb b/gcc/ada/a-cgaaso.adb
index abb8631..12763f1 100644
--- a/gcc/ada/a-cgaaso.adb
+++ b/gcc/ada/a-cgaaso.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2004-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-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- --
@@ -27,103 +27,21 @@
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
--- This algorithm was adapted from GNAT.Heap_Sort (see g-heasor.ad[sb])
+-- This unit was originally a GNAT-specific addition to Ada 2005. A unit
+-- providing the same feature, Ada.Containers.Generic_Sort, was defined for
+-- Ada 2012. We retain Generic_Anonymous_Array_Sort for compatibility, but
+-- implement it in terms of the official unit, Generic_Sort.
-with System;
+with Ada.Containers.Generic_Sort;
procedure Ada.Containers.Generic_Anonymous_Array_Sort
(First, Last : Index_Type'Base)
is
- type T is range System.Min_Int .. System.Max_Int;
-
- function To_Index (J : T) return Index_Type;
- pragma Inline (To_Index);
-
- function Lt (J, K : T) return Boolean;
- pragma Inline (Lt);
-
- procedure Xchg (J, K : T);
- pragma Inline (Xchg);
-
- procedure Sift (S : T);
-
- --------------
- -- To_Index --
- --------------
-
- function To_Index (J : T) return Index_Type is
- K : constant T'Base := Index_Type'Pos (First) + J - T'(1);
- begin
- return Index_Type'Val (K);
- end To_Index;
-
- --------
- -- Lt --
- --------
-
- function Lt (J, K : T) return Boolean is
- begin
- return Less (To_Index (J), To_Index (K));
- end Lt;
-
- ----------
- -- Xchg --
- ----------
-
- procedure Xchg (J, K : T) is
- begin
- Swap (To_Index (J), To_Index (K));
- end Xchg;
-
- Max : T := Index_Type'Pos (Last) - Index_Type'Pos (First) + T'(1);
-
- ----------
- -- Sift --
- ----------
-
- procedure Sift (S : T) is
- C : T := S;
- Son : T;
- Father : T;
-
- begin
- loop
- Son := C + C;
-
- if Son < Max then
- if Lt (Son, Son + 1) then
- Son := Son + 1;
- end if;
- elsif Son > Max then
- exit;
- end if;
-
- Xchg (Son, C);
- C := Son;
- end loop;
-
- while C /= S loop
- Father := C / 2;
-
- if Lt (Father, C) then
- Xchg (Father, C);
- C := Father;
- else
- exit;
- end if;
- end loop;
- end Sift;
-
--- Start of processing for Generic_Anonymous_Array_Sort
+ procedure Sort is new Ada.Containers.Generic_Sort
+ (Index_Type => Index_Type,
+ Before => Less,
+ Swap => Swap);
begin
- for J in reverse 1 .. Max / 2 loop
- Sift (J);
- end loop;
-
- while Max > 1 loop
- Xchg (1, Max);
- Max := Max - 1;
- Sift (1);
- end loop;
+ Sort (First, Last);
end Ada.Containers.Generic_Anonymous_Array_Sort;