From 3c08de34076ffc085e335cc9c89661945823c594 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 16 Dec 2019 10:34:37 +0000 Subject: [Ada] Prototype implementastion of Ada2020 Map-reduce construct 2019-12-16 Ed Schonberg gcc/ada/ * scng.adb (Scan): In Ada2020, a left-bracket indicates the start of an homogenous aggregate. * par-ch4.adb (P_Reduction_Attribute_Reference): New procedure. (P_Aggregate): Recognize Ada2020 bracket-delimited aggregates. (P_Primary): Ditto. * par-util.adb (Comma_Present): Return false on a right bracket in Ada2020, indicating the end of an aggregate. * snames.ads-tmpl: Introduce Name_Reduce and Attribute Reduce. * sinfo.ads, sinfo.adb (Is_Homogeneous_Aggregate): New flag on aggregates, to designate an Ada2020 array or container aggregate that is bracket-delimited in the source. * sem_attr.adb (Analyze_Attribute): For attribute Reduce, verify that two arguments are present, and verify that the prefix is a stream or an object that is iterable (array or contrainer). (Resolve_Attribute): For attribute Reduce, resolve initial value with the type of the context. Type-checking of element type of prefix is performed after expansion. * exp_attr.adb (Expand_N_Attribute_Reference): For attribute Reduce, expand into a loop: a) If prefix is an aggregate with a single iterated component association, use its iterator specification to construct a loop, b) If prefix is a name, build a loop using an element iterator loop. * scans.ads: Add brackets tokens. From-SVN: r279431 --- gcc/ada/sinfo.adb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/ada/sinfo.adb') diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb index b99a32d..41cb8c8 100644 --- a/gcc/ada/sinfo.adb +++ b/gcc/ada/sinfo.adb @@ -2010,6 +2010,14 @@ package body Sinfo is return Flag2 (N); end Is_Generic_Contract_Pragma; + function Is_Homogeneous_Aggregate + (N : Node_Id) return Boolean is + begin + pragma Assert (False + or else NT (N).Nkind = N_Aggregate); + return Flag14 (N); + end Is_Homogeneous_Aggregate; + function Is_Ignored (N : Node_Id) return Boolean is begin @@ -5505,6 +5513,14 @@ package body Sinfo is Set_Flag2 (N, Val); end Set_Is_Generic_Contract_Pragma; + procedure Set_Is_Homogeneous_Aggregate + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False + or else NT (N).Nkind = N_Aggregate); + Set_Flag14 (N, Val); + end Set_Is_Homogeneous_Aggregate; + procedure Set_Is_Ignored (N : Node_Id; Val : Boolean := True) is begin -- cgit v1.1