repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
RREE/ada-util | Ada | 5,922 | adb | -----------------------------------------------------------------------
-- util-locales -- Locale support
-- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2011, 2015, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Hash;
package body Util.Locales is
-- ------------------------------
-- Get the lowercase two-letter ISO-639 code.
-- ------------------------------
function Get_Language (Loc : in Locale) return String is
begin
if Loc = null then
return "";
else
return Loc (1 .. 2);
end if;
end Get_Language;
-- ------------------------------
-- Get the ISO 639-2 language code.
-- ------------------------------
function Get_ISO3_Language (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 3 then
return "";
end if;
if Loc'Length <= 6 then
return Loc (4 .. 6);
end if;
return Loc (7 .. 9);
end Get_ISO3_Language;
-- ------------------------------
-- Get the uppercase two-letter ISO-3166 code.
-- ------------------------------
function Get_Country (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 2 or else Loc (3) /= '_' then
return "";
else
return Loc (4 .. 5);
end if;
end Get_Country;
-- ------------------------------
-- Get the ISO-3166-2 country code.
-- ------------------------------
function Get_ISO3_Country (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 5 then
return "";
else
return Loc (10 .. Loc'Last);
end if;
end Get_ISO3_Country;
-- ------------------------------
-- Get the variant code
-- ------------------------------
function Get_Variant (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 13 then
return "";
else
return Loc (7 .. 8);
end if;
end Get_Variant;
-- ------------------------------
-- Get the locale for the given language code
-- ------------------------------
function Get_Locale (Language : in String) return Locale is
Length : constant Natural := Language'Length;
Lower : Natural := Locales'First;
Upper : Natural := Locales'Last;
Pos : Natural;
Result : Locale;
begin
while Lower <= Upper loop
Pos := (Lower + Upper) / 2;
Result := Locales (Pos);
if Result'Length < Length then
if Result.all < Language (Language'First .. Language'First + Result'Length - 1) then
Lower := Pos + 1;
else
Upper := Pos - 1;
end if;
elsif Result'Length > Length and then Result (Length + 1) = '.'
and then Result (1 .. Length) = Language
then
return Result;
elsif Result (1 .. Length) < Language then
Lower := Pos + 1;
else
Upper := Pos - 1;
end if;
end loop;
return NULL_LOCALE;
end Get_Locale;
-- ------------------------------
-- Get the locale for the given language and country code
-- ------------------------------
function Get_Locale (Language : in String;
Country : in String) return Locale is
begin
if Language'Length /= 2 or else (Country'Length /= 0 and Country'Length /= 2) then
return NULL_LOCALE;
elsif Country'Length = 0 then
return Get_Locale (Language);
else
return Get_Locale (Language & "_" & Country);
end if;
end Get_Locale;
-- ------------------------------
-- Get the locale for the given language, country and variant code
-- ------------------------------
function Get_Locale (Language : in String;
Country : in String;
Variant : in String) return Locale is
begin
if Language'Length /= 2
or else (Country'Length /= 0 and Country'Length /= 2)
or else (Variant'Length /= 0 and Variant'Length /= 2)
then
return NULL_LOCALE;
end if;
if Country'Length = 0 and Variant'Length = 0 then
return Get_Locale (Language);
elsif Variant'Length = 0 then
return Get_Locale (Language, Country);
else
return Get_Locale (Language & "_" & Country & "_" & Variant);
end if;
end Get_Locale;
-- ------------------------------
-- Get the locale code in the form <i>language</i>_<i>country</i>_<i>variant</i>.
-- ------------------------------
function To_String (Loc : in Locale) return String is
begin
if Loc = null then
return "";
elsif Loc'Length > 3 and Loc (3) = '.' then
return Loc (1 .. 2);
elsif Loc'Length > 6 and Loc (6) = '.' then
return Loc (1 .. 5);
else
return Loc (1 .. 8);
end if;
end To_String;
-- ------------------------------
-- Compute the hash value of the locale.
-- ------------------------------
function Hash (Loc : in Locale) return Ada.Containers.Hash_Type is
begin
return Ada.Strings.Hash (Loc.all);
end Hash;
end Util.Locales;
|
reznikmm/matreshka | Ada | 4,041 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Presentation_Pause_Attributes;
package Matreshka.ODF_Presentation.Pause_Attributes is
type Presentation_Pause_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Pause_Attributes.ODF_Presentation_Pause_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Pause_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Pause_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Pause_Attributes;
|
Fabien-Chouteau/samd51-hal | Ada | 6,954 | ads |
-- Generated by a script from an "avr tools device file" (atdf)
package SAM.Interrupt_Names is
Number_Of_Interrupts : constant := 137;
ac_interrupt : constant := 122;
adc0_other_interrupt : constant := 118;
adc0_resrdy_interrupt : constant := 119;
adc1_other_interrupt : constant := 120;
adc1_resrdy_interrupt : constant := 121;
aes_interrupt : constant := 130;
dac_other_interrupt : constant := 123;
dac_empty_0_interrupt : constant := 124;
dac_empty_1_interrupt : constant := 125;
dac_resrdy_0_interrupt : constant := 126;
dac_resrdy_1_interrupt : constant := 127;
dmac_0_interrupt : constant := 31;
dmac_1_interrupt : constant := 32;
dmac_2_interrupt : constant := 33;
dmac_3_interrupt : constant := 34;
dmac_other_interrupt : constant := 35;
eic_extint_0_interrupt : constant := 12;
eic_extint_1_interrupt : constant := 13;
eic_extint_2_interrupt : constant := 14;
eic_extint_3_interrupt : constant := 15;
eic_extint_4_interrupt : constant := 16;
eic_extint_5_interrupt : constant := 17;
eic_extint_6_interrupt : constant := 18;
eic_extint_7_interrupt : constant := 19;
eic_extint_8_interrupt : constant := 20;
eic_extint_9_interrupt : constant := 21;
eic_extint_10_interrupt : constant := 22;
eic_extint_11_interrupt : constant := 23;
eic_extint_12_interrupt : constant := 24;
eic_extint_13_interrupt : constant := 25;
eic_extint_14_interrupt : constant := 26;
eic_extint_15_interrupt : constant := 27;
evsys_0_interrupt : constant := 36;
evsys_1_interrupt : constant := 37;
evsys_2_interrupt : constant := 38;
evsys_3_interrupt : constant := 39;
evsys_other_interrupt : constant := 40;
freqm_interrupt : constant := 28;
icm_interrupt : constant := 132;
i2s_interrupt : constant := 128;
mclk_interrupt : constant := 1;
nvmctrl_0_interrupt : constant := 29;
nvmctrl_1_interrupt : constant := 30;
oscctrl_xosc0_interrupt : constant := 2;
oscctrl_xosc1_interrupt : constant := 3;
oscctrl_dfll_interrupt : constant := 4;
oscctrl_dpll0_interrupt : constant := 5;
oscctrl_dpll1_interrupt : constant := 6;
osc32kctrl_interrupt : constant := 7;
pac_interrupt : constant := 41;
pcc_interrupt : constant := 129;
pdec_other_interrupt : constant := 115;
pdec_mc0_interrupt : constant := 116;
pdec_mc1_interrupt : constant := 117;
pm_interrupt : constant := 0;
qspi_interrupt : constant := 134;
ramecc_interrupt : constant := 45;
rtc_interrupt : constant := 11;
sdhc0_interrupt : constant := 135;
sdhc1_interrupt : constant := 136;
sercom0_0_interrupt : constant := 46;
sercom0_1_interrupt : constant := 47;
sercom0_2_interrupt : constant := 48;
sercom0_other_interrupt : constant := 49;
sercom1_0_interrupt : constant := 50;
sercom1_1_interrupt : constant := 51;
sercom1_2_interrupt : constant := 52;
sercom1_other_interrupt : constant := 53;
sercom2_0_interrupt : constant := 54;
sercom2_1_interrupt : constant := 55;
sercom2_2_interrupt : constant := 56;
sercom2_other_interrupt : constant := 57;
sercom3_0_interrupt : constant := 58;
sercom3_1_interrupt : constant := 59;
sercom3_2_interrupt : constant := 60;
sercom3_other_interrupt : constant := 61;
sercom4_0_interrupt : constant := 62;
sercom4_1_interrupt : constant := 63;
sercom4_2_interrupt : constant := 64;
sercom4_other_interrupt : constant := 65;
sercom5_0_interrupt : constant := 66;
sercom5_1_interrupt : constant := 67;
sercom5_2_interrupt : constant := 68;
sercom5_other_interrupt : constant := 69;
sercom6_0_interrupt : constant := 70;
sercom6_1_interrupt : constant := 71;
sercom6_2_interrupt : constant := 72;
sercom6_other_interrupt : constant := 73;
sercom7_0_interrupt : constant := 74;
sercom7_1_interrupt : constant := 75;
sercom7_2_interrupt : constant := 76;
sercom7_other_interrupt : constant := 77;
supc_other_interrupt : constant := 8;
supc_boddet_interrupt : constant := 9;
tc0_interrupt : constant := 107;
tc1_interrupt : constant := 108;
tc2_interrupt : constant := 109;
tc3_interrupt : constant := 110;
tc4_interrupt : constant := 111;
tc5_interrupt : constant := 112;
tc6_interrupt : constant := 113;
tc7_interrupt : constant := 114;
tcc0_other_interrupt : constant := 85;
tcc0_mc0_interrupt : constant := 86;
tcc0_mc1_interrupt : constant := 87;
tcc0_mc2_interrupt : constant := 88;
tcc0_mc3_interrupt : constant := 89;
tcc0_mc4_interrupt : constant := 90;
tcc0_mc5_interrupt : constant := 91;
tcc1_other_interrupt : constant := 92;
tcc1_mc0_interrupt : constant := 93;
tcc1_mc1_interrupt : constant := 94;
tcc1_mc2_interrupt : constant := 95;
tcc1_mc3_interrupt : constant := 96;
tcc2_other_interrupt : constant := 97;
tcc2_mc0_interrupt : constant := 98;
tcc2_mc1_interrupt : constant := 99;
tcc2_mc2_interrupt : constant := 100;
tcc3_other_interrupt : constant := 101;
tcc3_mc0_interrupt : constant := 102;
tcc3_mc1_interrupt : constant := 103;
tcc4_other_interrupt : constant := 104;
tcc4_mc0_interrupt : constant := 105;
tcc4_mc1_interrupt : constant := 106;
trng_interrupt : constant := 131;
usb_other_interrupt : constant := 80;
usb_sof_hsof_interrupt : constant := 81;
usb_trcpt0_interrupt : constant := 82;
usb_trcpt1_interrupt : constant := 83;
wdt_interrupt : constant := 10;
end SAM.Interrupt_Names;
|
onox/orka | Ada | 981 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.SIMD.AVX is
pragma Pure;
type Index_8D is range 1 .. 8;
procedure Zero_All
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vzeroall";
procedure Zero_Upper
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vzeroupper";
end Orka.SIMD.AVX;
|
Chester-Gillon/ibv_message_passing | Ada | 1,907 | adb | -- @file coverage_for_ada_task.adb
-- @date 28 May 2022
-- @author Chester Gillon
-- @brief Example program to test getting coverage for an Ada task
with Ada.Text_IO;
with Ada.Command_Line;
procedure Coverage_For_Ada_Task is
generic
Name : String;
package Generic_Name is
procedure Display_Name;
end Generic_Name;
package body Generic_Name is
procedure Display_Name is
begin
Ada.Text_IO.Put_Line ("My name is " & Name);
end Display_Name;
end Generic_Name;
task Print_Task is
entry Print;
entry Finish;
end Print_Task;
task body Print_Task is
Finished : Boolean := False;
begin
while not Finished
loop
select
accept Print do
Ada.Text_IO.Put_Line ("In task Print_Task");
end Print;
or
accept Finish do
Finished := True;
end Finish;
or
terminate;
end select;
end loop;
end Print_Task;
package Package_A is new Generic_Name ("A");
package Package_B is new Generic_Name ("B");
package Package_C is new Generic_Name ("C");
begin
Package_A.Display_Name;
if Ada.Command_Line.Argument_Count > 0 then
-- If any command line arguments are passed call the generic function 'B'. This is to test getting coverage
-- from only certain generic packages.
Package_B.Display_Name;
end if;
for index in 1..3
loop
Print_Task.Print;
end loop;
Package_C.Display_Name;
Ada.Text_IO.Put_Line ("In main");
-- If any command line arguments are passed cause the task to execute the Finish entry point, otherwise leave to the
-- terminate alternate. This is to demonstrate getting coverage on only certain task entry points.
if Ada.Command_Line.Argument_Count > 0 then
Print_Task.Finish;
end if;
end Coverage_For_Ada_Task;
|
jhumphry/SPARK_SipHash | Ada | 1,257 | adb | -- Integer_Storage_IO
-- A re-implementation of Storage_IO for Integers with SPARK_Mode turned on in
-- the specification and off in the body.
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
with Ada.Unchecked_Conversion;
package body Integer_Storage_IO
with SPARK_Mode => Off
is
type Integer_Access is access all Integer;
type Storage_Element_Access is access all System.Storage_Elements.Storage_Element;
function SEA_to_ETA is
new Ada.Unchecked_Conversion(Source => Storage_Element_Access,
Target => Integer_Access);
procedure Read (Buffer : in Buffer_Type; Item : out Integer) is
B : aliased Buffer_Type := Buffer;
B_Access : constant Storage_Element_Access := B(1)'Unchecked_Access;
B_Access_As_ETA : constant Integer_Access := SEA_to_ETA(B_Access);
begin
Item := B_Access_As_ETA.all;
end Read;
procedure Write(Buffer : out Buffer_Type; Item : in Integer) is
B : aliased Buffer_Type;
B_Access : constant Storage_Element_Access := B(1)'Unchecked_Access;
B_Access_As_ETA : constant Integer_Access := SEA_to_ETA(B_Access);
begin
B_Access_As_ETA.all := Item;
Buffer := B;
end Write;
end Integer_Storage_IO;
|
optikos/oasis | Ada | 2,487 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Elements.Associations;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
package Program.Elements.Record_Component_Associations is
pragma Pure (Program.Elements.Record_Component_Associations);
type Record_Component_Association is
limited interface and Program.Elements.Associations.Association;
type Record_Component_Association_Access is
access all Record_Component_Association'Class with Storage_Size => 0;
not overriding function Choices
(Self : Record_Component_Association)
return Program.Element_Vectors.Element_Vector_Access is abstract;
not overriding function Expression
(Self : Record_Component_Association)
return Program.Elements.Expressions.Expression_Access is abstract;
type Record_Component_Association_Text is limited interface;
type Record_Component_Association_Text_Access is
access all Record_Component_Association_Text'Class with Storage_Size => 0;
not overriding function To_Record_Component_Association_Text
(Self : aliased in out Record_Component_Association)
return Record_Component_Association_Text_Access is abstract;
not overriding function Arrow_Token
(Self : Record_Component_Association_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Box_Token
(Self : Record_Component_Association_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
type Record_Component_Association_Vector is
limited interface and Program.Element_Vectors.Element_Vector;
type Record_Component_Association_Vector_Access is
access all Record_Component_Association_Vector'Class
with Storage_Size => 0;
overriding function Element
(Self : Record_Component_Association_Vector;
Index : Positive)
return not null Program.Elements.Element_Access is abstract
with Post'Class => Element'Result.Is_Record_Component_Association;
function To_Record_Component_Association
(Self : Record_Component_Association_Vector'Class;
Index : Positive)
return not null Record_Component_Association_Access
is (Self.Element (Index).To_Record_Component_Association);
end Program.Elements.Record_Component_Associations;
|
ZinebZaad/ENSEEIHT | Ada | 2,349 | adb | -- Auteurs :
-- Equipe :
-- Mini-projet 1 : Le jeu du devin
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
-- Deviner le nombre de l'utilisateur en interagissant avec lui.
procedure Deviner_Nombre is
--! declarations des variables du programme principal
BorneMin: Integer; -- la borne minimale.
BorneMax: Integer; -- la borne maximale.
Nombre: Integer; -- le nombre que l'ordinateur devine
Essaies: Integer; -- le nombre d'essaies
Choix: Character; -- le choix de l'utilisateur
begin
-- Demander à l'utilisateur de deviner le nombre.
loop
Put("Avez-vous choisi un nombre compris entre 1 et 999 (o/n) ? ");
Get(Choix);
if Choix = 'n' then
Put_Line("J'attends...");
end if;
exit when Choix = 'o';
end loop;
-- Initialiser les variables
BorneMin := 1;
BorneMax := 999;
Nombre := 500;
Essaies := 0;
-- Chercher le nombre deviné
loop
-- Mettre à jour les variables
if Choix = 'g' then
BorneMax := Nombre - 1;
elsif Choix = 'p' then
BorneMin := Nombre + 1;
end if;
-- Verifier si l'utilisateur ne triche pas
if BorneMax < BorneMin then
Put_Line("Vous trichez. J'arrête cette partie.");
return;
end if;
-- Calculer le nombre
Nombre := (BorneMin + BorneMax)/2; -- Valeur médiane
-- Incrementer les essaies
Essaies := Essaies + 1;
-- Afficher la proposition
Put ("Je propose ");
Put (Item => Nombre, Width => 1);
Put_Line("");
-- Saisir l'indice
loop
Put("Votre indice (t/p/g) ? ");
Get(Choix);
exit when Choix = 't' or Choix = 'p' or Choix = 'g';
end loop;
exit when Choix = 't';
end loop;
-- Afficher le nombre trouvé
Put ("J'ai trouvé ");
Put (Item => Nombre, Width => 1);
Put(" en ");
Put (Item => Essaies, Width => 1);
Put(" essai(s).");
end Deviner_Nombre;
|
zhmu/ananas | Ada | 5,056 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . T R A C E B A C K --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2022, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the default version of this package
-- Note: this unit must be compiled using -fno-optimize-sibling-calls.
-- See comment below in body of Call_Chain for details on the reason.
package body System.Traceback is
procedure Call_Chain
(Traceback : System.Address;
Max_Len : Natural;
Len : out Natural;
Exclude_Min : System.Address := System.Null_Address;
Exclude_Max : System.Address := System.Null_Address;
Skip_Frames : Natural := 1);
-- Same as the exported version, but takes Traceback as an Address
------------------
-- C_Call_Chain --
------------------
function C_Call_Chain
(Traceback : System.Address;
Max_Len : Natural) return Natural
is
Val : Natural;
begin
Call_Chain (Traceback, Max_Len, Val);
return Val;
end C_Call_Chain;
----------------
-- Call_Chain --
----------------
function Backtrace
(Traceback : System.Address;
Len : Integer;
Exclude_Min : System.Address;
Exclude_Max : System.Address;
Skip_Frames : Integer)
return Integer;
pragma Import (C, Backtrace, "__gnat_backtrace");
procedure Call_Chain
(Traceback : System.Address;
Max_Len : Natural;
Len : out Natural;
Exclude_Min : System.Address := System.Null_Address;
Exclude_Max : System.Address := System.Null_Address;
Skip_Frames : Natural := 1)
is
begin
-- Note: Backtrace relies on the following call actually creating a
-- stack frame. To ensure that this is the case, it is essential to
-- compile this unit without sibling call optimization.
-- We want the underlying engine to skip its own frame plus the
-- ones we have been requested to skip ourselves.
Len := Backtrace (Traceback => Traceback,
Len => Max_Len,
Exclude_Min => Exclude_Min,
Exclude_Max => Exclude_Max,
Skip_Frames => Skip_Frames + 1);
end Call_Chain;
procedure Call_Chain
(Traceback : in out System.Traceback_Entries.Tracebacks_Array;
Max_Len : Natural;
Len : out Natural;
Exclude_Min : System.Address := System.Null_Address;
Exclude_Max : System.Address := System.Null_Address;
Skip_Frames : Natural := 1)
is
begin
Call_Chain
(Traceback'Address, Max_Len, Len,
Exclude_Min, Exclude_Max,
-- Skip one extra frame to skip the other Call_Chain entry as well
Skip_Frames => Skip_Frames + 1);
end Call_Chain;
end System.Traceback;
|
charlie5/cBound | Ada | 1,528 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_big_requests_enable_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_big_requests_enable_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_big_requests_enable_request_t.Item,
Element_Array => xcb.xcb_big_requests_enable_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_big_requests_enable_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_big_requests_enable_request_t.Pointer,
Element_Array => xcb.xcb_big_requests_enable_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_big_requests_enable_request_t;
|
stcarrez/ada-util | Ada | 1,048 | ads | -----------------------------------------------------------------------
-- util-http-clients-curl-tests -- HTTP unit tests for AWS implementation
-- Copyright (C) 2012, 2019, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Http.Clients.Tests;
package Util.Http.Clients.AWS.Tests is
new Util.Http.Clients.Tests.Http_Tests (Util.Http.Clients.AWS.Register, "aws");
|
reznikmm/matreshka | Ada | 4,688 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Rejecting_Change_Id_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Rejecting_Change_Id_Attribute_Node is
begin
return Self : Table_Rejecting_Change_Id_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Rejecting_Change_Id_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Rejecting_Change_Id_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Rejecting_Change_Id_Attribute,
Table_Rejecting_Change_Id_Attribute_Node'Tag);
end Matreshka.ODF_Table.Rejecting_Change_Id_Attributes;
|
reznikmm/matreshka | Ada | 5,031 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.CMOF.Associations.Collections is
pragma Preelaborate;
package CMOF_Association_Collections is
new AMF.Generic_Collections
(CMOF_Association,
CMOF_Association_Access);
type Set_Of_CMOF_Association is
new CMOF_Association_Collections.Set with null record;
Empty_Set_Of_CMOF_Association : constant Set_Of_CMOF_Association;
type Ordered_Set_Of_CMOF_Association is
new CMOF_Association_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_CMOF_Association : constant Ordered_Set_Of_CMOF_Association;
type Bag_Of_CMOF_Association is
new CMOF_Association_Collections.Bag with null record;
Empty_Bag_Of_CMOF_Association : constant Bag_Of_CMOF_Association;
type Sequence_Of_CMOF_Association is
new CMOF_Association_Collections.Sequence with null record;
Empty_Sequence_Of_CMOF_Association : constant Sequence_Of_CMOF_Association;
private
Empty_Set_Of_CMOF_Association : constant Set_Of_CMOF_Association
:= (CMOF_Association_Collections.Set with null record);
Empty_Ordered_Set_Of_CMOF_Association : constant Ordered_Set_Of_CMOF_Association
:= (CMOF_Association_Collections.Ordered_Set with null record);
Empty_Bag_Of_CMOF_Association : constant Bag_Of_CMOF_Association
:= (CMOF_Association_Collections.Bag with null record);
Empty_Sequence_Of_CMOF_Association : constant Sequence_Of_CMOF_Association
:= (CMOF_Association_Collections.Sequence with null record);
end AMF.CMOF.Associations.Collections;
|
VMika/DES_Ada | Ada | 36,042 | ads | pragma Warnings (Off);
pragma Ada_95;
with System;
package ada_main is
gnat_argc : Integer;
gnat_argv : System.Address;
gnat_envp : System.Address;
pragma Import (C, gnat_argc);
pragma Import (C, gnat_argv);
pragma Import (C, gnat_envp);
gnat_exit_status : Integer;
pragma Import (C, gnat_exit_status);
GNAT_Version : constant String :=
"GNAT Version: GPL 2017 (20170515-63)" & ASCII.NUL;
pragma Export (C, GNAT_Version, "__gnat_version");
Ada_Main_Program_Name : constant String := "_ada_main" & ASCII.NUL;
pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name");
procedure adainit;
pragma Export (C, adainit, "adainit");
procedure adafinal;
pragma Export (C, adafinal, "adafinal");
function main
(argc : Integer;
argv : System.Address;
envp : System.Address)
return Integer;
pragma Export (C, main, "main");
type Version_32 is mod 2 ** 32;
u00001 : constant Version_32 := 16#d38f2cda#;
pragma Export (C, u00001, "mainB");
u00002 : constant Version_32 := 16#b6df930e#;
pragma Export (C, u00002, "system__standard_libraryB");
u00003 : constant Version_32 := 16#0a55feef#;
pragma Export (C, u00003, "system__standard_libraryS");
u00004 : constant Version_32 := 16#76789da1#;
pragma Export (C, u00004, "adaS");
u00005 : constant Version_32 := 16#0d7f1a43#;
pragma Export (C, u00005, "ada__calendarB");
u00006 : constant Version_32 := 16#5b279c75#;
pragma Export (C, u00006, "ada__calendarS");
u00007 : constant Version_32 := 16#85a06f66#;
pragma Export (C, u00007, "ada__exceptionsB");
u00008 : constant Version_32 := 16#1a0dcc03#;
pragma Export (C, u00008, "ada__exceptionsS");
u00009 : constant Version_32 := 16#e947e6a9#;
pragma Export (C, u00009, "ada__exceptions__last_chance_handlerB");
u00010 : constant Version_32 := 16#41e5552e#;
pragma Export (C, u00010, "ada__exceptions__last_chance_handlerS");
u00011 : constant Version_32 := 16#32a08138#;
pragma Export (C, u00011, "systemS");
u00012 : constant Version_32 := 16#4e7785b8#;
pragma Export (C, u00012, "system__soft_linksB");
u00013 : constant Version_32 := 16#ac24596d#;
pragma Export (C, u00013, "system__soft_linksS");
u00014 : constant Version_32 := 16#b01dad17#;
pragma Export (C, u00014, "system__parametersB");
u00015 : constant Version_32 := 16#4c8a8c47#;
pragma Export (C, u00015, "system__parametersS");
u00016 : constant Version_32 := 16#30ad09e5#;
pragma Export (C, u00016, "system__secondary_stackB");
u00017 : constant Version_32 := 16#88327e42#;
pragma Export (C, u00017, "system__secondary_stackS");
u00018 : constant Version_32 := 16#f103f468#;
pragma Export (C, u00018, "system__storage_elementsB");
u00019 : constant Version_32 := 16#1f63cb3c#;
pragma Export (C, u00019, "system__storage_elementsS");
u00020 : constant Version_32 := 16#41837d1e#;
pragma Export (C, u00020, "system__stack_checkingB");
u00021 : constant Version_32 := 16#bc1fead0#;
pragma Export (C, u00021, "system__stack_checkingS");
u00022 : constant Version_32 := 16#87a448ff#;
pragma Export (C, u00022, "system__exception_tableB");
u00023 : constant Version_32 := 16#6f0ee87a#;
pragma Export (C, u00023, "system__exception_tableS");
u00024 : constant Version_32 := 16#ce4af020#;
pragma Export (C, u00024, "system__exceptionsB");
u00025 : constant Version_32 := 16#5ac3ecce#;
pragma Export (C, u00025, "system__exceptionsS");
u00026 : constant Version_32 := 16#80916427#;
pragma Export (C, u00026, "system__exceptions__machineB");
u00027 : constant Version_32 := 16#047ef179#;
pragma Export (C, u00027, "system__exceptions__machineS");
u00028 : constant Version_32 := 16#aa0563fc#;
pragma Export (C, u00028, "system__exceptions_debugB");
u00029 : constant Version_32 := 16#4c2a78fc#;
pragma Export (C, u00029, "system__exceptions_debugS");
u00030 : constant Version_32 := 16#6c2f8802#;
pragma Export (C, u00030, "system__img_intB");
u00031 : constant Version_32 := 16#307b61fa#;
pragma Export (C, u00031, "system__img_intS");
u00032 : constant Version_32 := 16#39df8c17#;
pragma Export (C, u00032, "system__tracebackB");
u00033 : constant Version_32 := 16#6c825ffc#;
pragma Export (C, u00033, "system__tracebackS");
u00034 : constant Version_32 := 16#9ed49525#;
pragma Export (C, u00034, "system__traceback_entriesB");
u00035 : constant Version_32 := 16#32fb7748#;
pragma Export (C, u00035, "system__traceback_entriesS");
u00036 : constant Version_32 := 16#18d5fcc5#;
pragma Export (C, u00036, "system__traceback__symbolicB");
u00037 : constant Version_32 := 16#9df1ae6d#;
pragma Export (C, u00037, "system__traceback__symbolicS");
u00038 : constant Version_32 := 16#179d7d28#;
pragma Export (C, u00038, "ada__containersS");
u00039 : constant Version_32 := 16#701f9d88#;
pragma Export (C, u00039, "ada__exceptions__tracebackB");
u00040 : constant Version_32 := 16#20245e75#;
pragma Export (C, u00040, "ada__exceptions__tracebackS");
u00041 : constant Version_32 := 16#e865e681#;
pragma Export (C, u00041, "system__bounded_stringsB");
u00042 : constant Version_32 := 16#455da021#;
pragma Export (C, u00042, "system__bounded_stringsS");
u00043 : constant Version_32 := 16#42315736#;
pragma Export (C, u00043, "system__crtlS");
u00044 : constant Version_32 := 16#08e0d717#;
pragma Export (C, u00044, "system__dwarf_linesB");
u00045 : constant Version_32 := 16#b1bd2788#;
pragma Export (C, u00045, "system__dwarf_linesS");
u00046 : constant Version_32 := 16#5b4659fa#;
pragma Export (C, u00046, "ada__charactersS");
u00047 : constant Version_32 := 16#8f637df8#;
pragma Export (C, u00047, "ada__characters__handlingB");
u00048 : constant Version_32 := 16#3b3f6154#;
pragma Export (C, u00048, "ada__characters__handlingS");
u00049 : constant Version_32 := 16#4b7bb96a#;
pragma Export (C, u00049, "ada__characters__latin_1S");
u00050 : constant Version_32 := 16#e6d4fa36#;
pragma Export (C, u00050, "ada__stringsS");
u00051 : constant Version_32 := 16#e2ea8656#;
pragma Export (C, u00051, "ada__strings__mapsB");
u00052 : constant Version_32 := 16#1e526bec#;
pragma Export (C, u00052, "ada__strings__mapsS");
u00053 : constant Version_32 := 16#9dc9b435#;
pragma Export (C, u00053, "system__bit_opsB");
u00054 : constant Version_32 := 16#0765e3a3#;
pragma Export (C, u00054, "system__bit_opsS");
u00055 : constant Version_32 := 16#0626fdbb#;
pragma Export (C, u00055, "system__unsigned_typesS");
u00056 : constant Version_32 := 16#92f05f13#;
pragma Export (C, u00056, "ada__strings__maps__constantsS");
u00057 : constant Version_32 := 16#5ab55268#;
pragma Export (C, u00057, "interfacesS");
u00058 : constant Version_32 := 16#9f00b3d3#;
pragma Export (C, u00058, "system__address_imageB");
u00059 : constant Version_32 := 16#934c1c02#;
pragma Export (C, u00059, "system__address_imageS");
u00060 : constant Version_32 := 16#ec78c2bf#;
pragma Export (C, u00060, "system__img_unsB");
u00061 : constant Version_32 := 16#99d2c14c#;
pragma Export (C, u00061, "system__img_unsS");
u00062 : constant Version_32 := 16#d7aac20c#;
pragma Export (C, u00062, "system__ioB");
u00063 : constant Version_32 := 16#ace27677#;
pragma Export (C, u00063, "system__ioS");
u00064 : constant Version_32 := 16#11faaec1#;
pragma Export (C, u00064, "system__mmapB");
u00065 : constant Version_32 := 16#08d13e5f#;
pragma Export (C, u00065, "system__mmapS");
u00066 : constant Version_32 := 16#92d882c5#;
pragma Export (C, u00066, "ada__io_exceptionsS");
u00067 : constant Version_32 := 16#9d8ecedc#;
pragma Export (C, u00067, "system__mmap__os_interfaceB");
u00068 : constant Version_32 := 16#8f4541b8#;
pragma Export (C, u00068, "system__mmap__os_interfaceS");
u00069 : constant Version_32 := 16#54632e7c#;
pragma Export (C, u00069, "system__os_libB");
u00070 : constant Version_32 := 16#ed466fde#;
pragma Export (C, u00070, "system__os_libS");
u00071 : constant Version_32 := 16#d1060688#;
pragma Export (C, u00071, "system__case_utilB");
u00072 : constant Version_32 := 16#16a9e8ef#;
pragma Export (C, u00072, "system__case_utilS");
u00073 : constant Version_32 := 16#2a8e89ad#;
pragma Export (C, u00073, "system__stringsB");
u00074 : constant Version_32 := 16#4c1f905e#;
pragma Export (C, u00074, "system__stringsS");
u00075 : constant Version_32 := 16#769e25e6#;
pragma Export (C, u00075, "interfaces__cB");
u00076 : constant Version_32 := 16#70be4e8c#;
pragma Export (C, u00076, "interfaces__cS");
u00077 : constant Version_32 := 16#d0bc914c#;
pragma Export (C, u00077, "system__object_readerB");
u00078 : constant Version_32 := 16#7f932442#;
pragma Export (C, u00078, "system__object_readerS");
u00079 : constant Version_32 := 16#1a74a354#;
pragma Export (C, u00079, "system__val_lliB");
u00080 : constant Version_32 := 16#a8846798#;
pragma Export (C, u00080, "system__val_lliS");
u00081 : constant Version_32 := 16#afdbf393#;
pragma Export (C, u00081, "system__val_lluB");
u00082 : constant Version_32 := 16#7cd4aac9#;
pragma Export (C, u00082, "system__val_lluS");
u00083 : constant Version_32 := 16#27b600b2#;
pragma Export (C, u00083, "system__val_utilB");
u00084 : constant Version_32 := 16#9e0037c6#;
pragma Export (C, u00084, "system__val_utilS");
u00085 : constant Version_32 := 16#5bbc3f2f#;
pragma Export (C, u00085, "system__exception_tracesB");
u00086 : constant Version_32 := 16#167fa1a2#;
pragma Export (C, u00086, "system__exception_tracesS");
u00087 : constant Version_32 := 16#d178f226#;
pragma Export (C, u00087, "system__win32S");
u00088 : constant Version_32 := 16#8c33a517#;
pragma Export (C, u00088, "system__wch_conB");
u00089 : constant Version_32 := 16#29dda3ea#;
pragma Export (C, u00089, "system__wch_conS");
u00090 : constant Version_32 := 16#9721e840#;
pragma Export (C, u00090, "system__wch_stwB");
u00091 : constant Version_32 := 16#04cc8feb#;
pragma Export (C, u00091, "system__wch_stwS");
u00092 : constant Version_32 := 16#a831679c#;
pragma Export (C, u00092, "system__wch_cnvB");
u00093 : constant Version_32 := 16#266a1919#;
pragma Export (C, u00093, "system__wch_cnvS");
u00094 : constant Version_32 := 16#ece6fdb6#;
pragma Export (C, u00094, "system__wch_jisB");
u00095 : constant Version_32 := 16#a61a0038#;
pragma Export (C, u00095, "system__wch_jisS");
u00096 : constant Version_32 := 16#a99e1d66#;
pragma Export (C, u00096, "system__os_primitivesB");
u00097 : constant Version_32 := 16#b82f904e#;
pragma Export (C, u00097, "system__os_primitivesS");
u00098 : constant Version_32 := 16#b6166bc6#;
pragma Export (C, u00098, "system__task_lockB");
u00099 : constant Version_32 := 16#532ab656#;
pragma Export (C, u00099, "system__task_lockS");
u00100 : constant Version_32 := 16#1a9147da#;
pragma Export (C, u00100, "system__win32__extS");
u00101 : constant Version_32 := 16#f64b89a4#;
pragma Export (C, u00101, "ada__integer_text_ioB");
u00102 : constant Version_32 := 16#b85ee1d1#;
pragma Export (C, u00102, "ada__integer_text_ioS");
u00103 : constant Version_32 := 16#1d1c6062#;
pragma Export (C, u00103, "ada__text_ioB");
u00104 : constant Version_32 := 16#95711eac#;
pragma Export (C, u00104, "ada__text_ioS");
u00105 : constant Version_32 := 16#10558b11#;
pragma Export (C, u00105, "ada__streamsB");
u00106 : constant Version_32 := 16#67e31212#;
pragma Export (C, u00106, "ada__streamsS");
u00107 : constant Version_32 := 16#d85792d6#;
pragma Export (C, u00107, "ada__tagsB");
u00108 : constant Version_32 := 16#8813468c#;
pragma Export (C, u00108, "ada__tagsS");
u00109 : constant Version_32 := 16#c3335bfd#;
pragma Export (C, u00109, "system__htableB");
u00110 : constant Version_32 := 16#b66232d2#;
pragma Export (C, u00110, "system__htableS");
u00111 : constant Version_32 := 16#089f5cd0#;
pragma Export (C, u00111, "system__string_hashB");
u00112 : constant Version_32 := 16#143c59ac#;
pragma Export (C, u00112, "system__string_hashS");
u00113 : constant Version_32 := 16#1d9142a4#;
pragma Export (C, u00113, "system__val_unsB");
u00114 : constant Version_32 := 16#168e1080#;
pragma Export (C, u00114, "system__val_unsS");
u00115 : constant Version_32 := 16#4c01b69c#;
pragma Export (C, u00115, "interfaces__c_streamsB");
u00116 : constant Version_32 := 16#b1330297#;
pragma Export (C, u00116, "interfaces__c_streamsS");
u00117 : constant Version_32 := 16#6f0d52aa#;
pragma Export (C, u00117, "system__file_ioB");
u00118 : constant Version_32 := 16#95d1605d#;
pragma Export (C, u00118, "system__file_ioS");
u00119 : constant Version_32 := 16#86c56e5a#;
pragma Export (C, u00119, "ada__finalizationS");
u00120 : constant Version_32 := 16#95817ed8#;
pragma Export (C, u00120, "system__finalization_rootB");
u00121 : constant Version_32 := 16#7d52f2a8#;
pragma Export (C, u00121, "system__finalization_rootS");
u00122 : constant Version_32 := 16#cf3f1b90#;
pragma Export (C, u00122, "system__file_control_blockS");
u00123 : constant Version_32 := 16#f6fdca1c#;
pragma Export (C, u00123, "ada__text_io__integer_auxB");
u00124 : constant Version_32 := 16#b9793d30#;
pragma Export (C, u00124, "ada__text_io__integer_auxS");
u00125 : constant Version_32 := 16#181dc502#;
pragma Export (C, u00125, "ada__text_io__generic_auxB");
u00126 : constant Version_32 := 16#a6c327d3#;
pragma Export (C, u00126, "ada__text_io__generic_auxS");
u00127 : constant Version_32 := 16#b10ba0c7#;
pragma Export (C, u00127, "system__img_biuB");
u00128 : constant Version_32 := 16#c00475f6#;
pragma Export (C, u00128, "system__img_biuS");
u00129 : constant Version_32 := 16#4e06ab0c#;
pragma Export (C, u00129, "system__img_llbB");
u00130 : constant Version_32 := 16#81c36508#;
pragma Export (C, u00130, "system__img_llbS");
u00131 : constant Version_32 := 16#9dca6636#;
pragma Export (C, u00131, "system__img_lliB");
u00132 : constant Version_32 := 16#23efd4e9#;
pragma Export (C, u00132, "system__img_lliS");
u00133 : constant Version_32 := 16#a756d097#;
pragma Export (C, u00133, "system__img_llwB");
u00134 : constant Version_32 := 16#28af469e#;
pragma Export (C, u00134, "system__img_llwS");
u00135 : constant Version_32 := 16#eb55dfbb#;
pragma Export (C, u00135, "system__img_wiuB");
u00136 : constant Version_32 := 16#ae45f264#;
pragma Export (C, u00136, "system__img_wiuS");
u00137 : constant Version_32 := 16#d763507a#;
pragma Export (C, u00137, "system__val_intB");
u00138 : constant Version_32 := 16#7a05ab07#;
pragma Export (C, u00138, "system__val_intS");
u00139 : constant Version_32 := 16#03fc996e#;
pragma Export (C, u00139, "ada__real_timeB");
u00140 : constant Version_32 := 16#c3d451b0#;
pragma Export (C, u00140, "ada__real_timeS");
u00141 : constant Version_32 := 16#cb56a7b3#;
pragma Export (C, u00141, "system__taskingB");
u00142 : constant Version_32 := 16#70384b95#;
pragma Export (C, u00142, "system__taskingS");
u00143 : constant Version_32 := 16#c71f56c0#;
pragma Export (C, u00143, "system__task_primitivesS");
u00144 : constant Version_32 := 16#fa769fc7#;
pragma Export (C, u00144, "system__os_interfaceS");
u00145 : constant Version_32 := 16#22b0e2af#;
pragma Export (C, u00145, "interfaces__c__stringsB");
u00146 : constant Version_32 := 16#603c1c44#;
pragma Export (C, u00146, "interfaces__c__stringsS");
u00147 : constant Version_32 := 16#fc754292#;
pragma Export (C, u00147, "system__task_primitives__operationsB");
u00148 : constant Version_32 := 16#24684c98#;
pragma Export (C, u00148, "system__task_primitives__operationsS");
u00149 : constant Version_32 := 16#1b28662b#;
pragma Export (C, u00149, "system__float_controlB");
u00150 : constant Version_32 := 16#d25cc204#;
pragma Export (C, u00150, "system__float_controlS");
u00151 : constant Version_32 := 16#da8ccc08#;
pragma Export (C, u00151, "system__interrupt_managementB");
u00152 : constant Version_32 := 16#0f60a80c#;
pragma Export (C, u00152, "system__interrupt_managementS");
u00153 : constant Version_32 := 16#f65595cf#;
pragma Export (C, u00153, "system__multiprocessorsB");
u00154 : constant Version_32 := 16#0a0c1e4b#;
pragma Export (C, u00154, "system__multiprocessorsS");
u00155 : constant Version_32 := 16#77769007#;
pragma Export (C, u00155, "system__task_infoB");
u00156 : constant Version_32 := 16#e54688cf#;
pragma Export (C, u00156, "system__task_infoS");
u00157 : constant Version_32 := 16#9471a5c6#;
pragma Export (C, u00157, "system__tasking__debugB");
u00158 : constant Version_32 := 16#f1f2435f#;
pragma Export (C, u00158, "system__tasking__debugS");
u00159 : constant Version_32 := 16#fd83e873#;
pragma Export (C, u00159, "system__concat_2B");
u00160 : constant Version_32 := 16#300056e8#;
pragma Export (C, u00160, "system__concat_2S");
u00161 : constant Version_32 := 16#2b70b149#;
pragma Export (C, u00161, "system__concat_3B");
u00162 : constant Version_32 := 16#39d0dd9d#;
pragma Export (C, u00162, "system__concat_3S");
u00163 : constant Version_32 := 16#18e0e51c#;
pragma Export (C, u00163, "system__img_enum_newB");
u00164 : constant Version_32 := 16#53ec87f8#;
pragma Export (C, u00164, "system__img_enum_newS");
u00165 : constant Version_32 := 16#118e865d#;
pragma Export (C, u00165, "system__stack_usageB");
u00166 : constant Version_32 := 16#3a3ac346#;
pragma Export (C, u00166, "system__stack_usageS");
u00167 : constant Version_32 := 16#3791e504#;
pragma Export (C, u00167, "ada__strings__unboundedB");
u00168 : constant Version_32 := 16#9fdb1809#;
pragma Export (C, u00168, "ada__strings__unboundedS");
u00169 : constant Version_32 := 16#144f64ae#;
pragma Export (C, u00169, "ada__strings__searchB");
u00170 : constant Version_32 := 16#c1ab8667#;
pragma Export (C, u00170, "ada__strings__searchS");
u00171 : constant Version_32 := 16#933d1555#;
pragma Export (C, u00171, "system__compare_array_unsigned_8B");
u00172 : constant Version_32 := 16#9ba3f0b5#;
pragma Export (C, u00172, "system__compare_array_unsigned_8S");
u00173 : constant Version_32 := 16#97d13ec4#;
pragma Export (C, u00173, "system__address_operationsB");
u00174 : constant Version_32 := 16#21ac3f0b#;
pragma Export (C, u00174, "system__address_operationsS");
u00175 : constant Version_32 := 16#a2250034#;
pragma Export (C, u00175, "system__storage_pools__subpoolsB");
u00176 : constant Version_32 := 16#cc5a1856#;
pragma Export (C, u00176, "system__storage_pools__subpoolsS");
u00177 : constant Version_32 := 16#6abe5dbe#;
pragma Export (C, u00177, "system__finalization_mastersB");
u00178 : constant Version_32 := 16#695cb8f2#;
pragma Export (C, u00178, "system__finalization_mastersS");
u00179 : constant Version_32 := 16#7268f812#;
pragma Export (C, u00179, "system__img_boolB");
u00180 : constant Version_32 := 16#c779f0d3#;
pragma Export (C, u00180, "system__img_boolS");
u00181 : constant Version_32 := 16#6d4d969a#;
pragma Export (C, u00181, "system__storage_poolsB");
u00182 : constant Version_32 := 16#114d1f95#;
pragma Export (C, u00182, "system__storage_poolsS");
u00183 : constant Version_32 := 16#9aad1ff1#;
pragma Export (C, u00183, "system__storage_pools__subpools__finalizationB");
u00184 : constant Version_32 := 16#fe2f4b3a#;
pragma Export (C, u00184, "system__storage_pools__subpools__finalizationS");
u00185 : constant Version_32 := 16#70f25dad#;
pragma Export (C, u00185, "system__atomic_countersB");
u00186 : constant Version_32 := 16#86fcacb5#;
pragma Export (C, u00186, "system__atomic_countersS");
u00187 : constant Version_32 := 16#5fc82639#;
pragma Export (C, u00187, "system__machine_codeS");
u00188 : constant Version_32 := 16#3c420900#;
pragma Export (C, u00188, "system__stream_attributesB");
u00189 : constant Version_32 := 16#8bc30a4e#;
pragma Export (C, u00189, "system__stream_attributesS");
u00190 : constant Version_32 := 16#97a2d3b4#;
pragma Export (C, u00190, "ada__strings__unbounded__text_ioB");
u00191 : constant Version_32 := 16#f26abf4c#;
pragma Export (C, u00191, "ada__strings__unbounded__text_ioS");
u00192 : constant Version_32 := 16#64b60562#;
pragma Export (C, u00192, "p_stephandlerB");
u00193 : constant Version_32 := 16#c35ffe0a#;
pragma Export (C, u00193, "p_stephandlerS");
u00194 : constant Version_32 := 16#a9261bbe#;
pragma Export (C, u00194, "p_structuraltypesB");
u00195 : constant Version_32 := 16#386e2dac#;
pragma Export (C, u00195, "p_structuraltypesS");
u00196 : constant Version_32 := 16#a347755d#;
pragma Export (C, u00196, "ada__text_io__modular_auxB");
u00197 : constant Version_32 := 16#0d2bef47#;
pragma Export (C, u00197, "ada__text_io__modular_auxS");
u00198 : constant Version_32 := 16#3e932977#;
pragma Export (C, u00198, "system__img_lluB");
u00199 : constant Version_32 := 16#4feffd78#;
pragma Export (C, u00199, "system__img_lluS");
u00200 : constant Version_32 := 16#23e4cea4#;
pragma Export (C, u00200, "interfaces__cobolB");
u00201 : constant Version_32 := 16#394647ba#;
pragma Export (C, u00201, "interfaces__cobolS");
u00202 : constant Version_32 := 16#5a895de2#;
pragma Export (C, u00202, "system__pool_globalB");
u00203 : constant Version_32 := 16#7141203e#;
pragma Export (C, u00203, "system__pool_globalS");
u00204 : constant Version_32 := 16#ee101ba4#;
pragma Export (C, u00204, "system__memoryB");
u00205 : constant Version_32 := 16#6bdde70c#;
pragma Export (C, u00205, "system__memoryS");
u00206 : constant Version_32 := 16#3adf5e61#;
pragma Export (C, u00206, "p_stephandler__feistelhandlerB");
u00207 : constant Version_32 := 16#8e57995f#;
pragma Export (C, u00207, "p_stephandler__feistelhandlerS");
u00208 : constant Version_32 := 16#e76fa629#;
pragma Export (C, u00208, "p_stephandler__inputhandlerB");
u00209 : constant Version_32 := 16#abe41686#;
pragma Export (C, u00209, "p_stephandler__inputhandlerS");
u00210 : constant Version_32 := 16#4b3cf578#;
pragma Export (C, u00210, "system__byte_swappingS");
u00211 : constant Version_32 := 16#796b5f0d#;
pragma Export (C, u00211, "system__sequential_ioB");
u00212 : constant Version_32 := 16#d8cc2bc8#;
pragma Export (C, u00212, "system__sequential_ioS");
u00213 : constant Version_32 := 16#0806edc3#;
pragma Export (C, u00213, "system__strings__stream_opsB");
u00214 : constant Version_32 := 16#55d4bd57#;
pragma Export (C, u00214, "system__strings__stream_opsS");
u00215 : constant Version_32 := 16#17411e58#;
pragma Export (C, u00215, "ada__streams__stream_ioB");
u00216 : constant Version_32 := 16#31fc8e02#;
pragma Export (C, u00216, "ada__streams__stream_ioS");
u00217 : constant Version_32 := 16#5de653db#;
pragma Export (C, u00217, "system__communicationB");
u00218 : constant Version_32 := 16#2bc0d4ea#;
pragma Export (C, u00218, "system__communicationS");
u00219 : constant Version_32 := 16#8500a3df#;
pragma Export (C, u00219, "p_stephandler__iphandlerB");
u00220 : constant Version_32 := 16#780e2d9b#;
pragma Export (C, u00220, "p_stephandler__iphandlerS");
u00221 : constant Version_32 := 16#c0587cca#;
pragma Export (C, u00221, "p_stephandler__keyhandlerB");
u00222 : constant Version_32 := 16#3666019b#;
pragma Export (C, u00222, "p_stephandler__keyhandlerS");
u00223 : constant Version_32 := 16#13b3baa7#;
pragma Export (C, u00223, "p_stephandler__outputhandlerB");
u00224 : constant Version_32 := 16#3db246c7#;
pragma Export (C, u00224, "p_stephandler__outputhandlerS");
u00225 : constant Version_32 := 16#290d89e9#;
pragma Export (C, u00225, "p_stephandler__reverseiphandlerB");
u00226 : constant Version_32 := 16#f3f8e71c#;
pragma Export (C, u00226, "p_stephandler__reverseiphandlerS");
u00227 : constant Version_32 := 16#276453b7#;
pragma Export (C, u00227, "system__img_lldB");
u00228 : constant Version_32 := 16#c1828851#;
pragma Export (C, u00228, "system__img_lldS");
u00229 : constant Version_32 := 16#bd3715ff#;
pragma Export (C, u00229, "system__img_decB");
u00230 : constant Version_32 := 16#9c8d88e3#;
pragma Export (C, u00230, "system__img_decS");
u00231 : constant Version_32 := 16#96bbd7c2#;
pragma Export (C, u00231, "system__tasking__rendezvousB");
u00232 : constant Version_32 := 16#ea18a31e#;
pragma Export (C, u00232, "system__tasking__rendezvousS");
u00233 : constant Version_32 := 16#100eaf58#;
pragma Export (C, u00233, "system__restrictionsB");
u00234 : constant Version_32 := 16#c1c3a556#;
pragma Export (C, u00234, "system__restrictionsS");
u00235 : constant Version_32 := 16#6896b958#;
pragma Export (C, u00235, "system__tasking__entry_callsB");
u00236 : constant Version_32 := 16#df420580#;
pragma Export (C, u00236, "system__tasking__entry_callsS");
u00237 : constant Version_32 := 16#bc23950c#;
pragma Export (C, u00237, "system__tasking__initializationB");
u00238 : constant Version_32 := 16#efd25374#;
pragma Export (C, u00238, "system__tasking__initializationS");
u00239 : constant Version_32 := 16#72fc64c4#;
pragma Export (C, u00239, "system__soft_links__taskingB");
u00240 : constant Version_32 := 16#5ae92880#;
pragma Export (C, u00240, "system__soft_links__taskingS");
u00241 : constant Version_32 := 16#17d21067#;
pragma Export (C, u00241, "ada__exceptions__is_null_occurrenceB");
u00242 : constant Version_32 := 16#e1d7566f#;
pragma Export (C, u00242, "ada__exceptions__is_null_occurrenceS");
u00243 : constant Version_32 := 16#e774edef#;
pragma Export (C, u00243, "system__tasking__task_attributesB");
u00244 : constant Version_32 := 16#6bc95a13#;
pragma Export (C, u00244, "system__tasking__task_attributesS");
u00245 : constant Version_32 := 16#8bdfec1d#;
pragma Export (C, u00245, "system__tasking__protected_objectsB");
u00246 : constant Version_32 := 16#a9001c61#;
pragma Export (C, u00246, "system__tasking__protected_objectsS");
u00247 : constant Version_32 := 16#ee80728a#;
pragma Export (C, u00247, "system__tracesB");
u00248 : constant Version_32 := 16#c0bde992#;
pragma Export (C, u00248, "system__tracesS");
u00249 : constant Version_32 := 16#17aa7da7#;
pragma Export (C, u00249, "system__tasking__protected_objects__entriesB");
u00250 : constant Version_32 := 16#427cf21f#;
pragma Export (C, u00250, "system__tasking__protected_objects__entriesS");
u00251 : constant Version_32 := 16#1dc86ab7#;
pragma Export (C, u00251, "system__tasking__protected_objects__operationsB");
u00252 : constant Version_32 := 16#ba36ad85#;
pragma Export (C, u00252, "system__tasking__protected_objects__operationsS");
u00253 : constant Version_32 := 16#ab2f8f51#;
pragma Export (C, u00253, "system__tasking__queuingB");
u00254 : constant Version_32 := 16#d1ba2fcb#;
pragma Export (C, u00254, "system__tasking__queuingS");
u00255 : constant Version_32 := 16#f9053daa#;
pragma Export (C, u00255, "system__tasking__utilitiesB");
u00256 : constant Version_32 := 16#14a33d48#;
pragma Export (C, u00256, "system__tasking__utilitiesS");
u00257 : constant Version_32 := 16#bd6fc52e#;
pragma Export (C, u00257, "system__traces__taskingB");
u00258 : constant Version_32 := 16#09f07b39#;
pragma Export (C, u00258, "system__traces__taskingS");
u00259 : constant Version_32 := 16#d8fc9f88#;
pragma Export (C, u00259, "system__tasking__stagesB");
u00260 : constant Version_32 := 16#e9cef940#;
pragma Export (C, u00260, "system__tasking__stagesS");
-- BEGIN ELABORATION ORDER
-- ada%s
-- ada.characters%s
-- ada.characters.latin_1%s
-- interfaces%s
-- system%s
-- system.address_operations%s
-- system.address_operations%b
-- system.byte_swapping%s
-- system.case_util%s
-- system.case_util%b
-- system.float_control%s
-- system.float_control%b
-- system.img_bool%s
-- system.img_bool%b
-- system.img_enum_new%s
-- system.img_enum_new%b
-- system.img_int%s
-- system.img_int%b
-- system.img_dec%s
-- system.img_dec%b
-- system.img_lli%s
-- system.img_lli%b
-- system.img_lld%s
-- system.img_lld%b
-- system.io%s
-- system.io%b
-- system.machine_code%s
-- system.atomic_counters%s
-- system.atomic_counters%b
-- system.parameters%s
-- system.parameters%b
-- system.crtl%s
-- interfaces.c_streams%s
-- interfaces.c_streams%b
-- system.restrictions%s
-- system.restrictions%b
-- system.storage_elements%s
-- system.storage_elements%b
-- system.stack_checking%s
-- system.stack_checking%b
-- system.stack_usage%s
-- system.stack_usage%b
-- system.string_hash%s
-- system.string_hash%b
-- system.htable%s
-- system.htable%b
-- system.strings%s
-- system.strings%b
-- system.traceback_entries%s
-- system.traceback_entries%b
-- system.traces%s
-- system.traces%b
-- system.unsigned_types%s
-- system.img_biu%s
-- system.img_biu%b
-- system.img_llb%s
-- system.img_llb%b
-- system.img_llu%s
-- system.img_llu%b
-- system.img_llw%s
-- system.img_llw%b
-- system.img_uns%s
-- system.img_uns%b
-- system.img_wiu%s
-- system.img_wiu%b
-- system.wch_con%s
-- system.wch_con%b
-- system.wch_jis%s
-- system.wch_jis%b
-- system.wch_cnv%s
-- system.wch_cnv%b
-- system.compare_array_unsigned_8%s
-- system.compare_array_unsigned_8%b
-- system.concat_2%s
-- system.concat_2%b
-- system.concat_3%s
-- system.concat_3%b
-- system.traceback%s
-- system.traceback%b
-- system.val_util%s
-- system.standard_library%s
-- system.exception_traces%s
-- ada.exceptions%s
-- system.wch_stw%s
-- system.val_util%b
-- system.val_llu%s
-- system.val_lli%s
-- system.os_lib%s
-- system.bit_ops%s
-- ada.characters.handling%s
-- ada.exceptions.traceback%s
-- system.soft_links%s
-- system.exception_table%s
-- system.exception_table%b
-- ada.io_exceptions%s
-- ada.strings%s
-- ada.containers%s
-- system.exceptions%s
-- system.exceptions%b
-- system.secondary_stack%s
-- system.address_image%s
-- system.bounded_strings%s
-- system.soft_links%b
-- ada.exceptions.last_chance_handler%s
-- system.exceptions_debug%s
-- system.exceptions_debug%b
-- system.exception_traces%b
-- system.memory%s
-- system.memory%b
-- system.wch_stw%b
-- system.val_llu%b
-- system.val_lli%b
-- interfaces.c%s
-- system.win32%s
-- system.mmap%s
-- system.mmap.os_interface%s
-- system.mmap.os_interface%b
-- system.mmap%b
-- system.os_lib%b
-- system.bit_ops%b
-- ada.strings.maps%s
-- ada.strings.maps.constants%s
-- ada.characters.handling%b
-- ada.exceptions.traceback%b
-- system.exceptions.machine%s
-- system.exceptions.machine%b
-- system.secondary_stack%b
-- system.address_image%b
-- system.bounded_strings%b
-- ada.exceptions.last_chance_handler%b
-- system.standard_library%b
-- system.object_reader%s
-- system.dwarf_lines%s
-- system.dwarf_lines%b
-- interfaces.c%b
-- ada.strings.maps%b
-- system.traceback.symbolic%s
-- system.traceback.symbolic%b
-- ada.exceptions%b
-- system.object_reader%b
-- ada.exceptions.is_null_occurrence%s
-- ada.exceptions.is_null_occurrence%b
-- ada.strings.search%s
-- ada.strings.search%b
-- interfaces.c.strings%s
-- interfaces.c.strings%b
-- interfaces.cobol%s
-- interfaces.cobol%b
-- system.multiprocessors%s
-- system.multiprocessors%b
-- system.os_interface%s
-- system.interrupt_management%s
-- system.interrupt_management%b
-- system.task_info%s
-- system.task_info%b
-- system.task_lock%s
-- system.task_lock%b
-- system.task_primitives%s
-- system.val_uns%s
-- system.val_uns%b
-- ada.tags%s
-- ada.tags%b
-- ada.streams%s
-- ada.streams%b
-- system.communication%s
-- system.communication%b
-- system.file_control_block%s
-- system.finalization_root%s
-- system.finalization_root%b
-- ada.finalization%s
-- system.file_io%s
-- system.file_io%b
-- ada.streams.stream_io%s
-- ada.streams.stream_io%b
-- system.storage_pools%s
-- system.storage_pools%b
-- system.finalization_masters%s
-- system.finalization_masters%b
-- system.storage_pools.subpools%s
-- system.storage_pools.subpools.finalization%s
-- system.storage_pools.subpools%b
-- system.storage_pools.subpools.finalization%b
-- system.stream_attributes%s
-- system.stream_attributes%b
-- ada.strings.unbounded%s
-- ada.strings.unbounded%b
-- system.val_int%s
-- system.val_int%b
-- system.win32.ext%s
-- system.os_primitives%s
-- system.os_primitives%b
-- system.tasking%s
-- system.task_primitives.operations%s
-- system.tasking.debug%s
-- system.tasking%b
-- system.task_primitives.operations%b
-- system.tasking.debug%b
-- system.traces.tasking%s
-- system.traces.tasking%b
-- ada.calendar%s
-- ada.calendar%b
-- ada.real_time%s
-- ada.real_time%b
-- ada.text_io%s
-- ada.text_io%b
-- ada.strings.unbounded.text_io%s
-- ada.strings.unbounded.text_io%b
-- ada.text_io.generic_aux%s
-- ada.text_io.generic_aux%b
-- ada.text_io.integer_aux%s
-- ada.text_io.integer_aux%b
-- ada.integer_text_io%s
-- ada.integer_text_io%b
-- ada.text_io.modular_aux%s
-- ada.text_io.modular_aux%b
-- system.pool_global%s
-- system.pool_global%b
-- system.sequential_io%s
-- system.sequential_io%b
-- system.soft_links.tasking%s
-- system.soft_links.tasking%b
-- system.strings.stream_ops%s
-- system.strings.stream_ops%b
-- system.tasking.initialization%s
-- system.tasking.task_attributes%s
-- system.tasking.initialization%b
-- system.tasking.task_attributes%b
-- system.tasking.protected_objects%s
-- system.tasking.protected_objects%b
-- system.tasking.protected_objects.entries%s
-- system.tasking.protected_objects.entries%b
-- system.tasking.queuing%s
-- system.tasking.queuing%b
-- system.tasking.utilities%s
-- system.tasking.utilities%b
-- system.tasking.entry_calls%s
-- system.tasking.rendezvous%s
-- system.tasking.protected_objects.operations%s
-- system.tasking.protected_objects.operations%b
-- system.tasking.entry_calls%b
-- system.tasking.rendezvous%b
-- system.tasking.stages%s
-- system.tasking.stages%b
-- p_structuraltypes%s
-- p_structuraltypes%b
-- p_stephandler%s
-- p_stephandler%b
-- p_stephandler.feistelhandler%s
-- p_stephandler.feistelhandler%b
-- p_stephandler.inputhandler%s
-- p_stephandler.inputhandler%b
-- p_stephandler.iphandler%s
-- p_stephandler.iphandler%b
-- p_stephandler.keyhandler%s
-- p_stephandler.keyhandler%b
-- p_stephandler.outputhandler%s
-- p_stephandler.outputhandler%b
-- p_stephandler.reverseiphandler%s
-- p_stephandler.reverseiphandler%b
-- main%b
-- END ELABORATION ORDER
end ada_main;
|
AdaCore/libadalang | Ada | 51 | ads | package Pkg is
subtype Sub is Missing;
end Pkg;
|
fractal-mind/Amass | Ada | 1,045 | ads | -- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local url = require("url")
name = "Gists"
type = "scrape"
function start()
set_rate_limit(2)
end
function vertical(ctx, domain)
local gist_re = "https://gist[.]github[.]com/[a-zA-Z0-9-]{1,39}/[a-z0-9]{32}"
for i=1,20 do
local resp, err = request(ctx, {['url']=build_url(domain, i)})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
break
end
local gists = find(resp, gist_re)
if (gists == nil or #gists == 0) then
break
end
for _, gist in pairs(gists) do
scrape(ctx, {['url']=gist})
end
end
end
function build_url(domain, pagenum)
local params = {
['ref']="searchresults",
['q']=domain,
['p']=pagenum,
}
return "https://gist.github.com/search?" .. url.build_query_string(params)
end
|
clairvoyant/anagram | Ada | 8,858 | ads | -- Copyright (c) 2010-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ag_Tokens;
limited with Anagram.Grammars.Scanners;
with Anagram.Grammars.Scanner_Handlers;
with Anagram.Grammars.Scanner_Types;
package Anagram.Grammars.Scanner_Handler is
type Handler is new Anagram.Grammars.Scanner_Handlers.Handler with private;
procedure Equal_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Inherited_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Synthesized_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Local_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Attributes_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Rules_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Identifier_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Token_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure With_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Priority_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Integer_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Open_Rule_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Rule_Body_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Close_Rule_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Regexp_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Semicolon_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Open_Production_Name_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Close_Production_Name_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Open_Part_Name_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Close_Part_Name_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Open_List_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Close_List_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Open_Option_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Close_Option_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Colon_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Or_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Comma_Token
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
procedure Spaces
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean) is null;
procedure Comment
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean) is null;
procedure New_Line
(Self : not null access Handler;
Scanner : not null access Anagram.Grammars.Scanners.Scanner'Class;
Rule : Anagram.Grammars.Scanner_Types.Rule_Index;
Token : out Ag_Tokens.Token;
Skip : in out Boolean);
function Get_Line (Self : Handler) return Positive;
private
type Handler is new Anagram.Grammars.Scanner_Handlers.Handler with record
Line : Positive := 1;
end record;
end Anagram.Grammars.Scanner_Handler;
|
AdaCore/Ada_Drivers_Library | Ada | 3,671 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- This file is based on: --
-- @file stm32f469i_discovery_audio.h --
-- @author MCD Application Team --
------------------------------------------------------------------------------
with HAL.Audio; use HAL.Audio;
with HAL.I2C; use HAL.I2C;
with Ravenscar_Time;
private with CS43L22;
package Audio is
type CS43L22_Audio_Device (Port : not null Any_I2C_Port) is
tagged limited private;
procedure Initialize_Audio_Out
(This : in out CS43L22_Audio_Device;
Volume : Audio_Volume;
Frequency : Audio_Frequency);
procedure Play
(This : in out CS43L22_Audio_Device;
Buffer : Audio_Buffer);
procedure Pause
(This : in out CS43L22_Audio_Device);
procedure Resume
(This : in out CS43L22_Audio_Device);
procedure Stop
(This : in out CS43L22_Audio_Device);
procedure Set_Volume
(This : in out CS43L22_Audio_Device;
Volume : Audio_Volume);
procedure Set_Frequency
(This : in out CS43L22_Audio_Device;
Frequency : Audio_Frequency);
private
type CS43L22_Audio_Device (Port : not null Any_I2C_Port) is
tagged limited record
Device : CS43L22.CS43L22_Device (Port, Ravenscar_Time.Delays);
end record;
end Audio;
|
faelys/natools | Ada | 960 | adb | with Interfaces; use Interfaces;
package body Natools.S_Expressions.Printers.Pretty.Config.Token_Opt is
P : constant array (0 .. 2) of Natural :=
(1, 3, 9);
T1 : constant array (0 .. 2) of Unsigned_8 :=
(4, 10, 2);
T2 : constant array (0 .. 2) of Unsigned_8 :=
(10, 17, 11);
G : constant array (0 .. 18) of Unsigned_8 :=
(0, 0, 0, 0, 0, 6, 7, 2, 0, 2, 0, 0, 0, 0, 0, 3, 5, 6, 3);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Natural;
begin
for K in P'Range loop
exit when L < P (K);
J := Character'Pos (S (P (K) + F));
F1 := (F1 + Natural (T1 (K)) * J) mod 19;
F2 := (F2 + Natural (T2 (K)) * J) mod 19;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 9;
end Hash;
end Natools.S_Expressions.Printers.Pretty.Config.Token_Opt;
|
zhmu/ananas | Ada | 225,044 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ A G G R --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree;
with Checks; use Checks;
with Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
with Elists; use Elists;
with Errout; use Errout;
with Expander; use Expander;
with Exp_Ch6; use Exp_Ch6;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Freeze; use Freeze;
with Itypes; use Itypes;
with Lib; use Lib;
with Lib.Xref; use Lib.Xref;
with Namet; use Namet;
with Namet.Sp; use Namet.Sp;
with Nmake; use Nmake;
with Nlists; use Nlists;
with Opt; use Opt;
with Restrict; use Restrict;
with Rident; use Rident;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Case; use Sem_Case;
with Sem_Cat; use Sem_Cat;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch5; use Sem_Ch5;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
with Sem_Dim; use Sem_Dim;
with Sem_Eval; use Sem_Eval;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sem_Type; use Sem_Type;
with Sem_Warn; use Sem_Warn;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Snames; use Snames;
with Stringt; use Stringt;
with Stand; use Stand;
with Style; use Style;
with Targparm; use Targparm;
with Tbuild; use Tbuild;
with Ttypes; use Ttypes;
with Uintp; use Uintp;
package body Sem_Aggr is
type Case_Bounds is record
Lo : Node_Id;
-- Low bound of choice. Once we sort the Case_Table, then entries
-- will be in order of ascending Choice_Lo values.
Hi : Node_Id;
-- High Bound of choice. The sort does not pay any attention to the
-- high bound, so choices 1 .. 4 and 1 .. 5 could be in either order.
Highest : Uint;
-- If there are duplicates or missing entries, then in the sorted
-- table, this records the highest value among Choice_Hi values
-- seen so far, including this entry.
Choice : Node_Id;
-- The node of the choice
end record;
type Case_Table_Type is array (Pos range <>) of Case_Bounds;
-- Table type used by Check_Case_Choices procedure
-----------------------
-- Local Subprograms --
-----------------------
procedure Sort_Case_Table (Case_Table : in out Case_Table_Type);
-- Sort the Case Table using the Lower Bound of each Choice as the key. A
-- simple insertion sort is used since the choices in a case statement will
-- usually be in near sorted order.
procedure Check_Can_Never_Be_Null (Typ : Entity_Id; Expr : Node_Id);
-- Ada 2005 (AI-231): Check bad usage of null for a component for which
-- null exclusion (NOT NULL) is specified. Typ can be an E_Array_Type for
-- the array case (the component type of the array will be used) or an
-- E_Component/E_Discriminant entity in the record case, in which case the
-- type of the component will be used for the test. If Typ is any other
-- kind of entity, the call is ignored. Expr is the component node in the
-- aggregate which is known to have a null value. A warning message will be
-- issued if the component is null excluding.
--
-- It would be better to pass the proper type for Typ ???
procedure Check_Expr_OK_In_Limited_Aggregate (Expr : Node_Id);
-- Check that Expr is either not limited or else is one of the cases of
-- expressions allowed for a limited component association (namely, an
-- aggregate, function call, or <> notation). Report error for violations.
-- Expression is also OK in an instance or inlining context, because we
-- have already preanalyzed and it is known to be type correct.
------------------------------------------------------
-- Subprograms used for RECORD AGGREGATE Processing --
------------------------------------------------------
procedure Resolve_Record_Aggregate (N : Node_Id; Typ : Entity_Id);
-- This procedure performs all the semantic checks required for record
-- aggregates. Note that for aggregates analysis and resolution go
-- hand in hand. Aggregate analysis has been delayed up to here and
-- it is done while resolving the aggregate.
--
-- N is the N_Aggregate node.
-- Typ is the record type for the aggregate resolution
--
-- While performing the semantic checks, this procedure builds a new
-- Component_Association_List where each record field appears alone in a
-- Component_Choice_List along with its corresponding expression. The
-- record fields in the Component_Association_List appear in the same order
-- in which they appear in the record type Typ.
--
-- Once this new Component_Association_List is built and all the semantic
-- checks performed, the original aggregate subtree is replaced with the
-- new named record aggregate just built. This new record aggregate has no
-- positional associations, so its Expressions field is set to No_List.
-- Note that subtree substitution is performed with Rewrite so as to be
-- able to retrieve the original aggregate.
--
-- The aggregate subtree manipulation performed by Resolve_Record_Aggregate
-- yields the aggregate format expected by Gigi. Typically, this kind of
-- tree manipulations are done in the expander. However, because the
-- semantic checks that need to be performed on record aggregates really go
-- hand in hand with the record aggregate normalization, the aggregate
-- subtree transformation is performed during resolution rather than
-- expansion. Had we decided otherwise we would have had to duplicate most
-- of the code in the expansion procedure Expand_Record_Aggregate. Note,
-- however, that all the expansion concerning aggregates for tagged records
-- is done in Expand_Record_Aggregate.
--
-- The algorithm of Resolve_Record_Aggregate proceeds as follows:
--
-- 1. Make sure that the record type against which the record aggregate
-- has to be resolved is not abstract. Furthermore if the type is a
-- null aggregate make sure the input aggregate N is also null.
--
-- 2. Verify that the structure of the aggregate is that of a record
-- aggregate. Specifically, look for component associations and ensure
-- that each choice list only has identifiers or the N_Others_Choice
-- node. Also make sure that if present, the N_Others_Choice occurs
-- last and by itself.
--
-- 3. If Typ contains discriminants, the values for each discriminant is
-- looked for. If the record type Typ has variants, we check that the
-- expressions corresponding to each discriminant ruling the (possibly
-- nested) variant parts of Typ, are static. This allows us to determine
-- the variant parts to which the rest of the aggregate must conform.
-- The names of discriminants with their values are saved in a new
-- association list, New_Assoc_List which is later augmented with the
-- names and values of the remaining components in the record type.
--
-- During this phase we also make sure that every discriminant is
-- assigned exactly one value. Note that when several values for a given
-- discriminant are found, semantic processing continues looking for
-- further errors. In this case it's the first discriminant value found
-- which we will be recorded.
--
-- IMPORTANT NOTE: For derived tagged types this procedure expects
-- First_Discriminant and Next_Discriminant to give the correct list
-- of discriminants, in the correct order.
--
-- 4. After all the discriminant values have been gathered, we can set the
-- Etype of the record aggregate. If Typ contains no discriminants this
-- is straightforward: the Etype of N is just Typ, otherwise a new
-- implicit constrained subtype of Typ is built to be the Etype of N.
--
-- 5. Gather the remaining record components according to the discriminant
-- values. This involves recursively traversing the record type
-- structure to see what variants are selected by the given discriminant
-- values. This processing is a little more convoluted if Typ is a
-- derived tagged types since we need to retrieve the record structure
-- of all the ancestors of Typ.
--
-- 6. After gathering the record components we look for their values in the
-- record aggregate and emit appropriate error messages should we not
-- find such values or should they be duplicated.
--
-- 7. We then make sure no illegal component names appear in the record
-- aggregate and make sure that the type of the record components
-- appearing in a same choice list is the same. Finally we ensure that
-- the others choice, if present, is used to provide the value of at
-- least a record component.
--
-- 8. The original aggregate node is replaced with the new named aggregate
-- built in steps 3 through 6, as explained earlier.
--
-- Given the complexity of record aggregate resolution, the primary goal of
-- this routine is clarity and simplicity rather than execution and storage
-- efficiency. If there are only positional components in the aggregate the
-- running time is linear. If there are associations the running time is
-- still linear as long as the order of the associations is not too far off
-- the order of the components in the record type. If this is not the case
-- the running time is at worst quadratic in the size of the association
-- list.
procedure Check_Misspelled_Component
(Elements : Elist_Id;
Component : Node_Id);
-- Give possible misspelling diagnostic if Component is likely to be a
-- misspelling of one of the components of the Assoc_List. This is called
-- by Resolve_Aggr_Expr after producing an invalid component error message.
-----------------------------------------------------
-- Subprograms used for ARRAY AGGREGATE Processing --
-----------------------------------------------------
function Resolve_Array_Aggregate
(N : Node_Id;
Index : Node_Id;
Index_Constr : Node_Id;
Component_Typ : Entity_Id;
Others_Allowed : Boolean) return Boolean;
-- This procedure performs the semantic checks for an array aggregate.
-- True is returned if the aggregate resolution succeeds.
--
-- The procedure works by recursively checking each nested aggregate.
-- Specifically, after checking a sub-aggregate nested at the i-th level
-- we recursively check all the subaggregates at the i+1-st level (if any).
-- Note that aggregates analysis and resolution go hand in hand.
-- Aggregate analysis has been delayed up to here and it is done while
-- resolving the aggregate.
--
-- N is the current N_Aggregate node to be checked.
--
-- Index is the index node corresponding to the array sub-aggregate that
-- we are currently checking (RM 4.3.3 (8)). Its Etype is the
-- corresponding index type (or subtype).
--
-- Index_Constr is the node giving the applicable index constraint if
-- any (RM 4.3.3 (10)). It "is a constraint provided by certain
-- contexts [...] that can be used to determine the bounds of the array
-- value specified by the aggregate". If Others_Allowed below is False
-- there is no applicable index constraint and this node is set to Index.
--
-- Component_Typ is the array component type.
--
-- Others_Allowed indicates whether an others choice is allowed
-- in the context where the top-level aggregate appeared.
--
-- The algorithm of Resolve_Array_Aggregate proceeds as follows:
--
-- 1. Make sure that the others choice, if present, is by itself and
-- appears last in the sub-aggregate. Check that we do not have
-- positional and named components in the array sub-aggregate (unless
-- the named association is an others choice). Finally if an others
-- choice is present, make sure it is allowed in the aggregate context.
--
-- 2. If the array sub-aggregate contains discrete_choices:
--
-- (A) Verify their validity. Specifically verify that:
--
-- (a) If a null range is present it must be the only possible
-- choice in the array aggregate.
--
-- (b) Ditto for a non static range.
--
-- (c) Ditto for a non static expression.
--
-- In addition this step analyzes and resolves each discrete_choice,
-- making sure that its type is the type of the corresponding Index.
-- If we are not at the lowest array aggregate level (in the case of
-- multi-dimensional aggregates) then invoke Resolve_Array_Aggregate
-- recursively on each component expression. Otherwise, resolve the
-- bottom level component expressions against the expected component
-- type ONLY IF the component corresponds to a single discrete choice
-- which is not an others choice (to see why read the DELAYED
-- COMPONENT RESOLUTION below).
--
-- (B) Determine the bounds of the sub-aggregate and lowest and
-- highest choice values.
--
-- 3. For positional aggregates:
--
-- (A) Loop over the component expressions either recursively invoking
-- Resolve_Array_Aggregate on each of these for multi-dimensional
-- array aggregates or resolving the bottom level component
-- expressions against the expected component type.
--
-- (B) Determine the bounds of the positional sub-aggregates.
--
-- 4. Try to determine statically whether the evaluation of the array
-- sub-aggregate raises Constraint_Error. If yes emit proper
-- warnings. The precise checks are the following:
--
-- (A) Check that the index range defined by aggregate bounds is
-- compatible with corresponding index subtype.
-- We also check against the base type. In fact it could be that
-- Low/High bounds of the base type are static whereas those of
-- the index subtype are not. Thus if we can statically catch
-- a problem with respect to the base type we are guaranteed
-- that the same problem will arise with the index subtype
--
-- (B) If we are dealing with a named aggregate containing an others
-- choice and at least one discrete choice then make sure the range
-- specified by the discrete choices does not overflow the
-- aggregate bounds. We also check against the index type and base
-- type bounds for the same reasons given in (A).
--
-- (C) If we are dealing with a positional aggregate with an others
-- choice make sure the number of positional elements specified
-- does not overflow the aggregate bounds. We also check against
-- the index type and base type bounds as mentioned in (A).
--
-- Finally construct an N_Range node giving the sub-aggregate bounds.
-- Set the Aggregate_Bounds field of the sub-aggregate to be this
-- N_Range. The routine Array_Aggr_Subtype below uses such N_Ranges
-- to build the appropriate aggregate subtype. Aggregate_Bounds
-- information is needed during expansion.
--
-- DELAYED COMPONENT RESOLUTION: The resolution of bottom level component
-- expressions in an array aggregate may call Duplicate_Subexpr or some
-- other routine that inserts code just outside the outermost aggregate.
-- If the array aggregate contains discrete choices or an others choice,
-- this may be wrong. Consider for instance the following example.
--
-- type Rec is record
-- V : Integer := 0;
-- end record;
--
-- type Acc_Rec is access Rec;
-- Arr : array (1..3) of Acc_Rec := (1 .. 3 => new Rec);
--
-- Then the transformation of "new Rec" that occurs during resolution
-- entails the following code modifications
--
-- P7b : constant Acc_Rec := new Rec;
-- RecIP (P7b.all);
-- Arr : array (1..3) of Acc_Rec := (1 .. 3 => P7b);
--
-- This code transformation is clearly wrong, since we need to call
-- "new Rec" for each of the 3 array elements. To avoid this problem we
-- delay resolution of the components of non positional array aggregates
-- to the expansion phase. As an optimization, if the discrete choice
-- specifies a single value we do not delay resolution.
function Array_Aggr_Subtype (N : Node_Id; Typ : Entity_Id) return Entity_Id;
-- This routine returns the type or subtype of an array aggregate.
--
-- N is the array aggregate node whose type we return.
--
-- Typ is the context type in which N occurs.
--
-- This routine creates an implicit array subtype whose bounds are
-- those defined by the aggregate. When this routine is invoked
-- Resolve_Array_Aggregate has already processed aggregate N. Thus the
-- Aggregate_Bounds of each sub-aggregate, is an N_Range node giving the
-- sub-aggregate bounds. When building the aggregate itype, this function
-- traverses the array aggregate N collecting such Aggregate_Bounds and
-- constructs the proper array aggregate itype.
--
-- Note that in the case of multidimensional aggregates each inner
-- sub-aggregate corresponding to a given array dimension, may provide a
-- different bounds. If it is possible to determine statically that
-- some sub-aggregates corresponding to the same index do not have the
-- same bounds, then a warning is emitted. If such check is not possible
-- statically (because some sub-aggregate bounds are dynamic expressions)
-- then this job is left to the expander. In all cases the particular
-- bounds that this function will chose for a given dimension is the first
-- N_Range node for a sub-aggregate corresponding to that dimension.
--
-- Note that the Raises_Constraint_Error flag of an array aggregate
-- whose evaluation is determined to raise CE by Resolve_Array_Aggregate,
-- is set in Resolve_Array_Aggregate but the aggregate is not
-- immediately replaced with a raise CE. In fact, Array_Aggr_Subtype must
-- first construct the proper itype for the aggregate (Gigi needs
-- this). After constructing the proper itype we will eventually replace
-- the top-level aggregate with a raise CE (done in Resolve_Aggregate).
-- Of course in cases such as:
--
-- type Arr is array (integer range <>) of Integer;
-- A : Arr := (positive range -1 .. 2 => 0);
--
-- The bounds of the aggregate itype are cooked up to look reasonable
-- (in this particular case the bounds will be 1 .. 2).
procedure Make_String_Into_Aggregate (N : Node_Id);
-- A string literal can appear in a context in which a one dimensional
-- array of characters is expected. This procedure simply rewrites the
-- string as an aggregate, prior to resolution.
---------------------------------
-- Delta aggregate processing --
---------------------------------
procedure Resolve_Delta_Array_Aggregate (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Delta_Record_Aggregate (N : Node_Id; Typ : Entity_Id);
------------------------
-- Array_Aggr_Subtype --
------------------------
function Array_Aggr_Subtype
(N : Node_Id;
Typ : Entity_Id) return Entity_Id
is
Aggr_Dimension : constant Pos := Number_Dimensions (Typ);
-- Number of aggregate index dimensions
Aggr_Range : array (1 .. Aggr_Dimension) of Node_Id := (others => Empty);
-- Constrained N_Range of each index dimension in our aggregate itype
Aggr_Low : array (1 .. Aggr_Dimension) of Node_Id := (others => Empty);
Aggr_High : array (1 .. Aggr_Dimension) of Node_Id := (others => Empty);
-- Low and High bounds for each index dimension in our aggregate itype
Is_Fully_Positional : Boolean := True;
procedure Collect_Aggr_Bounds (N : Node_Id; Dim : Pos);
-- N is an array (sub-)aggregate. Dim is the dimension corresponding
-- to (sub-)aggregate N. This procedure collects and removes the side
-- effects of the constrained N_Range nodes corresponding to each index
-- dimension of our aggregate itype. These N_Range nodes are collected
-- in Aggr_Range above.
--
-- Likewise collect in Aggr_Low & Aggr_High above the low and high
-- bounds of each index dimension. If, when collecting, two bounds
-- corresponding to the same dimension are static and found to differ,
-- then emit a warning, and mark N as raising Constraint_Error.
-------------------------
-- Collect_Aggr_Bounds --
-------------------------
procedure Collect_Aggr_Bounds (N : Node_Id; Dim : Pos) is
This_Range : constant Node_Id := Aggregate_Bounds (N);
-- The aggregate range node of this specific sub-aggregate
This_Low : constant Node_Id := Low_Bound (Aggregate_Bounds (N));
This_High : constant Node_Id := High_Bound (Aggregate_Bounds (N));
-- The aggregate bounds of this specific sub-aggregate
Assoc : Node_Id;
Expr : Node_Id;
begin
Remove_Side_Effects (This_Low, Variable_Ref => True);
Remove_Side_Effects (This_High, Variable_Ref => True);
-- Collect the first N_Range for a given dimension that you find.
-- For a given dimension they must be all equal anyway.
if No (Aggr_Range (Dim)) then
Aggr_Low (Dim) := This_Low;
Aggr_High (Dim) := This_High;
Aggr_Range (Dim) := This_Range;
else
if Compile_Time_Known_Value (This_Low) then
if not Compile_Time_Known_Value (Aggr_Low (Dim)) then
Aggr_Low (Dim) := This_Low;
elsif Expr_Value (This_Low) /= Expr_Value (Aggr_Low (Dim)) then
Set_Raises_Constraint_Error (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("sub-aggregate low bound mismatch<<", N);
Error_Msg_N ("\Constraint_Error [<<", N);
end if;
end if;
if Compile_Time_Known_Value (This_High) then
if not Compile_Time_Known_Value (Aggr_High (Dim)) then
Aggr_High (Dim) := This_High;
elsif
Expr_Value (This_High) /= Expr_Value (Aggr_High (Dim))
then
Set_Raises_Constraint_Error (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("sub-aggregate high bound mismatch<<", N);
Error_Msg_N ("\Constraint_Error [<<", N);
end if;
end if;
end if;
if Dim < Aggr_Dimension then
-- Process positional components
if Present (Expressions (N)) then
Expr := First (Expressions (N));
while Present (Expr) loop
Collect_Aggr_Bounds (Expr, Dim + 1);
Next (Expr);
end loop;
end if;
-- Process component associations
if Present (Component_Associations (N)) then
Is_Fully_Positional := False;
Assoc := First (Component_Associations (N));
while Present (Assoc) loop
Expr := Expression (Assoc);
Collect_Aggr_Bounds (Expr, Dim + 1);
Next (Assoc);
end loop;
end if;
end if;
end Collect_Aggr_Bounds;
-- Array_Aggr_Subtype variables
Itype : Entity_Id;
-- The final itype of the overall aggregate
Index_Constraints : constant List_Id := New_List;
-- The list of index constraints of the aggregate itype
-- Start of processing for Array_Aggr_Subtype
begin
-- Make sure that the list of index constraints is properly attached to
-- the tree, and then collect the aggregate bounds.
-- If no aggregaate bounds have been set, this is an aggregate with
-- iterator specifications and a dynamic size to be determined by
-- first pass of expanded code.
if No (Aggregate_Bounds (N)) then
return Typ;
end if;
Set_Parent (Index_Constraints, N);
Collect_Aggr_Bounds (N, 1);
-- Build the list of constrained indexes of our aggregate itype
for J in 1 .. Aggr_Dimension loop
Create_Index : declare
Index_Base : constant Entity_Id :=
Base_Type (Etype (Aggr_Range (J)));
Index_Typ : Entity_Id;
begin
-- Construct the Index subtype, and associate it with the range
-- construct that generates it.
Index_Typ :=
Create_Itype (Subtype_Kind (Ekind (Index_Base)), Aggr_Range (J));
Set_Etype (Index_Typ, Index_Base);
if Is_Character_Type (Index_Base) then
Set_Is_Character_Type (Index_Typ);
end if;
Set_Size_Info (Index_Typ, (Index_Base));
Set_RM_Size (Index_Typ, RM_Size (Index_Base));
Set_First_Rep_Item (Index_Typ, First_Rep_Item (Index_Base));
Set_Scalar_Range (Index_Typ, Aggr_Range (J));
if Is_Discrete_Or_Fixed_Point_Type (Index_Typ) then
Set_RM_Size (Index_Typ, UI_From_Int (Minimum_Size (Index_Typ)));
end if;
Set_Etype (Aggr_Range (J), Index_Typ);
Append (Aggr_Range (J), To => Index_Constraints);
end Create_Index;
end loop;
-- Now build the Itype
Itype := Create_Itype (E_Array_Subtype, N);
Set_First_Rep_Item (Itype, First_Rep_Item (Typ));
Set_Convention (Itype, Convention (Typ));
Set_Depends_On_Private (Itype, Has_Private_Component (Typ));
Set_Etype (Itype, Base_Type (Typ));
Set_Has_Alignment_Clause (Itype, Has_Alignment_Clause (Typ));
Set_Is_Aliased (Itype, Is_Aliased (Typ));
Set_Is_Independent (Itype, Is_Independent (Typ));
Set_Depends_On_Private (Itype, Depends_On_Private (Typ));
Copy_Suppress_Status (Index_Check, Typ, Itype);
Copy_Suppress_Status (Length_Check, Typ, Itype);
Set_First_Index (Itype, First (Index_Constraints));
Set_Is_Constrained (Itype, True);
Set_Is_Internal (Itype, True);
if Has_Predicates (Typ) then
Set_Has_Predicates (Itype);
-- If the base type has a predicate, capture the predicated parent
-- or the existing predicate function for SPARK use.
if Present (Predicate_Function (Typ)) then
Set_Predicate_Function (Itype, Predicate_Function (Typ));
elsif Is_Itype (Typ) then
Set_Predicated_Parent (Itype, Predicated_Parent (Typ));
else
Set_Predicated_Parent (Itype, Typ);
end if;
end if;
-- A simple optimization: purely positional aggregates of static
-- components should be passed to gigi unexpanded whenever possible, and
-- regardless of the staticness of the bounds themselves. Subsequent
-- checks in exp_aggr verify that type is not packed, etc.
Set_Size_Known_At_Compile_Time
(Itype,
Is_Fully_Positional
and then Comes_From_Source (N)
and then Size_Known_At_Compile_Time (Component_Type (Typ)));
-- We always need a freeze node for a packed array subtype, so that we
-- can build the Packed_Array_Impl_Type corresponding to the subtype. If
-- expansion is disabled, the packed array subtype is not built, and we
-- must not generate a freeze node for the type, or else it will appear
-- incomplete to gigi.
if Is_Packed (Itype)
and then not In_Spec_Expression
and then Expander_Active
then
Freeze_Itype (Itype, N);
end if;
return Itype;
end Array_Aggr_Subtype;
--------------------------------
-- Check_Misspelled_Component --
--------------------------------
procedure Check_Misspelled_Component
(Elements : Elist_Id;
Component : Node_Id)
is
Max_Suggestions : constant := 2;
Nr_Of_Suggestions : Natural := 0;
Suggestion_1 : Entity_Id := Empty;
Suggestion_2 : Entity_Id := Empty;
Component_Elmt : Elmt_Id;
begin
-- All the components of List are matched against Component and a count
-- is maintained of possible misspellings. When at the end of the
-- analysis there are one or two (not more) possible misspellings,
-- these misspellings will be suggested as possible corrections.
Component_Elmt := First_Elmt (Elements);
while Nr_Of_Suggestions <= Max_Suggestions
and then Present (Component_Elmt)
loop
if Is_Bad_Spelling_Of
(Chars (Node (Component_Elmt)),
Chars (Component))
then
Nr_Of_Suggestions := Nr_Of_Suggestions + 1;
case Nr_Of_Suggestions is
when 1 => Suggestion_1 := Node (Component_Elmt);
when 2 => Suggestion_2 := Node (Component_Elmt);
when others => null;
end case;
end if;
Next_Elmt (Component_Elmt);
end loop;
-- Report at most two suggestions
if Nr_Of_Suggestions = 1 then
Error_Msg_NE -- CODEFIX
("\possible misspelling of&", Component, Suggestion_1);
elsif Nr_Of_Suggestions = 2 then
Error_Msg_Node_2 := Suggestion_2;
Error_Msg_NE -- CODEFIX
("\possible misspelling of& or&", Component, Suggestion_1);
end if;
end Check_Misspelled_Component;
----------------------------------------
-- Check_Expr_OK_In_Limited_Aggregate --
----------------------------------------
procedure Check_Expr_OK_In_Limited_Aggregate (Expr : Node_Id) is
begin
if Is_Limited_Type (Etype (Expr))
and then Comes_From_Source (Expr)
then
if In_Instance_Body or else In_Inlined_Body then
null;
elsif not OK_For_Limited_Init (Etype (Expr), Expr) then
Error_Msg_N
("initialization not allowed for limited types", Expr);
Explain_Limited_Type (Etype (Expr), Expr);
end if;
end if;
end Check_Expr_OK_In_Limited_Aggregate;
-------------------------
-- Is_Others_Aggregate --
-------------------------
function Is_Others_Aggregate (Aggr : Node_Id) return Boolean is
Assoc : constant List_Id := Component_Associations (Aggr);
begin
return No (Expressions (Aggr))
and then Nkind (First (Choice_List (First (Assoc)))) = N_Others_Choice;
end Is_Others_Aggregate;
-------------------------
-- Is_Single_Aggregate --
-------------------------
function Is_Single_Aggregate (Aggr : Node_Id) return Boolean is
Assoc : constant List_Id := Component_Associations (Aggr);
begin
return No (Expressions (Aggr))
and then No (Next (First (Assoc)))
and then No (Next (First (Choice_List (First (Assoc)))));
end Is_Single_Aggregate;
--------------------------------
-- Make_String_Into_Aggregate --
--------------------------------
procedure Make_String_Into_Aggregate (N : Node_Id) is
Exprs : constant List_Id := New_List;
Loc : constant Source_Ptr := Sloc (N);
Str : constant String_Id := Strval (N);
Strlen : constant Nat := String_Length (Str);
C : Char_Code;
C_Node : Node_Id;
New_N : Node_Id;
P : Source_Ptr;
begin
P := Loc + 1;
for J in 1 .. Strlen loop
C := Get_String_Char (Str, J);
Set_Character_Literal_Name (C);
C_Node :=
Make_Character_Literal (P,
Chars => Name_Find,
Char_Literal_Value => UI_From_CC (C));
Set_Etype (C_Node, Any_Character);
Append_To (Exprs, C_Node);
P := P + 1;
-- Something special for wide strings???
end loop;
New_N := Make_Aggregate (Loc, Expressions => Exprs);
Set_Analyzed (New_N);
Set_Etype (New_N, Any_Composite);
Rewrite (N, New_N);
end Make_String_Into_Aggregate;
-----------------------
-- Resolve_Aggregate --
-----------------------
procedure Resolve_Aggregate (N : Node_Id; Typ : Entity_Id) is
Loc : constant Source_Ptr := Sloc (N);
Aggr_Subtyp : Entity_Id;
-- The actual aggregate subtype. This is not necessarily the same as Typ
-- which is the subtype of the context in which the aggregate was found.
Others_Box : Boolean := False;
-- Set to True if N represents a simple aggregate with only
-- (others => <>), not nested as part of another aggregate.
function Within_Aggregate (N : Node_Id) return Boolean;
-- Return True if N is part of an N_Aggregate
----------------------
-- Within_Aggregate --
----------------------
function Within_Aggregate (N : Node_Id) return Boolean is
P : Node_Id := Parent (N);
begin
while Present (P) loop
if Nkind (P) = N_Aggregate then
return True;
end if;
P := Parent (P);
end loop;
return False;
end Within_Aggregate;
-- Start of processing for Resolve_Aggregate
begin
-- Ignore junk empty aggregate resulting from parser error
if No (Expressions (N))
and then No (Component_Associations (N))
and then not Null_Record_Present (N)
then
return;
end if;
-- If the aggregate has box-initialized components, its type must be
-- frozen so that initialization procedures can properly be called
-- in the resolution that follows. The replacement of boxes with
-- initialization calls is properly an expansion activity but it must
-- be done during resolution.
if Expander_Active
and then Present (Component_Associations (N))
then
declare
Comp : Node_Id;
First_Comp : Boolean := True;
begin
Comp := First (Component_Associations (N));
while Present (Comp) loop
if Box_Present (Comp) then
if First_Comp
and then No (Expressions (N))
and then Nkind (First (Choices (Comp))) = N_Others_Choice
and then not Within_Aggregate (N)
then
Others_Box := True;
end if;
Insert_Actions (N, Freeze_Entity (Typ, N));
exit;
end if;
First_Comp := False;
Next (Comp);
end loop;
end;
end if;
-- Check for aggregates not allowed in configurable run-time mode.
-- We allow all cases of aggregates that do not come from source, since
-- these are all assumed to be small (e.g. bounds of a string literal).
-- We also allow aggregates of types we know to be small.
if not Support_Aggregates_On_Target
and then Comes_From_Source (N)
and then (not Known_Static_Esize (Typ)
or else Esize (Typ) > System_Max_Integer_Size)
then
Error_Msg_CRT ("aggregate", N);
end if;
-- Ada 2005 (AI-287): Limited aggregates allowed
-- In an instance, ignore aggregate subcomponents that may be limited,
-- because they originate in view conflicts. If the original aggregate
-- is legal and the actuals are legal, the aggregate itself is legal.
if Is_Limited_Type (Typ)
and then Ada_Version < Ada_2005
and then not In_Instance
then
Error_Msg_N ("aggregate type cannot be limited", N);
Explain_Limited_Type (Typ, N);
elsif Is_Class_Wide_Type (Typ) then
Error_Msg_N ("type of aggregate cannot be class-wide", N);
elsif Typ = Any_String
or else Typ = Any_Composite
then
Error_Msg_N ("no unique type for aggregate", N);
Set_Etype (N, Any_Composite);
elsif Is_Array_Type (Typ) and then Null_Record_Present (N) then
Error_Msg_N ("null record forbidden in array aggregate", N);
elsif Present (Find_Aspect (Typ, Aspect_Aggregate))
and then Ekind (Typ) /= E_Record_Type
and then Ada_Version >= Ada_2022
then
-- Check for Ada 2022 and () aggregate.
if not Is_Homogeneous_Aggregate (N) then
Error_Msg_N ("container aggregate must use '['], not ()", N);
end if;
Resolve_Container_Aggregate (N, Typ);
elsif Is_Record_Type (Typ) then
Resolve_Record_Aggregate (N, Typ);
elsif Is_Array_Type (Typ) then
-- First a special test, for the case of a positional aggregate of
-- characters which can be replaced by a string literal.
-- Do not perform this transformation if this was a string literal
-- to start with, whose components needed constraint checks, or if
-- the component type is non-static, because it will require those
-- checks and be transformed back into an aggregate. If the index
-- type is not Integer the aggregate may represent a user-defined
-- string type but the context might need the original type so we
-- do not perform the transformation at this point.
if Number_Dimensions (Typ) = 1
and then Is_Standard_Character_Type (Component_Type (Typ))
and then No (Component_Associations (N))
and then not Is_Limited_Composite (Typ)
and then not Is_Private_Composite (Typ)
and then not Is_Bit_Packed_Array (Typ)
and then Nkind (Original_Node (Parent (N))) /= N_String_Literal
and then Is_OK_Static_Subtype (Component_Type (Typ))
and then Base_Type (Etype (First_Index (Typ))) =
Base_Type (Standard_Integer)
then
declare
Expr : Node_Id;
begin
Expr := First (Expressions (N));
while Present (Expr) loop
exit when Nkind (Expr) /= N_Character_Literal;
Next (Expr);
end loop;
if No (Expr) then
Start_String;
Expr := First (Expressions (N));
while Present (Expr) loop
Store_String_Char (UI_To_CC (Char_Literal_Value (Expr)));
Next (Expr);
end loop;
Rewrite (N, Make_String_Literal (Loc, End_String));
Analyze_And_Resolve (N, Typ);
return;
end if;
end;
end if;
-- Here if we have a real aggregate to deal with
Array_Aggregate : declare
Aggr_Resolved : Boolean;
Aggr_Typ : constant Entity_Id := Etype (Typ);
-- This is the unconstrained array type, which is the type against
-- which the aggregate is to be resolved. Typ itself is the array
-- type of the context which may not be the same subtype as the
-- subtype for the final aggregate.
begin
-- In the following we determine whether an OTHERS choice is
-- allowed inside the array aggregate. The test checks the context
-- in which the array aggregate occurs. If the context does not
-- permit it, or the aggregate type is unconstrained, an OTHERS
-- choice is not allowed (except that it is always allowed on the
-- right-hand side of an assignment statement; in this case the
-- constrainedness of the type doesn't matter, because an array
-- object is always constrained).
-- If expansion is disabled (generic context, or semantics-only
-- mode) actual subtypes cannot be constructed, and the type of an
-- object may be its unconstrained nominal type. However, if the
-- context is an assignment statement, OTHERS is allowed, because
-- the target of the assignment will have a constrained subtype
-- when fully compiled. Ditto if the context is an initialization
-- procedure where a component may have a predicate function that
-- carries the base type.
-- Note that there is no node for Explicit_Actual_Parameter.
-- To test for this context we therefore have to test for node
-- N_Parameter_Association which itself appears only if there is a
-- formal parameter. Consequently we also need to test for
-- N_Procedure_Call_Statement or N_Function_Call.
-- The context may be an N_Reference node, created by expansion.
-- Legality of the others clause was established in the source,
-- so the context is legal.
Set_Etype (N, Aggr_Typ); -- May be overridden later on
if Nkind (Parent (N)) = N_Assignment_Statement
or else Inside_Init_Proc
or else (Is_Constrained (Typ)
and then Nkind (Parent (N)) in
N_Parameter_Association
| N_Function_Call
| N_Procedure_Call_Statement
| N_Generic_Association
| N_Formal_Object_Declaration
| N_Simple_Return_Statement
| N_Object_Declaration
| N_Component_Declaration
| N_Parameter_Specification
| N_Qualified_Expression
| N_Reference
| N_Aggregate
| N_Extension_Aggregate
| N_Component_Association
| N_Case_Expression_Alternative
| N_If_Expression
| N_Expression_With_Actions)
then
Aggr_Resolved :=
Resolve_Array_Aggregate
(N,
Index => First_Index (Aggr_Typ),
Index_Constr => First_Index (Typ),
Component_Typ => Component_Type (Typ),
Others_Allowed => True);
else
Aggr_Resolved :=
Resolve_Array_Aggregate
(N,
Index => First_Index (Aggr_Typ),
Index_Constr => First_Index (Aggr_Typ),
Component_Typ => Component_Type (Typ),
Others_Allowed => False);
end if;
if not Aggr_Resolved then
-- A parenthesized expression may have been intended as an
-- aggregate, leading to a type error when analyzing the
-- component. This can also happen for a nested component
-- (see Analyze_Aggr_Expr).
if Paren_Count (N) > 0 then
Error_Msg_N
("positional aggregate cannot have one component", N);
end if;
Aggr_Subtyp := Any_Composite;
else
Aggr_Subtyp := Array_Aggr_Subtype (N, Typ);
end if;
Set_Etype (N, Aggr_Subtyp);
end Array_Aggregate;
elsif Is_Private_Type (Typ)
and then Present (Full_View (Typ))
and then (In_Inlined_Body or In_Instance_Body)
and then Is_Composite_Type (Full_View (Typ))
then
Resolve (N, Full_View (Typ));
else
Error_Msg_N ("illegal context for aggregate", N);
end if;
-- If we can determine statically that the evaluation of the aggregate
-- raises Constraint_Error, then replace the aggregate with an
-- N_Raise_Constraint_Error node, but set the Etype to the right
-- aggregate subtype. Gigi needs this.
if Raises_Constraint_Error (N) then
Aggr_Subtyp := Etype (N);
Rewrite (N,
Make_Raise_Constraint_Error (Loc, Reason => CE_Range_Check_Failed));
Set_Raises_Constraint_Error (N);
Set_Etype (N, Aggr_Subtyp);
Set_Analyzed (N);
end if;
if Warn_On_No_Value_Assigned
and then Others_Box
and then not Is_Fully_Initialized_Type (Etype (N))
then
Error_Msg_N ("?v?aggregate not fully initialized", N);
end if;
Check_Function_Writable_Actuals (N);
end Resolve_Aggregate;
-----------------------------
-- Resolve_Array_Aggregate --
-----------------------------
function Resolve_Array_Aggregate
(N : Node_Id;
Index : Node_Id;
Index_Constr : Node_Id;
Component_Typ : Entity_Id;
Others_Allowed : Boolean) return Boolean
is
Loc : constant Source_Ptr := Sloc (N);
Failure : constant Boolean := False;
Success : constant Boolean := True;
Index_Typ : constant Entity_Id := Etype (Index);
Index_Typ_Low : constant Node_Id := Type_Low_Bound (Index_Typ);
Index_Typ_High : constant Node_Id := Type_High_Bound (Index_Typ);
-- The type of the index corresponding to the array sub-aggregate along
-- with its low and upper bounds.
Index_Base : constant Entity_Id := Base_Type (Index_Typ);
Index_Base_Low : constant Node_Id := Type_Low_Bound (Index_Base);
Index_Base_High : constant Node_Id := Type_High_Bound (Index_Base);
-- Ditto for the base type
Others_Present : Boolean := False;
Nb_Choices : Nat := 0;
-- Contains the overall number of named choices in this sub-aggregate
function Add (Val : Uint; To : Node_Id) return Node_Id;
-- Creates a new expression node where Val is added to expression To.
-- Tries to constant fold whenever possible. To must be an already
-- analyzed expression.
procedure Check_Bound (BH : Node_Id; AH : in out Node_Id);
-- Checks that AH (the upper bound of an array aggregate) is less than
-- or equal to BH (the upper bound of the index base type). If the check
-- fails, a warning is emitted, the Raises_Constraint_Error flag of N is
-- set, and AH is replaced with a duplicate of BH.
procedure Check_Bounds (L, H : Node_Id; AL, AH : Node_Id);
-- Checks that range AL .. AH is compatible with range L .. H. Emits a
-- warning if not and sets the Raises_Constraint_Error flag in N.
procedure Check_Length (L, H : Node_Id; Len : Uint);
-- Checks that range L .. H contains at least Len elements. Emits a
-- warning if not and sets the Raises_Constraint_Error flag in N.
function Dynamic_Or_Null_Range (L, H : Node_Id) return Boolean;
-- Returns True if range L .. H is dynamic or null
procedure Get (Value : out Uint; From : Node_Id; OK : out Boolean);
-- Given expression node From, this routine sets OK to False if it
-- cannot statically evaluate From. Otherwise it stores this static
-- value into Value.
function Resolve_Aggr_Expr
(Expr : Node_Id;
Single_Elmt : Boolean) return Boolean;
-- Resolves aggregate expression Expr. Returns False if resolution
-- fails. If Single_Elmt is set to False, the expression Expr may be
-- used to initialize several array aggregate elements (this can happen
-- for discrete choices such as "L .. H => Expr" or the OTHERS choice).
-- In this event we do not resolve Expr unless expansion is disabled.
-- To know why, see the DELAYED COMPONENT RESOLUTION note above.
--
-- NOTE: In the case of "... => <>", we pass the in the
-- N_Component_Association node as Expr, since there is no Expression in
-- that case, and we need a Sloc for the error message.
procedure Resolve_Iterated_Component_Association
(N : Node_Id;
Index_Typ : Entity_Id);
-- For AI12-061
---------
-- Add --
---------
function Add (Val : Uint; To : Node_Id) return Node_Id is
Expr_Pos : Node_Id;
Expr : Node_Id;
To_Pos : Node_Id;
begin
if Raises_Constraint_Error (To) then
return To;
end if;
-- First test if we can do constant folding
if Compile_Time_Known_Value (To)
or else Nkind (To) = N_Integer_Literal
then
Expr_Pos := Make_Integer_Literal (Loc, Expr_Value (To) + Val);
Set_Is_Static_Expression (Expr_Pos);
Set_Etype (Expr_Pos, Etype (To));
Set_Analyzed (Expr_Pos, Analyzed (To));
if not Is_Enumeration_Type (Index_Typ) then
Expr := Expr_Pos;
-- If we are dealing with enumeration return
-- Index_Typ'Val (Expr_Pos)
else
Expr :=
Make_Attribute_Reference
(Loc,
Prefix => New_Occurrence_Of (Index_Typ, Loc),
Attribute_Name => Name_Val,
Expressions => New_List (Expr_Pos));
end if;
return Expr;
end if;
-- If we are here no constant folding possible
if not Is_Enumeration_Type (Index_Base) then
Expr :=
Make_Op_Add (Loc,
Left_Opnd => Duplicate_Subexpr (To),
Right_Opnd => Make_Integer_Literal (Loc, Val));
-- If we are dealing with enumeration return
-- Index_Typ'Val (Index_Typ'Pos (To) + Val)
else
To_Pos :=
Make_Attribute_Reference
(Loc,
Prefix => New_Occurrence_Of (Index_Typ, Loc),
Attribute_Name => Name_Pos,
Expressions => New_List (Duplicate_Subexpr (To)));
Expr_Pos :=
Make_Op_Add (Loc,
Left_Opnd => To_Pos,
Right_Opnd => Make_Integer_Literal (Loc, Val));
Expr :=
Make_Attribute_Reference
(Loc,
Prefix => New_Occurrence_Of (Index_Typ, Loc),
Attribute_Name => Name_Val,
Expressions => New_List (Expr_Pos));
-- If the index type has a non standard representation, the
-- attributes 'Val and 'Pos expand into function calls and the
-- resulting expression is considered non-safe for reevaluation
-- by the backend. Relocate it into a constant temporary in order
-- to make it safe for reevaluation.
if Has_Non_Standard_Rep (Etype (N)) then
declare
Def_Id : Entity_Id;
begin
Def_Id := Make_Temporary (Loc, 'R', Expr);
Set_Etype (Def_Id, Index_Typ);
Insert_Action (N,
Make_Object_Declaration (Loc,
Defining_Identifier => Def_Id,
Object_Definition =>
New_Occurrence_Of (Index_Typ, Loc),
Constant_Present => True,
Expression => Relocate_Node (Expr)));
Expr := New_Occurrence_Of (Def_Id, Loc);
end;
end if;
end if;
return Expr;
end Add;
-----------------
-- Check_Bound --
-----------------
procedure Check_Bound (BH : Node_Id; AH : in out Node_Id) is
Val_BH : Uint;
Val_AH : Uint;
OK_BH : Boolean;
OK_AH : Boolean;
begin
Get (Value => Val_BH, From => BH, OK => OK_BH);
Get (Value => Val_AH, From => AH, OK => OK_AH);
if OK_BH and then OK_AH and then Val_BH < Val_AH then
Set_Raises_Constraint_Error (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("upper bound out of range<<", AH);
Error_Msg_N ("\Constraint_Error [<<", AH);
-- You need to set AH to BH or else in the case of enumerations
-- indexes we will not be able to resolve the aggregate bounds.
AH := Duplicate_Subexpr (BH);
end if;
end Check_Bound;
------------------
-- Check_Bounds --
------------------
procedure Check_Bounds (L, H : Node_Id; AL, AH : Node_Id) is
Val_L : Uint;
Val_H : Uint;
Val_AL : Uint;
Val_AH : Uint;
OK_L : Boolean;
OK_H : Boolean;
OK_AL : Boolean;
OK_AH : Boolean;
pragma Warnings (Off, OK_AL);
pragma Warnings (Off, OK_AH);
begin
if Raises_Constraint_Error (N)
or else Dynamic_Or_Null_Range (AL, AH)
then
return;
end if;
Get (Value => Val_L, From => L, OK => OK_L);
Get (Value => Val_H, From => H, OK => OK_H);
Get (Value => Val_AL, From => AL, OK => OK_AL);
Get (Value => Val_AH, From => AH, OK => OK_AH);
if OK_L and then Val_L > Val_AL then
Set_Raises_Constraint_Error (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("lower bound of aggregate out of range<<", N);
Error_Msg_N ("\Constraint_Error [<<", N);
end if;
if OK_H and then Val_H < Val_AH then
Set_Raises_Constraint_Error (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("upper bound of aggregate out of range<<", N);
Error_Msg_N ("\Constraint_Error [<<", N);
end if;
end Check_Bounds;
------------------
-- Check_Length --
------------------
procedure Check_Length (L, H : Node_Id; Len : Uint) is
Val_L : Uint;
Val_H : Uint;
OK_L : Boolean;
OK_H : Boolean;
Range_Len : Uint;
begin
if Raises_Constraint_Error (N) then
return;
end if;
Get (Value => Val_L, From => L, OK => OK_L);
Get (Value => Val_H, From => H, OK => OK_H);
if not OK_L or else not OK_H then
return;
end if;
-- If null range length is zero
if Val_L > Val_H then
Range_Len := Uint_0;
else
Range_Len := Val_H - Val_L + 1;
end if;
if Range_Len < Len then
Set_Raises_Constraint_Error (N);
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("too many elements<<", N);
Error_Msg_N ("\Constraint_Error [<<", N);
end if;
end Check_Length;
---------------------------
-- Dynamic_Or_Null_Range --
---------------------------
function Dynamic_Or_Null_Range (L, H : Node_Id) return Boolean is
Val_L : Uint;
Val_H : Uint;
OK_L : Boolean;
OK_H : Boolean;
begin
Get (Value => Val_L, From => L, OK => OK_L);
Get (Value => Val_H, From => H, OK => OK_H);
return not OK_L or else not OK_H
or else not Is_OK_Static_Expression (L)
or else not Is_OK_Static_Expression (H)
or else Val_L > Val_H;
end Dynamic_Or_Null_Range;
---------
-- Get --
---------
procedure Get (Value : out Uint; From : Node_Id; OK : out Boolean) is
begin
OK := True;
if Compile_Time_Known_Value (From) then
Value := Expr_Value (From);
-- If expression From is something like Some_Type'Val (10) then
-- Value = 10.
elsif Nkind (From) = N_Attribute_Reference
and then Attribute_Name (From) = Name_Val
and then Compile_Time_Known_Value (First (Expressions (From)))
then
Value := Expr_Value (First (Expressions (From)));
else
Value := Uint_0;
OK := False;
end if;
end Get;
-----------------------
-- Resolve_Aggr_Expr --
-----------------------
function Resolve_Aggr_Expr
(Expr : Node_Id;
Single_Elmt : Boolean) return Boolean
is
Nxt_Ind : constant Node_Id := Next_Index (Index);
Nxt_Ind_Constr : constant Node_Id := Next_Index (Index_Constr);
-- Index is the current index corresponding to the expression
Resolution_OK : Boolean := True;
-- Set to False if resolution of the expression failed
begin
-- Defend against previous errors
if Nkind (Expr) = N_Error
or else Error_Posted (Expr)
then
return True;
end if;
-- If the array type against which we are resolving the aggregate
-- has several dimensions, the expressions nested inside the
-- aggregate must be further aggregates (or strings).
if Present (Nxt_Ind) then
if Nkind (Expr) /= N_Aggregate then
-- A string literal can appear where a one-dimensional array
-- of characters is expected. If the literal looks like an
-- operator, it is still an operator symbol, which will be
-- transformed into a string when analyzed.
if Is_Character_Type (Component_Typ)
and then No (Next_Index (Nxt_Ind))
and then Nkind (Expr) in N_String_Literal | N_Operator_Symbol
then
-- A string literal used in a multidimensional array
-- aggregate in place of the final one-dimensional
-- aggregate must not be enclosed in parentheses.
if Paren_Count (Expr) /= 0 then
Error_Msg_N ("no parenthesis allowed here", Expr);
end if;
Make_String_Into_Aggregate (Expr);
else
Error_Msg_N ("nested array aggregate expected", Expr);
-- If the expression is parenthesized, this may be
-- a missing component association for a 1-aggregate.
if Paren_Count (Expr) > 0 then
Error_Msg_N
("\if single-component aggregate is intended, "
& "write e.g. (1 ='> ...)", Expr);
end if;
return Failure;
end if;
end if;
-- If it's "... => <>", nothing to resolve
if Nkind (Expr) = N_Component_Association then
pragma Assert (Box_Present (Expr));
return Success;
end if;
-- Ada 2005 (AI-231): Propagate the type to the nested aggregate.
-- Required to check the null-exclusion attribute (if present).
-- This value may be overridden later on.
Set_Etype (Expr, Etype (N));
Resolution_OK := Resolve_Array_Aggregate
(Expr, Nxt_Ind, Nxt_Ind_Constr, Component_Typ, Others_Allowed);
else
-- If it's "... => <>", nothing to resolve
if Nkind (Expr) = N_Component_Association then
pragma Assert (Box_Present (Expr));
return Success;
end if;
-- Do not resolve the expressions of discrete or others choices
-- unless the expression covers a single component, or the
-- expander is inactive.
-- In SPARK mode, expressions that can perform side effects will
-- be recognized by the gnat2why back-end, and the whole
-- subprogram will be ignored. So semantic analysis can be
-- performed safely.
if Single_Elmt
or else not Expander_Active
or else In_Spec_Expression
then
Analyze_And_Resolve (Expr, Component_Typ);
Check_Expr_OK_In_Limited_Aggregate (Expr);
Check_Non_Static_Context (Expr);
Aggregate_Constraint_Checks (Expr, Component_Typ);
Check_Unset_Reference (Expr);
end if;
end if;
-- If an aggregate component has a type with predicates, an explicit
-- predicate check must be applied, as for an assignment statement,
-- because the aggregate might not be expanded into individual
-- component assignments. If the expression covers several components
-- the analysis and the predicate check take place later.
if Has_Predicates (Component_Typ)
and then Analyzed (Expr)
then
Apply_Predicate_Check (Expr, Component_Typ);
end if;
if Raises_Constraint_Error (Expr)
and then Nkind (Parent (Expr)) /= N_Component_Association
then
Set_Raises_Constraint_Error (N);
end if;
-- If the expression has been marked as requiring a range check,
-- then generate it here. It's a bit odd to be generating such
-- checks in the analyzer, but harmless since Generate_Range_Check
-- does nothing (other than making sure Do_Range_Check is set) if
-- the expander is not active.
if Do_Range_Check (Expr) then
Generate_Range_Check (Expr, Component_Typ, CE_Range_Check_Failed);
end if;
return Resolution_OK;
end Resolve_Aggr_Expr;
--------------------------------------------
-- Resolve_Iterated_Component_Association --
--------------------------------------------
procedure Resolve_Iterated_Component_Association
(N : Node_Id;
Index_Typ : Entity_Id)
is
Loc : constant Source_Ptr := Sloc (N);
Id : constant Entity_Id := Defining_Identifier (N);
Id_Typ : Entity_Id := Any_Type;
-----------------------
-- Remove_References --
-----------------------
function Remove_Ref (N : Node_Id) return Traverse_Result;
-- Remove references to the entity Id after analysis, so it can be
-- properly reanalyzed after construct is expanded into a loop.
function Remove_Ref (N : Node_Id) return Traverse_Result is
begin
if Nkind (N) = N_Identifier
and then Present (Entity (N))
and then Entity (N) = Id
then
Set_Entity (N, Empty);
Set_Etype (N, Empty);
end if;
Set_Analyzed (N, False);
return OK;
end Remove_Ref;
procedure Remove_References is new Traverse_Proc (Remove_Ref);
-- Local variables
Choice : Node_Id;
Dummy : Boolean;
Ent : Entity_Id;
Expr : Node_Id;
-- Start of processing for Resolve_Iterated_Component_Association
begin
Error_Msg_Ada_2022_Feature ("iterated component", Loc);
if Present (Iterator_Specification (N)) then
Analyze (Name (Iterator_Specification (N)));
-- We assume that the domain of iteration cannot be overloaded.
declare
Domain : constant Node_Id := Name (Iterator_Specification (N));
D_Type : constant Entity_Id := Etype (Domain);
Elt : Entity_Id;
begin
if Is_Array_Type (D_Type) then
Id_Typ := Component_Type (D_Type);
else
if Has_Aspect (D_Type, Aspect_Iterable) then
Elt :=
Get_Iterable_Type_Primitive (D_Type, Name_Element);
if No (Elt) then
Error_Msg_N
("missing Element primitive for iteration", Domain);
else
Id_Typ := Etype (Elt);
end if;
else
Error_Msg_N ("cannot iterate over", Domain);
end if;
end if;
end;
else
Id_Typ := Index_Typ;
Choice := First (Discrete_Choices (N));
while Present (Choice) loop
if Nkind (Choice) = N_Others_Choice then
Others_Present := True;
else
Analyze (Choice);
-- Choice can be a subtype name, a range, or an expression
if Is_Entity_Name (Choice)
and then Is_Type (Entity (Choice))
and then
Base_Type (Entity (Choice)) = Base_Type (Index_Typ)
then
null;
else
Analyze_And_Resolve (Choice, Index_Typ);
end if;
end if;
Next (Choice);
end loop;
end if;
-- Create a scope in which to introduce an index, which is usually
-- visible in the expression for the component, and needed for its
-- analysis.
Ent := New_Internal_Entity (E_Loop, Current_Scope, Loc, 'L');
Set_Etype (Ent, Standard_Void_Type);
Set_Parent (Ent, Parent (N));
Push_Scope (Ent);
-- Insert and decorate the index variable in the current scope.
-- The expression has to be analyzed once the index variable is
-- directly visible.
Enter_Name (Id);
Set_Etype (Id, Id_Typ);
Mutate_Ekind (Id, E_Variable);
Set_Scope (Id, Ent);
-- Analyze expression without expansion, to verify legality.
-- When generating code, we then remove references to the index
-- variable, because the expression will be analyzed anew after
-- rewritting as a loop with a new index variable; when not
-- generating code we leave the analyzed expression as it is.
Expr := Expression (N);
Expander_Mode_Save_And_Set (False);
Dummy := Resolve_Aggr_Expr (Expr, Single_Elmt => False);
Expander_Mode_Restore;
if Operating_Mode /= Check_Semantics then
Remove_References (Expr);
end if;
-- An iterated_component_association may appear in a nested
-- aggregate for a multidimensional structure: preserve the bounds
-- computed for the expression, as well as the anonymous array
-- type generated for it; both are needed during array expansion.
if Nkind (Expr) = N_Aggregate then
Set_Aggregate_Bounds (Expression (N), Aggregate_Bounds (Expr));
Set_Etype (Expression (N), Etype (Expr));
end if;
End_Scope;
end Resolve_Iterated_Component_Association;
-- Local variables
Assoc : Node_Id;
Choice : Node_Id;
Expr : Node_Id;
Discard : Node_Id;
Aggr_Low : Node_Id := Empty;
Aggr_High : Node_Id := Empty;
-- The actual low and high bounds of this sub-aggregate
Case_Table_Size : Nat;
-- Contains the size of the case table needed to sort aggregate choices
Choices_Low : Node_Id := Empty;
Choices_High : Node_Id := Empty;
-- The lowest and highest discrete choices values for a named aggregate
Delete_Choice : Boolean;
-- Used when replacing a subtype choice with predicate by a list
Has_Iterator_Specifications : Boolean := False;
-- Flag to indicate that all named associations are iterated component
-- associations with iterator specifications, in which case the
-- expansion will create two loops: one to evaluate the size and one
-- to generate the elements (4.3.3 (20.2/5)).
Nb_Elements : Uint := Uint_0;
-- The number of elements in a positional aggregate
Nb_Discrete_Choices : Nat := 0;
-- The overall number of discrete choices (not counting others choice)
-- Start of processing for Resolve_Array_Aggregate
begin
-- Ignore junk empty aggregate resulting from parser error
if No (Expressions (N))
and then No (Component_Associations (N))
and then not Null_Record_Present (N)
then
return False;
end if;
-- Disable the warning for GNAT Mode to allow for easier transition.
if Ada_Version >= Ada_2022
and then Warn_On_Obsolescent_Feature
and then not GNAT_Mode
and then not Is_Homogeneous_Aggregate (N)
and then not Is_Enum_Array_Aggregate (N)
and then Is_Parenthesis_Aggregate (N)
and then Nkind (Parent (N)) /= N_Qualified_Expression
and then Comes_From_Source (N)
then
Error_Msg_N
("?j?array aggregate using () is an" &
" obsolescent syntax, use '['] instead", N);
end if;
-- STEP 1: make sure the aggregate is correctly formatted
if Present (Component_Associations (N)) then
-- Verify that all or none of the component associations
-- include an iterator specification.
Assoc := First (Component_Associations (N));
if Nkind (Assoc) = N_Iterated_Component_Association
and then Present (Iterator_Specification (Assoc))
then
-- All other component associations must have an iterator spec.
Next (Assoc);
while Present (Assoc) loop
if Nkind (Assoc) /= N_Iterated_Component_Association
or else No (Iterator_Specification (Assoc))
then
Error_Msg_N ("mixed iterated component association"
& " (RM 4.4.3 (17.1/5))",
Assoc);
return False;
end if;
Next (Assoc);
end loop;
Has_Iterator_Specifications := True;
else
-- or none of them do.
Next (Assoc);
while Present (Assoc) loop
if Nkind (Assoc) = N_Iterated_Component_Association
and then Present (Iterator_Specification (Assoc))
then
Error_Msg_N ("mixed iterated component association"
& " (RM 4.4.3 (17.1/5))",
Assoc);
return False;
end if;
Next (Assoc);
end loop;
while Present (Assoc) loop
Next (Assoc);
end loop;
end if;
Assoc := First (Component_Associations (N));
while Present (Assoc) loop
if Nkind (Assoc) = N_Iterated_Component_Association then
Resolve_Iterated_Component_Association (Assoc, Index_Typ);
end if;
Choice := First (Choice_List (Assoc));
Delete_Choice := False;
while Present (Choice) loop
if Nkind (Choice) = N_Others_Choice then
Others_Present := True;
if Choice /= First (Choice_List (Assoc))
or else Present (Next (Choice))
then
Error_Msg_N
("OTHERS must appear alone in a choice list", Choice);
return Failure;
end if;
if Present (Next (Assoc)) then
Error_Msg_N
("OTHERS must appear last in an aggregate", Choice);
return Failure;
end if;
if Ada_Version = Ada_83
and then Assoc /= First (Component_Associations (N))
and then Nkind (Parent (N)) in
N_Assignment_Statement | N_Object_Declaration
then
Error_Msg_N
("(Ada 83) illegal context for OTHERS choice", N);
end if;
elsif Is_Entity_Name (Choice) then
Analyze (Choice);
declare
E : constant Entity_Id := Entity (Choice);
New_Cs : List_Id;
P : Node_Id;
C : Node_Id;
begin
if Is_Type (E) and then Has_Predicates (E) then
Freeze_Before (N, E);
if Has_Dynamic_Predicate_Aspect (E) then
Error_Msg_NE
("subtype& has dynamic predicate, not allowed "
& "in aggregate choice", Choice, E);
elsif not Is_OK_Static_Subtype (E) then
Error_Msg_NE
("non-static subtype& has predicate, not allowed "
& "in aggregate choice", Choice, E);
end if;
-- If the subtype has a static predicate, replace the
-- original choice with the list of individual values
-- covered by the predicate.
-- This should be deferred to expansion time ???
if Present (Static_Discrete_Predicate (E)) then
Delete_Choice := True;
New_Cs := New_List;
P := First (Static_Discrete_Predicate (E));
while Present (P) loop
C := New_Copy (P);
Set_Sloc (C, Sloc (Choice));
Append_To (New_Cs, C);
Next (P);
end loop;
Insert_List_After (Choice, New_Cs);
end if;
end if;
end;
end if;
Nb_Choices := Nb_Choices + 1;
declare
C : constant Node_Id := Choice;
begin
Next (Choice);
if Delete_Choice then
Remove (C);
Nb_Choices := Nb_Choices - 1;
Delete_Choice := False;
end if;
end;
end loop;
Next (Assoc);
end loop;
end if;
-- At this point we know that the others choice, if present, is by
-- itself and appears last in the aggregate. Check if we have mixed
-- positional and discrete associations (other than the others choice).
if Present (Expressions (N))
and then (Nb_Choices > 1
or else (Nb_Choices = 1 and then not Others_Present))
then
Error_Msg_N
("cannot mix named and positional associations in array aggregate",
First (Choice_List (First (Component_Associations (N)))));
return Failure;
end if;
-- Test for the validity of an others choice if present
if Others_Present and then not Others_Allowed then
declare
Others_N : constant Node_Id :=
First (Choice_List (First (Component_Associations (N))));
begin
Error_Msg_N ("OTHERS choice not allowed here", Others_N);
Error_Msg_N ("\qualify the aggregate with a constrained subtype "
& "to provide bounds for it", Others_N);
return Failure;
end;
end if;
-- Protect against cascaded errors
if Etype (Index_Typ) = Any_Type then
return Failure;
end if;
-- STEP 2: Process named components
if No (Expressions (N)) then
if Others_Present then
Case_Table_Size := Nb_Choices - 1;
else
Case_Table_Size := Nb_Choices;
end if;
Step_2 : declare
function Empty_Range (A : Node_Id) return Boolean;
-- If an association covers an empty range, some warnings on the
-- expression of the association can be disabled.
-----------------
-- Empty_Range --
-----------------
function Empty_Range (A : Node_Id) return Boolean is
R : constant Node_Id := First (Choices (A));
begin
return No (Next (R))
and then Nkind (R) = N_Range
and then Compile_Time_Compare
(Low_Bound (R), High_Bound (R), False) = GT;
end Empty_Range;
-- Local variables
Low : Node_Id;
High : Node_Id;
-- Denote the lowest and highest values in an aggregate choice
S_Low : Node_Id := Empty;
S_High : Node_Id := Empty;
-- if a choice in an aggregate is a subtype indication these
-- denote the lowest and highest values of the subtype
Table : Case_Table_Type (1 .. Case_Table_Size);
-- Used to sort all the different choice values
Single_Choice : Boolean;
-- Set to true every time there is a single discrete choice in a
-- discrete association
Prev_Nb_Discrete_Choices : Nat;
-- Used to keep track of the number of discrete choices in the
-- current association.
Errors_Posted_On_Choices : Boolean := False;
-- Keeps track of whether any choices have semantic errors
-- Start of processing for Step_2
begin
-- STEP 2 (A): Check discrete choices validity
-- No need if this is an element iteration.
Assoc := First (Component_Associations (N));
while Present (Assoc)
and then Present (Choice_List (Assoc))
loop
Prev_Nb_Discrete_Choices := Nb_Discrete_Choices;
Choice := First (Choice_List (Assoc));
loop
Analyze (Choice);
if Nkind (Choice) = N_Others_Choice then
Single_Choice := False;
exit;
-- Test for subtype mark without constraint
elsif Is_Entity_Name (Choice) and then
Is_Type (Entity (Choice))
then
if Base_Type (Entity (Choice)) /= Index_Base then
Error_Msg_N
("invalid subtype mark in aggregate choice",
Choice);
return Failure;
end if;
-- Case of subtype indication
elsif Nkind (Choice) = N_Subtype_Indication then
Resolve_Discrete_Subtype_Indication (Choice, Index_Base);
if Has_Dynamic_Predicate_Aspect
(Entity (Subtype_Mark (Choice)))
then
Error_Msg_NE
("subtype& has dynamic predicate, "
& "not allowed in aggregate choice",
Choice, Entity (Subtype_Mark (Choice)));
end if;
-- Does the subtype indication evaluation raise CE?
Get_Index_Bounds (Subtype_Mark (Choice), S_Low, S_High);
Get_Index_Bounds (Choice, Low, High);
Check_Bounds (S_Low, S_High, Low, High);
-- Case of range or expression
else
Resolve (Choice, Index_Base);
Check_Unset_Reference (Choice);
Check_Non_Static_Context (Choice);
-- If semantic errors were posted on the choice, then
-- record that for possible early return from later
-- processing (see handling of enumeration choices).
if Error_Posted (Choice) then
Errors_Posted_On_Choices := True;
end if;
-- Do not range check a choice. This check is redundant
-- since this test is already done when we check that the
-- bounds of the array aggregate are within range.
Set_Do_Range_Check (Choice, False);
end if;
-- If we could not resolve the discrete choice stop here
if Etype (Choice) = Any_Type then
return Failure;
-- If the discrete choice raises CE get its original bounds
elsif Nkind (Choice) = N_Raise_Constraint_Error then
Set_Raises_Constraint_Error (N);
Get_Index_Bounds (Original_Node (Choice), Low, High);
-- Otherwise get its bounds as usual
else
Get_Index_Bounds (Choice, Low, High);
end if;
if (Dynamic_Or_Null_Range (Low, High)
or else (Nkind (Choice) = N_Subtype_Indication
and then
Dynamic_Or_Null_Range (S_Low, S_High)))
and then Nb_Choices /= 1
then
Error_Msg_N
("dynamic or empty choice in aggregate "
& "must be the only choice", Choice);
return Failure;
end if;
if not (All_Composite_Constraints_Static (Low)
and then All_Composite_Constraints_Static (High)
and then All_Composite_Constraints_Static (S_Low)
and then All_Composite_Constraints_Static (S_High))
then
Check_Restriction (No_Dynamic_Sized_Objects, Choice);
end if;
Nb_Discrete_Choices := Nb_Discrete_Choices + 1;
Table (Nb_Discrete_Choices).Lo := Low;
Table (Nb_Discrete_Choices).Hi := High;
Table (Nb_Discrete_Choices).Choice := Choice;
Next (Choice);
if No (Choice) then
-- Check if we have a single discrete choice and whether
-- this discrete choice specifies a single value.
Single_Choice :=
(Nb_Discrete_Choices = Prev_Nb_Discrete_Choices + 1)
and then (Low = High);
exit;
end if;
end loop;
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_2005
and then Known_Null (Expression (Assoc))
and then not Empty_Range (Assoc)
then
Check_Can_Never_Be_Null (Etype (N), Expression (Assoc));
end if;
-- Ada 2005 (AI-287): In case of default initialized component
-- we delay the resolution to the expansion phase.
if Box_Present (Assoc) then
-- Ada 2005 (AI-287): In case of default initialization of a
-- component the expander will generate calls to the
-- corresponding initialization subprogram. We need to call
-- Resolve_Aggr_Expr to check the rules about
-- dimensionality.
if not Resolve_Aggr_Expr
(Assoc, Single_Elmt => Single_Choice)
then
return Failure;
end if;
-- ??? Checks for dynamically tagged expressions below will
-- be only applied to iterated_component_association after
-- expansion; in particular, errors might not be reported when
-- -gnatc switch is used.
elsif Nkind (Assoc) = N_Iterated_Component_Association then
null; -- handled above, in a loop context
elsif not Resolve_Aggr_Expr
(Expression (Assoc), Single_Elmt => Single_Choice)
then
return Failure;
-- Check incorrect use of dynamically tagged expression
-- We differentiate here two cases because the expression may
-- not be decorated. For example, the analysis and resolution
-- of the expression associated with the others choice will be
-- done later with the full aggregate. In such case we
-- duplicate the expression tree to analyze the copy and
-- perform the required check.
elsif not Present (Etype (Expression (Assoc))) then
declare
Save_Analysis : constant Boolean := Full_Analysis;
Expr : constant Node_Id :=
New_Copy_Tree (Expression (Assoc));
begin
Expander_Mode_Save_And_Set (False);
Full_Analysis := False;
-- Analyze the expression, making sure it is properly
-- attached to the tree before we do the analysis.
Set_Parent (Expr, Parent (Expression (Assoc)));
Analyze (Expr);
-- Compute its dimensions now, rather than at the end of
-- resolution, because in the case of multidimensional
-- aggregates subsequent expansion may lead to spurious
-- errors.
Check_Expression_Dimensions (Expr, Component_Typ);
-- If the expression is a literal, propagate this info
-- to the expression in the association, to enable some
-- optimizations downstream.
if Is_Entity_Name (Expr)
and then Present (Entity (Expr))
and then Ekind (Entity (Expr)) = E_Enumeration_Literal
then
Analyze_And_Resolve
(Expression (Assoc), Component_Typ);
end if;
Full_Analysis := Save_Analysis;
Expander_Mode_Restore;
if Is_Tagged_Type (Etype (Expr)) then
Check_Dynamically_Tagged_Expression
(Expr => Expr,
Typ => Component_Type (Etype (N)),
Related_Nod => N);
end if;
end;
elsif Is_Tagged_Type (Etype (Expression (Assoc))) then
Check_Dynamically_Tagged_Expression
(Expr => Expression (Assoc),
Typ => Component_Type (Etype (N)),
Related_Nod => N);
end if;
Next (Assoc);
end loop;
-- If aggregate contains more than one choice then these must be
-- static. Check for duplicate and missing values.
-- Note: there is duplicated code here wrt Check_Choice_Set in
-- the body of Sem_Case, and it is possible we could just reuse
-- that procedure. To be checked ???
if Nb_Discrete_Choices > 1 then
Check_Choices : declare
Choice : Node_Id;
-- Location of choice for messages
Hi_Val : Uint;
Lo_Val : Uint;
-- High end of one range and Low end of the next. Should be
-- contiguous if there is no hole in the list of values.
Lo_Dup : Uint;
Hi_Dup : Uint;
-- End points of duplicated range
Missing_Or_Duplicates : Boolean := False;
-- Set True if missing or duplicate choices found
procedure Output_Bad_Choices (Lo, Hi : Uint; C : Node_Id);
-- Output continuation message with a representation of the
-- bounds (just Lo if Lo = Hi, else Lo .. Hi). C is the
-- choice node where the message is to be posted.
------------------------
-- Output_Bad_Choices --
------------------------
procedure Output_Bad_Choices (Lo, Hi : Uint; C : Node_Id) is
begin
-- Enumeration type case
if Is_Enumeration_Type (Index_Typ) then
Error_Msg_Name_1 :=
Chars (Get_Enum_Lit_From_Pos (Index_Typ, Lo, Loc));
Error_Msg_Name_2 :=
Chars (Get_Enum_Lit_From_Pos (Index_Typ, Hi, Loc));
if Lo = Hi then
Error_Msg_N ("\\ %!", C);
else
Error_Msg_N ("\\ % .. %!", C);
end if;
-- Integer types case
else
Error_Msg_Uint_1 := Lo;
Error_Msg_Uint_2 := Hi;
if Lo = Hi then
Error_Msg_N ("\\ ^!", C);
else
Error_Msg_N ("\\ ^ .. ^!", C);
end if;
end if;
end Output_Bad_Choices;
-- Start of processing for Check_Choices
begin
Sort_Case_Table (Table);
-- First we do a quick linear loop to find out if we have
-- any duplicates or missing entries (usually we have a
-- legal aggregate, so this will get us out quickly).
for J in 1 .. Nb_Discrete_Choices - 1 loop
Hi_Val := Expr_Value (Table (J).Hi);
Lo_Val := Expr_Value (Table (J + 1).Lo);
if Lo_Val <= Hi_Val
or else (Lo_Val > Hi_Val + 1
and then not Others_Present)
then
Missing_Or_Duplicates := True;
exit;
end if;
end loop;
-- If we have missing or duplicate entries, first fill in
-- the Highest entries to make life easier in the following
-- loops to detect bad entries.
if Missing_Or_Duplicates then
Table (1).Highest := Expr_Value (Table (1).Hi);
for J in 2 .. Nb_Discrete_Choices loop
Table (J).Highest :=
UI_Max
(Table (J - 1).Highest, Expr_Value (Table (J).Hi));
end loop;
-- Loop through table entries to find duplicate indexes
for J in 2 .. Nb_Discrete_Choices loop
Lo_Val := Expr_Value (Table (J).Lo);
Hi_Val := Expr_Value (Table (J).Hi);
-- Case where we have duplicates (the lower bound of
-- this choice is less than or equal to the highest
-- high bound found so far).
if Lo_Val <= Table (J - 1).Highest then
-- We move backwards looking for duplicates. We can
-- abandon this loop as soon as we reach a choice
-- highest value that is less than Lo_Val.
for K in reverse 1 .. J - 1 loop
exit when Table (K).Highest < Lo_Val;
-- Here we may have duplicates between entries
-- for K and J. Get range of duplicates.
Lo_Dup :=
UI_Max (Lo_Val, Expr_Value (Table (K).Lo));
Hi_Dup :=
UI_Min (Hi_Val, Expr_Value (Table (K).Hi));
-- Nothing to do if duplicate range is null
if Lo_Dup > Hi_Dup then
null;
-- Otherwise place proper message
else
-- We place message on later choice, with a
-- line reference to the earlier choice.
if Sloc (Table (J).Choice) <
Sloc (Table (K).Choice)
then
Choice := Table (K).Choice;
Error_Msg_Sloc := Sloc (Table (J).Choice);
else
Choice := Table (J).Choice;
Error_Msg_Sloc := Sloc (Table (K).Choice);
end if;
if Lo_Dup = Hi_Dup then
Error_Msg_N
("index value in array aggregate "
& "duplicates the one given#!", Choice);
else
Error_Msg_N
("index values in array aggregate "
& "duplicate those given#!", Choice);
end if;
Output_Bad_Choices (Lo_Dup, Hi_Dup, Choice);
end if;
end loop;
end if;
end loop;
-- Loop through entries in table to find missing indexes.
-- Not needed if others, since missing impossible.
if not Others_Present then
for J in 2 .. Nb_Discrete_Choices loop
Lo_Val := Expr_Value (Table (J).Lo);
Hi_Val := Table (J - 1).Highest;
if Lo_Val > Hi_Val + 1 then
declare
Error_Node : Node_Id;
begin
-- If the choice is the bound of a range in
-- a subtype indication, it is not in the
-- source lists for the aggregate itself, so
-- post the error on the aggregate. Otherwise
-- post it on choice itself.
Choice := Table (J).Choice;
if Is_List_Member (Choice) then
Error_Node := Choice;
else
Error_Node := N;
end if;
if Hi_Val + 1 = Lo_Val - 1 then
Error_Msg_N
("missing index value "
& "in array aggregate!", Error_Node);
else
Error_Msg_N
("missing index values "
& "in array aggregate!", Error_Node);
end if;
Output_Bad_Choices
(Hi_Val + 1, Lo_Val - 1, Error_Node);
end;
end if;
end loop;
end if;
-- If either missing or duplicate values, return failure
Set_Etype (N, Any_Composite);
return Failure;
end if;
end Check_Choices;
end if;
if Has_Iterator_Specifications then
-- Bounds will be determined dynamically.
return Success;
end if;
-- STEP 2 (B): Compute aggregate bounds and min/max choices values
if Nb_Discrete_Choices > 0 then
Choices_Low := Table (1).Lo;
Choices_High := Table (Nb_Discrete_Choices).Hi;
end if;
-- If Others is present, then bounds of aggregate come from the
-- index constraint (not the choices in the aggregate itself).
if Others_Present then
Get_Index_Bounds (Index_Constr, Aggr_Low, Aggr_High);
-- Abandon processing if either bound is already signalled as
-- an error (prevents junk cascaded messages and blow ups).
if Nkind (Aggr_Low) = N_Error
or else
Nkind (Aggr_High) = N_Error
then
return False;
end if;
-- No others clause present
else
-- Special processing if others allowed and not present. This
-- means that the bounds of the aggregate come from the index
-- constraint (and the length must match).
if Others_Allowed then
Get_Index_Bounds (Index_Constr, Aggr_Low, Aggr_High);
-- Abandon processing if either bound is already signalled
-- as an error (stop junk cascaded messages and blow ups).
if Nkind (Aggr_Low) = N_Error
or else
Nkind (Aggr_High) = N_Error
then
return False;
end if;
-- If others allowed, and no others present, then the array
-- should cover all index values. If it does not, we will
-- get a length check warning, but there is two cases where
-- an additional warning is useful:
-- If we have no positional components, and the length is
-- wrong (which we can tell by others being allowed with
-- missing components), and the index type is an enumeration
-- type, then issue appropriate warnings about these missing
-- components. They are only warnings, since the aggregate
-- is fine, it's just the wrong length. We skip this check
-- for standard character types (since there are no literals
-- and it is too much trouble to concoct them), and also if
-- any of the bounds have values that are not known at
-- compile time.
-- Another case warranting a warning is when the length
-- is right, but as above we have an index type that is
-- an enumeration, and the bounds do not match. This is a
-- case where dubious sliding is allowed and we generate a
-- warning that the bounds do not match.
if No (Expressions (N))
and then Nkind (Index) = N_Range
and then Is_Enumeration_Type (Etype (Index))
and then not Is_Standard_Character_Type (Etype (Index))
and then Compile_Time_Known_Value (Aggr_Low)
and then Compile_Time_Known_Value (Aggr_High)
and then Compile_Time_Known_Value (Choices_Low)
and then Compile_Time_Known_Value (Choices_High)
then
-- If any of the expressions or range bounds in choices
-- have semantic errors, then do not attempt further
-- resolution, to prevent cascaded errors.
if Errors_Posted_On_Choices then
return Failure;
end if;
declare
ALo : constant Node_Id := Expr_Value_E (Aggr_Low);
AHi : constant Node_Id := Expr_Value_E (Aggr_High);
CLo : constant Node_Id := Expr_Value_E (Choices_Low);
CHi : constant Node_Id := Expr_Value_E (Choices_High);
Ent : Entity_Id;
begin
-- Warning case 1, missing values at start/end. Only
-- do the check if the number of entries is too small.
if (Enumeration_Pos (CHi) - Enumeration_Pos (CLo))
<
(Enumeration_Pos (AHi) - Enumeration_Pos (ALo))
then
Error_Msg_N
("missing index value(s) in array aggregate??",
N);
-- Output missing value(s) at start
if Chars (ALo) /= Chars (CLo) then
Ent := Prev (CLo);
if Chars (ALo) = Chars (Ent) then
Error_Msg_Name_1 := Chars (ALo);
Error_Msg_N ("\ %??", N);
else
Error_Msg_Name_1 := Chars (ALo);
Error_Msg_Name_2 := Chars (Ent);
Error_Msg_N ("\ % .. %??", N);
end if;
end if;
-- Output missing value(s) at end
if Chars (AHi) /= Chars (CHi) then
Ent := Next (CHi);
if Chars (AHi) = Chars (Ent) then
Error_Msg_Name_1 := Chars (Ent);
Error_Msg_N ("\ %??", N);
else
Error_Msg_Name_1 := Chars (Ent);
Error_Msg_Name_2 := Chars (AHi);
Error_Msg_N ("\ % .. %??", N);
end if;
end if;
-- Warning case 2, dubious sliding. The First_Subtype
-- test distinguishes between a constrained type where
-- sliding is not allowed (so we will get a warning
-- later that Constraint_Error will be raised), and
-- the unconstrained case where sliding is permitted.
elsif (Enumeration_Pos (CHi) - Enumeration_Pos (CLo))
=
(Enumeration_Pos (AHi) - Enumeration_Pos (ALo))
and then Chars (ALo) /= Chars (CLo)
and then
not Is_Constrained (First_Subtype (Etype (N)))
then
Error_Msg_N
("bounds of aggregate do not match target??", N);
end if;
end;
end if;
end if;
-- If no others, aggregate bounds come from aggregate
Aggr_Low := Choices_Low;
Aggr_High := Choices_High;
end if;
end Step_2;
-- STEP 3: Process positional components
else
-- STEP 3 (A): Process positional elements
Expr := First (Expressions (N));
Nb_Elements := Uint_0;
while Present (Expr) loop
Nb_Elements := Nb_Elements + 1;
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_2005 and then Known_Null (Expr) then
Check_Can_Never_Be_Null (Etype (N), Expr);
end if;
if not Resolve_Aggr_Expr (Expr, Single_Elmt => True) then
return Failure;
end if;
-- Check incorrect use of dynamically tagged expression
if Is_Tagged_Type (Etype (Expr)) then
Check_Dynamically_Tagged_Expression
(Expr => Expr,
Typ => Component_Type (Etype (N)),
Related_Nod => N);
end if;
Next (Expr);
end loop;
if Others_Present then
Assoc := Last (Component_Associations (N));
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_2005 and then Known_Null (Assoc) then
Check_Can_Never_Be_Null (Etype (N), Expression (Assoc));
end if;
-- Ada 2005 (AI-287): In case of default initialized component,
-- we delay the resolution to the expansion phase.
if Box_Present (Assoc) then
-- Ada 2005 (AI-287): In case of default initialization of a
-- component the expander will generate calls to the
-- corresponding initialization subprogram. We need to call
-- Resolve_Aggr_Expr to check the rules about
-- dimensionality.
if not Resolve_Aggr_Expr (Assoc, Single_Elmt => False) then
return Failure;
end if;
elsif not Resolve_Aggr_Expr (Expression (Assoc),
Single_Elmt => False)
then
return Failure;
-- Check incorrect use of dynamically tagged expression. The
-- expression of the others choice has not been resolved yet.
-- In order to diagnose the semantic error we create a duplicate
-- tree to analyze it and perform the check.
elsif Nkind (Assoc) /= N_Iterated_Component_Association then
declare
Save_Analysis : constant Boolean := Full_Analysis;
Expr : constant Node_Id :=
New_Copy_Tree (Expression (Assoc));
begin
Expander_Mode_Save_And_Set (False);
Full_Analysis := False;
Analyze (Expr);
Full_Analysis := Save_Analysis;
Expander_Mode_Restore;
if Is_Tagged_Type (Etype (Expr)) then
Check_Dynamically_Tagged_Expression
(Expr => Expr,
Typ => Component_Type (Etype (N)),
Related_Nod => N);
end if;
end;
end if;
end if;
-- STEP 3 (B): Compute the aggregate bounds
if Others_Present then
Get_Index_Bounds (Index_Constr, Aggr_Low, Aggr_High);
else
if Others_Allowed then
Get_Index_Bounds (Index_Constr, Aggr_Low, Discard);
else
Aggr_Low := Index_Typ_Low;
end if;
Aggr_High := Add (Nb_Elements - 1, To => Aggr_Low);
Check_Bound (Index_Base_High, Aggr_High);
end if;
end if;
-- STEP 4: Perform static aggregate checks and save the bounds
-- Check (A)
Check_Bounds (Index_Typ_Low, Index_Typ_High, Aggr_Low, Aggr_High);
Check_Bounds (Index_Base_Low, Index_Base_High, Aggr_Low, Aggr_High);
-- Check (B)
if Others_Present and then Nb_Discrete_Choices > 0 then
Check_Bounds (Aggr_Low, Aggr_High, Choices_Low, Choices_High);
Check_Bounds (Index_Typ_Low, Index_Typ_High,
Choices_Low, Choices_High);
Check_Bounds (Index_Base_Low, Index_Base_High,
Choices_Low, Choices_High);
-- Check (C)
elsif Others_Present and then Nb_Elements > 0 then
Check_Length (Aggr_Low, Aggr_High, Nb_Elements);
Check_Length (Index_Typ_Low, Index_Typ_High, Nb_Elements);
Check_Length (Index_Base_Low, Index_Base_High, Nb_Elements);
end if;
if Raises_Constraint_Error (Aggr_Low)
or else Raises_Constraint_Error (Aggr_High)
then
Set_Raises_Constraint_Error (N);
end if;
Aggr_Low := Duplicate_Subexpr (Aggr_Low);
-- Do not duplicate Aggr_High if Aggr_High = Aggr_Low + Nb_Elements
-- since the addition node returned by Add is not yet analyzed. Attach
-- to tree and analyze first. Reset analyzed flag to ensure it will get
-- analyzed when it is a literal bound whose type must be properly set.
if Others_Present or else Nb_Discrete_Choices > 0 then
Aggr_High := Duplicate_Subexpr (Aggr_High);
if Etype (Aggr_High) = Universal_Integer then
Set_Analyzed (Aggr_High, False);
end if;
end if;
-- If the aggregate already has bounds attached to it, it means this is
-- a positional aggregate created as an optimization by
-- Exp_Aggr.Convert_To_Positional, so we don't want to change those
-- bounds.
if Present (Aggregate_Bounds (N))
and then not Others_Allowed
and then not Comes_From_Source (N)
then
Aggr_Low := Low_Bound (Aggregate_Bounds (N));
Aggr_High := High_Bound (Aggregate_Bounds (N));
end if;
Set_Aggregate_Bounds
(N, Make_Range (Loc, Low_Bound => Aggr_Low, High_Bound => Aggr_High));
-- The bounds may contain expressions that must be inserted upwards.
-- Attach them fully to the tree. After analysis, remove side effects
-- from upper bound, if still needed.
Set_Parent (Aggregate_Bounds (N), N);
Analyze_And_Resolve (Aggregate_Bounds (N), Index_Typ);
Check_Unset_Reference (Aggregate_Bounds (N));
if not Others_Present and then Nb_Discrete_Choices = 0 then
Set_High_Bound
(Aggregate_Bounds (N),
Duplicate_Subexpr (High_Bound (Aggregate_Bounds (N))));
end if;
-- Check the dimensions of each component in the array aggregate
Analyze_Dimension_Array_Aggregate (N, Component_Typ);
return Success;
end Resolve_Array_Aggregate;
---------------------------------
-- Resolve_Container_Aggregate --
---------------------------------
procedure Resolve_Container_Aggregate (N : Node_Id; Typ : Entity_Id) is
procedure Resolve_Iterated_Association
(Comp : Node_Id;
Key_Type : Entity_Id;
Elmt_Type : Entity_Id);
-- Resolve choices and expression in an iterated component association
-- or an iterated element association, which has a key_expression.
-- This is similar but not identical to the handling of this construct
-- in an array aggregate.
-- For a named container, the type of each choice must be compatible
-- with the key type. For a positional container, the choice must be
-- a subtype indication or an iterator specification that determines
-- an element type.
Asp : constant Node_Id := Find_Value_Of_Aspect (Typ, Aspect_Aggregate);
Empty_Subp : Node_Id := Empty;
Add_Named_Subp : Node_Id := Empty;
Add_Unnamed_Subp : Node_Id := Empty;
New_Indexed_Subp : Node_Id := Empty;
Assign_Indexed_Subp : Node_Id := Empty;
----------------------------------
-- Resolve_Iterated_Association --
----------------------------------
procedure Resolve_Iterated_Association
(Comp : Node_Id;
Key_Type : Entity_Id;
Elmt_Type : Entity_Id)
is
Loc : constant Source_Ptr := Sloc (N);
Choice : Node_Id;
Ent : Entity_Id;
Expr : Node_Id;
Key_Expr : Node_Id;
Id : Entity_Id;
Id_Name : Name_Id;
Iter : Node_Id;
Typ : Entity_Id := Empty;
begin
Error_Msg_Ada_2022_Feature ("iterated component", Loc);
-- If this is an Iterated_Element_Association then either a
-- an Iterator_Specification or a Loop_Parameter specification
-- is present. In both cases a Key_Expression is present.
if Nkind (Comp) = N_Iterated_Element_Association then
if Present (Loop_Parameter_Specification (Comp)) then
Analyze_Loop_Parameter_Specification
(Loop_Parameter_Specification (Comp));
Id_Name := Chars (Defining_Identifier
(Loop_Parameter_Specification (Comp)));
else
Iter := Copy_Separate_Tree (Iterator_Specification (Comp));
Analyze (Iter);
Typ := Etype (Defining_Identifier (Iter));
Id_Name := Chars (Defining_Identifier
(Iterator_Specification (Comp)));
end if;
-- Key expression must have the type of the key. We analyze
-- a copy of the original expression, because it will be
-- reanalyzed and copied as needed during expansion of the
-- corresponding loop.
Key_Expr := Key_Expression (Comp);
Analyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type);
elsif Present (Iterator_Specification (Comp)) then
Iter := Copy_Separate_Tree (Iterator_Specification (Comp));
Id_Name := Chars (Defining_Identifier (Comp));
Analyze (Iter);
Typ := Etype (Defining_Identifier (Iter));
else
Choice := First (Discrete_Choices (Comp));
while Present (Choice) loop
Analyze (Choice);
-- Choice can be a subtype name, a range, or an expression
if Is_Entity_Name (Choice)
and then Is_Type (Entity (Choice))
and then Base_Type (Entity (Choice)) = Base_Type (Key_Type)
then
null;
elsif Present (Key_Type) then
Analyze_And_Resolve (Choice, Key_Type);
else
Typ := Etype (Choice); -- assume unique for now
end if;
Next (Choice);
end loop;
Id_Name := Chars (Defining_Identifier (Comp));
end if;
-- Create a scope in which to introduce an index, which is usually
-- visible in the expression for the component, and needed for its
-- analysis.
Id := Make_Defining_Identifier (Sloc (Comp), Id_Name);
Ent := New_Internal_Entity (E_Loop, Current_Scope, Sloc (Comp), 'L');
Set_Etype (Ent, Standard_Void_Type);
Set_Parent (Ent, Parent (Comp));
Push_Scope (Ent);
-- Insert and decorate the loop variable in the current scope.
-- The expression has to be analyzed once the loop variable is
-- directly visible. Mark the variable as referenced to prevent
-- spurious warnings, given that subsequent uses of its name in the
-- expression will reference the internal (synonym) loop variable.
Enter_Name (Id);
if No (Key_Type) then
pragma Assert (Present (Typ));
Set_Etype (Id, Typ);
else
Set_Etype (Id, Key_Type);
end if;
Mutate_Ekind (Id, E_Variable);
Set_Scope (Id, Ent);
Set_Referenced (Id);
-- Analyze a copy of the expression, to verify legality. We use
-- a copy because the expression will be analyzed anew when the
-- enclosing aggregate is expanded, and the construct is rewritten
-- as a loop with a new index variable.
Expr := New_Copy_Tree (Expression (Comp));
Preanalyze_And_Resolve (Expr, Elmt_Type);
End_Scope;
end Resolve_Iterated_Association;
begin
pragma Assert (Nkind (Asp) = N_Aggregate);
Set_Etype (N, Typ);
Parse_Aspect_Aggregate (Asp,
Empty_Subp, Add_Named_Subp, Add_Unnamed_Subp,
New_Indexed_Subp, Assign_Indexed_Subp);
if Present (Add_Unnamed_Subp)
and then No (New_Indexed_Subp)
then
declare
Elmt_Type : constant Entity_Id :=
Etype (Next_Formal
(First_Formal (Entity (Add_Unnamed_Subp))));
Comp : Node_Id;
begin
if Present (Expressions (N)) then
-- positional aggregate
Comp := First (Expressions (N));
while Present (Comp) loop
Analyze_And_Resolve (Comp, Elmt_Type);
Next (Comp);
end loop;
end if;
-- Empty aggregate, to be replaced by Empty during
-- expansion, or iterated component association.
if Present (Component_Associations (N)) then
declare
Comp : Node_Id := First (Component_Associations (N));
begin
while Present (Comp) loop
if Nkind (Comp) /=
N_Iterated_Component_Association
then
Error_Msg_N ("illegal component association "
& "for unnamed container aggregate", Comp);
return;
else
Resolve_Iterated_Association
(Comp, Empty, Elmt_Type);
end if;
Next (Comp);
end loop;
end;
end if;
end;
elsif Present (Add_Named_Subp) then
declare
-- Retrieves types of container, key, and element from the
-- specified insertion procedure.
Container : constant Entity_Id :=
First_Formal (Entity (Add_Named_Subp));
Key_Type : constant Entity_Id := Etype (Next_Formal (Container));
Elmt_Type : constant Entity_Id :=
Etype (Next_Formal (Next_Formal (Container)));
Comp : Node_Id;
Choice : Node_Id;
begin
Comp := First (Component_Associations (N));
while Present (Comp) loop
if Nkind (Comp) = N_Component_Association then
Choice := First (Choices (Comp));
while Present (Choice) loop
Analyze_And_Resolve (Choice, Key_Type);
if not Is_Static_Expression (Choice) then
Error_Msg_N ("choice must be static", Choice);
end if;
Next (Choice);
end loop;
Analyze_And_Resolve (Expression (Comp), Elmt_Type);
elsif Nkind (Comp) in
N_Iterated_Component_Association |
N_Iterated_Element_Association
then
Resolve_Iterated_Association
(Comp, Key_Type, Elmt_Type);
end if;
Next (Comp);
end loop;
end;
else
-- Indexed Aggregate. Positional or indexed component
-- can be present, but not both. Choices must be static
-- values or ranges with static bounds.
declare
Container : constant Entity_Id :=
First_Formal (Entity (Assign_Indexed_Subp));
Index_Type : constant Entity_Id := Etype (Next_Formal (Container));
Comp_Type : constant Entity_Id :=
Etype (Next_Formal (Next_Formal (Container)));
Comp : Node_Id;
Choice : Node_Id;
Num_Choices : Nat := 0;
Hi_Val : Uint;
Lo_Val : Uint;
begin
if Present (Expressions (N)) then
Comp := First (Expressions (N));
while Present (Comp) loop
Analyze_And_Resolve (Comp, Comp_Type);
Next (Comp);
end loop;
end if;
if Present (Component_Associations (N)) then
if Present (Expressions (N)) then
Error_Msg_N ("container aggregate cannot be "
& "both positional and named", N);
return;
end if;
Comp := First (Component_Associations (N));
while Present (Comp) loop
if Nkind (Comp) = N_Component_Association then
Choice := First (Choices (Comp));
while Present (Choice) loop
Analyze_And_Resolve (Choice, Index_Type);
Num_Choices := Num_Choices + 1;
Next (Choice);
end loop;
Analyze_And_Resolve (Expression (Comp), Comp_Type);
elsif Nkind (Comp) in
N_Iterated_Component_Association |
N_Iterated_Element_Association
then
Resolve_Iterated_Association
(Comp, Index_Type, Comp_Type);
Num_Choices := Num_Choices + 1;
end if;
Next (Comp);
end loop;
-- The component associations in an indexed aggregate
-- must denote a contiguous set of static values. We
-- build a table of values/ranges and sort it, as is done
-- elsewhere for case statements and array aggregates.
-- If the aggregate has a single iterated association it
-- is allowed to be nonstatic and there is nothing to check.
if Num_Choices > 1 then
declare
Table : Case_Table_Type (1 .. Num_Choices);
No_Choice : Pos := 1;
Lo, Hi : Node_Id;
-- Traverse aggregate to determine size of needed table.
-- Verify that bounds are static and that loops have no
-- filters or key expressions.
begin
Comp := First (Component_Associations (N));
while Present (Comp) loop
if Nkind (Comp) = N_Iterated_Element_Association then
if Present
(Loop_Parameter_Specification (Comp))
then
if Present (Iterator_Filter
(Loop_Parameter_Specification (Comp)))
then
Error_Msg_N
("iterator filter not allowed " &
"in indexed aggregate", Comp);
return;
elsif Present (Key_Expression
(Loop_Parameter_Specification (Comp)))
then
Error_Msg_N
("key expression not allowed " &
"in indexed aggregate", Comp);
return;
end if;
end if;
else
Choice := First (Choices (Comp));
while Present (Choice) loop
Get_Index_Bounds (Choice, Lo, Hi);
Table (No_Choice).Choice := Choice;
Table (No_Choice).Lo := Lo;
Table (No_Choice).Hi := Hi;
-- Verify staticness of value or range
if not Is_Static_Expression (Lo)
or else not Is_Static_Expression (Hi)
then
Error_Msg_N
("nonstatic expression for index " &
"for indexed aggregate", Choice);
return;
end if;
No_Choice := No_Choice + 1;
Next (Choice);
end loop;
end if;
Next (Comp);
end loop;
Sort_Case_Table (Table);
for J in 1 .. Num_Choices - 1 loop
Hi_Val := Expr_Value (Table (J).Hi);
Lo_Val := Expr_Value (Table (J + 1).Lo);
if Lo_Val = Hi_Val then
Error_Msg_N
("duplicate index in indexed aggregate",
Table (J + 1).Choice);
exit;
elsif Lo_Val < Hi_Val then
Error_Msg_N
("overlapping indices in indexed aggregate",
Table (J + 1).Choice);
exit;
elsif Lo_Val > Hi_Val + 1 then
Error_Msg_N
("missing index values", Table (J + 1).Choice);
exit;
end if;
end loop;
end;
end if;
end if;
end;
end if;
end Resolve_Container_Aggregate;
-----------------------------
-- Resolve_Delta_Aggregate --
-----------------------------
procedure Resolve_Delta_Aggregate (N : Node_Id; Typ : Entity_Id) is
Base : constant Node_Id := Expression (N);
begin
Error_Msg_Ada_2022_Feature ("delta aggregate", Sloc (N));
if not Is_Composite_Type (Typ) then
Error_Msg_N ("not a composite type", N);
end if;
Analyze_And_Resolve (Base, Typ);
if Is_Array_Type (Typ) then
Resolve_Delta_Array_Aggregate (N, Typ);
else
Resolve_Delta_Record_Aggregate (N, Typ);
end if;
Set_Etype (N, Typ);
end Resolve_Delta_Aggregate;
-----------------------------------
-- Resolve_Delta_Array_Aggregate --
-----------------------------------
procedure Resolve_Delta_Array_Aggregate (N : Node_Id; Typ : Entity_Id) is
Deltas : constant List_Id := Component_Associations (N);
Index_Type : constant Entity_Id := Etype (First_Index (Typ));
Assoc : Node_Id;
Choice : Node_Id;
Expr : Node_Id;
begin
Assoc := First (Deltas);
while Present (Assoc) loop
if Nkind (Assoc) = N_Iterated_Component_Association then
Choice := First (Choice_List (Assoc));
while Present (Choice) loop
if Nkind (Choice) = N_Others_Choice then
Error_Msg_N
("OTHERS not allowed in delta aggregate", Choice);
elsif Nkind (Choice) = N_Subtype_Indication then
Resolve_Discrete_Subtype_Indication
(Choice, Base_Type (Index_Type));
else
Analyze_And_Resolve (Choice, Index_Type);
end if;
Next (Choice);
end loop;
declare
Id : constant Entity_Id := Defining_Identifier (Assoc);
Ent : constant Entity_Id :=
New_Internal_Entity
(E_Loop, Current_Scope, Sloc (Assoc), 'L');
begin
Set_Etype (Ent, Standard_Void_Type);
Set_Parent (Ent, Assoc);
Push_Scope (Ent);
if No (Scope (Id)) then
Set_Etype (Id, Index_Type);
Mutate_Ekind (Id, E_Variable);
Set_Scope (Id, Ent);
end if;
Enter_Name (Id);
-- Resolve a copy of the expression, after setting
-- its parent properly to preserve its context.
Expr := New_Copy_Tree (Expression (Assoc));
Set_Parent (Expr, Assoc);
Analyze_And_Resolve (Expr, Component_Type (Typ));
End_Scope;
end;
else
Choice := First (Choice_List (Assoc));
while Present (Choice) loop
Analyze (Choice);
if Nkind (Choice) = N_Others_Choice then
Error_Msg_N
("OTHERS not allowed in delta aggregate", Choice);
elsif Is_Entity_Name (Choice)
and then Is_Type (Entity (Choice))
then
-- Choice covers a range of values
if Base_Type (Entity (Choice)) /=
Base_Type (Index_Type)
then
Error_Msg_NE
("choice does not match index type of &",
Choice, Typ);
end if;
elsif Nkind (Choice) = N_Subtype_Indication then
Resolve_Discrete_Subtype_Indication
(Choice, Base_Type (Index_Type));
else
Resolve (Choice, Index_Type);
end if;
Next (Choice);
end loop;
Analyze_And_Resolve (Expression (Assoc), Component_Type (Typ));
end if;
Next (Assoc);
end loop;
end Resolve_Delta_Array_Aggregate;
------------------------------------
-- Resolve_Delta_Record_Aggregate --
------------------------------------
procedure Resolve_Delta_Record_Aggregate (N : Node_Id; Typ : Entity_Id) is
-- Variables used to verify that discriminant-dependent components
-- appear in the same variant.
Comp_Ref : Entity_Id := Empty; -- init to avoid warning
Variant : Node_Id;
procedure Check_Variant (Id : Entity_Id);
-- If a given component of the delta aggregate appears in a variant
-- part, verify that it is within the same variant as that of previous
-- specified variant components of the delta.
function Get_Component (Nam : Node_Id) return Entity_Id;
-- Locate component with a given name and return it. If none found then
-- report error and return Empty.
function Nested_In (V1 : Node_Id; V2 : Node_Id) return Boolean;
-- Determine whether variant V1 is within variant V2
function Variant_Depth (N : Node_Id) return Natural;
-- Determine the distance of a variant to the enclosing type declaration
--------------------
-- Check_Variant --
--------------------
procedure Check_Variant (Id : Entity_Id) is
Comp : Entity_Id;
Comp_Variant : Node_Id;
begin
if not Has_Discriminants (Typ) then
return;
end if;
Comp := First_Entity (Typ);
while Present (Comp) loop
exit when Chars (Comp) = Chars (Id);
Next_Component (Comp);
end loop;
-- Find the variant, if any, whose component list includes the
-- component declaration.
Comp_Variant := Parent (Parent (List_Containing (Parent (Comp))));
if Nkind (Comp_Variant) = N_Variant then
if No (Variant) then
Variant := Comp_Variant;
Comp_Ref := Comp;
elsif Variant /= Comp_Variant then
declare
D1 : constant Integer := Variant_Depth (Variant);
D2 : constant Integer := Variant_Depth (Comp_Variant);
begin
if D1 = D2
or else
(D1 > D2 and then not Nested_In (Variant, Comp_Variant))
or else
(D2 > D1 and then not Nested_In (Comp_Variant, Variant))
then
pragma Assert (Present (Comp_Ref));
Error_Msg_Node_2 := Comp_Ref;
Error_Msg_NE
("& and & appear in different variants", Id, Comp);
-- Otherwise retain the deeper variant for subsequent tests
elsif D2 > D1 then
Variant := Comp_Variant;
end if;
end;
end if;
end if;
end Check_Variant;
-------------------
-- Get_Component --
-------------------
function Get_Component (Nam : Node_Id) return Entity_Id is
Comp : Entity_Id;
begin
Comp := First_Entity (Typ);
while Present (Comp) loop
if Chars (Comp) = Chars (Nam) then
if Ekind (Comp) = E_Discriminant then
Error_Msg_N ("delta cannot apply to discriminant", Nam);
end if;
return Comp;
end if;
Next_Entity (Comp);
end loop;
Error_Msg_NE ("type& has no component with this name", Nam, Typ);
return Empty;
end Get_Component;
---------------
-- Nested_In --
---------------
function Nested_In (V1, V2 : Node_Id) return Boolean is
Par : Node_Id;
begin
Par := Parent (V1);
while Nkind (Par) /= N_Full_Type_Declaration loop
if Par = V2 then
return True;
end if;
Par := Parent (Par);
end loop;
return False;
end Nested_In;
-------------------
-- Variant_Depth --
-------------------
function Variant_Depth (N : Node_Id) return Natural is
Depth : Natural;
Par : Node_Id;
begin
Depth := 0;
Par := Parent (N);
while Nkind (Par) /= N_Full_Type_Declaration loop
Depth := Depth + 1;
Par := Parent (Par);
end loop;
return Depth;
end Variant_Depth;
-- Local variables
Deltas : constant List_Id := Component_Associations (N);
Assoc : Node_Id;
Choice : Node_Id;
Comp : Entity_Id;
Comp_Type : Entity_Id := Empty; -- init to avoid warning
-- Start of processing for Resolve_Delta_Record_Aggregate
begin
Variant := Empty;
Assoc := First (Deltas);
while Present (Assoc) loop
Choice := First (Choice_List (Assoc));
while Present (Choice) loop
Comp := Get_Component (Choice);
if Present (Comp) then
Check_Variant (Choice);
Comp_Type := Etype (Comp);
-- Decorate the component reference by setting its entity and
-- type, as otherwise backends like GNATprove would have to
-- rediscover this information by themselves.
Set_Entity (Choice, Comp);
Set_Etype (Choice, Comp_Type);
else
Comp_Type := Any_Type;
end if;
Next (Choice);
end loop;
pragma Assert (Present (Comp_Type));
-- A record_component_association in record_delta_aggregate shall not
-- use the box compound delimiter <> rather than an expression; see
-- RM 4.3.1(17.3/5).
pragma Assert (Present (Expression (Assoc)) xor Box_Present (Assoc));
if Box_Present (Assoc) then
Error_Msg_N
("'<'> in record delta aggregate is not allowed", Assoc);
else
Analyze_And_Resolve (Expression (Assoc), Comp_Type);
end if;
Next (Assoc);
end loop;
end Resolve_Delta_Record_Aggregate;
---------------------------------
-- Resolve_Extension_Aggregate --
---------------------------------
-- There are two cases to consider:
-- a) If the ancestor part is a type mark, the components needed are the
-- difference between the components of the expected type and the
-- components of the given type mark.
-- b) If the ancestor part is an expression, it must be unambiguous, and
-- once we have its type we can also compute the needed components as in
-- the previous case. In both cases, if the ancestor type is not the
-- immediate ancestor, we have to build this ancestor recursively.
-- In both cases, discriminants of the ancestor type do not play a role in
-- the resolution of the needed components, because inherited discriminants
-- cannot be used in a type extension. As a result we can compute
-- independently the list of components of the ancestor type and of the
-- expected type.
procedure Resolve_Extension_Aggregate (N : Node_Id; Typ : Entity_Id) is
A : constant Node_Id := Ancestor_Part (N);
A_Type : Entity_Id;
I : Interp_Index;
It : Interp;
function Valid_Limited_Ancestor (Anc : Node_Id) return Boolean;
-- If the type is limited, verify that the ancestor part is a legal
-- expression (aggregate or function call, including 'Input)) that does
-- not require a copy, as specified in 7.5(2).
function Valid_Ancestor_Type return Boolean;
-- Verify that the type of the ancestor part is a non-private ancestor
-- of the expected type, which must be a type extension.
procedure Transform_BIP_Assignment (Typ : Entity_Id);
-- For an extension aggregate whose ancestor part is a build-in-place
-- call returning a nonlimited type, this is used to transform the
-- assignment to the ancestor part to use a temp.
----------------------------
-- Valid_Limited_Ancestor --
----------------------------
function Valid_Limited_Ancestor (Anc : Node_Id) return Boolean is
begin
if Is_Entity_Name (Anc) and then Is_Type (Entity (Anc)) then
return True;
-- The ancestor must be a call or an aggregate, but a call may
-- have been expanded into a temporary, so check original node.
elsif Nkind (Anc) in N_Aggregate
| N_Extension_Aggregate
| N_Function_Call
then
return True;
elsif Nkind (Original_Node (Anc)) = N_Function_Call then
return True;
elsif Nkind (Anc) = N_Attribute_Reference
and then Attribute_Name (Anc) = Name_Input
then
return True;
elsif Nkind (Anc) = N_Qualified_Expression then
return Valid_Limited_Ancestor (Expression (Anc));
elsif Nkind (Anc) = N_Raise_Expression then
return True;
else
return False;
end if;
end Valid_Limited_Ancestor;
-------------------------
-- Valid_Ancestor_Type --
-------------------------
function Valid_Ancestor_Type return Boolean is
Imm_Type : Entity_Id;
begin
Imm_Type := Base_Type (Typ);
while Is_Derived_Type (Imm_Type) loop
if Etype (Imm_Type) = Base_Type (A_Type) then
return True;
-- The base type of the parent type may appear as a private
-- extension if it is declared as such in a parent unit of the
-- current one. For consistency of the subsequent analysis use
-- the partial view for the ancestor part.
elsif Is_Private_Type (Etype (Imm_Type))
and then Present (Full_View (Etype (Imm_Type)))
and then Base_Type (A_Type) = Full_View (Etype (Imm_Type))
then
A_Type := Etype (Imm_Type);
return True;
-- The parent type may be a private extension. The aggregate is
-- legal if the type of the aggregate is an extension of it that
-- is not a private extension.
elsif Is_Private_Type (A_Type)
and then not Is_Private_Type (Imm_Type)
and then Present (Full_View (A_Type))
and then Base_Type (Full_View (A_Type)) = Etype (Imm_Type)
then
return True;
-- The parent type may be a raise expression (which is legal in
-- any expression context).
elsif A_Type = Raise_Type then
A_Type := Etype (Imm_Type);
return True;
else
Imm_Type := Etype (Base_Type (Imm_Type));
end if;
end loop;
-- If previous loop did not find a proper ancestor, report error
Error_Msg_NE ("expect ancestor type of &", A, Typ);
return False;
end Valid_Ancestor_Type;
------------------------------
-- Transform_BIP_Assignment --
------------------------------
procedure Transform_BIP_Assignment (Typ : Entity_Id) is
Loc : constant Source_Ptr := Sloc (N);
Def_Id : constant Entity_Id := Make_Temporary (Loc, 'Y', A);
Obj_Decl : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier => Def_Id,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Typ, Loc),
Expression => A,
Has_Init_Expression => True);
begin
Set_Etype (Def_Id, Typ);
Set_Ancestor_Part (N, New_Occurrence_Of (Def_Id, Loc));
Insert_Action (N, Obj_Decl);
end Transform_BIP_Assignment;
-- Start of processing for Resolve_Extension_Aggregate
begin
-- Analyze the ancestor part and account for the case where it is a
-- parameterless function call.
Analyze (A);
Check_Parameterless_Call (A);
if Is_Entity_Name (A) and then Is_Type (Entity (A)) then
-- AI05-0115: If the ancestor part is a subtype mark, the ancestor
-- must not have unknown discriminants. To catch cases where the
-- aggregate occurs at a place where the full view of the ancestor
-- type is visible and doesn't have unknown discriminants, but the
-- aggregate type was derived from a partial view that has unknown
-- discriminants, we check whether the aggregate type has unknown
-- discriminants (unknown discriminants were inherited), along
-- with checking that the partial view of the ancestor has unknown
-- discriminants. (It might be sufficient to replace the entire
-- condition with Has_Unknown_Discriminants (Typ), but that might
-- miss some cases, not clear, and causes error changes in some tests
-- such as class-wide cases, that aren't clearly improvements. ???)
if Has_Unknown_Discriminants (Entity (A))
or else (Has_Unknown_Discriminants (Typ)
and then Partial_View_Has_Unknown_Discr (Entity (A)))
then
Error_Msg_NE
("aggregate not available for type& whose ancestor "
& "has unknown discriminants", N, Typ);
end if;
end if;
if not Is_Tagged_Type (Typ) then
Error_Msg_N ("type of extension aggregate must be tagged", N);
return;
elsif Is_Limited_Type (Typ) then
-- Ada 2005 (AI-287): Limited aggregates are allowed
if Ada_Version < Ada_2005 then
Error_Msg_N ("aggregate type cannot be limited", N);
Explain_Limited_Type (Typ, N);
return;
elsif Valid_Limited_Ancestor (A) then
null;
else
Error_Msg_N
("limited ancestor part must be aggregate or function call", A);
end if;
elsif Is_Class_Wide_Type (Typ) then
Error_Msg_N ("aggregate cannot be of a class-wide type", N);
return;
end if;
if Is_Entity_Name (A) and then Is_Type (Entity (A)) then
A_Type := Get_Full_View (Entity (A));
if Valid_Ancestor_Type then
Set_Entity (A, A_Type);
Set_Etype (A, A_Type);
Validate_Ancestor_Part (N);
Resolve_Record_Aggregate (N, Typ);
end if;
elsif Nkind (A) /= N_Aggregate then
if Is_Overloaded (A) then
A_Type := Any_Type;
Get_First_Interp (A, I, It);
while Present (It.Typ) loop
-- Consider limited interpretations if Ada 2005 or higher
if Is_Tagged_Type (It.Typ)
and then (Ada_Version >= Ada_2005
or else not Is_Limited_Type (It.Typ))
then
if A_Type /= Any_Type then
Error_Msg_N ("cannot resolve expression", A);
return;
else
A_Type := It.Typ;
end if;
end if;
Get_Next_Interp (I, It);
end loop;
if A_Type = Any_Type then
if Ada_Version >= Ada_2005 then
Error_Msg_N
("ancestor part must be of a tagged type", A);
else
Error_Msg_N
("ancestor part must be of a nonlimited tagged type", A);
end if;
return;
end if;
else
A_Type := Etype (A);
end if;
if Valid_Ancestor_Type then
Resolve (A, A_Type);
Check_Unset_Reference (A);
Check_Non_Static_Context (A);
-- The aggregate is illegal if the ancestor expression is a call
-- to a function with a limited unconstrained result, unless the
-- type of the aggregate is a null extension. This restriction
-- was added in AI05-67 to simplify implementation.
if Nkind (A) = N_Function_Call
and then Is_Limited_Type (A_Type)
and then not Is_Null_Extension (Typ)
and then not Is_Constrained (A_Type)
then
Error_Msg_N
("type of limited ancestor part must be constrained", A);
-- Reject the use of CPP constructors that leave objects partially
-- initialized. For example:
-- type CPP_Root is tagged limited record ...
-- pragma Import (CPP, CPP_Root);
-- type CPP_DT is new CPP_Root and Iface ...
-- pragma Import (CPP, CPP_DT);
-- type Ada_DT is new CPP_DT with ...
-- Obj : Ada_DT := Ada_DT'(New_CPP_Root with others => <>);
-- Using the constructor of CPP_Root the slots of the dispatch
-- table of CPP_DT cannot be set, and the secondary tag of
-- CPP_DT is unknown.
elsif Nkind (A) = N_Function_Call
and then Is_CPP_Constructor_Call (A)
and then Enclosing_CPP_Parent (Typ) /= A_Type
then
Error_Msg_NE
("??must use 'C'P'P constructor for type &", A,
Enclosing_CPP_Parent (Typ));
-- The following call is not needed if the previous warning
-- is promoted to an error.
Resolve_Record_Aggregate (N, Typ);
elsif Is_Class_Wide_Type (Etype (A))
and then Nkind (Original_Node (A)) = N_Function_Call
then
-- If the ancestor part is a dispatching call, it appears
-- statically to be a legal ancestor, but it yields any member
-- of the class, and it is not possible to determine whether
-- it is an ancestor of the extension aggregate (much less
-- which ancestor). It is not possible to determine the
-- components of the extension part.
-- This check implements AI-306, which in fact was motivated by
-- an AdaCore query to the ARG after this test was added.
Error_Msg_N ("ancestor part must be statically tagged", A);
else
-- We are using the build-in-place protocol, but we can't build
-- in place, because we need to call the function before
-- allocating the aggregate. Could do better for null
-- extensions, and maybe for nondiscriminated types.
-- This is wrong for limited, but those were wrong already.
if not Is_Limited_View (A_Type)
and then Is_Build_In_Place_Function_Call (A)
then
Transform_BIP_Assignment (A_Type);
end if;
Resolve_Record_Aggregate (N, Typ);
end if;
end if;
else
Error_Msg_N ("no unique type for this aggregate", A);
end if;
Check_Function_Writable_Actuals (N);
end Resolve_Extension_Aggregate;
------------------------------
-- Resolve_Record_Aggregate --
------------------------------
procedure Resolve_Record_Aggregate (N : Node_Id; Typ : Entity_Id) is
New_Assoc_List : constant List_Id := New_List;
-- New_Assoc_List is the newly built list of N_Component_Association
-- nodes.
Others_Etype : Entity_Id := Empty;
-- This variable is used to save the Etype of the last record component
-- that takes its value from the others choice. Its purpose is:
--
-- (a) make sure the others choice is useful
--
-- (b) make sure the type of all the components whose value is
-- subsumed by the others choice are the same.
--
-- This variable is updated as a side effect of function Get_Value.
Box_Node : Node_Id := Empty;
Is_Box_Present : Boolean := False;
Is_Box_Init_By_Default : Boolean := False;
Others_Box : Natural := 0;
-- Ada 2005 (AI-287): Variables used in case of default initialization
-- to provide a functionality similar to Others_Etype. Box_Present
-- indicates that the component takes its default initialization;
-- Others_Box counts the number of components of the current aggregate
-- (which may be a sub-aggregate of a larger one) that are default-
-- initialized. A value of One indicates that an others_box is present.
-- Any larger value indicates that the others_box is not redundant.
-- These variables, similar to Others_Etype, are also updated as a side
-- effect of function Get_Value. Box_Node is used to place a warning on
-- a redundant others_box.
procedure Add_Association
(Component : Entity_Id;
Expr : Node_Id;
Assoc_List : List_Id;
Is_Box_Present : Boolean := False);
-- Builds a new N_Component_Association node which associates Component
-- to expression Expr and adds it to the association list being built,
-- either New_Assoc_List, or the association being built for an inner
-- aggregate.
procedure Add_Discriminant_Values
(New_Aggr : Node_Id;
Assoc_List : List_Id);
-- The constraint to a component may be given by a discriminant of the
-- enclosing type, in which case we have to retrieve its value, which is
-- part of the enclosing aggregate. Assoc_List provides the discriminant
-- associations of the current type or of some enclosing record.
function Discriminant_Present (Input_Discr : Entity_Id) return Boolean;
-- If aggregate N is a regular aggregate this routine will return True.
-- Otherwise, if N is an extension aggregate, then Input_Discr denotes
-- a discriminant whose value may already have been specified by N's
-- ancestor part. This routine checks whether this is indeed the case
-- and if so returns False, signaling that no value for Input_Discr
-- should appear in N's aggregate part. Also, in this case, the routine
-- appends to New_Assoc_List the discriminant value specified in the
-- ancestor part.
--
-- If the aggregate is in a context with expansion delayed, it will be
-- reanalyzed. The inherited discriminant values must not be reinserted
-- in the component list to prevent spurious errors, but they must be
-- present on first analysis to build the proper subtype indications.
-- The flag Inherited_Discriminant is used to prevent the re-insertion.
function Find_Private_Ancestor (Typ : Entity_Id) return Entity_Id;
-- AI05-0115: Find earlier ancestor in the derivation chain that is
-- derived from private view Typ. Whether the aggregate is legal depends
-- on the current visibility of the type as well as that of the parent
-- of the ancestor.
function Get_Value
(Compon : Entity_Id;
From : List_Id;
Consider_Others_Choice : Boolean := False) return Node_Id;
-- Given a record component stored in parameter Compon, this function
-- returns its value as it appears in the list From, which is a list
-- of N_Component_Association nodes.
--
-- If no component association has a choice for the searched component,
-- the value provided by the others choice is returned, if there is one,
-- and Consider_Others_Choice is set to true. Otherwise Empty is
-- returned. If there is more than one component association giving a
-- value for the searched record component, an error message is emitted
-- and the first found value is returned.
--
-- If Consider_Others_Choice is set and the returned expression comes
-- from the others choice, then Others_Etype is set as a side effect.
-- An error message is emitted if the components taking their value from
-- the others choice do not have same type.
procedure Propagate_Discriminants
(Aggr : Node_Id;
Assoc_List : List_Id);
-- Nested components may themselves be discriminated types constrained
-- by outer discriminants, whose values must be captured before the
-- aggregate is expanded into assignments.
procedure Resolve_Aggr_Expr (Expr : Node_Id; Component : Entity_Id);
-- Analyzes and resolves expression Expr against the Etype of the
-- Component. This routine also applies all appropriate checks to Expr.
-- It finally saves a Expr in the newly created association list that
-- will be attached to the final record aggregate. Note that if the
-- Parent pointer of Expr is not set then Expr was produced with a
-- New_Copy_Tree or some such.
procedure Rewrite_Range (Root_Type : Entity_Id; Rge : Node_Id);
-- Rewrite a range node Rge when its bounds refer to non-stored
-- discriminants from Root_Type, to replace them with the stored
-- discriminant values. This is required in GNATprove mode, and is
-- adopted in all modes to avoid special-casing GNATprove mode.
---------------------
-- Add_Association --
---------------------
procedure Add_Association
(Component : Entity_Id;
Expr : Node_Id;
Assoc_List : List_Id;
Is_Box_Present : Boolean := False)
is
Choice_List : constant List_Id := New_List;
Loc : Source_Ptr;
begin
-- If this is a box association the expression is missing, so use the
-- Sloc of the aggregate itself for the new association.
pragma Assert (Present (Expr) xor Is_Box_Present);
if Present (Expr) then
Loc := Sloc (Expr);
else
Loc := Sloc (N);
end if;
Append_To (Choice_List, New_Occurrence_Of (Component, Loc));
Append_To (Assoc_List,
Make_Component_Association (Loc,
Choices => Choice_List,
Expression => Expr,
Box_Present => Is_Box_Present));
-- If this association has a box for a component that is initialized
-- by default, then set flag on the new association to indicate that
-- the original association was for such a box-initialized component.
if Is_Box_Init_By_Default then
Set_Was_Default_Init_Box_Association (Last (Assoc_List));
end if;
end Add_Association;
-----------------------------
-- Add_Discriminant_Values --
-----------------------------
procedure Add_Discriminant_Values
(New_Aggr : Node_Id;
Assoc_List : List_Id)
is
Assoc : Node_Id;
Discr : Entity_Id;
Discr_Elmt : Elmt_Id;
Discr_Val : Node_Id;
Val : Entity_Id;
begin
Discr := First_Discriminant (Etype (New_Aggr));
Discr_Elmt := First_Elmt (Discriminant_Constraint (Etype (New_Aggr)));
while Present (Discr_Elmt) loop
Discr_Val := Node (Discr_Elmt);
-- If the constraint is given by a discriminant then it is a
-- discriminant of an enclosing record, and its value has already
-- been placed in the association list.
if Is_Entity_Name (Discr_Val)
and then Ekind (Entity (Discr_Val)) = E_Discriminant
then
Val := Entity (Discr_Val);
Assoc := First (Assoc_List);
while Present (Assoc) loop
if Present (Entity (First (Choices (Assoc))))
and then Entity (First (Choices (Assoc))) = Val
then
Discr_Val := Expression (Assoc);
exit;
end if;
Next (Assoc);
end loop;
end if;
Add_Association
(Discr, New_Copy_Tree (Discr_Val),
Component_Associations (New_Aggr));
-- If the discriminant constraint is a current instance, mark the
-- current aggregate so that the self-reference can be expanded
-- later. The constraint may refer to the subtype of aggregate, so
-- use base type for comparison.
if Nkind (Discr_Val) = N_Attribute_Reference
and then Is_Entity_Name (Prefix (Discr_Val))
and then Is_Type (Entity (Prefix (Discr_Val)))
and then Base_Type (Etype (N)) = Entity (Prefix (Discr_Val))
then
Set_Has_Self_Reference (N);
end if;
Next_Elmt (Discr_Elmt);
Next_Discriminant (Discr);
end loop;
end Add_Discriminant_Values;
--------------------------
-- Discriminant_Present --
--------------------------
function Discriminant_Present (Input_Discr : Entity_Id) return Boolean is
Regular_Aggr : constant Boolean := Nkind (N) /= N_Extension_Aggregate;
Ancestor_Is_Subtyp : Boolean;
Loc : Source_Ptr;
Ancestor : Node_Id;
Ancestor_Typ : Entity_Id;
Comp_Assoc : Node_Id;
Discr : Entity_Id;
Discr_Expr : Node_Id;
Discr_Val : Elmt_Id := No_Elmt;
Orig_Discr : Entity_Id;
begin
if Regular_Aggr then
return True;
end if;
-- Check whether inherited discriminant values have already been
-- inserted in the aggregate. This will be the case if we are
-- re-analyzing an aggregate whose expansion was delayed.
if Present (Component_Associations (N)) then
Comp_Assoc := First (Component_Associations (N));
while Present (Comp_Assoc) loop
if Inherited_Discriminant (Comp_Assoc) then
return True;
end if;
Next (Comp_Assoc);
end loop;
end if;
Ancestor := Ancestor_Part (N);
Ancestor_Typ := Etype (Ancestor);
Loc := Sloc (Ancestor);
-- For a private type with unknown discriminants, use the underlying
-- record view if it is available.
if Has_Unknown_Discriminants (Ancestor_Typ)
and then Present (Full_View (Ancestor_Typ))
and then Present (Underlying_Record_View (Full_View (Ancestor_Typ)))
then
Ancestor_Typ := Underlying_Record_View (Full_View (Ancestor_Typ));
end if;
Ancestor_Is_Subtyp :=
Is_Entity_Name (Ancestor) and then Is_Type (Entity (Ancestor));
-- If the ancestor part has no discriminants clearly N's aggregate
-- part must provide a value for Discr.
if not Has_Discriminants (Ancestor_Typ) then
return True;
-- If the ancestor part is an unconstrained subtype mark then the
-- Discr must be present in N's aggregate part.
elsif Ancestor_Is_Subtyp
and then not Is_Constrained (Entity (Ancestor))
then
return True;
end if;
-- Now look to see if Discr was specified in the ancestor part
if Ancestor_Is_Subtyp then
Discr_Val :=
First_Elmt (Discriminant_Constraint (Entity (Ancestor)));
end if;
Orig_Discr := Original_Record_Component (Input_Discr);
Discr := First_Discriminant (Ancestor_Typ);
while Present (Discr) loop
-- If Ancestor has already specified Disc value then insert its
-- value in the final aggregate.
if Original_Record_Component (Discr) = Orig_Discr then
if Ancestor_Is_Subtyp then
Discr_Expr := New_Copy_Tree (Node (Discr_Val));
else
Discr_Expr :=
Make_Selected_Component (Loc,
Prefix => Duplicate_Subexpr (Ancestor),
Selector_Name => New_Occurrence_Of (Input_Discr, Loc));
end if;
Resolve_Aggr_Expr (Discr_Expr, Input_Discr);
Set_Inherited_Discriminant (Last (New_Assoc_List));
return False;
end if;
Next_Discriminant (Discr);
if Ancestor_Is_Subtyp then
Next_Elmt (Discr_Val);
end if;
end loop;
return True;
end Discriminant_Present;
---------------------------
-- Find_Private_Ancestor --
---------------------------
function Find_Private_Ancestor (Typ : Entity_Id) return Entity_Id is
Par : Entity_Id;
begin
Par := Typ;
loop
if Has_Private_Ancestor (Par)
and then not Has_Private_Ancestor (Etype (Base_Type (Par)))
then
return Par;
elsif not Is_Derived_Type (Par) then
return Empty;
else
Par := Etype (Base_Type (Par));
end if;
end loop;
end Find_Private_Ancestor;
---------------
-- Get_Value --
---------------
function Get_Value
(Compon : Entity_Id;
From : List_Id;
Consider_Others_Choice : Boolean := False) return Node_Id
is
Typ : constant Entity_Id := Etype (Compon);
Assoc : Node_Id;
Expr : Node_Id := Empty;
Selector_Name : Node_Id;
begin
Is_Box_Present := False;
Is_Box_Init_By_Default := False;
if No (From) then
return Empty;
end if;
Assoc := First (From);
while Present (Assoc) loop
Selector_Name := First (Choices (Assoc));
while Present (Selector_Name) loop
if Nkind (Selector_Name) = N_Others_Choice then
if Consider_Others_Choice and then No (Expr) then
-- We need to duplicate the expression for each
-- successive component covered by the others choice.
-- This is redundant if the others_choice covers only
-- one component (small optimization possible???), but
-- indispensable otherwise, because each one must be
-- expanded individually to preserve side effects.
-- Ada 2005 (AI-287): In case of default initialization
-- of components, we duplicate the corresponding default
-- expression (from the record type declaration). The
-- copy must carry the sloc of the association (not the
-- original expression) to prevent spurious elaboration
-- checks when the default includes function calls.
if Box_Present (Assoc) then
Others_Box := Others_Box + 1;
Is_Box_Present := True;
if Expander_Active then
return
New_Copy_Tree_And_Copy_Dimensions
(Expression (Parent (Compon)),
New_Sloc => Sloc (Assoc));
else
return Expression (Parent (Compon));
end if;
else
if Present (Others_Etype)
and then Base_Type (Others_Etype) /= Base_Type (Typ)
then
-- If the components are of an anonymous access
-- type they are distinct, but this is legal in
-- Ada 2012 as long as designated types match.
if (Ekind (Typ) = E_Anonymous_Access_Type
or else Ekind (Typ) =
E_Anonymous_Access_Subprogram_Type)
and then Designated_Type (Typ) =
Designated_Type (Others_Etype)
then
null;
else
Error_Msg_N
("components in OTHERS choice must have same "
& "type", Selector_Name);
end if;
end if;
Others_Etype := Typ;
-- Copy the expression so that it is resolved
-- independently for each component, This is needed
-- for accessibility checks on components of anonymous
-- access types, even in compile_only mode.
if not Inside_A_Generic then
return
New_Copy_Tree_And_Copy_Dimensions
(Expression (Assoc));
else
return Expression (Assoc);
end if;
end if;
end if;
elsif Chars (Compon) = Chars (Selector_Name) then
if No (Expr) then
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_2005
and then Known_Null (Expression (Assoc))
then
Check_Can_Never_Be_Null (Compon, Expression (Assoc));
end if;
-- We need to duplicate the expression when several
-- components are grouped together with a "|" choice.
-- For instance "filed1 | filed2 => Expr"
-- Ada 2005 (AI-287)
if Box_Present (Assoc) then
Is_Box_Present := True;
-- Duplicate the default expression of the component
-- from the record type declaration, so a new copy
-- can be attached to the association.
-- Note that we always copy the default expression,
-- even when the association has a single choice, in
-- order to create a proper association for the
-- expanded aggregate.
-- Component may have no default, in which case the
-- expression is empty and the component is default-
-- initialized, but an association for the component
-- exists, and it is not covered by an others clause.
-- Scalar and private types have no initialization
-- procedure, so they remain uninitialized. If the
-- target of the aggregate is a constant this
-- deserves a warning.
if No (Expression (Parent (Compon)))
and then not Has_Non_Null_Base_Init_Proc (Typ)
and then not Has_Aspect (Typ, Aspect_Default_Value)
and then not Is_Concurrent_Type (Typ)
and then Nkind (Parent (N)) = N_Object_Declaration
and then Constant_Present (Parent (N))
then
Error_Msg_Node_2 := Typ;
Error_Msg_NE
("component&? of type& is uninitialized",
Assoc, Selector_Name);
-- An additional reminder if the component type
-- is a generic formal.
if Is_Generic_Type (Base_Type (Typ)) then
Error_Msg_NE
("\instance should provide actual type with "
& "initialization for&", Assoc, Typ);
end if;
end if;
return
New_Copy_Tree_And_Copy_Dimensions
(Expression (Parent (Compon)));
else
if Present (Next (Selector_Name)) then
Expr := New_Copy_Tree_And_Copy_Dimensions
(Expression (Assoc));
else
Expr := Expression (Assoc);
end if;
end if;
Generate_Reference (Compon, Selector_Name, 'm');
else
Error_Msg_NE
("more than one value supplied for &",
Selector_Name, Compon);
end if;
end if;
Next (Selector_Name);
end loop;
Next (Assoc);
end loop;
return Expr;
end Get_Value;
-----------------------------
-- Propagate_Discriminants --
-----------------------------
procedure Propagate_Discriminants
(Aggr : Node_Id;
Assoc_List : List_Id)
is
Loc : constant Source_Ptr := Sloc (N);
procedure Process_Component (Comp : Entity_Id);
-- Add one component with a box association to the inner aggregate,
-- and recurse if component is itself composite.
-----------------------
-- Process_Component --
-----------------------
procedure Process_Component (Comp : Entity_Id) is
T : constant Entity_Id := Etype (Comp);
New_Aggr : Node_Id;
begin
if Is_Record_Type (T) and then Has_Discriminants (T) then
New_Aggr := Make_Aggregate (Loc, No_List, New_List);
Set_Etype (New_Aggr, T);
Add_Association
(Comp, New_Aggr, Component_Associations (Aggr));
-- Collect discriminant values and recurse
Add_Discriminant_Values (New_Aggr, Assoc_List);
Propagate_Discriminants (New_Aggr, Assoc_List);
Build_Constrained_Itype
(New_Aggr, T, Component_Associations (New_Aggr));
else
Add_Association
(Comp, Empty, Component_Associations (Aggr),
Is_Box_Present => True);
end if;
end Process_Component;
-- Local variables
Aggr_Type : constant Entity_Id := Base_Type (Etype (Aggr));
Components : constant Elist_Id := New_Elmt_List;
Def_Node : constant Node_Id :=
Type_Definition (Declaration_Node (Aggr_Type));
Comp : Node_Id;
Comp_Elmt : Elmt_Id;
Errors : Boolean;
-- Start of processing for Propagate_Discriminants
begin
-- The component type may be a variant type. Collect the components
-- that are ruled by the known values of the discriminants. Their
-- values have already been inserted into the component list of the
-- current aggregate.
if Nkind (Def_Node) = N_Record_Definition
and then Present (Component_List (Def_Node))
and then Present (Variant_Part (Component_List (Def_Node)))
then
Gather_Components (Aggr_Type,
Component_List (Def_Node),
Governed_By => Component_Associations (Aggr),
Into => Components,
Report_Errors => Errors);
Comp_Elmt := First_Elmt (Components);
while Present (Comp_Elmt) loop
if Ekind (Node (Comp_Elmt)) /= E_Discriminant then
Process_Component (Node (Comp_Elmt));
end if;
Next_Elmt (Comp_Elmt);
end loop;
-- No variant part, iterate over all components
else
Comp := First_Component (Etype (Aggr));
while Present (Comp) loop
Process_Component (Comp);
Next_Component (Comp);
end loop;
end if;
end Propagate_Discriminants;
-----------------------
-- Resolve_Aggr_Expr --
-----------------------
procedure Resolve_Aggr_Expr (Expr : Node_Id; Component : Entity_Id) is
function Has_Expansion_Delayed (Expr : Node_Id) return Boolean;
-- If the expression is an aggregate (possibly qualified) then its
-- expansion is delayed until the enclosing aggregate is expanded
-- into assignments. In that case, do not generate checks on the
-- expression, because they will be generated later, and will other-
-- wise force a copy (to remove side effects) that would leave a
-- dynamic-sized aggregate in the code, something that gigi cannot
-- handle.
---------------------------
-- Has_Expansion_Delayed --
---------------------------
function Has_Expansion_Delayed (Expr : Node_Id) return Boolean is
begin
return
(Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
and then Present (Etype (Expr))
and then Is_Record_Type (Etype (Expr))
and then Expansion_Delayed (Expr))
or else
(Nkind (Expr) = N_Qualified_Expression
and then Has_Expansion_Delayed (Expression (Expr)));
end Has_Expansion_Delayed;
-- Local variables
Expr_Type : Entity_Id := Empty;
New_C : Entity_Id := Component;
New_Expr : Node_Id;
Relocate : Boolean;
-- Set to True if the resolved Expr node needs to be relocated when
-- attached to the newly created association list. This node need not
-- be relocated if its parent pointer is not set. In fact in this
-- case Expr is the output of a New_Copy_Tree call. If Relocate is
-- True then we have analyzed the expression node in the original
-- aggregate and hence it needs to be relocated when moved over to
-- the new association list.
-- Start of processing for Resolve_Aggr_Expr
begin
-- If the type of the component is elementary or the type of the
-- aggregate does not contain discriminants, use the type of the
-- component to resolve Expr.
if Is_Elementary_Type (Etype (Component))
or else not Has_Discriminants (Etype (N))
then
Expr_Type := Etype (Component);
-- Otherwise we have to pick up the new type of the component from
-- the new constrained subtype of the aggregate. In fact components
-- which are of a composite type might be constrained by a
-- discriminant, and we want to resolve Expr against the subtype were
-- all discriminant occurrences are replaced with their actual value.
else
New_C := First_Component (Etype (N));
while Present (New_C) loop
if Chars (New_C) = Chars (Component) then
Expr_Type := Etype (New_C);
exit;
end if;
Next_Component (New_C);
end loop;
pragma Assert (Present (Expr_Type));
-- For each range in an array type where a discriminant has been
-- replaced with the constraint, check that this range is within
-- the range of the base type. This checks is done in the init
-- proc for regular objects, but has to be done here for
-- aggregates since no init proc is called for them.
if Is_Array_Type (Expr_Type) then
declare
Index : Node_Id;
-- Range of the current constrained index in the array
Orig_Index : Node_Id := First_Index (Etype (Component));
-- Range corresponding to the range Index above in the
-- original unconstrained record type. The bounds of this
-- range may be governed by discriminants.
Unconstr_Index : Node_Id := First_Index (Etype (Expr_Type));
-- Range corresponding to the range Index above for the
-- unconstrained array type. This range is needed to apply
-- range checks.
begin
Index := First_Index (Expr_Type);
while Present (Index) loop
if Depends_On_Discriminant (Orig_Index) then
Apply_Range_Check (Index, Etype (Unconstr_Index));
end if;
Next_Index (Index);
Next_Index (Orig_Index);
Next_Index (Unconstr_Index);
end loop;
end;
end if;
end if;
-- If the Parent pointer of Expr is not set, Expr is an expression
-- duplicated by New_Tree_Copy (this happens for record aggregates
-- that look like (Field1 | Filed2 => Expr) or (others => Expr)).
-- Such a duplicated expression must be attached to the tree
-- before analysis and resolution to enforce the rule that a tree
-- fragment should never be analyzed or resolved unless it is
-- attached to the current compilation unit.
if No (Parent (Expr)) then
Set_Parent (Expr, N);
Relocate := False;
else
Relocate := True;
end if;
Analyze_And_Resolve (Expr, Expr_Type);
Check_Expr_OK_In_Limited_Aggregate (Expr);
Check_Non_Static_Context (Expr);
Check_Unset_Reference (Expr);
-- Check wrong use of class-wide types
if Is_Class_Wide_Type (Etype (Expr)) then
Error_Msg_N ("dynamically tagged expression not allowed", Expr);
end if;
if not Has_Expansion_Delayed (Expr) then
Aggregate_Constraint_Checks (Expr, Expr_Type);
end if;
-- If an aggregate component has a type with predicates, an explicit
-- predicate check must be applied, as for an assignment statement,
-- because the aggregate might not be expanded into individual
-- component assignments.
if Has_Predicates (Expr_Type)
and then Analyzed (Expr)
then
Apply_Predicate_Check (Expr, Expr_Type);
end if;
if Raises_Constraint_Error (Expr) then
Set_Raises_Constraint_Error (N);
end if;
-- If the expression has been marked as requiring a range check, then
-- generate it here. It's a bit odd to be generating such checks in
-- the analyzer, but harmless since Generate_Range_Check does nothing
-- (other than making sure Do_Range_Check is set) if the expander is
-- not active.
if Do_Range_Check (Expr) then
Generate_Range_Check (Expr, Expr_Type, CE_Range_Check_Failed);
end if;
-- Add association Component => Expr if the caller requests it
if Relocate then
New_Expr := Relocate_Node (Expr);
-- Since New_Expr is not gonna be analyzed later on, we need to
-- propagate here the dimensions form Expr to New_Expr.
Copy_Dimensions (Expr, New_Expr);
else
New_Expr := Expr;
end if;
Add_Association (New_C, New_Expr, New_Assoc_List);
end Resolve_Aggr_Expr;
-------------------
-- Rewrite_Range --
-------------------
procedure Rewrite_Range (Root_Type : Entity_Id; Rge : Node_Id) is
procedure Rewrite_Bound
(Bound : Node_Id;
Disc : Entity_Id;
Expr_Disc : Node_Id);
-- Rewrite a bound of the range Bound, when it is equal to the
-- non-stored discriminant Disc, into the stored discriminant
-- value Expr_Disc.
-------------------
-- Rewrite_Bound --
-------------------
procedure Rewrite_Bound
(Bound : Node_Id;
Disc : Entity_Id;
Expr_Disc : Node_Id)
is
begin
if Nkind (Bound) /= N_Identifier then
return;
end if;
-- We expect either the discriminant or the discriminal
if Entity (Bound) = Disc
or else (Ekind (Entity (Bound)) = E_In_Parameter
and then Discriminal_Link (Entity (Bound)) = Disc)
then
Rewrite (Bound, New_Copy_Tree (Expr_Disc));
end if;
end Rewrite_Bound;
-- Local variables
Low, High : Node_Id;
Disc : Entity_Id;
Expr_Disc : Elmt_Id;
-- Start of processing for Rewrite_Range
begin
if Has_Discriminants (Root_Type) and then Nkind (Rge) = N_Range then
Low := Low_Bound (Rge);
High := High_Bound (Rge);
Disc := First_Discriminant (Root_Type);
Expr_Disc := First_Elmt (Stored_Constraint (Etype (N)));
while Present (Disc) loop
Rewrite_Bound (Low, Disc, Node (Expr_Disc));
Rewrite_Bound (High, Disc, Node (Expr_Disc));
Next_Discriminant (Disc);
Next_Elmt (Expr_Disc);
end loop;
end if;
end Rewrite_Range;
-- Local variables
Components : constant Elist_Id := New_Elmt_List;
-- Components is the list of the record components whose value must be
-- provided in the aggregate. This list does include discriminants.
Component : Entity_Id;
Component_Elmt : Elmt_Id;
Expr : Node_Id;
Positional_Expr : Node_Id;
-- Start of processing for Resolve_Record_Aggregate
begin
-- A record aggregate is restricted in SPARK:
-- Each named association can have only a single choice.
-- OTHERS cannot be used.
-- Positional and named associations cannot be mixed.
if Present (Component_Associations (N))
and then Present (First (Component_Associations (N)))
then
declare
Assoc : Node_Id;
begin
Assoc := First (Component_Associations (N));
while Present (Assoc) loop
if Nkind (Assoc) = N_Iterated_Component_Association then
Error_Msg_N
("iterated component association can only appear in an "
& "array aggregate", N);
raise Unrecoverable_Error;
end if;
Next (Assoc);
end loop;
end;
end if;
-- We may end up calling Duplicate_Subexpr on expressions that are
-- attached to New_Assoc_List. For this reason we need to attach it
-- to the tree by setting its parent pointer to N. This parent point
-- will change in STEP 8 below.
Set_Parent (New_Assoc_List, N);
-- STEP 1: abstract type and null record verification
if Is_Abstract_Type (Typ) then
Error_Msg_N ("type of aggregate cannot be abstract", N);
end if;
if No (First_Entity (Typ)) and then Null_Record_Present (N) then
Set_Etype (N, Typ);
return;
elsif Present (First_Entity (Typ))
and then Null_Record_Present (N)
and then not Is_Tagged_Type (Typ)
then
Error_Msg_N ("record aggregate cannot be null", N);
return;
-- If the type has no components, then the aggregate should either
-- have "null record", or in Ada 2005 it could instead have a single
-- component association given by "others => <>". For Ada 95 we flag an
-- error at this point, but for Ada 2005 we proceed with checking the
-- associations below, which will catch the case where it's not an
-- aggregate with "others => <>". Note that the legality of a <>
-- aggregate for a null record type was established by AI05-016.
elsif No (First_Entity (Typ))
and then Ada_Version < Ada_2005
then
Error_Msg_N ("record aggregate must be null", N);
return;
end if;
-- STEP 2: Verify aggregate structure
Step_2 : declare
Assoc : Node_Id;
Bad_Aggregate : Boolean := False;
Selector_Name : Node_Id;
begin
if Present (Component_Associations (N)) then
Assoc := First (Component_Associations (N));
else
Assoc := Empty;
end if;
while Present (Assoc) loop
Selector_Name := First (Choices (Assoc));
while Present (Selector_Name) loop
if Nkind (Selector_Name) = N_Identifier then
null;
elsif Nkind (Selector_Name) = N_Others_Choice then
if Selector_Name /= First (Choices (Assoc))
or else Present (Next (Selector_Name))
then
Error_Msg_N
("OTHERS must appear alone in a choice list",
Selector_Name);
return;
elsif Present (Next (Assoc)) then
Error_Msg_N
("OTHERS must appear last in an aggregate",
Selector_Name);
return;
-- (Ada 2005): If this is an association with a box,
-- indicate that the association need not represent
-- any component.
elsif Box_Present (Assoc) then
Others_Box := 1;
Box_Node := Assoc;
end if;
else
Error_Msg_N
("selector name should be identifier or OTHERS",
Selector_Name);
Bad_Aggregate := True;
end if;
Next (Selector_Name);
end loop;
Next (Assoc);
end loop;
if Bad_Aggregate then
return;
end if;
end Step_2;
-- STEP 3: Find discriminant Values
Step_3 : declare
Discrim : Entity_Id;
Missing_Discriminants : Boolean := False;
begin
if Present (Expressions (N)) then
Positional_Expr := First (Expressions (N));
else
Positional_Expr := Empty;
end if;
-- AI05-0115: if the ancestor part is a subtype mark, the ancestor
-- must not have unknown discriminants.
-- ??? We are not checking any subtype mark here and this code is not
-- exercised by any test, so it's likely wrong (in particular
-- we should not use Root_Type here but the subtype mark, if any),
-- and possibly not needed.
if Is_Derived_Type (Typ)
and then Has_Unknown_Discriminants (Root_Type (Typ))
and then Nkind (N) /= N_Extension_Aggregate
then
Error_Msg_NE
("aggregate not available for type& whose ancestor "
& "has unknown discriminants", N, Typ);
end if;
if Has_Unknown_Discriminants (Typ)
and then Present (Underlying_Record_View (Typ))
then
Discrim := First_Discriminant (Underlying_Record_View (Typ));
elsif Has_Discriminants (Typ) then
Discrim := First_Discriminant (Typ);
else
Discrim := Empty;
end if;
-- First find the discriminant values in the positional components
while Present (Discrim) and then Present (Positional_Expr) loop
if Discriminant_Present (Discrim) then
Resolve_Aggr_Expr (Positional_Expr, Discrim);
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_2005
and then Known_Null (Positional_Expr)
then
Check_Can_Never_Be_Null (Discrim, Positional_Expr);
end if;
Next (Positional_Expr);
end if;
if Present (Get_Value (Discrim, Component_Associations (N))) then
Error_Msg_NE
("more than one value supplied for discriminant&",
N, Discrim);
end if;
Next_Discriminant (Discrim);
end loop;
-- Find remaining discriminant values if any among named components
while Present (Discrim) loop
Expr := Get_Value (Discrim, Component_Associations (N), True);
if not Discriminant_Present (Discrim) then
if Present (Expr) then
Error_Msg_NE
("more than one value supplied for discriminant &",
N, Discrim);
end if;
elsif No (Expr) then
Error_Msg_NE
("no value supplied for discriminant &", N, Discrim);
Missing_Discriminants := True;
else
Resolve_Aggr_Expr (Expr, Discrim);
end if;
Next_Discriminant (Discrim);
end loop;
if Missing_Discriminants then
return;
end if;
-- At this point and until the beginning of STEP 6, New_Assoc_List
-- contains only the discriminants and their values.
end Step_3;
-- STEP 4: Set the Etype of the record aggregate
if Has_Discriminants (Typ)
or else (Has_Unknown_Discriminants (Typ)
and then Present (Underlying_Record_View (Typ)))
then
Build_Constrained_Itype (N, Typ, New_Assoc_List);
else
Set_Etype (N, Typ);
end if;
-- STEP 5: Get remaining components according to discriminant values
Step_5 : declare
Dnode : Node_Id;
Errors_Found : Boolean := False;
Record_Def : Node_Id;
Parent_Typ : Entity_Id;
Parent_Typ_List : Elist_Id;
Parent_Elmt : Elmt_Id;
Root_Typ : Entity_Id;
begin
if Is_Derived_Type (Typ) and then Is_Tagged_Type (Typ) then
Parent_Typ_List := New_Elmt_List;
-- If this is an extension aggregate, the component list must
-- include all components that are not in the given ancestor type.
-- Otherwise, the component list must include components of all
-- ancestors, starting with the root.
if Nkind (N) = N_Extension_Aggregate then
Root_Typ := Base_Type (Etype (Ancestor_Part (N)));
else
-- AI05-0115: check legality of aggregate for type with a
-- private ancestor.
Root_Typ := Root_Type (Typ);
if Has_Private_Ancestor (Typ) then
declare
Ancestor : constant Entity_Id :=
Find_Private_Ancestor (Typ);
Ancestor_Unit : constant Entity_Id :=
Cunit_Entity
(Get_Source_Unit (Ancestor));
Parent_Unit : constant Entity_Id :=
Cunit_Entity (Get_Source_Unit
(Base_Type (Etype (Ancestor))));
begin
-- Check whether we are in a scope that has full view
-- over the private ancestor and its parent. This can
-- only happen if the derivation takes place in a child
-- unit of the unit that declares the parent, and we are
-- in the private part or body of that child unit, else
-- the aggregate is illegal.
if Is_Child_Unit (Ancestor_Unit)
and then Scope (Ancestor_Unit) = Parent_Unit
and then In_Open_Scopes (Scope (Ancestor))
and then
(In_Private_Part (Scope (Ancestor))
or else In_Package_Body (Scope (Ancestor)))
then
null;
else
Error_Msg_NE
("type of aggregate has private ancestor&!",
N, Root_Typ);
Error_Msg_N ("must use extension aggregate!", N);
return;
end if;
end;
end if;
Dnode := Declaration_Node (Base_Type (Root_Typ));
-- If we don't get a full declaration, then we have some error
-- which will get signalled later so skip this part. Otherwise
-- gather components of root that apply to the aggregate type.
-- We use the base type in case there is an applicable stored
-- constraint that renames the discriminants of the root.
if Nkind (Dnode) = N_Full_Type_Declaration then
Record_Def := Type_Definition (Dnode);
Gather_Components
(Base_Type (Typ),
Component_List (Record_Def),
Governed_By => New_Assoc_List,
Into => Components,
Report_Errors => Errors_Found);
if Errors_Found then
Error_Msg_N
("discriminant controlling variant part is not static",
N);
return;
end if;
end if;
end if;
Parent_Typ := Base_Type (Typ);
while Parent_Typ /= Root_Typ loop
Prepend_Elmt (Parent_Typ, To => Parent_Typ_List);
Parent_Typ := Etype (Parent_Typ);
-- Check whether a private parent requires the use of
-- an extension aggregate. This test does not apply in
-- an instantiation: if the generic unit is legal so is
-- the instance.
if Nkind (Parent (Base_Type (Parent_Typ))) =
N_Private_Type_Declaration
or else Nkind (Parent (Base_Type (Parent_Typ))) =
N_Private_Extension_Declaration
then
if Nkind (N) /= N_Extension_Aggregate
and then not In_Instance
then
Error_Msg_NE
("type of aggregate has private ancestor&!",
N, Parent_Typ);
Error_Msg_N ("must use extension aggregate!", N);
return;
elsif Parent_Typ /= Root_Typ then
Error_Msg_NE
("ancestor part of aggregate must be private type&",
Ancestor_Part (N), Parent_Typ);
return;
end if;
-- The current view of ancestor part may be a private type,
-- while the context type is always non-private.
elsif Is_Private_Type (Root_Typ)
and then Present (Full_View (Root_Typ))
and then Nkind (N) = N_Extension_Aggregate
then
exit when Base_Type (Full_View (Root_Typ)) = Parent_Typ;
end if;
end loop;
-- Now collect components from all other ancestors, beginning
-- with the current type. If the type has unknown discriminants
-- use the component list of the Underlying_Record_View, which
-- needs to be used for the subsequent expansion of the aggregate
-- into assignments.
Parent_Elmt := First_Elmt (Parent_Typ_List);
while Present (Parent_Elmt) loop
Parent_Typ := Node (Parent_Elmt);
if Has_Unknown_Discriminants (Parent_Typ)
and then Present (Underlying_Record_View (Typ))
then
Parent_Typ := Underlying_Record_View (Parent_Typ);
end if;
Record_Def := Type_Definition (Parent (Base_Type (Parent_Typ)));
Gather_Components (Empty,
Component_List (Record_Extension_Part (Record_Def)),
Governed_By => New_Assoc_List,
Into => Components,
Report_Errors => Errors_Found);
Next_Elmt (Parent_Elmt);
end loop;
-- Typ is not a derived tagged type
else
Record_Def := Type_Definition (Parent (Base_Type (Typ)));
if Null_Present (Record_Def) then
null;
elsif not Has_Unknown_Discriminants (Typ) then
Gather_Components
(Base_Type (Typ),
Component_List (Record_Def),
Governed_By => New_Assoc_List,
Into => Components,
Report_Errors => Errors_Found);
else
Gather_Components
(Base_Type (Underlying_Record_View (Typ)),
Component_List (Record_Def),
Governed_By => New_Assoc_List,
Into => Components,
Report_Errors => Errors_Found);
end if;
end if;
if Errors_Found then
return;
end if;
end Step_5;
-- STEP 6: Find component Values
Component := Empty;
Component_Elmt := First_Elmt (Components);
-- First scan the remaining positional associations in the aggregate.
-- Remember that at this point Positional_Expr contains the current
-- positional association if any is left after looking for discriminant
-- values in step 3.
while Present (Positional_Expr) and then Present (Component_Elmt) loop
Component := Node (Component_Elmt);
Resolve_Aggr_Expr (Positional_Expr, Component);
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_2005 and then Known_Null (Positional_Expr) then
Check_Can_Never_Be_Null (Component, Positional_Expr);
end if;
if Present (Get_Value (Component, Component_Associations (N))) then
Error_Msg_NE
("more than one value supplied for component &", N, Component);
end if;
Next (Positional_Expr);
Next_Elmt (Component_Elmt);
end loop;
if Present (Positional_Expr) then
Error_Msg_N
("too many components for record aggregate", Positional_Expr);
end if;
-- Now scan for the named arguments of the aggregate
while Present (Component_Elmt) loop
Component := Node (Component_Elmt);
Expr := Get_Value (Component, Component_Associations (N), True);
-- Note: The previous call to Get_Value sets the value of the
-- variable Is_Box_Present.
-- Ada 2005 (AI-287): Handle components with default initialization.
-- Note: This feature was originally added to Ada 2005 for limited
-- but it was finally allowed with any type.
if Is_Box_Present then
Check_Box_Component : declare
Ctyp : constant Entity_Id := Etype (Component);
begin
-- Initially assume that the box is for a default-initialized
-- component and reset to False in cases where that's not true.
Is_Box_Init_By_Default := True;
-- If there is a default expression for the aggregate, copy
-- it into a new association. This copy must modify the scopes
-- of internal types that may be attached to the expression
-- (e.g. index subtypes of arrays) because in general the type
-- declaration and the aggregate appear in different scopes,
-- and the backend requires the scope of the type to match the
-- point at which it is elaborated.
-- If the component has an initialization procedure (IP) we
-- pass the component to the expander, which will generate
-- the call to such IP.
-- If the component has discriminants, their values must
-- be taken from their subtype. This is indispensable for
-- constraints that are given by the current instance of an
-- enclosing type, to allow the expansion of the aggregate to
-- replace the reference to the current instance by the target
-- object of the aggregate.
if Is_Case_Choice_Pattern (N) then
-- Do not transform box component values in a case-choice
-- aggregate.
Add_Association
(Component => Component,
Expr => Empty,
Assoc_List => New_Assoc_List,
Is_Box_Present => True);
elsif Present (Parent (Component))
and then Nkind (Parent (Component)) = N_Component_Declaration
and then Present (Expression (Parent (Component)))
then
-- If component declaration has an initialization expression
-- then this is not a case of default initialization.
Is_Box_Init_By_Default := False;
Expr :=
New_Copy_Tree_And_Copy_Dimensions
(Expression (Parent (Component)),
New_Scope => Current_Scope,
New_Sloc => Sloc (N));
-- As the type of the copied default expression may refer
-- to discriminants of the record type declaration, these
-- non-stored discriminants need to be rewritten into stored
-- discriminant values for the aggregate. This is required
-- in GNATprove mode, and is adopted in all modes to avoid
-- special-casing GNATprove mode.
if Is_Array_Type (Etype (Expr)) then
declare
Rec_Typ : constant Entity_Id := Scope (Component);
-- Root record type whose discriminants may be used as
-- bounds in range nodes.
Assoc : Node_Id;
Choice : Node_Id;
Index : Node_Id;
begin
-- Rewrite the range nodes occurring in the indexes
-- and their types.
Index := First_Index (Etype (Expr));
while Present (Index) loop
Rewrite_Range (Rec_Typ, Index);
Rewrite_Range
(Rec_Typ, Scalar_Range (Etype (Index)));
Next_Index (Index);
end loop;
-- Rewrite the range nodes occurring as aggregate
-- bounds and component associations.
if Nkind (Expr) = N_Aggregate then
if Present (Aggregate_Bounds (Expr)) then
Rewrite_Range (Rec_Typ, Aggregate_Bounds (Expr));
end if;
if Present (Component_Associations (Expr)) then
Assoc := First (Component_Associations (Expr));
while Present (Assoc) loop
Choice := First (Choices (Assoc));
while Present (Choice) loop
Rewrite_Range (Rec_Typ, Choice);
Next (Choice);
end loop;
Next (Assoc);
end loop;
end if;
end if;
end;
end if;
Add_Association
(Component => Component,
Expr => Expr,
Assoc_List => New_Assoc_List);
Set_Has_Self_Reference (N);
elsif Needs_Simple_Initialization (Ctyp) then
Add_Association
(Component => Component,
Expr => Empty,
Assoc_List => New_Assoc_List,
Is_Box_Present => True);
elsif Has_Non_Null_Base_Init_Proc (Ctyp)
or else not Expander_Active
then
if Is_Record_Type (Ctyp)
and then Has_Discriminants (Ctyp)
and then not Is_Private_Type (Ctyp)
then
-- We build a partially initialized aggregate with the
-- values of the discriminants and box initialization
-- for the rest, if other components are present.
-- The type of the aggregate is the known subtype of
-- the component. The capture of discriminants must be
-- recursive because subcomponents may be constrained
-- (transitively) by discriminants of enclosing types.
-- For a private type with discriminants, a call to the
-- initialization procedure will be generated, and no
-- subaggregate is needed.
Capture_Discriminants : declare
Loc : constant Source_Ptr := Sloc (N);
Expr : Node_Id;
begin
Expr := Make_Aggregate (Loc, No_List, New_List);
Set_Etype (Expr, Ctyp);
-- If the enclosing type has discriminants, they have
-- been collected in the aggregate earlier, and they
-- may appear as constraints of subcomponents.
-- Similarly if this component has discriminants, they
-- might in turn be propagated to their components.
if Has_Discriminants (Typ) then
Add_Discriminant_Values (Expr, New_Assoc_List);
Propagate_Discriminants (Expr, New_Assoc_List);
elsif Has_Discriminants (Ctyp) then
Add_Discriminant_Values
(Expr, Component_Associations (Expr));
Propagate_Discriminants
(Expr, Component_Associations (Expr));
Build_Constrained_Itype
(Expr, Ctyp, Component_Associations (Expr));
else
declare
Comp : Entity_Id;
begin
-- If the type has additional components, create
-- an OTHERS box association for them.
Comp := First_Component (Ctyp);
while Present (Comp) loop
if Ekind (Comp) = E_Component then
if not Is_Record_Type (Etype (Comp)) then
Append_To
(Component_Associations (Expr),
Make_Component_Association (Loc,
Choices =>
New_List (
Make_Others_Choice (Loc)),
Expression => Empty,
Box_Present => True));
end if;
exit;
end if;
Next_Component (Comp);
end loop;
end;
end if;
Add_Association
(Component => Component,
Expr => Expr,
Assoc_List => New_Assoc_List);
end Capture_Discriminants;
-- Otherwise the component type is not a record, or it has
-- not discriminants, or it is private.
else
Add_Association
(Component => Component,
Expr => Empty,
Assoc_List => New_Assoc_List,
Is_Box_Present => True);
end if;
-- Otherwise we only need to resolve the expression if the
-- component has partially initialized values (required to
-- expand the corresponding assignments and run-time checks).
elsif Present (Expr)
and then Is_Partially_Initialized_Type (Ctyp)
then
Resolve_Aggr_Expr (Expr, Component);
end if;
end Check_Box_Component;
elsif No (Expr) then
-- Ignore hidden components associated with the position of the
-- interface tags: these are initialized dynamically.
if not Present (Related_Type (Component)) then
Error_Msg_NE
("no value supplied for component &!", N, Component);
end if;
else
Resolve_Aggr_Expr (Expr, Component);
end if;
Next_Elmt (Component_Elmt);
end loop;
-- STEP 7: check for invalid components + check type in choice list
Step_7 : declare
Assoc : Node_Id;
New_Assoc : Node_Id;
Selectr : Node_Id;
-- Selector name
Typech : Entity_Id;
-- Type of first component in choice list
begin
if Present (Component_Associations (N)) then
Assoc := First (Component_Associations (N));
else
Assoc := Empty;
end if;
Verification : while Present (Assoc) loop
Selectr := First (Choices (Assoc));
Typech := Empty;
if Nkind (Selectr) = N_Others_Choice then
-- Ada 2005 (AI-287): others choice may have expression or box
if No (Others_Etype) and then Others_Box = 0 then
Error_Msg_N
("OTHERS must represent at least one component", Selectr);
elsif Others_Box = 1 and then Warn_On_Redundant_Constructs then
Error_Msg_N ("OTHERS choice is redundant?", Box_Node);
Error_Msg_N
("\previous choices cover all components?", Box_Node);
end if;
exit Verification;
end if;
while Present (Selectr) loop
New_Assoc := First (New_Assoc_List);
while Present (New_Assoc) loop
Component := First (Choices (New_Assoc));
if Chars (Selectr) = Chars (Component) then
if Style_Check then
Check_Identifier (Selectr, Entity (Component));
end if;
exit;
end if;
Next (New_Assoc);
end loop;
-- If no association, this is not a legal component of the type
-- in question, unless its association is provided with a box.
if No (New_Assoc) then
if Box_Present (Parent (Selectr)) then
-- This may still be a bogus component with a box. Scan
-- list of components to verify that a component with
-- that name exists.
declare
C : Entity_Id;
begin
C := First_Component (Typ);
while Present (C) loop
if Chars (C) = Chars (Selectr) then
-- If the context is an extension aggregate,
-- the component must not be inherited from
-- the ancestor part of the aggregate.
if Nkind (N) /= N_Extension_Aggregate
or else
Scope (Original_Record_Component (C)) /=
Etype (Ancestor_Part (N))
then
exit;
end if;
end if;
Next_Component (C);
end loop;
if No (C) then
Error_Msg_Node_2 := Typ;
Error_Msg_N ("& is not a component of}", Selectr);
end if;
end;
elsif Chars (Selectr) /= Name_uTag
and then Chars (Selectr) /= Name_uParent
then
if not Has_Discriminants (Typ) then
Error_Msg_Node_2 := Typ;
Error_Msg_N ("& is not a component of}", Selectr);
else
Error_Msg_N
("& is not a component of the aggregate subtype",
Selectr);
end if;
Check_Misspelled_Component (Components, Selectr);
end if;
elsif No (Typech) then
Typech := Base_Type (Etype (Component));
-- AI05-0199: In Ada 2012, several components of anonymous
-- access types can appear in a choice list, as long as the
-- designated types match.
elsif Typech /= Base_Type (Etype (Component)) then
if Ada_Version >= Ada_2012
and then Ekind (Typech) = E_Anonymous_Access_Type
and then
Ekind (Etype (Component)) = E_Anonymous_Access_Type
and then Base_Type (Designated_Type (Typech)) =
Base_Type (Designated_Type (Etype (Component)))
and then
Subtypes_Statically_Match (Typech, (Etype (Component)))
then
null;
elsif not Box_Present (Parent (Selectr)) then
Error_Msg_N
("components in choice list must have same type",
Selectr);
end if;
end if;
Next (Selectr);
end loop;
Next (Assoc);
end loop Verification;
end Step_7;
-- STEP 8: replace the original aggregate
Step_8 : declare
New_Aggregate : constant Node_Id := New_Copy (N);
begin
Set_Expressions (New_Aggregate, No_List);
Set_Etype (New_Aggregate, Etype (N));
Set_Component_Associations (New_Aggregate, New_Assoc_List);
Set_Check_Actuals (New_Aggregate, Check_Actuals (N));
Rewrite (N, New_Aggregate);
end Step_8;
-- Check the dimensions of the components in the record aggregate
Analyze_Dimension_Extension_Or_Record_Aggregate (N);
end Resolve_Record_Aggregate;
-----------------------------
-- Check_Can_Never_Be_Null --
-----------------------------
procedure Check_Can_Never_Be_Null (Typ : Entity_Id; Expr : Node_Id) is
Comp_Typ : Entity_Id;
begin
pragma Assert
(Ada_Version >= Ada_2005
and then Present (Expr)
and then Known_Null (Expr));
case Ekind (Typ) is
when E_Array_Type =>
Comp_Typ := Component_Type (Typ);
when E_Component
| E_Discriminant
=>
Comp_Typ := Etype (Typ);
when others =>
return;
end case;
if Can_Never_Be_Null (Comp_Typ) then
-- Here we know we have a constraint error. Note that we do not use
-- Apply_Compile_Time_Constraint_Error here to the Expr, which might
-- seem the more natural approach. That's because in some cases the
-- components are rewritten, and the replacement would be missed.
-- We do not mark the whole aggregate as raising a constraint error,
-- because the association may be a null array range.
Error_Msg_N
("(Ada 2005) NULL not allowed in null-excluding component??", Expr);
Error_Msg_N
("\Constraint_Error will be raised at run time??", Expr);
Rewrite (Expr,
Make_Raise_Constraint_Error
(Sloc (Expr), Reason => CE_Access_Check_Failed));
Set_Etype (Expr, Comp_Typ);
Set_Analyzed (Expr);
end if;
end Check_Can_Never_Be_Null;
---------------------
-- Sort_Case_Table --
---------------------
procedure Sort_Case_Table (Case_Table : in out Case_Table_Type) is
U : constant Int := Case_Table'Last;
K : Int;
J : Int;
T : Case_Bounds;
begin
K := 1;
while K < U loop
T := Case_Table (K + 1);
J := K + 1;
while J > 1
and then Expr_Value (Case_Table (J - 1).Lo) > Expr_Value (T.Lo)
loop
Case_Table (J) := Case_Table (J - 1);
J := J - 1;
end loop;
Case_Table (J) := T;
K := K + 1;
end loop;
end Sort_Case_Table;
end Sem_Aggr;
|
reznikmm/matreshka | Ada | 4,707 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.ODF_Elements.Text.Outline_Style is
type Text_Outline_Style_Node is
new Matreshka.ODF_Elements.Text.Text_Node_Base with null record;
type Text_Outline_Style_Access is access all Text_Outline_Style_Node'Class;
overriding procedure Enter_Element
(Self : not null access Text_Outline_Style_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Local_Name
(Self : not null access constant Text_Outline_Style_Node)
return League.Strings.Universal_String;
overriding procedure Leave_Element
(Self : not null access Text_Outline_Style_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access Text_Outline_Style_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.ODF_Elements.Text.Outline_Style;
|
thorstel/Advent-of-Code-2018 | Ada | 2,682 | adb | with Ada.Containers.Ordered_Maps; use Ada.Containers;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Input12; use Input12;
procedure Day12 is
package String_Maps is new Ordered_Maps
(Key_Type => String_Pattern,
Element_Type => Character);
type Integer_64 is range -(2**63) .. +(2**63 - 1);
Lookup_Table : String_Maps.Map;
function Generation_Sum
(Initial_State : String;
Num_Gens : Integer_64) return Integer_64
is
Diff_Count : Natural := 0;
Old_Sum : Integer_64 := 0;
Old_Diff : Integer_64 := 0;
Zero_Index : Positive := Initial_State'First + 5;
Current_State : Unbounded_String :=
To_Unbounded_String ("....." & Initial_State & ".....");
begin
for Gen in 1 .. Num_Gens loop
declare
Old_State : constant String := To_String (Current_State);
New_State : String := Old_State;
Sum : Integer_64 := 0;
begin
for I in Old_State'First + 2 .. Old_State'Last - 2 loop
declare
Pattern : constant String := Old_State (I - 2 .. I + 2);
begin
New_State (I) := Lookup_Table.Element (Pattern);
if New_State (I) = '#' then
Sum := Sum + Integer_64 (I - Zero_Index);
end if;
end;
end loop;
if Old_Diff = (Sum - Old_Sum) then
Diff_Count := Diff_Count + 1;
else
Diff_Count := 0;
end if;
if Diff_Count > 10 then
return Sum + ((Num_Gens - Gen) * (Sum - Old_Sum));
end if;
Old_Diff := Sum - Old_Sum;
Old_Sum := Sum;
Current_State := To_Unbounded_String (New_State);
if New_State (1 .. 5) /= "....." then
Current_State := "....." & Current_State;
Zero_Index := Zero_Index + 5;
end if;
if New_State (New_State'Last - 4 .. New_State'Last) /= "....." then
Append (Current_State, ".....");
end if;
end;
end loop;
return Old_Sum;
end Generation_Sum;
begin
for I in Inputs'Range loop
Lookup_Table.Insert (Inputs (I).Pattern, Inputs (I).Plant);
end loop;
Put_Line
("Part 1 =" & Integer_64'Image (Generation_Sum (Initial_State, 20)));
Put_Line
("Part 2 =" &
Integer_64'Image (Generation_Sum (Initial_State, 50000000000)));
end Day12;
|
sungyeon/drake | Ada | 681 | ads | pragma License (Unrestricted);
-- implementation unit specialized for FreeBSD
package System.Native_IO.Names is
pragma Preelaborate;
procedure Open_Ordinary (
Method : Open_Method;
Handle : aliased out Handle_Type;
Mode : File_Mode;
Name : String;
Out_Name : aliased out Name_Pointer; -- Name & NUL
Form : Packed_Form);
procedure Get_Full_Name (
Handle : Handle_Type;
Has_Full_Name : in out Boolean;
Name : in out Name_Pointer;
Is_Standard : Boolean;
Raise_On_Error : Boolean) is null;
pragma Inline (Get_Full_Name);
-- [gcc-7] can not skip calling null procedure
end System.Native_IO.Names;
|
zhmu/ananas | Ada | 18,063 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . M U L T I W A Y _ T R E E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Iterator_Interfaces;
with Ada.Containers.Helpers;
private with Ada.Finalization;
private with Ada.Streams;
private with Ada.Strings.Text_Buffers;
generic
type Element_Type is private;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Multiway_Trees with
SPARK_Mode => Off
is
pragma Annotate (CodePeer, Skip_Analysis);
pragma Preelaborate;
pragma Remote_Types;
type Tree is tagged private
with Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
pragma Preelaborable_Initialization (Tree);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_Tree : constant Tree;
No_Element : constant Cursor;
function Has_Element (Position : Cursor) return Boolean;
package Tree_Iterator_Interfaces is new
Ada.Iterator_Interfaces (Cursor, Has_Element);
function Equal_Subtree
(Left_Position : Cursor;
Right_Position : Cursor) return Boolean;
function "=" (Left, Right : Tree) return Boolean;
function Is_Empty (Container : Tree) return Boolean;
function Node_Count (Container : Tree) return Count_Type;
function Subtree_Node_Count (Position : Cursor) return Count_Type;
function Depth (Position : Cursor) return Count_Type;
function Is_Root (Position : Cursor) return Boolean;
function Is_Leaf (Position : Cursor) return Boolean;
function Root (Container : Tree) return Cursor;
procedure Clear (Container : in out Tree);
function Element (Position : Cursor) return Element_Type;
procedure Replace_Element
(Container : in out Tree;
Position : Cursor;
New_Item : Element_Type);
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type));
procedure Update_Element
(Container : in out Tree;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type));
type Constant_Reference_Type
(Element : not null access constant Element_Type) is private
with Implicit_Dereference => Element;
type Reference_Type
(Element : not null access Element_Type) is private
with Implicit_Dereference => Element;
function Constant_Reference
(Container : aliased Tree;
Position : Cursor) return Constant_Reference_Type;
pragma Inline (Constant_Reference);
function Reference
(Container : aliased in out Tree;
Position : Cursor) return Reference_Type;
pragma Inline (Reference);
procedure Assign (Target : in out Tree; Source : Tree);
function Copy (Source : Tree) return Tree;
procedure Move (Target : in out Tree; Source : in out Tree);
procedure Delete_Leaf
(Container : in out Tree;
Position : in out Cursor);
procedure Delete_Subtree
(Container : in out Tree;
Position : in out Cursor);
procedure Swap
(Container : in out Tree;
I, J : Cursor);
function Find
(Container : Tree;
Item : Element_Type) return Cursor;
-- This version of the AI:
-- 10-06-02 AI05-0136-1/07
-- declares Find_In_Subtree this way:
--
-- function Find_In_Subtree
-- (Container : Tree;
-- Item : Element_Type;
-- Position : Cursor) return Cursor;
--
-- It seems that the Container parameter is there by mistake, but we need
-- an official ruling from the ARG. ???
function Find_In_Subtree
(Position : Cursor;
Item : Element_Type) return Cursor;
-- This version of the AI:
-- 10-06-02 AI05-0136-1/07
-- declares Ancestor_Find this way:
--
-- function Ancestor_Find
-- (Container : Tree;
-- Item : Element_Type;
-- Position : Cursor) return Cursor;
--
-- It seems that the Container parameter is there by mistake, but we need
-- an official ruling from the ARG. ???
function Ancestor_Find
(Position : Cursor;
Item : Element_Type) return Cursor;
function Contains
(Container : Tree;
Item : Element_Type) return Boolean;
procedure Iterate
(Container : Tree;
Process : not null access procedure (Position : Cursor));
procedure Iterate_Subtree
(Position : Cursor;
Process : not null access procedure (Position : Cursor));
function Iterate (Container : Tree)
return Tree_Iterator_Interfaces.Forward_Iterator'Class;
function Iterate_Subtree (Position : Cursor)
return Tree_Iterator_Interfaces.Forward_Iterator'Class;
function Iterate_Children
(Container : Tree;
Parent : Cursor)
return Tree_Iterator_Interfaces.Reversible_Iterator'Class;
function Child_Count (Parent : Cursor) return Count_Type;
function Child_Depth (Parent, Child : Cursor) return Count_Type;
procedure Insert_Child
(Container : in out Tree;
Parent : Cursor;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1);
procedure Insert_Child
(Container : in out Tree;
Parent : Cursor;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1);
procedure Insert_Child
(Container : in out Tree;
Parent : Cursor;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1);
procedure Prepend_Child
(Container : in out Tree;
Parent : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1);
procedure Append_Child
(Container : in out Tree;
Parent : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1);
procedure Delete_Children
(Container : in out Tree;
Parent : Cursor);
procedure Copy_Subtree
(Target : in out Tree;
Parent : Cursor;
Before : Cursor;
Source : Cursor);
procedure Splice_Subtree
(Target : in out Tree;
Parent : Cursor;
Before : Cursor;
Source : in out Tree;
Position : in out Cursor);
procedure Splice_Subtree
(Container : in out Tree;
Parent : Cursor;
Before : Cursor;
Position : Cursor);
procedure Splice_Children
(Target : in out Tree;
Target_Parent : Cursor;
Before : Cursor;
Source : in out Tree;
Source_Parent : Cursor);
procedure Splice_Children
(Container : in out Tree;
Target_Parent : Cursor;
Before : Cursor;
Source_Parent : Cursor);
function Parent (Position : Cursor) return Cursor;
function First_Child (Parent : Cursor) return Cursor;
function First_Child_Element (Parent : Cursor) return Element_Type;
function Last_Child (Parent : Cursor) return Cursor;
function Last_Child_Element (Parent : Cursor) return Element_Type;
function Next_Sibling (Position : Cursor) return Cursor;
function Previous_Sibling (Position : Cursor) return Cursor;
procedure Next_Sibling (Position : in out Cursor);
procedure Previous_Sibling (Position : in out Cursor);
-- This version of the AI:
-- 10-06-02 AI05-0136-1/07
-- declares Iterate_Children this way:
--
-- procedure Iterate_Children
-- (Container : Tree;
-- Parent : Cursor;
-- Process : not null access procedure (Position : Cursor));
--
-- It seems that the Container parameter is there by mistake, but we need
-- an official ruling from the ARG. ???
procedure Iterate_Children
(Parent : Cursor;
Process : not null access procedure (Position : Cursor));
procedure Reverse_Iterate_Children
(Parent : Cursor;
Process : not null access procedure (Position : Cursor));
private
-- A node of this multiway tree comprises an element and a list of children
-- (that are themselves trees). The root node is distinguished because it
-- contains only children: it does not have an element itself.
-- This design feature puts two design goals in tension with one another:
-- (1) treat the root node the same as any other node
-- (2) not declare any objects of type Element_Type unnecessarily
-- To satisfy (1), we could simply declare the Root node of the tree
-- using the normal Tree_Node_Type, but that would mean that (2) is not
-- satisfied. To resolve the tension (in favor of (2)), we declare the
-- component Root as having a different node type, without an Element
-- component (thus satisfying goal (2)) but otherwise identical to a normal
-- node, and then use Unchecked_Conversion to convert an access object
-- designating the Root node component to the access type designating a
-- normal, non-root node (thus satisfying goal (1)). We make an explicit
-- check for Root when there is any attempt to manipulate the Element
-- component of the node (a check required by the RM anyway).
-- In order to be explicit about node (and pointer) representation, we
-- specify that the respective node types have convention C, to ensure
-- that the layout of the components of the node records is the same,
-- thus guaranteeing that (unchecked) conversions between access types
-- designating each kind of node type is a meaningful conversion.
use Ada.Containers.Helpers;
package Implementation is new Generic_Implementation;
use Implementation;
type Tree_Node_Type;
type Tree_Node_Access is access all Tree_Node_Type;
pragma Convention (C, Tree_Node_Access);
pragma No_Strict_Aliasing (Tree_Node_Access);
-- The above-mentioned Unchecked_Conversion is a violation of the normal
-- aliasing rules.
type Children_Type is record
First : Tree_Node_Access;
Last : Tree_Node_Access;
end record;
-- See the comment above. This declaration must exactly match the
-- declaration of Root_Node_Type (except for the Element component).
type Tree_Node_Type is record
Parent : Tree_Node_Access;
Prev : Tree_Node_Access;
Next : Tree_Node_Access;
Children : Children_Type;
Element : aliased Element_Type;
end record;
pragma Convention (C, Tree_Node_Type);
-- See the comment above. This declaration must match the declaration of
-- Tree_Node_Type (except for the Element component).
type Root_Node_Type is record
Parent : Tree_Node_Access;
Prev : Tree_Node_Access;
Next : Tree_Node_Access;
Children : Children_Type;
end record;
pragma Convention (C, Root_Node_Type);
for Root_Node_Type'Alignment use Standard'Maximum_Alignment;
-- The alignment has to be large enough to allow Root_Node to Tree_Node
-- access value conversions, and Tree_Node_Type's alignment may be bumped
-- up by the Element component.
use Ada.Finalization;
-- The Count component of type Tree represents the number of nodes that
-- have been (dynamically) allocated. It does not include the root node
-- itself. As implementors, we decide to cache this value, so that the
-- selector function Node_Count can execute in O(1) time, in order to be
-- consistent with the behavior of the Length selector function for other
-- standard container library units. This does mean, however, that the
-- two-container forms for Splice_XXX (that move subtrees across tree
-- containers) will execute in O(n) time, because we must count the number
-- of nodes in the subtree(s) that get moved. (We resolve the tension
-- between Node_Count and Splice_XXX in favor of Node_Count, under the
-- assumption that Node_Count is the more common operation).
type Tree is new Controlled with record
Root : aliased Root_Node_Type;
TC : aliased Tamper_Counts;
Count : Count_Type := 0;
end record with Put_Image => Put_Image;
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Tree);
overriding procedure Adjust (Container : in out Tree);
overriding procedure Finalize (Container : in out Tree) renames Clear;
use Ada.Streams;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Tree);
for Tree'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Tree);
for Tree'Read use Read;
type Tree_Access is access all Tree;
for Tree_Access'Storage_Size use 0;
type Cursor is record
Container : Tree_Access;
Node : Tree_Node_Access;
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Position : Cursor);
for Cursor'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Position : out Cursor);
for Cursor'Read use Read;
subtype Reference_Control_Type is Implementation.Reference_Control_Type;
-- It is necessary to rename this here, so that the compiler can find it
type Constant_Reference_Type
(Element : not null access constant Element_Type) is
record
Control : Reference_Control_Type :=
raise Program_Error with "uninitialized reference";
-- The RM says, "The default initialization of an object of
-- type Constant_Reference_Type or Reference_Type propagates
-- Program_Error."
end record;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type);
for Constant_Reference_Type'Read use Read;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type);
for Constant_Reference_Type'Write use Write;
type Reference_Type
(Element : not null access Element_Type) is
record
Control : Reference_Control_Type :=
raise Program_Error with "uninitialized reference";
-- The RM says, "The default initialization of an object of
-- type Constant_Reference_Type or Reference_Type propagates
-- Program_Error."
end record;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type);
for Reference_Type'Read use Read;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type);
for Reference_Type'Write use Write;
-- Three operations are used to optimize in the expansion of "for ... of"
-- loops: the Next(Cursor) procedure in the visible part, and the following
-- Pseudo_Reference and Get_Element_Access functions. See Exp_Ch5 for
-- details.
function Pseudo_Reference
(Container : aliased Tree'Class) return Reference_Control_Type;
pragma Inline (Pseudo_Reference);
-- Creates an object of type Reference_Control_Type pointing to the
-- container, and increments the Lock. Finalization of this object will
-- decrement the Lock.
type Element_Access is access all Element_Type with
Storage_Size => 0;
function Get_Element_Access
(Position : Cursor) return not null Element_Access;
-- Returns a pointer to the element designated by Position.
Empty_Tree : constant Tree := (Controlled with others => <>);
No_Element : constant Cursor := (others => <>);
end Ada.Containers.Multiway_Trees;
|
AdaCore/gpr | Ada | 5,262 | adb | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with Gpr_Parser_Support.Errors; use Gpr_Parser_Support.Errors;
with Gpr_Parser_Support.Internal; use Gpr_Parser_Support.Internal;
with Gpr_Parser_Support.Internal.Descriptor;
use Gpr_Parser_Support.Internal.Descriptor;
-- Even though we don't directly use entities from the Internal.Descriptor
-- package, we still need to import it to get visibility over the
-- Language_Descriptor type (and access its components).
pragma Unreferenced (Gpr_Parser_Support.Internal.Descriptor);
package body Gpr_Parser_Support.Generic_API is
-------------------
-- Language_Name --
-------------------
function Language_Name (Id : Language_Id) return Name_Type is
begin
return Create_Name (Id.Language_Name.all);
end Language_Name;
--------------
-- Language --
--------------
function Language (Rule : Grammar_Rule_Ref) return Language_Id is
begin
Check_Grammar_Rule (Rule);
return Rule.Id;
end Language;
--------------------------
-- Default_Grammar_Rule --
--------------------------
function Default_Grammar_Rule (Id : Language_Id) return Grammar_Rule_Ref
is
begin
return (Id, Id.Default_Grammar_Rule);
end Default_Grammar_Rule;
-----------------------
-- Grammar_Rule_Name --
-----------------------
function Grammar_Rule_Name (Rule : Grammar_Rule_Ref) return Name_Type is
begin
return Create_Name (Rule.Id.Grammar_Rules (Rule.Index).Name.all);
end Grammar_Rule_Name;
---------------
-- Is_Public --
---------------
function Is_Public (Rule : Grammar_Rule_Ref) return Boolean is
begin
Check_Grammar_Rule (Rule);
return Rule.Id.Grammar_Rules (Rule.Index).Is_Public;
end Is_Public;
----------------------
-- Grammar_Rule_Doc --
----------------------
function Grammar_Rule_Doc (Rule : Grammar_Rule_Ref) return Text_Type is
begin
Check_Grammar_Rule (Rule);
return Rule.Id.Grammar_Rules (Rule.Index).Doc.all;
end Grammar_Rule_Doc;
--------------
-- To_Index --
--------------
function To_Index (Rule : Grammar_Rule_Ref) return Grammar_Rule_Index is
begin
Check_Grammar_Rule (Rule);
return Rule.Index;
end To_Index;
----------------
-- From_Index --
----------------
function From_Index
(Id : Language_Id; Rule : Grammar_Rule_Index) return Grammar_Rule_Ref is
begin
Check_Grammar_Rule (Id, Rule);
return (Id, Rule);
end From_Index;
-----------------------
-- Last_Grammar_Rule --
-----------------------
function Last_Grammar_Rule (Id : Language_Id) return Grammar_Rule_Index is
begin
return Id.Grammar_Rules'Last;
end Last_Grammar_Rule;
------------------------
-- Check_Grammar_Rule --
------------------------
procedure Check_Grammar_Rule (Rule : Grammar_Rule_Ref) is
begin
if Rule.Id = null then
raise Precondition_Failure with "null grammar rule reference";
end if;
end Check_Grammar_Rule;
------------------------
-- Check_Grammar_Rule --
------------------------
procedure Check_Grammar_Rule (Id : Language_Id; Rule : Grammar_Rule_Index)
is
begin
if Rule not in Id.Grammar_Rules.all'Range then
raise Precondition_Failure with
"invalid grammar rule for this language";
end if;
end Check_Grammar_Rule;
--------------
-- Language --
--------------
function Language (Kind : Token_Kind_Ref) return Language_Id is
begin
Check_Token_Kind (Kind);
return Kind.Id;
end Language;
---------------------
-- Token_Kind_Name --
---------------------
function Token_Kind_Name (Kind : Token_Kind_Ref) return Name_Type is
begin
return Create_Name (Kind.Id.Token_Kind_Names (Kind.Index).all);
end Token_Kind_Name;
--------------
-- To_Index --
--------------
function To_Index (Kind : Token_Kind_Ref) return Token_Kind_Index is
begin
Check_Token_Kind (Kind);
return Kind.Index;
end To_Index;
----------------
-- From_Index --
----------------
function From_Index
(Id : Language_Id; Kind : Token_Kind_Index) return Token_Kind_Ref is
begin
Check_Token_Kind (Id, Kind);
return (Id, Kind);
end From_Index;
---------------------
-- Last_Token_Kind --
---------------------
function Last_Token_Kind (Id : Language_Id) return Token_Kind_Index is
begin
return Id.Token_Kind_Names'Last;
end Last_Token_Kind;
----------------------
-- Check_Token_Kind --
----------------------
procedure Check_Token_Kind (Kind : Token_Kind_Ref) is
begin
if Kind.Id = null then
raise Precondition_Failure with "null token kind reference";
end if;
end Check_Token_Kind;
----------------------
-- Check_Token_Kind --
----------------------
procedure Check_Token_Kind (Id : Language_Id; Kind : Token_Kind_Index)
is
begin
if Kind not in Id.Token_Kind_Names.all'Range then
raise Precondition_Failure with
"invalid token kind for this language";
end if;
end Check_Token_Kind;
end Gpr_Parser_Support.Generic_API;
|
stcarrez/stm32-ui | Ada | 4,789 | adb | -----------------------------------------------------------------------
-- ui-texts -- Utilities to draw text strings
-- Copyright (C) 2016, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Bitmapped_Drawing;
with Bitmap_Color_Conversion;
package body UI.Texts is
function Char_Width (C : in Character) return Natural;
function Char_Width (C : in Character) return Natural is
pragma Unreferenced (C);
use type BMP_Fonts.BMP_Font;
begin
if Current_Font /= BMP_Fonts.Font12x12 then
return BMP_Fonts.Char_Width (Current_Font);
end if;
return BMP_Fonts.Char_Width (Current_Font) - 2;
end Char_Width;
-- ------------------------------
-- Get the width of the string in pixels after rendering with the current font.
-- ------------------------------
function Get_Width (S : in String) return Natural is
W : constant Natural := Char_Width ('a');
begin
return W * S'Length;
end Get_Width;
-- ------------------------------
-- Draw the string at the given position and using the justification so that we don't
-- span more than the width. The current font, foreground and background are used
-- to draw the string.
-- ------------------------------
procedure Draw_String (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Start : in HAL.Bitmap.Point;
Width : in Natural;
Msg : in String;
Justify : in Justify_Type := LEFT) is
X : Natural := Start.X;
Y : constant Natural := Start.Y;
Last : Natural := Start.X + Width;
FG : constant HAL.UInt32 := Bitmap_Color_Conversion.Bitmap_Color_To_Word (Buffer.Color_Mode,
Foreground);
BG : constant HAL.UInt32 := Bitmap_Color_Conversion.Bitmap_Color_To_Word (Buffer.Color_Mode,
Background);
begin
if Last > Buffer.Width then
Last := Buffer.Width;
end if;
case Justify is
when LEFT =>
for C of Msg loop
exit when X > Last;
Bitmapped_Drawing.Draw_Char (Buffer => Buffer,
Start => (X, Y),
Char => C,
Font => Current_Font,
Foreground => FG,
Background => BG);
X := X + Char_Width (C);
end loop;
when RIGHT =>
X := X + Width;
for C of reverse Msg loop
exit when X - Char_Width (C) < Start.X;
X := X - Char_Width (C);
Bitmapped_Drawing.Draw_Char (Buffer => Buffer,
Start => (X, Y),
Char => C,
Font => Current_Font,
Foreground => FG,
Background => BG);
end loop;
when CENTER =>
declare
L : constant Natural := Get_Width (Msg);
begin
if L < Width then
X := X + (Width - L) / 2;
end if;
for C of Msg loop
exit when X > Last;
Bitmapped_Drawing.Draw_Char (Buffer => Buffer,
Start => (X, Y),
Char => C,
Font => Current_Font,
Foreground => FG,
Background => BG);
X := X + Char_Width (C);
end loop;
end;
end case;
end Draw_String;
end UI.Texts;
|
charlie5/cBound | Ada | 1,723 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_alloc_color_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
cmap : aliased xcb.xcb_colormap_t;
red : aliased Interfaces.Unsigned_16;
green : aliased Interfaces.Unsigned_16;
blue : aliased Interfaces.Unsigned_16;
pad1 : aliased swig.int8_t_Array (0 .. 1);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_alloc_color_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_alloc_color_request_t.Item,
Element_Array => xcb.xcb_alloc_color_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_alloc_color_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_alloc_color_request_t.Pointer,
Element_Array => xcb.xcb_alloc_color_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_alloc_color_request_t;
|
io7m/coreland-lua-ada | Ada | 455 | adb | with UTest;
with Lua;
with Lua.Lib;
procedure loadstring1 is
use type Lua.Error_t;
State : Lua.State_t;
Error_Code : Lua.Error_t;
begin
State := Lua.Open;
Lua.Lib.Open_Base (State);
Error_Code := Lua.Load_String (State, "print 'loaded string'");
if Error_Code /= Lua.Lua_Error_None then
UTest.Fail (1, Lua.To_String (State, -1));
end if;
exception
when others =>
UTest.Fail (2, "unexpected exception");
end loadstring1;
|
stcarrez/ada-ado | Ada | 24,150 | ads | -----------------------------------------------------------------------
-- ado-statements -- Database statements
-- Copyright (C) 2009 - 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Finalization;
with Ada.Calendar;
with ADO.Schemas;
with ADO.Parameters;
with ADO.SQL;
with ADO.Objects;
private with Ada.Unchecked_Conversion;
private with System;
private with Interfaces.C;
private with Interfaces.C.Strings;
-- = Database Statements =
-- The `ADO.Statements` package provides high level operations to construct database
-- statements and execute them. They allow to represent SQL statements (prepared or not)
-- and provide support to execute them and retreive their result. The SQL statements are
-- represented by several Ada types depending on their behavior:
--
-- * The `Statement` type represents the base type for all the SQL statements.
-- * The `Query_Statement` type is intended to be used for database query statements
-- and provides additional operations to retrieve results.
-- * The `Update_Statement` type targets the database update statements and it
-- provides specific operations to update fields. The `Insert_Statement`
-- extends the `Update_Statement` type and is intended for database insertion.
-- * The `Delete_Statement` type is intended to be used to remove elements
-- from the database.
--
-- The database statements are created by using the database session and by providing
-- the SQL or the named query to be used.
--
-- @include ado-parameters.ads
--
-- == Query Statements ==
-- The database query statement is represented by the `Query_Statement` type.
-- The `Create_Statement` operation is provided on the `Session` type
-- and it gets the SQL to execute as parameter. For example:
--
-- Stmt : ADO.Statements.Query_Statement := Session.Create_Statement
-- ("SELECT * FROM user WHERE name = :name");
--
-- After the creation of the query statement, the parameters for the SQL query are provided
-- by using either the `Bind_Param` or `Add_Param` procedures as follows:
--
-- Stmt.Bind_Param ("name", name);
--
-- Once all the parameters are defined, the query statement is executed by calling the
-- `Execute` procedure:
--
-- Stmt.Execute;
--
-- Several operations are provided to retrieve the result. First, the `Has_Elements`
-- function will indicate whether some database rows are available in the result. It is then
-- possible to retrieve each row and proceed to the next one by calling the `Next`
-- procedure. The number of rows is also returned by the `Get_Row_Count` function.
-- A simple loop to iterate over the query result looks like:
--
-- while Stmt.Has_Elements loop
-- Id := Stmt.Get_Identifier (1);
-- ...
-- Stmt.Next;
-- end loop;
--
-- @include ado-queries.ads
package ADO.Statements is
use Ada.Strings.Unbounded;
Invalid_Statement : exception;
-- Exception raised when an SQL statement failed.
SQL_Error : exception;
-- Exception raised when a column number is invalid.
Invalid_Column : exception;
-- Exception raised when a value cannot be converted to the target type.
Invalid_Type : exception;
-- ---------
-- SQL statement
-- ---------
-- The SQL statement
--
type Statement is abstract new ADO.Parameters.Abstract_List with private;
type Statement_Access is access all Statement'Class;
function Get_Query (Query : Statement) return ADO.SQL.Query_Access;
overriding
procedure Add_Parameter (Query : in out Statement;
Param : in ADO.Parameters.Parameter);
overriding
procedure Set_Parameters (Query : in out Statement;
From : in ADO.Parameters.Abstract_List'Class);
-- Return the number of parameters in the list.
overriding
function Length (Query : in Statement) return Natural;
-- Return the parameter at the given position
overriding
function Element (Query : in Statement;
Position : in Natural) return ADO.Parameters.Parameter;
-- Execute the <b>Process</b> procedure with the given parameter as argument.
overriding
procedure Query_Element (Query : in Statement;
Position : in Natural;
Process : not null access
procedure (Element : in ADO.Parameters.Parameter));
-- Clear the list of parameters.
overriding
procedure Clear (Query : in out Statement);
subtype Query_String is String;
procedure Add_Param (Params : in out Statement;
Value : in ADO.Objects.Object_Key);
-- Add the parameter by using the primary key of the object.
-- Use null if the object is a null reference.
procedure Add_Param (Params : in out Statement;
Value : in ADO.Objects.Object_Ref'Class);
-- Operations to build the SQL query
procedure Append (Query : in out Statement; SQL : in String);
procedure Append (Query : in out Statement; SQL : in Unbounded_String);
procedure Append (Query : in out Statement; Value : in Integer);
procedure Append (Query : in out Statement; Value : in Long_Integer);
-- Append the value to the SQL query string.
procedure Append_Escape (Query : in out Statement; Value : in String);
-- Append the value to the SQL query string.
procedure Append_Escape (Query : in out Statement;
Value : in Unbounded_String);
procedure Set_Filter (Query : in out Statement;
Filter : in String);
-- Execute the query
procedure Execute (Query : in out Statement) is abstract;
-- ------------------------------
-- An SQL query statement
--
-- The Query_Statement provides operations to retrieve the
-- results after execution of the query.
-- ------------------------------
type Query_Statement is new Statement with private;
type Query_Statement_Access is access all Query_Statement'Class;
-- Execute the query
overriding
procedure Execute (Query : in out Query_Statement);
-- Get the number of rows returned by the query
function Get_Row_Count (Query : in Query_Statement) return Natural;
-- Returns True if there is more data (row) to fetch
function Has_Elements (Query : in Query_Statement) return Boolean;
-- Fetch the next row
procedure Next (Query : in out Query_Statement);
-- Returns true if the column <b>Column</b> is null.
function Is_Null (Query : in Query_Statement;
Column : in Natural) return Boolean;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Int64</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Int64 (Query : Query_Statement;
Column : Natural) return Int64;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Identifier</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Identifier (Query : Query_Statement;
Column : Natural) return Identifier;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Integer</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Integer (Query : Query_Statement;
Column : Natural) return Integer;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Integer</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Natural (Query : in Query_Statement;
Column : in Natural) return Natural;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Nullable_Integer</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Nullable_Integer (Query : Query_Statement;
Column : Natural) return Nullable_Integer;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Float</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Float (Query : Query_Statement;
Column : Natural) return Float;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Long_Float</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Long_Float (Query : Query_Statement;
Column : Natural) return Long_Float;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Boolean</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Boolean (Query : Query_Statement;
Column : Natural) return Boolean;
-- Get the column value at position <b>Column</b> and
-- return it as a <b>Nullable_Boolean</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Nullable_Boolean (Query : Query_Statement;
Column : Natural) return Nullable_Boolean;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Unbounded_String</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Unbounded_String (Query : Query_Statement;
Column : Natural) return Unbounded_String;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Nullable_String</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Nullable_String (Query : Query_Statement;
Column : Natural) return Nullable_String;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Unbounded_String</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_String (Query : Query_Statement;
Column : Natural) return String;
-- Get the column value at position <b>Column</b> and
-- return it as a <b>Blob</b> reference.
function Get_Blob (Query : in Query_Statement;
Column : in Natural) return ADO.Blob_Ref;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Time</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Time (Query : Query_Statement;
Column : Natural) return Ada.Calendar.Time;
-- Get the column value at position <b>Column</b> and
-- return it as a <b>Nullable_Time</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Nullable_Time (Query : Query_Statement;
Column : Natural) return Nullable_Time;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Entity_Type</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Entity_Type (Query : Query_Statement;
Column : Natural) return Entity_Type;
-- Get the column value at position <b>Column</b> and
-- return it as an <b>Nullable_Entity_Type</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Nullable_Entity_Type (Query : Query_Statement;
Column : Natural) return Nullable_Entity_Type;
-- Get the column type
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Column_Type (Query : Query_Statement;
Column : Natural)
return ADO.Schemas.Column_Type;
-- Get the column name.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Column_Name (Query : in Query_Statement;
Column : in Natural)
return String;
-- Get the number of columns in the result.
function Get_Column_Count (Query : in Query_Statement)
return Natural;
-- Get the query result as an integer
function Get_Result_Integer (Query : in Query_Statement) return Integer;
-- Get the query result as an blob.
function Get_Result_Blob (Query : in Query_Statement) return ADO.Blob_Ref;
-- ------------------------------
-- Delete statement
-- ------------------------------
type Delete_Statement is new Statement with private;
type Delete_Statement_Access is access all Delete_Statement'Class;
-- Execute the delete query.
overriding
procedure Execute (Query : in out Delete_Statement);
-- Execute the delete query.
-- Returns the number of rows deleted.
procedure Execute (Query : in out Delete_Statement;
Result : out Natural);
-- ------------------------------
-- Update statement
-- ------------------------------
type Update_Statement is new Statement with private;
type Update_Statement_Access is access all Update_Statement'Class;
-- Get the update query object associated with this update statement.
function Get_Update_Query (Update : in Update_Statement)
return ADO.SQL.Update_Query_Access;
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Boolean);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Nullable_Boolean);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Integer);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Nullable_Integer);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Long_Long_Integer);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Float);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Long_Float);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Identifier);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Entity_Type);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Nullable_Entity_Type);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Ada.Calendar.Time);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Nullable_Time);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in String);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Unbounded_String);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in Nullable_String);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in ADO.Objects.Object_Key);
-- Prepare the update/insert query to save the table field.
-- identified by <b>Name</b> and set it to the identifier key held by <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in ADO.Objects.Object_Ref'Class);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
procedure Save_Field (Update : in out Update_Statement;
Name : in String;
Value : in ADO.Blob_Ref);
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to NULL.
procedure Save_Null_Field (Update : in out Update_Statement;
Name : in String);
-- Check if the update/insert query has some fields to update.
function Has_Save_Fields (Update : in Update_Statement) return Boolean;
-- Execute the query
overriding
procedure Execute (Query : in out Update_Statement);
-- Execute the query
procedure Execute (Query : in out Update_Statement;
Result : out Integer);
-- ------------------------------
-- Insert statement
-- ------------------------------
type Insert_Statement is new Update_Statement with private;
type Insert_Statement_Access is access all Insert_Statement'Class;
-- Execute the query
overriding
procedure Execute (Query : in out Insert_Statement);
private
type Statement is abstract new ADO.Parameters.Abstract_List with record
Query : ADO.SQL.Query_Access;
end record;
type Driver_Statement is new Ada.Finalization.Limited_Controlled with null record;
procedure Execute (Query : in out Statement;
SQL : in Unbounded_String;
Params : in ADO.Parameters.Abstract_List'Class);
type Query_Statement is new Statement with record
Proxy : Query_Statement_Access := null;
Ref_Counter : Natural := 0;
end record;
overriding
procedure Adjust (Stmt : in out Query_Statement);
overriding
procedure Finalize (Stmt : in out Query_Statement);
-- String pointer to interface with a C library
type chars_ptr is access all Character;
pragma Convention (C, chars_ptr);
type Size_T is mod 2 ** Standard'Address_Size;
use Interfaces.C;
function To_Chars_Ptr is
new Ada.Unchecked_Conversion (System.Address, chars_ptr);
function To_Chars_Ptr is
new Ada.Unchecked_Conversion (Interfaces.C.Strings.chars_ptr, chars_ptr);
function To_Address is
new Ada.Unchecked_Conversion (chars_ptr, System.Address);
function "+" (Left : chars_ptr; Right : Size_T) return chars_ptr;
pragma Inline ("+");
-- Get an unsigned 64-bit number from a C string terminated by \0
function Get_Uint64 (Str : chars_ptr) return unsigned_long;
-- Get a signed 64-bit number from a C string terminated by \0
function Get_Int64 (Str : chars_ptr) return Int64;
-- Get a double number from a C string terminated by \0
function Get_Long_Float (Str : chars_ptr) return Long_Float;
-- Get a time from the C string passed in <b>Value</b>.
-- Raises <b>Invalid_Type</b> if the value cannot be converted.
-- Raises <b>Invalid_Column</b> if the column does not exist.
function Get_Time (Value : in chars_ptr) return Ada.Calendar.Time;
-- Create a blob initialized with the given data buffer pointed to by <b>Data</b>
-- and which contains <b>Size</b> bytes.
function Get_Blob (Data : in chars_ptr;
Size : in Natural) return Blob_Ref;
type Delete_Statement is new Statement with record
Proxy : Delete_Statement_Access := null;
Ref_Counter : Natural := 0;
end record;
overriding
procedure Adjust (Stmt : in out Delete_Statement);
overriding
procedure Finalize (Stmt : in out Delete_Statement);
type Update_Statement is new Statement with record
Proxy : Update_Statement_Access := null;
Update : ADO.SQL.Update_Query_Access;
Ref_Counter : Natural := 0;
end record;
overriding
procedure Adjust (Stmt : in out Update_Statement);
overriding
procedure Finalize (Stmt : in out Update_Statement);
type Insert_Statement is new Update_Statement with record
Pos2 : Natural := 0;
end record;
end ADO.Statements;
|
reznikmm/matreshka | Ada | 3,636 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Multiplicity_Elements.Hash is
new AMF.Elements.Generic_Hash (UML_Multiplicity_Element, UML_Multiplicity_Element_Access);
|
ytomino/zlib-ada | Ada | 18,350 | adb | with Ada.Unchecked_Conversion;
with System;
with C.string;
package body zlib is
use type C.signed_int;
use type C.size_t;
type unsigned_char_array is
array (C.size_t range <>) of aliased C.unsigned_char
with Convention => C;
pragma Suppress_Initialization (unsigned_char_array);
-- C.unsigned_char_array is not generated in some cases
Flush_Table : constant array (Boolean) of C.signed_int :=
(C.zlib.Z_NO_FLUSH, C.zlib.Z_FINISH);
function To_String (S : not null access constant C.char) return String is
Result : String (1 .. Natural (C.string.strlen (S)));
for Result'Address use S.all'Address;
begin
return Result;
end To_String;
procedure Raise_Error (Result : C.signed_int);
pragma No_Return (Raise_Error);
procedure Raise_Error (Result : C.signed_int) is
begin
case Result is
when C.zlib.Z_DATA_ERROR =>
raise Data_Error with To_String (C.zlib.zError (Result));
when C.zlib.Z_MEM_ERROR =>
raise Storage_Error with To_String (C.zlib.zError (Result));
when C.zlib.Z_BUF_ERROR =>
raise Constraint_Error with To_String (C.zlib.zError (Result));
when others =>
raise Use_Error with To_String (C.zlib.zError (Result));
end case;
end Raise_Error;
function Make_Window_Bits (
Window_Bits : zlib.Window_Bits;
Header : Inflation_Header)
return C.signed_int is
begin
case Header is
when None =>
return -C.signed_int (Window_Bits);
when Default =>
return C.signed_int (Window_Bits);
when GZip =>
return C.signed_int (Window_Bits + 16);
when Auto =>
return C.signed_int (Window_Bits + 32);
end case;
end Make_Window_Bits;
procedure Internal_Deflate_Init (
Stream : in out zlib.Stream;
Level : in Compression_Level;
Method : in Compression_Method;
Window_Bits : in zlib.Window_Bits;
Header : in Deflation_Header;
Memory_Level : in zlib.Memory_Level;
Strategy : in zlib.Strategy)
is
function To_signed_int is
new Ada.Unchecked_Conversion (Compression_Method, C.signed_int);
function To_signed_int is
new Ada.Unchecked_Conversion (zlib.Strategy, C.signed_int);
NC_Stream : Non_Controlled_Stream
renames Controlled.Reference (Stream).all;
Result : C.signed_int;
begin
NC_Stream.Z_Stream.zalloc := null;
NC_Stream.Z_Stream.zfree := null;
NC_Stream.Z_Stream.opaque := C.void_ptr (System.Null_Address);
Result :=
C.zlib.deflateInit2q (
NC_Stream.Z_Stream'Access,
level => C.signed_int (Level),
method => To_signed_int (Method),
windowBits => Make_Window_Bits (Window_Bits, Header),
memLevel => C.signed_int (Memory_Level),
strategy => To_signed_int (Strategy),
version => C.zlib.ZLIB_VERSION (C.zlib.ZLIB_VERSION'First)'Access,
stream_size => C.zlib.z_stream'Size / System.Storage_Unit);
if Result /= C.zlib.Z_OK then
Raise_Error (Result);
end if;
NC_Stream.Finalize := C.zlib.deflateEnd'Access;
NC_Stream.Is_Open := True;
NC_Stream.Mode := Deflating;
NC_Stream.Stream_End := False;
end Internal_Deflate_Init;
procedure Internal_Inflate_Init (
Stream : in out zlib.Stream;
Window_Bits : in zlib.Window_Bits;
Header : in Inflation_Header)
is
NC_Stream : Non_Controlled_Stream
renames Controlled.Reference (Stream).all;
Result : C.signed_int;
begin
NC_Stream.Z_Stream.zalloc := null;
NC_Stream.Z_Stream.zfree := null;
NC_Stream.Z_Stream.opaque := C.void_ptr (System.Null_Address);
Result :=
C.zlib.inflateInit2q (
NC_Stream.Z_Stream'Access,
windowBits => Make_Window_Bits (Window_Bits, Header),
version => C.zlib.ZLIB_VERSION (C.zlib.ZLIB_VERSION'First)'Access,
stream_size => C.zlib.z_stream'Size / System.Storage_Unit);
if Result /= C.zlib.Z_OK then
Raise_Error (Result);
end if;
NC_Stream.Finalize := C.zlib.inflateEnd'Access;
NC_Stream.Is_Open := True;
NC_Stream.Mode := Inflating;
NC_Stream.Stream_End := False;
end Internal_Inflate_Init;
procedure Close (
NC_Stream : in out Non_Controlled_Stream;
Raise_On_Error : Boolean)
is
Result : C.signed_int;
begin
Result := NC_Stream.Finalize (NC_Stream.Z_Stream'Access);
if Result /= C.zlib.Z_OK and then Raise_On_Error then
Raise_Error (Result);
end if;
NC_Stream.Is_Open := False;
end Close;
-- implementation
procedure Deflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (Stream) = Deflating or else raise Mode_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Reference (Stream).all;
Z_Stream : constant not null access C.zlib.z_stream :=
NC_Stream.Z_Stream'Access;
C_In_Size : constant C.size_t := In_Item'Length;
C_In_Item : unsigned_char_array (0 .. C.size_t'Max (C_In_Size, 1) - 1);
for C_In_Item'Address use In_Item'Address;
C_Out_Size : constant C.size_t := Out_Item'Length;
C_Out_Item : unsigned_char_array (0 .. C.size_t'Max (C_Out_Size, 1) - 1);
for C_Out_Item'Address use Out_Item'Address;
Result : C.signed_int;
begin
Z_Stream.next_in := C_In_Item (0)'Unchecked_Access;
Z_Stream.avail_in := C.zconf.uInt (C_In_Size);
Z_Stream.next_out := C_Out_Item (0)'Unchecked_Access;
Z_Stream.avail_out := C.zconf.uInt (C_Out_Size);
Result := C.zlib.deflate (Z_Stream, Flush_Table (Finish));
case Result is
when C.zlib.Z_OK | C.zlib.Z_STREAM_END =>
In_Last :=
In_Item'First
+ Ada.Streams.Stream_Element_Offset (C_In_Size)
- Ada.Streams.Stream_Element_Offset (Z_Stream.avail_in)
- 1;
Out_Last :=
Out_Item'First
+ Ada.Streams.Stream_Element_Offset (C_Out_Size)
- Ada.Streams.Stream_Element_Offset (Z_Stream.avail_out)
- 1;
Finished := Result = C.zlib.Z_STREAM_END;
if Finished then
NC_Stream.Stream_End := True;
end if;
when others =>
Raise_Error (Result);
end case;
end Deflate;
procedure Deflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset)
is
Dummy_Finished : Boolean;
begin
Deflate (
Stream, -- Status_Error would be raised if Stream is not open
In_Item,
In_Last,
Out_Item,
Out_Last,
False,
Dummy_Finished);
end Deflate;
procedure Deflate (
Stream : in out zlib.Stream;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean)
is
Dummy_In_Item : Ada.Streams.Stream_Element_Array (1 .. 0);
Dummy_In_Last : Ada.Streams.Stream_Element_Offset;
begin
Deflate (
Stream, -- Status_Error would be raised if Stream is not open
Dummy_In_Item,
Dummy_In_Last,
Out_Item,
Out_Last,
Finish,
Finished);
end Deflate;
function Deflate_Init (
Level : Compression_Level := Default_Compression;
Method : Compression_Method := Deflated;
Window_Bits : zlib.Window_Bits := Default_Window_Bits;
Header : Deflation_Header := Default;
Memory_Level : zlib.Memory_Level := Default_Memory_Level;
Strategy : zlib.Strategy := Default_Strategy)
return Stream is
begin
return Result : Stream do
Internal_Deflate_Init (
Result,
Level,
Method,
Window_Bits,
Header,
Memory_Level,
Strategy);
end return;
end Deflate_Init;
procedure Deflate_Or_Inflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Reference (Stream).all;
begin
case NC_Stream.Mode is
when Deflating =>
Deflate (
Stream,
In_Item,
In_Last,
Out_Item,
Out_Last,
Finish,
Finished);
when Inflating =>
Inflate (
Stream,
In_Item,
In_Last,
Out_Item,
Out_Last,
Finish,
Finished);
end case;
end Deflate_Or_Inflate;
procedure Inflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (Stream) = Inflating or else raise Mode_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Reference (Stream).all;
Z_Stream : constant not null access C.zlib.z_stream :=
NC_Stream.Z_Stream'Access;
C_In_Size : constant C.size_t := In_Item'Length;
C_In_Item : unsigned_char_array (0 .. C.size_t'Max (C_In_Size, 1) - 1);
for C_In_Item'Address use In_Item'Address;
C_Out_Size : constant C.size_t := Out_Item'Length;
C_Out_Item : unsigned_char_array (0 .. C.size_t'Max (C_Out_Size, 1) - 1);
for C_Out_Item'Address use Out_Item'Address;
Result : C.signed_int;
begin
Z_Stream.next_in := C_In_Item (0)'Unchecked_Access;
Z_Stream.avail_in := C.zconf.uInt (C_In_Size);
Z_Stream.next_out := C_Out_Item (0)'Unchecked_Access;
Z_Stream.avail_out := C.zconf.uInt (C_Out_Size);
Result := C.zlib.inflate (Z_Stream, Flush_Table (Finish));
case Result is
when C.zlib.Z_OK | C.zlib.Z_STREAM_END =>
In_Last :=
In_Item'First
+ Ada.Streams.Stream_Element_Offset (C_In_Size)
- Ada.Streams.Stream_Element_Offset (Z_Stream.avail_in)
- 1;
Out_Last :=
Out_Item'First
+ Ada.Streams.Stream_Element_Offset (C_Out_Size)
- Ada.Streams.Stream_Element_Offset (Z_Stream.avail_out)
- 1;
Finished := Result = C.zlib.Z_STREAM_END;
if Finished then
NC_Stream.Stream_End := True;
end if;
when others =>
Raise_Error (Result);
end case;
end Inflate;
procedure Inflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset)
is
Dummy_Finished : Boolean;
begin
Inflate (
Stream, -- Status_Error would be raised if Stream is not open
In_Item,
In_Last,
Out_Item,
Out_Last,
False,
Dummy_Finished);
end Inflate;
procedure Inflate (
Stream : in out zlib.Stream;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean)
is
Dummy_In_Item : Ada.Streams.Stream_Element_Array (1 .. 0);
Dummy_In_Last : Ada.Streams.Stream_Element_Offset;
begin
Inflate (
Stream, -- Status_Error would be raised if Stream is not open
Dummy_In_Item,
Dummy_In_Last,
Out_Item,
Out_Last,
Finish,
Finished);
end Inflate;
function Inflate_Init (
Window_Bits : zlib.Window_Bits := Default_Window_Bits;
Header : Inflation_Header := Auto)
return Stream is
begin
return Result : Stream do
Internal_Inflate_Init (Result, Window_Bits, Header);
end return;
end Inflate_Init;
procedure Close (Stream : in out zlib.Stream) is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Reference (Stream).all;
begin
Close (NC_Stream, Raise_On_Error => True);
end Close;
function Is_Open (Stream : zlib.Stream) return Boolean is
NC_Stream : Non_Controlled_Stream
renames Controlled.Constant_Reference (Stream).all;
begin
return NC_Stream.Is_Open;
end Is_Open;
function Mode (
Stream : zlib.Stream)
return Stream_Mode
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Constant_Reference (Stream).all;
begin
return NC_Stream.Mode;
end Mode;
function Total_In (
Stream : zlib.Stream)
return Ada.Streams.Stream_Element_Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Constant_Reference (Stream).all;
begin
return Ada.Streams.Stream_Element_Count (NC_Stream.Z_Stream.total_in);
end Total_In;
function Total_Out (
Stream : zlib.Stream)
return Ada.Streams.Stream_Element_Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Stream) or else raise Status_Error);
NC_Stream : Non_Controlled_Stream
renames Controlled.Constant_Reference (Stream).all;
begin
return Ada.Streams.Stream_Element_Count (NC_Stream.Z_Stream.total_out);
end Total_Out;
function Version return String is
begin
return To_String (C.zlib.zlibVersion);
end Version;
package body Controlled is
function Constant_Reference (Object : zlib.Stream)
return not null access constant Non_Controlled_Stream is
begin
return Stream (Object).Data'Unchecked_Access;
end Constant_Reference;
function Reference (Object : in out zlib.Stream)
return not null access Non_Controlled_Stream is
begin
return Stream (Object).Variable_View.Data'Access;
end Reference;
overriding procedure Finalize (Object : in out Stream) is
begin
if Object.Data.Is_Open then
Close (Object.Data, Raise_On_Error => False);
end if;
end Finalize;
end Controlled;
-- compatibility
procedure Deflate_Init (
Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Method : in Compression_Method := Deflated;
Window_Bits : in zlib.Window_Bits := Default_Window_Bits;
Header : in Deflation_Header := Default;
Memory_Level : in zlib.Memory_Level := Default_Memory_Level;
Strategy : in Strategy_Type := Default_Strategy)
is
pragma Check (Dynamic_Predicate,
Check => not Is_Open (Filter) or else raise Status_Error);
begin
Internal_Deflate_Init (
Filter,
Level,
Method,
Window_Bits,
Header,
Memory_Level,
Strategy);
end Deflate_Init;
procedure Generic_Translate (Filter : in out Filter_Type) is
NC_Filter : Non_Controlled_Stream
renames Controlled.Reference (Filter).all;
In_Item : Ada.Streams.Stream_Element_Array (1 .. 2 ** 15);
In_First : Ada.Streams.Stream_Element_Offset := In_Item'Last + 1;
In_Last : Ada.Streams.Stream_Element_Offset;
In_Used : Ada.Streams.Stream_Element_Offset;
Out_Item : Ada.Streams.Stream_Element_Array (1 .. 2 ** 15);
Out_Last : Ada.Streams.Stream_Element_Offset;
begin
loop
if In_First > In_Item'Last then
Data_In (In_Item, In_Last);
In_First := In_Item'First;
end if;
Translate (
Filter, -- Status_Error would be raised if Filter is not open
In_Item (In_First .. In_Last),
In_Used,
Out_Item,
Out_Last,
In_Last < In_Item'Last);
Data_Out (Out_Item (Out_Item'First .. Out_Last));
exit when NC_Filter.Stream_End;
In_First := In_Used + 1;
end loop;
end Generic_Translate;
procedure Inflate_Init (
Filter : in out Filter_Type;
Window_Bits : in zlib.Window_Bits := Default_Window_Bits;
Header : in Header_Type := Auto)
is
pragma Check (Dynamic_Predicate,
Check => not Is_Open (Filter) or else raise Status_Error);
begin
Internal_Inflate_Init (Filter, Window_Bits, Header);
end Inflate_Init;
procedure Read (
Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode := No_Flush)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Filter) or else raise Status_Error);
NC_Filter : Non_Controlled_Stream
renames Controlled.Reference (Filter).all;
begin
if NC_Filter.Stream_End then
Last := Item'First - 1;
else
declare
In_Used : Ada.Streams.Stream_Element_Offset;
Out_First : Ada.Streams.Stream_Element_Offset := Item'First;
Finish : Boolean := Flush;
begin
loop
if Rest_First > Rest_Last then
Read (Buffer, Rest_Last);
Rest_First := Buffer'First;
if NC_Filter.Mode = Deflating then
Finish := Finish or else Rest_Last < Buffer'Last;
end if;
end if;
Translate (
Filter,
Buffer (Rest_First .. Rest_Last),
In_Used,
Item (Out_First .. Item'Last),
Last,
Finish);
Rest_First := In_Used + 1;
exit when NC_Filter.Stream_End or else Last >= Item'Last;
Out_First := Last + 1;
end loop;
end;
end if;
end Read;
procedure Translate (
Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
Dummy_Finished : Boolean;
begin
Deflate_Or_Inflate (
Filter, -- Status_Error would be raised if Filter is not open
In_Data,
In_Last,
Out_Data,
Out_Last,
Flush,
Dummy_Finished);
end Translate;
procedure Write (
Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode := No_Flush) is
begin
if Flush or else Item'First <= Item'Last then
declare
In_First : Ada.Streams.Stream_Element_Offset := Item'First;
begin
loop
declare
In_Used : Ada.Streams.Stream_Element_Offset;
Out_Item : Ada.Streams.Stream_Element_Array (1 .. 2 ** 15);
Out_Last : Ada.Streams.Stream_Element_Offset;
Finished : Boolean;
begin
Deflate_Or_Inflate (
Filter, -- Status_Error would be raised if it is not open
Item (In_First .. Item'Last),
In_Used,
Out_Item,
Out_Last,
Flush,
Finished);
Write (Out_Item (Out_Item'First .. Out_Last));
exit when Finished or else In_Used >= Item'Last;
In_First := In_Used + 1;
end;
end loop;
end;
end if;
end Write;
end zlib;
|
zhmu/ananas | Ada | 48,495 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.INDEFINITE_ORDERED_MAPS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2022, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Containers.Helpers; use Ada.Containers.Helpers;
with Ada.Containers.Red_Black_Trees.Generic_Operations;
pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Operations);
with Ada.Containers.Red_Black_Trees.Generic_Keys;
pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys);
with System; use type System.Address;
with System.Put_Images;
package body Ada.Containers.Indefinite_Ordered_Maps with
SPARK_Mode => Off
is
pragma Suppress (All_Checks);
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------------
-- Node Access Subprograms --
-----------------------------
-- These subprograms provide a functional interface to access fields
-- of a node, and a procedural interface for modifying these values.
function Color (Node : Node_Access) return Color_Type;
pragma Inline (Color);
function Left (Node : Node_Access) return Node_Access;
pragma Inline (Left);
function Parent (Node : Node_Access) return Node_Access;
pragma Inline (Parent);
function Right (Node : Node_Access) return Node_Access;
pragma Inline (Right);
procedure Set_Parent (Node : Node_Access; Parent : Node_Access);
pragma Inline (Set_Parent);
procedure Set_Left (Node : Node_Access; Left : Node_Access);
pragma Inline (Set_Left);
procedure Set_Right (Node : Node_Access; Right : Node_Access);
pragma Inline (Set_Right);
procedure Set_Color (Node : Node_Access; Color : Color_Type);
pragma Inline (Set_Color);
-----------------------
-- Local Subprograms --
-----------------------
function Copy_Node (Source : Node_Access) return Node_Access;
pragma Inline (Copy_Node);
procedure Free (X : in out Node_Access);
function Is_Equal_Node_Node
(L, R : Node_Access) return Boolean;
pragma Inline (Is_Equal_Node_Node);
function Is_Greater_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean;
pragma Inline (Is_Greater_Key_Node);
function Is_Less_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean;
pragma Inline (Is_Less_Key_Node);
--------------------------
-- Local Instantiations --
--------------------------
package Tree_Operations is
new Red_Black_Trees.Generic_Operations (Tree_Types);
procedure Delete_Tree is
new Tree_Operations.Generic_Delete_Tree (Free);
function Copy_Tree is
new Tree_Operations.Generic_Copy_Tree (Copy_Node, Delete_Tree);
use Tree_Operations;
package Key_Ops is
new Red_Black_Trees.Generic_Keys
(Tree_Operations => Tree_Operations,
Key_Type => Key_Type,
Is_Less_Key_Node => Is_Less_Key_Node,
Is_Greater_Key_Node => Is_Greater_Key_Node);
procedure Free_Key is
new Ada.Unchecked_Deallocation (Key_Type, Key_Access);
procedure Free_Element is
new Ada.Unchecked_Deallocation (Element_Type, Element_Access);
function Is_Equal is
new Tree_Operations.Generic_Equal (Is_Equal_Node_Node);
---------
-- "<" --
---------
function "<" (Left, Right : Cursor) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
end if;
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
end if;
if Checks and then Left.Node.Key = null then
raise Program_Error with "Left cursor in ""<"" is bad";
end if;
if Checks and then Right.Node.Key = null then
raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"Left cursor in ""<"" is bad");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"Right cursor in ""<"" is bad");
return Left.Node.Key.all < Right.Node.Key.all;
end "<";
function "<" (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
end if;
if Checks and then Left.Node.Key = null then
raise Program_Error with "Left cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"Left cursor in ""<"" is bad");
return Left.Node.Key.all < Right;
end "<";
function "<" (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
end if;
if Checks and then Right.Node.Key = null then
raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"Right cursor in ""<"" is bad");
return Left < Right.Node.Key.all;
end "<";
---------
-- "=" --
---------
function "=" (Left, Right : Map) return Boolean is
begin
return Is_Equal (Left.Tree, Right.Tree);
end "=";
---------
-- ">" --
---------
function ">" (Left, Right : Cursor) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor of "">"" equals No_Element";
end if;
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor of "">"" equals No_Element";
end if;
if Checks and then Left.Node.Key = null then
raise Program_Error with "Left cursor in ""<"" is bad";
end if;
if Checks and then Right.Node.Key = null then
raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"Left cursor in "">"" is bad");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"Right cursor in "">"" is bad");
return Right.Node.Key.all < Left.Node.Key.all;
end ">";
function ">" (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor of "">"" equals No_Element";
end if;
if Checks and then Left.Node.Key = null then
raise Program_Error with "Left cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"Left cursor in "">"" is bad");
return Right < Left.Node.Key.all;
end ">";
function ">" (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor of "">"" equals No_Element";
end if;
if Checks and then Right.Node.Key = null then
raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"Right cursor in "">"" is bad");
return Right.Node.Key.all < Left;
end ">";
------------
-- Adjust --
------------
procedure Adjust is new Tree_Operations.Generic_Adjust (Copy_Tree);
procedure Adjust (Container : in out Map) is
begin
Adjust (Container.Tree);
end Adjust;
------------
-- Assign --
------------
procedure Assign (Target : in out Map; Source : Map) is
procedure Insert_Item (Node : Node_Access);
pragma Inline (Insert_Item);
procedure Insert_Items is
new Tree_Operations.Generic_Iteration (Insert_Item);
-----------------
-- Insert_Item --
-----------------
procedure Insert_Item (Node : Node_Access) is
begin
Target.Insert (Key => Node.Key.all, New_Item => Node.Element.all);
end Insert_Item;
-- Start of processing for Assign
begin
if Target'Address = Source'Address then
return;
end if;
Target.Clear;
Insert_Items (Source.Tree);
end Assign;
-------------
-- Ceiling --
-------------
function Ceiling (Container : Map; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Ops.Ceiling (Container.Tree, Key);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Ceiling;
-----------
-- Clear --
-----------
procedure Clear is new Tree_Operations.Generic_Clear (Delete_Tree);
procedure Clear (Container : in out Map) is
begin
Clear (Container.Tree);
end Clear;
-----------
-- Color --
-----------
function Color (Node : Node_Access) return Color_Type is
begin
return Node.Color;
end Color;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Map;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Node has no element";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"Position cursor in Constant_Reference is bad");
declare
TC : constant Tamper_Counts_Access :=
Container.Tree.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => Position.Node.Element.all'Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Constant_Reference;
function Constant_Reference
(Container : aliased Map;
Key : Key_Type) return Constant_Reference_Type
is
Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if Checks and then Node = null then
raise Constraint_Error with "key not in map";
end if;
if Checks and then Node.Element = null then
raise Program_Error with "Node has no element";
end if;
declare
TC : constant Tamper_Counts_Access :=
Container.Tree.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => Node.Element.all'Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains (Container : Map; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= No_Element;
end Contains;
----------
-- Copy --
----------
function Copy (Source : Map) return Map is
begin
return Target : Map do
Target.Assign (Source);
end return;
end Copy;
---------------
-- Copy_Node --
---------------
function Copy_Node (Source : Node_Access) return Node_Access is
K : Key_Access := new Key_Type'(Source.Key.all);
E : Element_Access;
begin
E := new Element_Type'(Source.Element.all);
return new Node_Type'(Parent => null,
Left => null,
Right => null,
Color => Source.Color,
Key => K,
Element => E);
exception
when others =>
Free_Key (K);
Free_Element (E);
raise;
end Copy_Node;
------------
-- Delete --
------------
procedure Delete
(Container : in out Map;
Position : in out Cursor)
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor of Delete equals No_Element";
end if;
if Checks and then
(Position.Node.Key = null or else Position.Node.Element = null)
then
raise Program_Error with "Position cursor of Delete is bad";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Delete designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"Position cursor of Delete is bad");
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node);
Free (Position.Node);
Position.Container := null;
end Delete;
procedure Delete (Container : in out Map; Key : Key_Type) is
X : Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if Checks and then X = null then
raise Constraint_Error with "key not in map";
end if;
Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end Delete;
------------------
-- Delete_First --
------------------
procedure Delete_First (Container : in out Map) is
X : Node_Access := Container.Tree.First;
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end if;
end Delete_First;
-----------------
-- Delete_Last --
-----------------
procedure Delete_Last (Container : in out Map) is
X : Node_Access := Container.Tree.Last;
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end if;
end Delete_Last;
-------------
-- Element --
-------------
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor of function Element equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with
"Position cursor of function Element is bad";
end if;
if Checks
and then (Left (Position.Node) = Position.Node
or else
Right (Position.Node) = Position.Node)
then
raise Program_Error with "dangling cursor";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"Position cursor of function Element is bad");
return Position.Node.Element.all;
end Element;
function Element (Container : Map; Key : Key_Type) return Element_Type is
Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if Checks and then Node = null then
raise Constraint_Error with "key not in map";
end if;
return Node.Element.all;
end Element;
---------------------
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
begin
return (if Left < Right or else Right < Left then False else True);
end Equivalent_Keys;
-------------
-- Exclude --
-------------
procedure Exclude (Container : in out Map; Key : Key_Type) is
X : Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end if;
end Exclude;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
if Object.Container /= null then
Unbusy (Object.Container.Tree.TC);
end if;
end Finalize;
----------
-- Find --
----------
function Find (Container : Map; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
-----------
-- First --
-----------
function First (Container : Map) return Cursor is
T : Tree_Type renames Container.Tree;
begin
return (if T.First = null then No_Element
else Cursor'(Container'Unrestricted_Access, T.First));
end First;
function First (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Node component influences the
-- behavior of the First (and Last) selector function.
-- When the Node component is null, this means the iterator object was
-- constructed without a start expression, in which case the (forward)
-- iteration starts from the (logical) beginning of the entire sequence
-- of items (corresponding to Container.First for a forward iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Node component is non-null, the iterator object was constructed
-- with a start expression, that specifies the position from which the
-- (forward) partial iteration begins.
if Object.Node = null then
return Object.Container.First;
else
return Cursor'(Object.Container, Object.Node);
end if;
end First;
-------------------
-- First_Element --
-------------------
function First_Element (Container : Map) return Element_Type is
T : Tree_Type renames Container.Tree;
begin
if Checks and then T.First = null then
raise Constraint_Error with "map is empty";
end if;
return T.First.Element.all;
end First_Element;
---------------
-- First_Key --
---------------
function First_Key (Container : Map) return Key_Type is
T : Tree_Type renames Container.Tree;
begin
if Checks and then T.First = null then
raise Constraint_Error with "map is empty";
end if;
return T.First.Key.all;
end First_Key;
-----------
-- Floor --
-----------
function Floor (Container : Map; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Ops.Floor (Container.Tree, Key);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Floor;
----------
-- Free --
----------
procedure Free (X : in out Node_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
begin
if X = null then
return;
end if;
X.Parent := X;
X.Left := X;
X.Right := X;
begin
Free_Key (X.Key);
exception
when others =>
X.Key := null;
begin
Free_Element (X.Element);
exception
when others =>
X.Element := null;
end;
Deallocate (X);
raise;
end;
begin
Free_Element (X.Element);
exception
when others =>
X.Element := null;
Deallocate (X);
raise;
end;
Deallocate (X);
end Free;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Node.Element;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= No_Element;
end Has_Element;
-------------
-- Include --
-------------
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
K : Key_Access;
E : Element_Access;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if not Inserted then
TE_Check (Container.Tree.TC);
K := Position.Node.Key;
E := Position.Node.Element;
Position.Node.Key := new Key_Type'(Key);
declare
-- The element allocator may need an accessibility check in the
-- case the actual type is class-wide or has access discriminants
-- (see RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Position.Node.Element := new Element_Type'(New_Item);
exception
when others =>
Free_Key (K);
raise;
end;
Free_Key (K);
Free_Element (E);
end if;
end Include;
------------
-- Insert --
------------
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
function New_Node return Node_Access;
pragma Inline (New_Node);
procedure Insert_Post is
new Key_Ops.Generic_Insert_Post (New_Node);
procedure Insert_Sans_Hint is
new Key_Ops.Generic_Conditional_Insert (Insert_Post);
--------------
-- New_Node --
--------------
function New_Node return Node_Access is
Node : Node_Access := new Node_Type;
-- The element allocator may need an accessibility check in the case
-- the actual type is class-wide or has access discriminants (see
-- RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Node.Key := new Key_Type'(Key);
Node.Element := new Element_Type'(New_Item);
return Node;
exception
when others =>
-- On exception, deallocate key and elem. Note that free
-- deallocates both the key and the elem.
Free (Node);
raise;
end New_Node;
-- Start of processing for Insert
begin
Insert_Sans_Hint
(Container.Tree,
Key,
Position.Node,
Inserted);
Position.Container := Container'Unrestricted_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if Checks and then not Inserted then
raise Constraint_Error with "key already in map";
end if;
end Insert;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Map) return Boolean is
begin
return Container.Tree.Length = 0;
end Is_Empty;
------------------------
-- Is_Equal_Node_Node --
------------------------
function Is_Equal_Node_Node (L, R : Node_Access) return Boolean is
begin
return (if L.Key.all < R.Key.all then False
elsif R.Key.all < L.Key.all then False
else L.Element.all = R.Element.all);
end Is_Equal_Node_Node;
-------------------------
-- Is_Greater_Key_Node --
-------------------------
function Is_Greater_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean
is
begin
-- k > node same as node < k
return Right.Key.all < Left;
end Is_Greater_Key_Node;
----------------------
-- Is_Less_Key_Node --
----------------------
function Is_Less_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean is
begin
return Left < Right.Key.all;
end Is_Less_Key_Node;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Node_Access);
pragma Inline (Process_Node);
procedure Local_Iterate is
new Tree_Operations.Generic_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Node_Access) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
Busy : With_Busy (Container.Tree.TC'Unrestricted_Access);
-- Start of processing for Iterate
begin
Local_Iterate (Container.Tree);
end Iterate;
function Iterate
(Container : Map) return Map_Iterator_Interfaces.Reversible_Iterator'Class
is
begin
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
-- component is null (as is the case here), this means the iterator
-- object was constructed without a start expression. This is a complete
-- iterator, meaning that the iteration starts from the (logical)
-- beginning of the sequence of items.
-- Note: For a forward iterator, Container.First is the beginning, and
-- for a reverse iterator, Container.Last is the beginning.
return It : constant Iterator :=
(Limited_Controlled with
Container => Container'Unrestricted_Access,
Node => null)
do
Busy (Container.Tree.TC'Unrestricted_Access.all);
end return;
end Iterate;
function Iterate
(Container : Map;
Start : Cursor)
return Map_Iterator_Interfaces.Reversible_Iterator'Class
is
begin
-- It was formerly the case that when Start = No_Element, the partial
-- iterator was defined to behave the same as for a complete iterator,
-- and iterate over the entire sequence of items. However, those
-- semantics were unintuitive and arguably error-prone (it is too easy
-- to accidentally create an endless loop), and so they were changed,
-- per the ARG meeting in Denver on 2011/11. However, there was no
-- consensus about what positive meaning this corner case should have,
-- and so it was decided to simply raise an exception. This does imply,
-- however, that it is not possible to use a partial iterator to specify
-- an empty sequence of items.
if Checks and then Start = No_Element then
raise Constraint_Error with
"Start position for iterator equals No_Element";
end if;
if Checks and then Start.Container /= Container'Unrestricted_Access then
raise Program_Error with
"Start cursor of Iterate designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Start.Node),
"Start cursor of Iterate is bad");
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
-- component is non-null (as is the case here), it means that this
-- is a partial iteration, over a subset of the complete sequence of
-- items. The iterator object was constructed with a start expression,
-- indicating the position from which the iteration begins. Note that
-- the start position has the same value irrespective of whether this
-- is a forward or reverse iteration.
return It : constant Iterator :=
(Limited_Controlled with
Container => Container'Unrestricted_Access,
Node => Start.Node)
do
Busy (Container.Tree.TC'Unrestricted_Access.all);
end return;
end Iterate;
---------
-- Key --
---------
function Key (Position : Cursor) return Key_Type is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor of function Key equals No_Element";
end if;
if Checks and then Position.Node.Key = null then
raise Program_Error with
"Position cursor of function Key is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"Position cursor of function Key is bad");
return Position.Node.Key.all;
end Key;
----------
-- Last --
----------
function Last (Container : Map) return Cursor is
T : Tree_Type renames Container.Tree;
begin
return (if T.Last = null then No_Element
else Cursor'(Container'Unrestricted_Access, T.Last));
end Last;
function Last (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Node component influences the
-- behavior of the Last (and First) selector function.
-- When the Node component is null, this means the iterator object was
-- constructed without a start expression, in which case the (reverse)
-- iteration starts from the (logical) beginning of the entire sequence
-- (corresponding to Container.Last, for a reverse iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Node component is non-null, the iterator object was constructed
-- with a start expression, that specifies the position from which the
-- (reverse) partial iteration begins.
if Object.Node = null then
return Object.Container.Last;
else
return Cursor'(Object.Container, Object.Node);
end if;
end Last;
------------------
-- Last_Element --
------------------
function Last_Element (Container : Map) return Element_Type is
T : Tree_Type renames Container.Tree;
begin
if Checks and then T.Last = null then
raise Constraint_Error with "map is empty";
end if;
return T.Last.Element.all;
end Last_Element;
--------------
-- Last_Key --
--------------
function Last_Key (Container : Map) return Key_Type is
T : Tree_Type renames Container.Tree;
begin
if Checks and then T.Last = null then
raise Constraint_Error with "map is empty";
end if;
return T.Last.Key.all;
end Last_Key;
----------
-- Left --
----------
function Left (Node : Node_Access) return Node_Access is
begin
return Node.Left;
end Left;
------------
-- Length --
------------
function Length (Container : Map) return Count_Type is
begin
return Container.Tree.Length;
end Length;
----------
-- Move --
----------
procedure Move is new Tree_Operations.Generic_Move (Clear);
procedure Move (Target : in out Map; Source : in out Map) is
begin
Move (Target => Target.Tree, Source => Source.Tree);
end Move;
----------
-- Next --
----------
function Next (Position : Cursor) return Cursor is
begin
if Position = No_Element then
return No_Element;
end if;
pragma Assert (Position.Node /= null);
pragma Assert (Position.Node.Key /= null);
pragma Assert (Position.Node.Element /= null);
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"Position cursor of Next is bad");
declare
Node : constant Node_Access :=
Tree_Operations.Next (Position.Node);
begin
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Next;
procedure Next (Position : in out Cursor) is
begin
Position := Next (Position);
end Next;
function Next
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong map";
end if;
return Next (Position);
end Next;
------------
-- Parent --
------------
function Parent (Node : Node_Access) return Node_Access is
begin
return Node.Parent;
end Parent;
--------------
-- Previous --
--------------
function Previous (Position : Cursor) return Cursor is
begin
if Position = No_Element then
return No_Element;
end if;
pragma Assert (Position.Node /= null);
pragma Assert (Position.Node.Key /= null);
pragma Assert (Position.Node.Element /= null);
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"Position cursor of Previous is bad");
declare
Node : constant Node_Access :=
Tree_Operations.Previous (Position.Node);
begin
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Previous;
procedure Previous (Position : in out Cursor) is
begin
Position := Previous (Position);
end Previous;
function Previous
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Previous designates wrong map";
end if;
return Previous (Position);
end Previous;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased Map'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access :=
Container.Tree.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Busy (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : Element_Type))
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor of Query_Element equals No_Element";
end if;
if Checks and then
(Position.Node.Key = null or else Position.Node.Element = null)
then
raise Program_Error with
"Position cursor of Query_Element is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"Position cursor of Query_Element is bad");
declare
T : Tree_Type renames Position.Container.Tree;
Lock : With_Lock (T.TC'Unrestricted_Access);
K : Key_Type renames Position.Node.Key.all;
E : Element_Type renames Position.Node.Element.all;
begin
Process (K, E);
end;
end Query_Element;
---------------
-- Put_Image --
---------------
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Map)
is
First_Time : Boolean := True;
use System.Put_Images;
procedure Put_Key_Value (Position : Cursor);
procedure Put_Key_Value (Position : Cursor) is
begin
if First_Time then
First_Time := False;
else
Simple_Array_Between (S);
end if;
Key_Type'Put_Image (S, Key (Position));
Put_Arrow (S);
Element_Type'Put_Image (S, Element (Position));
end Put_Key_Value;
begin
Array_Before (S);
Iterate (V, Put_Key_Value'Access);
Array_After (S);
end Put_Image;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Map)
is
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Node_Access;
pragma Inline (Read_Node);
procedure Read is
new Tree_Operations.Generic_Read (Clear, Read_Node);
---------------
-- Read_Node --
---------------
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Node_Access
is
Node : Node_Access := new Node_Type;
begin
Node.Key := new Key_Type'(Key_Type'Input (Stream));
Node.Element := new Element_Type'(Element_Type'Input (Stream));
return Node;
exception
when others =>
Free (Node); -- Note that Free deallocates key and elem too
raise;
end Read_Node;
-- Start of processing for Read
begin
Read (Stream, Container.Tree);
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
---------------
-- Reference --
---------------
function Reference
(Container : aliased in out Map;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Node has no element";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"Position cursor in function Reference is bad");
declare
TC : constant Tamper_Counts_Access :=
Container.Tree.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => Position.Node.Element.all'Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Reference;
function Reference
(Container : aliased in out Map;
Key : Key_Type) return Reference_Type
is
Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
begin
if Checks and then Node = null then
raise Constraint_Error with "key not in map";
end if;
if Checks and then Node.Element = null then
raise Program_Error with "Node has no element";
end if;
declare
TC : constant Tamper_Counts_Access :=
Container.Tree.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => Node.Element.all'Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Reference;
-------------
-- Replace --
-------------
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
K : Key_Access;
E : Element_Access;
begin
TE_Check (Container.Tree.TC);
if Checks and then Node = null then
raise Constraint_Error with "key not in map";
end if;
K := Node.Key;
E := Node.Element;
Node.Key := new Key_Type'(Key);
declare
-- The element allocator may need an accessibility check in the case
-- the actual type is class-wide or has access discriminants (see
-- RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Node.Element := new Element_Type'(New_Item);
exception
when others =>
Free_Key (K);
raise;
end;
Free_Key (K);
Free_Element (E);
end Replace;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type)
is
begin
TE_Check (Container.Tree.TC);
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor of Replace_Element equals No_Element";
end if;
if Checks and then
(Position.Node.Key = null or else Position.Node.Element = null)
then
raise Program_Error with
"Position cursor of Replace_Element is bad";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Replace_Element designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"Position cursor of Replace_Element is bad");
declare
X : Element_Access := Position.Node.Element;
-- The element allocator may need an accessibility check in the case
-- the actual type is class-wide or has access discriminants (see
-- RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Position.Node.Element := new Element_Type'(New_Item);
Free_Element (X);
end;
end Replace_Element;
---------------------
-- Reverse_Iterate --
---------------------
procedure Reverse_Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Node_Access);
pragma Inline (Process_Node);
procedure Local_Reverse_Iterate is
new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Node_Access) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
Busy : With_Busy (Container.Tree.TC'Unrestricted_Access);
-- Start of processing for Reverse_Iterate
begin
Local_Reverse_Iterate (Container.Tree);
end Reverse_Iterate;
-----------
-- Right --
-----------
function Right (Node : Node_Access) return Node_Access is
begin
return Node.Right;
end Right;
---------------
-- Set_Color --
---------------
procedure Set_Color (Node : Node_Access; Color : Color_Type) is
begin
Node.Color := Color;
end Set_Color;
--------------
-- Set_Left --
--------------
procedure Set_Left (Node : Node_Access; Left : Node_Access) is
begin
Node.Left := Left;
end Set_Left;
----------------
-- Set_Parent --
----------------
procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is
begin
Node.Parent := Parent;
end Set_Parent;
---------------
-- Set_Right --
---------------
procedure Set_Right (Node : Node_Access; Right : Node_Access) is
begin
Node.Right := Right;
end Set_Right;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type))
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor of Update_Element equals No_Element";
end if;
if Checks and then
(Position.Node.Key = null or else Position.Node.Element = null)
then
raise Program_Error with
"Position cursor of Update_Element is bad";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Update_Element designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"Position cursor of Update_Element is bad");
declare
T : Tree_Type renames Position.Container.Tree;
Lock : With_Lock (T.TC'Unrestricted_Access);
K : Key_Type renames Position.Node.Key.all;
E : Element_Type renames Position.Node.Element.all;
begin
Process (K, E);
end;
end Update_Element;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Map)
is
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Access);
pragma Inline (Write_Node);
procedure Write is
new Tree_Operations.Generic_Write (Write_Node);
----------------
-- Write_Node --
----------------
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Access)
is
begin
Key_Type'Output (Stream, Node.Key.all);
Element_Type'Output (Stream, Node.Element.all);
end Write_Node;
-- Start of processing for Write
begin
Write (Stream, Container.Tree);
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Indefinite_Ordered_Maps;
|
AdaCore/training_material | Ada | 3,942 | adb | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2009, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this program; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with Solar_System; use Solar_System;
with Solar_System.Button; use Solar_System.Button;
with Display; use Display;
with Display.Basic; use Display.Basic;
with Solar_System.Graphics; use Solar_System.Graphics;
with Last_Chance_Handler;
procedure Main is
-- declare a variable Now of type Time to record current time
Now : Time;
-- declare a constant Period of 40 milliseconds of type Time_Span defining the loop period
Period : constant Time_Span := Milliseconds (40);
-- reference to the application window
Window : Window_ID;
begin
-- Create the main window
Window :=
Create_Window (Width => 240, Height => 320, Name => "Solar System");
Graphic_Context.Set_Window (Window);
-- initialize Bodies using Init_Body procedure
Init_Body
(B => Sun,
Radius => 20.0,
Color => Yellow,
Distance => 0.0,
Speed => 0.0,
Turns_Around => Sun);
Init_Body
(B => Earth,
Radius => 5.0,
Color => Blue,
Distance => 50.0,
Speed => 0.02,
Turns_Around => Sun);
Init_Body
(B => Moon,
Radius => 2.0,
Color => Gray,
Distance => 15.0,
Speed => 0.04,
Turns_Around => Earth);
Init_Body
(B => Satellite,
Radius => 1.0,
Color => Red,
Distance => 8.0,
Speed => 0.1,
Turns_Around => Earth);
Init_Body
(B => Comet,
Radius => 1.0,
Color => Yellow,
Distance => 80.0,
Speed => 0.05,
Tail => True,
Turns_Around => Sun);
Init_Body
(B => Black_Hole,
Radius => 0.0,
Color => Blue,
Distance => 75.0,
Speed => -0.02,
Turns_Around => Sun,
Visible => False);
Init_Body
(B => Asteroid_1,
Radius => 2.0,
Color => Green,
Distance => 5.0,
Speed => 0.1,
Turns_Around => Black_Hole);
Init_Body
(B => Asteroid_2,
Radius => 2.0,
Color => Blue,
Distance => 5.0,
Speed => 0.1,
Angle => 1.57,
Turns_Around => Black_Hole);
-- create an infinite loop
-- update the Now time with current clock
-- wait until Now + Period time elapsed before the next
loop
Now := Clock;
delay until Now + Period;
end loop;
end Main;
|
leonhxx/pok | Ada | 4,744 | ads | -- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2021 POK team
-- ---------------------------------------------------------------------------
-- --
-- PROCESS constant and type definitions and management services --
-- --
-- ---------------------------------------------------------------------------
package APEX.Processes is
Max_Number_Of_Processes : constant := System_Limit_Number_Of_Processes;
Min_Priority_Value : constant := 0;
Max_Priority_Value : constant := 249;
Max_Lock_Level : constant := 32;
subtype Process_Name_Type is Name_Type;
type Process_Id_Type is private;
Null_Process_Id : constant Process_Id_Type;
subtype Lock_Level_Type is APEX_Integer range 0 .. Max_Lock_Level;
subtype Stack_Size_Type is APEX_Unsigned;
subtype Waiting_Range_Type is APEX_Integer range
0 .. Max_Number_Of_Processes;
subtype Priority_Type is APEX_Integer range
Min_Priority_Value .. Max_Priority_Value;
type Process_State_Type is (Dormant, Ready, Running, Waiting);
type Deadline_Type is (Soft, Hard);
type Process_Attribute_Type is record
Period : System_Time_Type;
Time_Capacity : System_Time_Type;
Entry_Point : System_Address_Type;
Stack_Size : Stack_Size_Type;
Base_Priority : Priority_Type;
Deadline : Deadline_Type;
Name : Process_Name_Type;
end record;
type Process_Status_Type is record
Deadline_Time : System_Time_Type;
Current_Priority : Priority_Type;
Process_State : Process_State_Type;
Attributes : Process_Attribute_Type;
end record;
procedure Create_Process
(Attributes : in Process_Attribute_Type;
Process_Id : out Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Set_Priority
(Process_Id : in Process_Id_Type;
Priority : in Priority_Type;
Return_Code : out Return_Code_Type);
procedure Suspend_Self
(Time_Out : in System_Time_Type;
Return_Code : out Return_Code_Type);
procedure Suspend
(Process_Id : in Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Resume
(Process_Id : in Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Stop_Self;
procedure Stop
(Process_Id : in Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Start
(Process_Id : in Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Delayed_Start
(Process_Id : in Process_Id_Type;
Delay_Time : in System_Time_Type;
Return_Code : out Return_Code_Type);
procedure Lock_Preemption
(Lock_Level : out Lock_Level_Type;
Return_Code : out Return_Code_Type);
procedure Unlock_Preemption
(Lock_Level : out Lock_Level_Type;
Return_Code : out Return_Code_Type);
procedure Get_My_Id
(Process_Id : out Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Get_Process_Id
(Process_Name : in Process_Name_Type;
Process_Id : out Process_Id_Type;
Return_Code : out Return_Code_Type);
procedure Get_Process_Status
(Process_Id : in Process_Id_Type;
Process_Status : out Process_Status_Type;
Return_Code : out Return_Code_Type);
private
type Process_ID_Type is new APEX_Integer;
Null_Process_Id : constant Process_Id_Type := 0;
pragma Convention (C, Process_State_Type);
pragma Convention (C, Deadline_Type);
pragma Convention (C, Process_Attribute_Type);
pragma Convention (C, Process_Status_Type);
-- POK BINDINGS
pragma Import (C, Create_Process, "CREATE_PROCESS");
pragma Import (C, Set_Priority, "SET_PRIORITY");
pragma Import (C, Suspend_Self, "SUSPEND_SELF");
pragma Import (C, Suspend, "SUSPEND");
pragma Import (C, Resume, "SUSPEND");
pragma Import (C, Stop_Self, "STOP_SELF");
pragma Import (C, Stop, "STOP");
pragma Import (C, Start, "START");
pragma Import (C, Delayed_Start, "DELAYED_START");
pragma Import (C, Lock_Preemption, "LOCK_PREEMPTION");
pragma Import (C, Unlock_Preemption, "UNLOCK_PREEMPTION");
pragma Import (C, Get_My_Id, "GET_MY_ID");
pragma Import (C, Get_Process_Id, "GET_PROCESS_ID");
pragma Import (C, Get_Process_Status, "GET_PROCESS_STATUS");
-- END OF POK BINDINGS
end APEX.Processes;
|
sungyeon/drake | Ada | 34 | ads | ../machine-pc-freebsd/s-ndfina.ads |
zhmu/ananas | Ada | 201 | adb | with Ada.Text_IO; use Ada.Text_IO;
package body Assertion_Policy1_Pkg is
procedure Proc (Low : Integer; High : Integer) is
begin
Put_Line ("Proc");
end Proc;
end Assertion_Policy1_Pkg;
|
Letractively/ada-el | Ada | 3,458 | adb | -----------------------------------------------------------------------
-- EL.Functions -- Default function mapper
-- Copyright (C) 2009, 2010 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- The default function mapper allows to register
-- The expression context provides information to resolve runtime
-- information when evaluating an expression. The context provides
-- a resolver whose role is to find variables given their name.
package body EL.Functions.Default is
-- ------------------------------
-- Default Function mapper
-- ------------------------------
--
use Function_Maps;
-- ------------------------------
-- Find the function knowing its name.
-- ------------------------------
function Get_Function (Mapper : Default_Function_Mapper;
Namespace : String;
Name : String) return Function_Access is
Full_Name : constant String := Namespace & ":" & Name;
C : constant Cursor := Mapper.Map.Find (Key => To_Unbounded_String (Full_Name));
begin
if Has_Element (C) then
return Element (C);
end if;
raise No_Function with "Function '" & Full_Name & "' not found";
end Get_Function;
-- ------------------------------
-- Bind a name to a function.
-- ------------------------------
procedure Set_Function (Mapper : in out Default_Function_Mapper;
Namespace : in String;
Name : in String;
Func : in Function_Access) is
Full_Name : constant String := Namespace & ":" & Name;
begin
Mapper.Map.Include (Key => To_Unbounded_String (Full_Name), New_Item => Func);
end Set_Function;
-- ------------------------------
-- Truncate the string representation represented by <b>Value</b> to
-- the length specified by <b>Size</b>.
-- ------------------------------
function Truncate (Value : EL.Objects.Object;
Size : EL.Objects.Object) return EL.Objects.Object is
Cnt : constant Integer := To_Integer (Size);
begin
if Cnt <= 0 then
return To_Object (String '(""));
end if;
if Get_Type (Value) = TYPE_WIDE_STRING then
declare
S : constant Wide_Wide_String := To_Wide_Wide_String (Value);
begin
return To_Object (S (1 .. Cnt));
end;
else
-- Optimized case: use a String if we can.
declare
S : constant String := To_String (Value);
begin
return To_Object (S (1 .. Cnt));
end;
end if;
end Truncate;
end EL.Functions.Default;
|
reznikmm/matreshka | Ada | 4,696 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Chart.Include_Hidden_Cells_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Include_Hidden_Cells_Attribute_Node is
begin
return Self : Chart_Include_Hidden_Cells_Attribute_Node do
Matreshka.ODF_Chart.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Chart_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Chart_Include_Hidden_Cells_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Include_Hidden_Cells_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Chart_URI,
Matreshka.ODF_String_Constants.Include_Hidden_Cells_Attribute,
Chart_Include_Hidden_Cells_Attribute_Node'Tag);
end Matreshka.ODF_Chart.Include_Hidden_Cells_Attributes;
|
godunko/adawebui | Ada | 3,507 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2018-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 5870 $ $Date: 2018-09-22 11:46:16 +0200 (Sat, 22 Sep 2018) $
------------------------------------------------------------------------------
with Web.UI.Slots.Widgets.Widgets;
package Web.UI.Widgets_Widgets_Slots renames Web.UI.Slots.Widgets.Widgets;
|
reznikmm/matreshka | Ada | 18,624 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A classifier is a classification of instances - it describes a set of
-- instances that have features in common. A classifier can specify a
-- generalization hierarchy by referencing its general classifiers.
--
-- A classifier has the capability to own collaboration uses. These
-- collaboration uses link a collaboration with the classifier to give a
-- description of the workings of the classifier.
--
-- Classifier is defined to be a kind of templateable element so that a
-- classifier can be parameterized. It is also defined to be a kind of
-- parameterable element so that a classifier can be a formal template
-- parameter.
--
-- A classifier has the capability to own use cases. Although the owning
-- classifier typically represents the subject to which the owned use cases
-- apply, this is not necessarily the case. In principle, the same use case
-- can be applied to multiple subjects, as identified by the subject
-- association role of a use case.
------------------------------------------------------------------------------
limited with AMF.UML.Classifier_Template_Parameters;
limited with AMF.UML.Classifiers.Collections;
limited with AMF.UML.Collaboration_Uses.Collections;
limited with AMF.UML.Features.Collections;
limited with AMF.UML.Generalization_Sets.Collections;
limited with AMF.UML.Generalizations.Collections;
limited with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
limited with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements;
limited with AMF.UML.Redefinable_Template_Signatures;
limited with AMF.UML.Substitutions.Collections;
with AMF.UML.Templateable_Elements;
with AMF.UML.Types;
limited with AMF.UML.Use_Cases.Collections;
package AMF.UML.Classifiers is
pragma Preelaborate;
type UML_Classifier is limited interface
and AMF.UML.Namespaces.UML_Namespace
and AMF.UML.Types.UML_Type
and AMF.UML.Templateable_Elements.UML_Templateable_Element
and AMF.UML.Redefinable_Elements.UML_Redefinable_Element;
type UML_Classifier_Access is
access all UML_Classifier'Class;
for UML_Classifier_Access'Storage_Size use 0;
not overriding function Get_Attribute
(Self : not null access constant UML_Classifier)
return AMF.UML.Properties.Collections.Set_Of_UML_Property is abstract;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
not overriding function Get_Collaboration_Use
(Self : not null access constant UML_Classifier)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use is abstract;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
not overriding function Get_Feature
(Self : not null access constant UML_Classifier)
return AMF.UML.Features.Collections.Set_Of_UML_Feature is abstract;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
not overriding function Get_General
(Self : not null access constant UML_Classifier)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is abstract;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
not overriding function Get_Generalization
(Self : not null access constant UML_Classifier)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization is abstract;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
not overriding function Get_Inherited_Member
(Self : not null access constant UML_Classifier)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
not overriding function Get_Is_Abstract
(Self : not null access constant UML_Classifier)
return Boolean is abstract;
-- Getter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
not overriding procedure Set_Is_Abstract
(Self : not null access UML_Classifier;
To : Boolean) is abstract;
-- Setter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
not overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Classifier)
return Boolean is abstract;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
not overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Classifier;
To : Boolean) is abstract;
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
not overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Classifier)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access is abstract;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
not overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Classifier;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access) is abstract;
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
not overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Classifier)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is abstract;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
not overriding function Get_Powertype_Extent
(Self : not null access constant UML_Classifier)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set is abstract;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
not overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Classifier)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is abstract;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
not overriding function Get_Representation
(Self : not null access constant UML_Classifier)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access is abstract;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
not overriding procedure Set_Representation
(Self : not null access UML_Classifier;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access) is abstract;
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
not overriding function Get_Substitution
(Self : not null access constant UML_Classifier)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution is abstract;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
not overriding function Get_Template_Parameter
(Self : not null access constant UML_Classifier)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access is abstract;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
not overriding procedure Set_Template_Parameter
(Self : not null access UML_Classifier;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access) is abstract;
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
not overriding function Get_Use_Case
(Self : not null access constant UML_Classifier)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is abstract;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
not overriding function All_Features
(Self : not null access constant UML_Classifier)
return AMF.UML.Features.Collections.Set_Of_UML_Feature is abstract;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
not overriding function All_Parents
(Self : not null access constant UML_Classifier)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is abstract;
-- Operation Classifier::allParents.
--
-- The query allParents() gives all of the direct and indirect ancestors
-- of a generalized Classifier.
not overriding function Conforms_To
(Self : not null access constant UML_Classifier;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean is abstract;
-- Operation Classifier::conformsTo.
--
-- The query conformsTo() gives true for a classifier that defines a type
-- that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
not overriding function General
(Self : not null access constant UML_Classifier)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is abstract;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
not overriding function Has_Visibility_Of
(Self : not null access constant UML_Classifier;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean is abstract;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
not overriding function Inherit
(Self : not null access constant UML_Classifier;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Operation Classifier::inherit.
--
-- The query inherit() defines how to inherit a set of elements. Here the
-- operation is defined to inherit them all. It is intended to be
-- redefined in circumstances where inheritance is affected by
-- redefinition.
-- The inherit operation is overridden to exclude redefined properties.
not overriding function Inheritable_Members
(Self : not null access constant UML_Classifier;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
not overriding function Inherited_Member
(Self : not null access constant UML_Classifier)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Classifier)
return Boolean is abstract;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
not overriding function May_Specialize_Type
(Self : not null access constant UML_Classifier;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean is abstract;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
not overriding function Parents
(Self : not null access constant UML_Classifier)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is abstract;
-- Operation Classifier::parents.
--
-- The query parents() gives all of the immediate ancestors of a
-- generalized Classifier.
end AMF.UML.Classifiers;
|
pchapin/augusta | Ada | 116 | adb | begin
X := (A + B) * C;
X := ((A + B)/C + D);
X := ((A + B)/(C + D));
X := ((A + B)/(C + D)) / E;
end
|
zhmu/ananas | Ada | 13,395 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S T R I N G T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Alloc;
with Output; use Output;
with Table;
package body Stringt is
-- The following table stores the sequence of character codes for the
-- stored string constants. The entries are referenced from the
-- separate Strings table.
package String_Chars is new Table.Table (
Table_Component_Type => Char_Code,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => Alloc.String_Chars_Initial,
Table_Increment => Alloc.String_Chars_Increment,
Table_Name => "String_Chars");
-- The String_Id values reference entries in the Strings table, which
-- contains String_Entry records that record the length of each stored
-- string and its starting location in the String_Chars table.
type String_Entry is record
String_Index : Int;
Length : Nat;
end record;
package Strings is new Table.Table (
Table_Component_Type => String_Entry,
Table_Index_Type => String_Id'Base,
Table_Low_Bound => First_String_Id,
Table_Initial => Alloc.Strings_Initial,
Table_Increment => Alloc.Strings_Increment,
Table_Name => "Strings");
-- Note: it is possible that two entries in the Strings table can share
-- string data in the String_Chars table, and in particular this happens
-- when Start_String is called with a parameter that is the last string
-- currently allocated in the table.
Strings_Last : String_Id := First_String_Id;
String_Chars_Last : Int := 0;
-- Strings_Last and String_Chars_Last are used by procedure Mark and
-- Release to get a snapshot of the tables and to restore them to their
-- previous situation.
------------
-- Append --
------------
procedure Append (Buf : in out Bounded_String; S : String_Id) is
begin
for X in 1 .. String_Length (S) loop
Append (Buf, Get_Character (Get_String_Char (S, X)));
end loop;
end Append;
----------------
-- End_String --
----------------
function End_String return String_Id is
begin
return Strings.Last;
end End_String;
---------------------
-- Get_String_Char --
---------------------
function Get_String_Char (Id : String_Id; Index : Int) return Char_Code is
begin
pragma Assert (Id in First_String_Id .. Strings.Last
and then Index in 1 .. Strings.Table (Id).Length);
return String_Chars.Table (Strings.Table (Id).String_Index + Index - 1);
end Get_String_Char;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
String_Chars.Init;
Strings.Init;
-- Set up the null string
Start_String;
Null_String_Id := End_String;
end Initialize;
----------
-- Lock --
----------
procedure Lock is
begin
String_Chars.Release;
String_Chars.Locked := True;
Strings.Release;
Strings.Locked := True;
end Lock;
----------
-- Mark --
----------
procedure Mark is
begin
Strings_Last := Strings.Last;
String_Chars_Last := String_Chars.Last;
end Mark;
-------------
-- Release --
-------------
procedure Release is
begin
Strings.Set_Last (Strings_Last);
String_Chars.Set_Last (String_Chars_Last);
end Release;
------------------
-- Start_String --
------------------
-- Version to start completely new string
procedure Start_String is
begin
Strings.Append ((String_Index => String_Chars.Last + 1, Length => 0));
end Start_String;
-- Version to start from initially stored string
procedure Start_String (S : String_Id) is
begin
Strings.Increment_Last;
-- Case of initial string value is at the end of the string characters
-- table, so it does not need copying, instead it can be shared.
if Strings.Table (S).String_Index + Strings.Table (S).Length =
String_Chars.Last + 1
then
Strings.Table (Strings.Last).String_Index :=
Strings.Table (S).String_Index;
-- Case of initial string value must be copied to new string
else
Strings.Table (Strings.Last).String_Index :=
String_Chars.Last + 1;
for J in 1 .. Strings.Table (S).Length loop
String_Chars.Append
(String_Chars.Table (Strings.Table (S).String_Index + (J - 1)));
end loop;
end if;
-- In either case the result string length is copied from the argument
Strings.Table (Strings.Last).Length := Strings.Table (S).Length;
end Start_String;
-----------------------
-- Store_String_Char --
-----------------------
procedure Store_String_Char (C : Char_Code) is
begin
String_Chars.Append (C);
Strings.Table (Strings.Last).Length :=
Strings.Table (Strings.Last).Length + 1;
end Store_String_Char;
procedure Store_String_Char (C : Character) is
begin
Store_String_Char (Get_Char_Code (C));
end Store_String_Char;
------------------------
-- Store_String_Chars --
------------------------
procedure Store_String_Chars (S : String) is
begin
for J in S'First .. S'Last loop
Store_String_Char (Get_Char_Code (S (J)));
end loop;
end Store_String_Chars;
procedure Store_String_Chars (S : String_Id) is
-- We are essentially doing this:
-- for J in 1 .. String_Length (S) loop
-- Store_String_Char (Get_String_Char (S, J));
-- end loop;
-- but when the string is long it's more efficient to grow the
-- String_Chars table all at once.
S_First : constant Int := Strings.Table (S).String_Index;
S_Len : constant Nat := String_Length (S);
Old_Last : constant Int := String_Chars.Last;
New_Last : constant Int := Old_Last + S_Len;
begin
String_Chars.Set_Last (New_Last);
String_Chars.Table (Old_Last + 1 .. New_Last) :=
String_Chars.Table (S_First .. S_First + S_Len - 1);
Strings.Table (Strings.Last).Length :=
Strings.Table (Strings.Last).Length + S_Len;
end Store_String_Chars;
----------------------
-- Store_String_Int --
----------------------
procedure Store_String_Int (N : Int) is
begin
if N < 0 then
Store_String_Char ('-');
Store_String_Int (-N);
else
if N > 9 then
Store_String_Int (N / 10);
end if;
Store_String_Char (Character'Val (Character'Pos ('0') + N mod 10));
end if;
end Store_String_Int;
--------------------------
-- String_Chars_Address --
--------------------------
function String_Chars_Address return System.Address is
begin
return String_Chars.Table (0)'Address;
end String_Chars_Address;
------------------
-- String_Equal --
------------------
function String_Equal (L, R : String_Id) return Boolean is
Len : constant Nat := Strings.Table (L).Length;
begin
if Len /= Strings.Table (R).Length then
return False;
else
for J in 1 .. Len loop
if Get_String_Char (L, J) /= Get_String_Char (R, J) then
return False;
end if;
end loop;
return True;
end if;
end String_Equal;
-----------------------------
-- String_From_Name_Buffer --
-----------------------------
function String_From_Name_Buffer
(Buf : Bounded_String := Global_Name_Buffer) return String_Id
is
begin
Start_String;
Store_String_Chars (+Buf);
return End_String;
end String_From_Name_Buffer;
-------------------
-- String_Length --
-------------------
function String_Length (Id : String_Id) return Nat is
begin
return Strings.Table (Id).Length;
end String_Length;
--------------------
-- String_To_Name --
--------------------
function String_To_Name (S : String_Id) return Name_Id is
Buf : Bounded_String;
begin
Append (Buf, S);
return Name_Find (Buf);
end String_To_Name;
---------------------------
-- String_To_Name_Buffer --
---------------------------
procedure String_To_Name_Buffer (S : String_Id) is
begin
Name_Len := 0;
Append (Global_Name_Buffer, S);
end String_To_Name_Buffer;
---------------------
-- Strings_Address --
---------------------
function Strings_Address return System.Address is
begin
return Strings.Table (First_String_Id)'Address;
end Strings_Address;
---------------
-- To_String --
---------------
function To_String (S : String_Id) return String is
Buf : Bounded_String;
begin
Append (Buf, S);
return To_String (Buf);
end To_String;
------------
-- Unlock --
------------
procedure Unlock is
begin
String_Chars.Locked := False;
Strings.Locked := False;
end Unlock;
-------------------------
-- Unstore_String_Char --
-------------------------
procedure Unstore_String_Char is
begin
String_Chars.Decrement_Last;
Strings.Table (Strings.Last).Length :=
Strings.Table (Strings.Last).Length - 1;
end Unstore_String_Char;
---------------------
-- Write_Char_Code --
---------------------
procedure Write_Char_Code (Code : Char_Code) is
procedure Write_Hex_Byte (J : Char_Code);
-- Write single hex byte (value in range 0 .. 255) as two digits
--------------------
-- Write_Hex_Byte --
--------------------
procedure Write_Hex_Byte (J : Char_Code) is
Hexd : constant array (Char_Code range 0 .. 15) of Character :=
"0123456789abcdef";
begin
Write_Char (Hexd (J / 16));
Write_Char (Hexd (J mod 16));
end Write_Hex_Byte;
-- Start of processing for Write_Char_Code
begin
if Code in 16#20# .. 16#7E# then
Write_Char (Character'Val (Code));
else
Write_Char ('[');
Write_Char ('"');
if Code > 16#FF_FFFF# then
Write_Hex_Byte (Code / 2 ** 24);
end if;
if Code > 16#FFFF# then
Write_Hex_Byte ((Code / 2 ** 16) mod 256);
end if;
if Code > 16#FF# then
Write_Hex_Byte ((Code / 256) mod 256);
end if;
Write_Hex_Byte (Code mod 256);
Write_Char ('"');
Write_Char (']');
end if;
end Write_Char_Code;
------------------------------
-- Write_String_Table_Entry --
------------------------------
procedure Write_String_Table_Entry (Id : String_Id) is
C : Char_Code;
begin
if Id = No_String then
Write_Str ("no string");
else
Write_Char ('"');
for J in 1 .. String_Length (Id) loop
C := Get_String_Char (Id, J);
if C = Character'Pos ('"') then
Write_Str ("""""");
else
Write_Char_Code (C);
end if;
-- If string is very long, quit
if J >= 1000 then -- arbitrary limit
Write_Str ("""...etc (length = ");
Write_Int (String_Length (Id));
Write_Str (")");
return;
end if;
end loop;
Write_Char ('"');
end if;
end Write_String_Table_Entry;
end Stringt;
|
reznikmm/matreshka | Ada | 3,739 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Used_Hierarchy_Attributes is
pragma Preelaborate;
type ODF_Table_Used_Hierarchy_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Used_Hierarchy_Attribute_Access is
access all ODF_Table_Used_Hierarchy_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Used_Hierarchy_Attributes;
|
reznikmm/gela | Ada | 11,551 | adb | ------------------------------------------------------------------------------
-- G E L A G R A M M A R S --
-- Library for dealing with tests for for Gela project, --
-- a portable Ada compiler --
-- http://gela.ada-ru.org/ --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license in gela.ads file --
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Directories;
with Ada.Streams;
with Ada.Wide_Wide_Text_IO;
with GNAT.OS_Lib;
with GNAT.Source_Info;
with Interfaces.C.Strings;
with League.Application;
with League.Text_Codecs;
with League.Stream_Element_Vectors;
package body Gela.Host is
use League.Strings;
function "+"
(Text : Wide_Wide_String)
return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
Is_Windows : constant Boolean :=
League.Application.Environment.Value (+"OS") = +"Windows_NT";
Suffixes : constant array (Boolean) of League.Strings.Universal_String :=
(False => League.Strings.Empty_Universal_String,
True => +".exe");
Exe_Suffix : constant League.Strings.Universal_String :=
Suffixes (Is_Windows);
Verbose : constant Boolean :=
not League.Application.Arguments.Is_Empty and then
League.Application.Arguments.Element (1).Starts_With ("-v");
Build_Root_Value : League.Strings.Universal_String;
Source_Root_Value : League.Strings.Universal_String;
function Is_Absolute_Path
(File : League.Strings.Universal_String)
return Boolean;
function To_C
(Text : League.Strings.Universal_String)
return Interfaces.C.Strings.chars_ptr;
procedure Error_Exit
(Output : GNAT.OS_Lib.File_Descriptor;
Name : String);
-- Print errno code and exit
----------------
-- Error_Exit --
----------------
procedure Error_Exit
(Output : GNAT.OS_Lib.File_Descriptor;
Name : String)
is
Ignore : Integer;
pragma Unreferenced (Ignore);
Error : constant String := Name & " failed:"
& Integer'Image (GNAT.OS_Lib.Errno)
& ASCII.LF;
begin
Ignore := GNAT.OS_Lib.Write
(Output, Error (1)'Address, Error'Length);
GNAT.OS_Lib.OS_Exit (-1);
end Error_Exit;
-------------
-- Execute --
-------------
procedure Execute
(Command : League.Strings.Universal_String;
Arguments : League.String_Vectors.Universal_String_Vector :=
League.String_Vectors.Empty_Universal_String_Vector;
Exit_Code : out Integer;
Output : out League.Strings.Universal_String;
Directory : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
is
use Interfaces;
use type C.int;
use type C.Strings.chars_ptr;
type File_Discriptor_Pair is
array (0 .. 1) of GNAT.OS_Lib.File_Descriptor;
function pipe2
(FD : out File_Discriptor_Pair; Flags : C.int) return C.int;
pragma Import (C, pipe2, "pipe2");
O_CLOEXEC : constant := 8#2000000#;
procedure dup2
(oldfd : GNAT.OS_Lib.File_Descriptor;
newfd : GNAT.OS_Lib.File_Descriptor);
pragma Import (C, dup2, "dup2");
function fork return C.int;
pragma Import (C, fork, "fork");
function chdir (Path : C.Strings.chars_ptr) return C.int;
pragma Import (C, chdir, "chdir");
type char_prt_array is array (Natural range <>) of C.Strings.chars_ptr;
procedure execvp
(Path : C.Strings.chars_ptr;
Args : char_prt_array);
pragma Import (C, execvp, "execvp");
procedure waitpid
(PID : C.int;
Status : out C.int;
Option : C.int);
pragma Import (C, waitpid, "waitpid");
Args : char_prt_array (0 .. Arguments.Length + 1);
Dir : C.Strings.chars_ptr := To_C (Directory);
PID : C.int;
Result : C.int;
Input : File_Discriptor_Pair; -- Input of child process
Output1 : File_Discriptor_Pair; -- Output of child process
Exe : constant League.Strings.Universal_String := Command & Exe_Suffix;
Exec : GNAT.OS_Lib.String_Access;
Text : League.Strings.Universal_String;
begin
if not Is_Absolute_Path (Exe) and not Is_Windows then
Exec := GNAT.OS_Lib.Locate_Exec_On_Path (Exe.To_UTF_8_String);
else
Exec := new String'(Exe.To_UTF_8_String);
end if;
Text := League.Strings.From_UTF_8_String (Exec.all);
Text.Append (' ');
Text.Append (Arguments.Join (' '));
if not Directory.Is_Empty then
Ada.Directories.Set_Directory (Directory.To_UTF_8_String);
Text.Append (" [ in ");
Text.Append (Directory);
Text.Append ("]");
end if;
if Verbose then
Ada.Wide_Wide_Text_IO.Put_Line (Text.To_Wide_Wide_String);
end if;
if pipe2 (FD => Output1, Flags => O_CLOEXEC) = -1 then
raise Program_Error with "pipe (output) failed";
end if;
if pipe2 (FD => Input, Flags => O_CLOEXEC) = -1 then
raise Program_Error with "pipe (input) failed";
end if;
Args (0) := To_C (Exe);
for J in 1 .. Arguments.Length loop
Args (J) := To_C (Arguments.Element (J));
end loop;
Args (Arguments.Length + 1) := C.Strings.Null_Ptr;
PID := fork;
-- Child.stdin := Input (1);
-- Child.stdout := Output (0);
if PID = 0 then
-- Please no more tricks with controlled values after fork here
if Dir = C.Strings.Null_Ptr or else chdir (Dir) /= -1 then
GNAT.OS_Lib.Close (Input (1));
GNAT.OS_Lib.Close (Output1 (0));
dup2 (newfd => 0, oldfd => Input (0));
dup2 (newfd => 1, oldfd => Output1 (1));
dup2 (newfd => 2, oldfd => Output1 (1));
execvp (Args (0), Args);
-- We are here only if error occured. Print Errno and exit
declare
Name : constant String := "execvp ("
& C.Strings.Value (Args (0)) & ")";
begin
Error_Exit (Output1 (1), Name);
end;
else
-- chdir failed. Print Errno and exit
Error_Exit (Output1 (1), "chdir");
end if;
elsif PID = -1 then
Error_Exit (2, "fork");
else
C.Strings.Free (Dir);
for Arg of Args loop
C.Strings.Free (Arg);
end loop;
GNAT.OS_Lib.Close (Input (0));
GNAT.OS_Lib.Close (Output1 (1));
declare
Data : League.Stream_Element_Vectors.Stream_Element_Vector;
Codec : constant League.Text_Codecs.Text_Codec :=
League.Text_Codecs.Codec_For_Application_Locale;
Buffer : Ada.Streams.Stream_Element_Array (1 .. 1024);
Count : Integer;
begin
loop
Count := GNAT.OS_Lib.Read
(Output1 (0), Buffer (1)'Address, Buffer'Length);
exit when Count <= 0;
Data.Append
(Buffer (1 .. Ada.Streams.Stream_Element_Offset (Count)));
end loop;
Output.Append (Codec.Decode (Data));
GNAT.OS_Lib.Close (Input (1));
GNAT.OS_Lib.Close (Output1 (0));
end;
waitpid (PID, Result, 0);
Exit_Code := Integer (Result);
end if;
end Execute;
----------------------
-- Is_Absolute_Path --
----------------------
function Is_Absolute_Path
(File : League.Strings.Universal_String)
return Boolean
is
use Ada.Directories;
Name : constant String := File.To_UTF_8_String;
begin
return Name /= Simple_Name (Name);
end Is_Absolute_Path;
--------------------
-- Temp_Directory --
--------------------
function Build_Root return League.Strings.Universal_String is
begin
if Build_Root_Value.Is_Empty then
Build_Root_Value := League.Strings.From_UTF_8_String
(Ada.Directories.Containing_Directory
(Ada.Command_Line.Command_Name));
end if;
return Build_Root_Value;
end Build_Root;
function Source_Root return League.Strings.Universal_String is
CR : constant Wide_Wide_Character := Wide_Wide_Character'Val (13);
LF : constant Wide_Wide_Character := Wide_Wide_Character'Val (10);
TAB : constant Wide_Wide_String := (1 => Wide_Wide_Character'Val (09));
Found : League.Strings.Universal_String;
Exe_File : League.Strings.Universal_String;
Arguments : League.String_Vectors.Universal_String_Vector;
Exit_Code : Integer;
Output : League.Strings.Universal_String;
Pos : Positive := 1;
begin
if Source_Root_Value.Is_Empty then
Exe_File := League.Strings.From_UTF_8_String
(Ada.Command_Line.Command_Name);
Arguments.Append (+"--dwarf=info");
Arguments.Append (Exe_File);
Execute
(Command => +"objdump",
Arguments => Arguments,
Exit_Code => Exit_Code,
Output => Output);
if Exit_Code /= 0 then
raise Constraint_Error;
end if;
Search_Path :
loop
declare
use League.String_Vectors;
File_Name : constant Universal_String :=
League.Strings.From_UTF_8_String (GNAT.Source_Info.File);
Line : Universal_String;
Block_Size : constant := 1024;
Lines : constant Universal_String_Vector :=
Output.Slice (Pos, Pos + Block_Size).Split (LF);
begin
Pos := Pos + Block_Size - Lines.Element (Lines.Length).Length;
for J in 1 .. Lines.Length loop
Line := Lines.Element (J);
if Line.Ends_With (TAB & CR) then
Line := Line.Slice (1, Line.Length - 2);
elsif Line.Ends_With (TAB) then
Line := Line.Slice (1, Line.Length - 1);
end if;
if Line.Ends_With (File_Name) then
declare
Words : constant Universal_String_Vector :=
Line.Split (' ');
begin
Found := Words.Element (Words.Length);
exit Search_Path;
end;
end if;
end loop;
end;
end loop Search_Path;
declare
function Up (X : String) return String renames
Ada.Directories.Containing_Directory;
begin
Source_Root_Value := League.Strings.From_UTF_8_String
(Up (Up (Up (Found.To_UTF_8_String))));
end;
end if;
return Source_Root_Value;
end Source_Root;
----------
-- To_C --
----------
function To_C
(Text : League.Strings.Universal_String)
return Interfaces.C.Strings.chars_ptr is
begin
if Text.Is_Empty then
return Interfaces.C.Strings.Null_Ptr;
else
return Interfaces.C.Strings.New_String (Text.To_UTF_8_String);
end if;
end To_C;
end Gela.Host;
|
reznikmm/matreshka | Ada | 9,418 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Includes;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Use_Cases;
with AMF.Visitors;
package AMF.Internals.UML_Includes is
type UML_Include_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Includes.UML_Include with null record;
overriding function Get_Addition
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Use_Cases.UML_Use_Case_Access;
-- Getter of Include::addition.
--
-- References the use case that is to be included.
overriding procedure Set_Addition
(Self : not null access UML_Include_Proxy;
To : AMF.UML.Use_Cases.UML_Use_Case_Access);
-- Setter of Include::addition.
--
-- References the use case that is to be included.
overriding function Get_Including_Case
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Use_Cases.UML_Use_Case_Access;
-- Getter of Include::includingCase.
--
-- References the use case which will include the addition and owns the
-- include relationship.
overriding procedure Set_Including_Case
(Self : not null access UML_Include_Proxy;
To : AMF.UML.Use_Cases.UML_Use_Case_Access);
-- Setter of Include::includingCase.
--
-- References the use case which will include the addition and owns the
-- include relationship.
overriding function Get_Source
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::source.
--
-- Specifies the sources of the DirectedRelationship.
overriding function Get_Target
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::target.
--
-- Specifies the targets of the DirectedRelationship.
overriding function Get_Related_Element
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Relationship::relatedElement.
--
-- Specifies the elements related by the Relationship.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Include_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Include_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function All_Owning_Packages
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Include_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Include_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Include_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Include_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Include_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Includes;
|
io7m/coreland-posix-ada | Ada | 716 | adb | with POSIX.Error;
use type POSIX.Error.Error_t;
with POSIX.User_DB;
use type POSIX.User_DB.Group_ID_t;
with Test;
with Test_Config;
procedure T_UDB_GE4 is
Error_Value : POSIX.Error.Error_t;
Database_Entry : POSIX.User_DB.Database_Entry_t;
Found_Entry : Boolean;
begin
POSIX.User_DB.Get_Entry_By_Name
(User_Name => Test_Config.User_Name,
Database_Entry => Database_Entry,
Found_Entry => Found_Entry,
Error_Value => Error_Value);
Test.Assert (Found_Entry);
Test.Assert (Error_Value = POSIX.Error.Error_None);
Test.Assert (POSIX.User_DB.Is_Valid (Database_Entry));
Test.Assert (POSIX.User_DB.Get_Group_ID (Database_Entry) = Test_Config.User_GID);
end T_UDB_GE4;
|
charlie5/lace | Ada | 124 | ads | with
any_Math.any_fast_Trigonometry;
package float_Math.fast_Trigonometry is new float_Math.any_fast_Trigonometry;
|
reznikmm/matreshka | Ada | 18,470 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.CMOF.Elements;
with AMF.DI.Styles;
with AMF.Internals.UMLDI_UML_Diagrams;
with AMF.UML.Comments.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements;
with AMF.UML.String_Expressions;
with AMF.UML.Template_Parameters;
with AMF.UMLDI.UML_Labels;
with AMF.UMLDI.UML_Profile_Diagrams;
with AMF.UMLDI.UML_Styles;
with AMF.Visitors;
with League.Strings;
package AMF.Internals.UMLDI_UML_Profile_Diagrams is
type UMLDI_UML_Profile_Diagram_Proxy is
limited new AMF.Internals.UMLDI_UML_Diagrams.UMLDI_UML_Diagram_Proxy
and AMF.UMLDI.UML_Profile_Diagrams.UMLDI_UML_Profile_Diagram with null record;
overriding function Get_Heading
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access;
-- Getter of UMLDiagram::heading.
--
overriding procedure Set_Heading
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access);
-- Setter of UMLDiagram::heading.
--
overriding function Get_Is_Frame
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return Boolean;
-- Getter of UMLDiagram::isFrame.
--
-- Indicates when diagram frames shall be shown.
overriding procedure Set_Is_Frame
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : Boolean);
-- Setter of UMLDiagram::isFrame.
--
-- Indicates when diagram frames shall be shown.
overriding function Get_Is_Iso
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return Boolean;
-- Getter of UMLDiagram::isIso.
--
-- Indicate when ISO notation rules shall be followed.
overriding procedure Set_Is_Iso
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : Boolean);
-- Setter of UMLDiagram::isIso.
--
-- Indicate when ISO notation rules shall be followed.
overriding function Get_Is_Icon
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return Boolean;
-- Getter of UMLDiagramElement::isIcon.
--
-- For modelElements that have an option to be shown with shapes other
-- than rectangles, such as Actors, or with other identifying shapes
-- inside them, such as arrows distinguishing InputPins and OutputPins, or
-- edges that have an option to be shown with lines other than solid with
-- open arrow heads, such as Realization. A value of true for isIcon
-- indicates the alternative notation shall be shown.
overriding procedure Set_Is_Icon
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : Boolean);
-- Setter of UMLDiagramElement::isIcon.
--
-- For modelElements that have an option to be shown with shapes other
-- than rectangles, such as Actors, or with other identifying shapes
-- inside them, such as arrows distinguishing InputPins and OutputPins, or
-- edges that have an option to be shown with lines other than solid with
-- open arrow heads, such as Realization. A value of true for isIcon
-- indicates the alternative notation shall be shown.
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access;
-- Getter of UMLDiagramElement::localStyle.
--
-- Restricts owned styles to UMLStyles.
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access);
-- Setter of UMLDiagramElement::localStyle.
--
-- Restricts owned styles to UMLStyles.
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of UMLDiagramElement::modelElement.
--
-- Restricts UMLDiagramElements to show UML Elements, rather than other
-- language elements.
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access;
-- Getter of DiagramElement::modelElement.
--
-- a reference to a depicted model element, which can be any MOF-based
-- element
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.DI.Styles.DI_Style_Access;
-- Getter of DiagramElement::localStyle.
--
-- a reference to an optional locally-owned style for this diagram element.
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.DI.Styles.DI_Style_Access);
-- Setter of DiagramElement::localStyle.
--
-- a reference to an optional locally-owned style for this diagram element.
overriding function Get_Name
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return League.Strings.Universal_String;
-- Getter of Diagram::name.
--
-- the name of the diagram.
overriding procedure Set_Name
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : League.Strings.Universal_String);
-- Setter of Diagram::name.
--
-- the name of the diagram.
overriding function Get_Documentation
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return League.Strings.Universal_String;
-- Getter of Diagram::documentation.
--
-- the documentation of the diagram.
overriding procedure Set_Documentation
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : League.Strings.Universal_String);
-- Setter of Diagram::documentation.
--
-- the documentation of the diagram.
overriding function Get_Resolution
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.Real;
-- Getter of Diagram::resolution.
--
-- the resolution of the diagram expressed in user units per inch.
overriding procedure Set_Resolution
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.Real);
-- Setter of Diagram::resolution.
--
-- the resolution of the diagram expressed in user units per inch.
overriding function Get_Client_Dependency
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::name.
--
-- The name of the NamedElement.
overriding procedure Set_Name
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.Optional_String);
-- Setter of NamedElement::name.
--
-- The name of the NamedElement.
overriding function Get_Name_Expression
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Owned_Comment
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Comments.Collections.Set_Of_UML_Comment;
-- Getter of Element::ownedComment.
--
-- The Comments owned by this element.
overriding function Get_Owned_Element
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Element::ownedElement.
--
-- The Elements owned by this element.
overriding function Get_Owner
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Elements.UML_Element_Access;
-- Getter of Element::owner.
--
-- The Element that owns this element.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UMLDI_UML_Profile_Diagram_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function All_Namespaces
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace;
-- Operation NamedElement::allNamespaces.
--
-- The query allNamespaces() gives the sequence of namespaces in which the
-- NamedElement is nested, working outwards.
overriding function All_Owning_Packages
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Qualified_Name
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return League.Strings.Universal_String;
-- Operation NamedElement::qualifiedName.
--
-- When there is a name, and all of the containing namespaces have a name,
-- the qualified name is constructed from the names of the containing
-- namespaces.
overriding function Separator
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return League.Strings.Universal_String;
-- Operation NamedElement::separator.
--
-- The query separator() gives the string that is used to separate names
-- when constructing a qualified name.
overriding function All_Owned_Elements
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Operation Element::allOwnedElements.
--
-- The query allOwnedElements() gives all of the direct and indirect owned
-- elements of an element.
overriding function Is_Compatible_With
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding procedure Enter_Element
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant UMLDI_UML_Profile_Diagram_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.UMLDI_UML_Profile_Diagrams;
|
faelys/natools | Ada | 42,672 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2014-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Containers;
with Ada.Strings.Unbounded;
with Natools.Constant_Indefinite_Ordered_Maps;
package body Natools.Constant_Indefinite_Ordered_Map_Tests is
package Test_Maps is new
Constant_Indefinite_Ordered_Maps
(Key_Type => String,
Element_Type => Integer);
function Image (Map : Test_Maps.Unsafe_Maps.Map) return String;
function Image (Map : Test_Maps.Updatable_Map) return String;
function Sample_Map return Test_Maps.Unsafe_Maps.Map;
function Sample_Map return Test_Maps.Updatable_Map
is (Test_Maps.Create (Sample_Map));
------------------------------
-- Local Helper Subprograms --
------------------------------
function Image (Map : Test_Maps.Unsafe_Maps.Map) return String is
use Ada.Strings.Unbounded;
Result : Unbounded_String;
First : Boolean := True;
procedure Process (Cursor : Test_Maps.Unsafe_Maps.Cursor);
procedure Process (Cursor : Test_Maps.Unsafe_Maps.Cursor) is
begin
if First then
First := False;
else
Append (Result, ", ");
end if;
Append (Result, Test_Maps.Unsafe_Maps.Key (Cursor));
Append (Result, " ->");
Append
(Result, Integer'Image (Test_Maps.Unsafe_Maps.Element (Cursor)));
end Process;
begin
Append (Result, "(");
Map.Iterate (Process'Access);
Append (Result, ")");
return To_String (Result);
end Image;
function Image (Map : Test_Maps.Updatable_Map) return String is
begin
return Image (Map.To_Unsafe_Map);
end Image;
function Sample_Map return Test_Maps.Unsafe_Maps.Map is
Result : Test_Maps.Unsafe_Maps.Map;
begin
for I in 0 .. 9 loop
Result.Insert
((1 => '1',
2 => Character'Val (Character'Pos ('0') + I)),
I + 10);
Result.Insert
((1 => '2',
2 => Character'Val (Character'Pos ('0') + I)),
I + 20);
end loop;
return Result;
end Sample_Map;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Consistency (Report);
Cursor_Operations (Report);
Direct_Access (Report);
Empty_Map (Report);
Iterations (Report);
Map_Updates (Report);
Unsafe_Map_Roundtrip (Report);
Ada_2012_Indexing (Report);
Ada_2012_Iteration (Report);
Ada_2012_Errors (Report);
Range_Iterators (Report);
Update_Constructors (Report);
Update_Constructor_Exceptions (Report);
Rank (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
procedure Ada_2012_Errors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Errors in Ada 2012 extensions");
begin
declare
Map : Test_Maps.Updatable_Map := Sample_Map;
Fixed_Map : constant Test_Maps.Updatable_Map := Sample_Map;
Empty_Map : constant Test_Maps.Updatable_Map
:= Test_Maps.Create (Test_Maps.Unsafe_Maps.Empty_Map);
I : Integer;
begin
for Position in Empty_Map.Iterate loop
Test.Fail ("Found element in empty map:");
Test.Info (" (" & Test_Maps.Key (Position)
& " ->" & Integer'Image (Test_Maps.Element (Position)) & ')');
end loop;
for Position in reverse Empty_Map.Iterate loop
Test.Fail ("Found element in reverse empty map:");
Test.Info (" (" & Test_Maps.Key (Position)
& " ->" & Integer'Image (Test_Maps.Element (Position)) & ')');
end loop;
begin
I := Fixed_Map ("#1");
Test.Fail ("Found value " & Integer'Image (I) & " for key ""#1""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception for value ""#1""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
I := Fixed_Map (Fixed_Map.Find ("#2"));
Test.Fail ("Found value " & Integer'Image (I) & " for key ""#2""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with value for ""#2""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
I := Fixed_Map (Map.Find ("20"));
Test.Fail ("Found value " & Integer'Image (I)
& " for key ""20"" in foreign map");
exception
when Program_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with for foreign cursor");
Test.Report_Exception (Error, NT.Fail);
end;
begin
Map ("#3") := 93;
Test.Fail ("Found node for key ""#3""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception for value ""#3""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
Map (Map.Find ("#4")) := 94;
Test.Fail ("Found node for key ""#4""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with node for ""#4""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
Map (Fixed_Map.Find ("20")) := 95;
Test.Fail ("Found node for key ""20"" in foreign map");
exception
when Program_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with node for foreign cursor");
Test.Report_Exception (Error, NT.Fail);
end;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Ada_2012_Errors;
procedure Ada_2012_Indexing (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Ada 2012 user-defined indexing");
procedure Test_Constant (Map : in Test_Maps.Updatable_Map);
procedure Test_Constant (Map : in Test_Maps.Updatable_Map) is
I : Integer;
begin
I := Map ("25");
if I /= 25 then
Test.Fail ("Unexpacted value" & Integer'Image (I)
& " for Map (""25"")");
end if;
I := Map (Map.Find ("12"));
if I /= 12 then
Test.Fail ("Unexpacted value" & Integer'Image (I)
& " for Map (""12"")");
end if;
end Test_Constant;
begin
declare
Map : Test_Maps.Updatable_Map := Sample_Map;
I : Integer;
begin
I := Map ("15");
if I /= 15 then
Test.Fail ("Unexpacted value" & Integer'Image (I)
& " for Map (""15"")");
end if;
Map ("23") := 2;
I := Map.Element ("23");
if I /= 2 then
Test.Fail ("Unexpected value" & Integer'Image (I)
& " for updated Map (""23"")");
Test.Info ("Full map: " & Image (Map));
end if;
Test_Constant (Map);
end;
exception
when Error : others => Test.Report_Exception (Error);
end Ada_2012_Indexing;
procedure Ada_2012_Iteration (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Ada 2012 user-defined iteration");
begin
declare
Map : Test_Maps.Updatable_Map := Sample_Map;
Expected, Direction : Integer;
Abort_Loop : Boolean := False;
procedure Test_Element (Element : in Integer);
procedure Test_Element (Element : in Integer) is
begin
if Expected /= Element then
Test.Fail ("Got element" & Integer'Image (Element)
& ", expected" & Integer'Image (Expected));
Test.Info ("Current map: " & Image (Map));
Abort_Loop := True;
end if;
Expected := Expected + Direction;
end Test_Element;
begin
Direction := 1;
Expected := 10;
Abort_Loop := False;
for Element of Map loop
Test_Element (Element);
exit when Abort_Loop;
end loop;
Direction := -1;
Expected := 29;
Abort_Loop := False;
for Element of reverse Map loop
Test_Element (Element);
exit when Abort_Loop;
end loop;
Expected := 59;
Direction := -1;
for Element of Map loop
Element := Expected;
Expected := Expected + Direction;
end loop;
Direction := 1;
Expected := 40;
Abort_Loop := False;
for Element of reverse Map loop
Test_Element (Element);
exit when Abort_Loop;
end loop;
Direction := 1;
Expected := 50;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("19")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Direction := -1;
Expected := 50;
Abort_Loop := False;
for Position in Map.Iterate (Map.Find ("19")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Ada_2012_Iteration;
procedure Consistency (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Consistency checks");
begin
if Test_Maps.Has_Element (Test_Maps.No_Element) then
Test.Fail ("No_Element has an element");
end if;
declare
use type Ada.Containers.Count_Type;
use type Test_Maps.Cursor;
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Cursor : Test_Maps.Cursor;
begin
if Map.Length /= 20 then
Test.Fail ("Unexpected map length:"
& Ada.Containers.Count_Type'Image (Map.Length));
end if;
Cursor := Map.First;
if Test_Maps.Key (Cursor) /= Map.First_Key then
Test.Fail ("Key (First) /= First_Key");
end if;
if Test_Maps.Element (Cursor) /= Map.First_Element then
Test.Fail ("Element (First) /= First_Element");
end if;
if Test_Maps.Previous (Cursor) /= Test_Maps.No_Element then
Test.Fail ("Previous (First) has element");
end if;
Test_Maps.Next (Cursor);
if Cursor < Map.First then
Test.Fail ("Second < First");
end if;
if Cursor < Map.First_Key then
Test.Fail ("Second < First_Key");
end if;
if not (Map.First_Key < Cursor) then
Test.Fail ("Second <= First_Key");
end if;
Cursor := Map.Last;
if Test_Maps.Key (Cursor) /= Map.Last_Key then
Test.Fail ("Key (Last) /= Last_Key");
end if;
if Test_Maps.Element (Cursor) /= Map.Last_Element then
Test.Fail ("Element (Last) /= Last_Element");
end if;
if Test_Maps.Next (Cursor) /= Test_Maps.No_Element then
Test.Fail ("Next (Last) has element");
end if;
Test_Maps.Previous (Cursor);
if Cursor > Map.Last then
Test.Fail ("Before_Last > Last");
end if;
if Cursor > Map.Last_Key then
Test.Fail ("Before_Last > Last_Key");
end if;
if not (Map.Last_Key > Cursor) then
Test.Fail ("Before_Last >= Last_Key");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Consistency;
procedure Cursor_Operations (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Cursor operations");
begin
declare
procedure Check (Cursor : in Test_Maps.Cursor);
procedure Check (Key : in String; Element : in Integer);
Expected : String := "??";
procedure Check (Cursor : in Test_Maps.Cursor) is
begin
Test_Maps.Query_Element (Cursor, Check'Access);
end Check;
procedure Check (Key : in String; Element : in Integer) is
begin
if Key /= Expected or Element /= Integer'Value (Expected) then
Test.Fail ("Expected """ & Expected
& """, got (""" & Key
& " ->" & Integer'Image (Element) & ')');
end if;
end Check;
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Cursor, Alternate : Test_Maps.Cursor;
begin
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Default cursor is not empty");
return;
end if;
Expected := "17";
Cursor := Map.Find (Expected);
if not Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Find (""17"") has no element");
return;
end if;
Check (Cursor);
Alternate := Test_Maps.Previous (Cursor);
Expected := "16";
Check (Alternate);
Alternate := Test_Maps.Next (Cursor);
Expected := "18";
Check (Alternate);
Test_Maps.Clear (Alternate);
if Test_Maps.Has_Element (Alternate) then
Test.Fail ("Clear cursor has element");
return;
end if;
Test_Maps.Next (Alternate);
if Test_Maps.Has_Element (Alternate) then
Test.Fail ("Next (Empty_Cursor) has element");
return;
end if;
Test_Maps.Previous (Alternate);
if Test_Maps.Has_Element (Alternate) then
Test.Fail ("Previous (Empty_Cursor) has element");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Cursor_Operations;
procedure Direct_Access (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Direct node access");
begin
declare
use type Test_Maps.Cursor;
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Img : String := "??";
Cursor : Test_Maps.Cursor;
begin
for I in 10 .. 29 loop
Img (1) := Character'Val (Character'Pos ('0') + I / 10);
Img (2) := Character'Val (Character'Pos ('0') + I mod 10);
if not Map.Contains (Img) then
Test.Fail ("Sample_Map should contain key """ & Img & '"');
elsif Map.Floor (Img) /= Map.Ceiling (Img) then
Test.Fail ("Floor /= Ceiling for existing key """ & Img & '"');
elsif Map.Element (Img) /= I then
Test.Fail ("Unexpected element"
& Integer'Image (Map.Element (Img))
& " for key """ & Img & '"');
end if;
Cursor := Map.Floor ("1");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Floor (""1"") is not empty ("""
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Find ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Find (""2"") is not empty ("""
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Ceiling ("3");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Ceiling (""3"") is not empty ("""
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Floor ("2");
if not Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Floor (""2"") is empty");
elsif Test_Maps.Key (Cursor) /= "19" then
Test.Fail ("Map.Floor (""2"") returns unexpected node """
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Ceiling ("2");
if not Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Ceiling (""2"") is empty");
elsif Test_Maps.Key (Cursor) /= "20" then
Test.Fail ("Map.Ceiling (""2"") returns unexpected node """
& Test_Maps.Key (Cursor) & '"');
end if;
end loop;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Direct_Access;
procedure Empty_Map (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Operations on empty map");
begin
declare
use type Ada.Containers.Count_Type;
use type Test_Maps.Updatable_Map;
procedure Fail_Test (Cursor : in Test_Maps.Cursor);
procedure Fail_Test (Cursor : in Test_Maps.Cursor) is
pragma Unreferenced (Cursor);
begin
Test.Fail ("Unexpected callback use");
end Fail_Test;
Cursor : Test_Maps.Cursor;
Map : Test_Maps.Updatable_Map;
pragma Unmodified (Map);
begin
Map.Iterate (Fail_Test'Access);
Map.Reverse_Iterate (Fail_Test'Access);
if Test_Maps.Has_Element (Map.First) then
Test.Fail ("Empty_Map.First has an element");
end if;
if Test_Maps.Has_Element (Map.Last) then
Test.Fail ("Empty_Map.Last has an element");
end if;
if not Map.To_Unsafe_Map.Is_Empty then
Test.Fail ("Empty_Map.To_Unsafe_Map is not empty");
end if;
if Map.Length /= 0 then
Test.Fail ("Empty_Map.Length is not zero");
end if;
if Map.Contains ("foo") then
Test.Fail ("Empty_Map.Contains (""foo"")");
end if;
Cursor := Map.Find ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Empty_Map.Find (""2"") has element ("""
& Test_Maps.Key (Cursor) & """ ->"
& Integer'Image (Test_Maps.Element (Cursor)) & ')');
end if;
Cursor := Map.Floor ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Empty_Map.Floor (""2"") has element ("""
& Test_Maps.Key (Cursor) & """ ->"
& Integer'Image (Test_Maps.Element (Cursor)) & ')');
end if;
Cursor := Map.Ceiling ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Empty_Map.Ceiling (""2"") has element ("""
& Test_Maps.Key (Cursor) & """ ->"
& Integer'Image (Test_Maps.Element (Cursor)) & ')');
end if;
if Map /= Test_Maps.Create (Test_Maps.Unsafe_Maps.Empty_Map) then
Test.Fail ("Empty_Map /= Create (Unsafe_Empty_Map)");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Empty_Map;
procedure Iterations (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Iterative visit of the whole container");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
procedure Check (Key : in String; Element : in Integer);
procedure Check_Cursor (Cursor : in Test_Maps.Cursor);
procedure Init_Backward (Id_Char : in Character);
procedure Init_Forward (Id_Char : in Character);
Id : String := "??";
Index : Integer := 0;
Direction : Integer := 1;
procedure Check (Key : in String; Element : in Integer) is
Space_Image : constant String := Integer'Image (Index);
Image : constant String
:= Space_Image (Space_Image'First + 1 .. Space_Image'Last);
begin
if Key /= Image then
Test.Fail (Id & '.' & Image
& ". unexpected key """ & Key & '"');
end if;
if Element /= Index then
Test.Fail (Id & '.' & Image
& ". unexpected element" & Integer'Image (Element));
end if;
Index := Index + Direction;
end Check;
procedure Check_Cursor (Cursor : in Test_Maps.Cursor) is
begin
Check (Test_Maps.Key (Cursor), Test_Maps.Element (Cursor));
end Check_Cursor;
procedure Init_Backward (Id_Char : in Character) is
begin
Id := Id_Char & 'b';
Index := 29;
Direction := -1;
end Init_Backward;
procedure Init_Forward (Id_Char : in Character) is
begin
Id := Id_Char & 'f';
Index := 10;
Direction := 1;
end Init_Forward;
begin
begin
Init_Forward ('1');
Map.Iterate (Check_Cursor'Access);
end;
begin
Init_Backward ('1');
Map.Reverse_Iterate (Check_Cursor'Access);
end;
declare
Cursor : Test_Maps.Cursor := Map.First;
begin
Init_Forward ('2');
while Test_Maps.Has_Element (Cursor) loop
Check_Cursor (Cursor);
Test_Maps.Next (Cursor);
end loop;
end;
declare
Cursor : Test_Maps.Cursor := Map.Last;
begin
Init_Backward ('2');
while Test_Maps.Has_Element (Cursor) loop
Check_Cursor (Cursor);
Test_Maps.Previous (Cursor);
end loop;
end;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Iterations;
procedure Map_Updates (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Map updates");
begin
declare
use type Test_Maps.Updatable_Map;
procedure Update (Key : in String; Element : in out Integer);
procedure Update (Key : in String; Element : in out Integer) is
pragma Unreferenced (Key);
begin
Element := 7;
end Update;
Map_A : Test_Maps.Updatable_Map := Sample_Map;
Map_B : Test_Maps.Updatable_Map := Sample_Map;
Cursor : Test_Maps.Cursor;
begin
if Map_A = Map_B then
Test.Fail ("Unrelated maps are equal");
return;
end if;
Cursor := Map_A.Find ("17");
pragma Assert (Test_Maps.Has_Element (Cursor));
if Test_Maps.Is_Related (Map_B, Cursor) then
Test.Fail ("Map_B and Cursor should be unrelated");
return;
end if;
Map_A.Update_Element (Cursor, Update'Access);
if Test_Maps.Element (Cursor) /= 7 then
Test.Fail ("Update failure, element is"
& Integer'Image (Test_Maps.Element (Cursor))
& ", should be 7");
end if;
Test_Maps.Move (Map_B, Map_A);
if not Map_A.Is_Empty then
Test.Fail ("Move source is not empty");
end if;
if not Test_Maps.Is_Related (Map_B, Cursor) then
Test.Fail ("Move target is not related to old source");
else
Map_B.Update_Element (Cursor, Update'Access);
end if;
Map_A.Replace (Map_B.To_Unsafe_Map);
if Map_A.Is_Empty then
Test.Fail ("Replaced map is empty");
end if;
if Map_A.Element ("17") /= 7 then
Test.Fail ("Unexpected value"
& Integer'Image (Map_A.Element ("17"))
& "for Map_A.Element (""17"")");
end if;
Map_B.Clear;
if not Map_B.Is_Empty then
Test.Fail ("Cleared map is not empty");
end if;
if Test_Maps.Is_Related (Map_B, Cursor) then
Test.Fail ("Clear map is still related to cursor");
end if;
if (not Test_Maps.Has_Element (Cursor))
or else Test_Maps.Element (Cursor) /= 7
then
Test.Fail ("Orphaned cursor has lost its value");
end if;
Test_Maps.Next (Cursor);
if (not Test_Maps.Has_Element (Cursor))
or else Test_Maps.Element (Cursor) /= 18
then
Test.Fail ("Moved orphaned cursor has lost its value");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Map_Updates;
procedure Range_Iterators (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Map updates");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Expected, Direction : Integer;
Abort_Loop : Boolean := False;
procedure Test_Element (Element : in Integer);
procedure Test_Element (Element : in Integer) is
begin
if Expected /= Element then
Test.Fail ("Got element" & Integer'Image (Element)
& ", expected" & Integer'Image (Expected));
Test.Info ("Current map: " & Image (Map));
Abort_Loop := True;
end if;
Expected := Expected + Direction;
end Test_Element;
begin
Direction := 1;
Expected := 10;
Abort_Loop := False;
for Position in Map.Iterate loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Direction := 1;
Expected := 15;
Abort_Loop := False;
for Position in Map.Iterate (Map.Find ("15"), Map.Find ("25")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (26);
Direction := -1;
Expected := 23;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("13"), Map.Find ("23"))
loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (12);
Direction := 1;
Expected := 99;
Abort_Loop := False;
for Position in Map.Iterate (Map.Find ("17"), Map.Find ("16")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (99);
Direction := 1;
Expected := 99;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("27"), Map.Find ("26"))
loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (99);
Direction := 1;
Expected := 10;
Abort_Loop := False;
for Position in Map.Iterate (Map.First, Map.Find ("20")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (21);
Direction := -1;
Expected := 29;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("25"), Map.Last) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (24);
end;
exception
when Error : others => Test.Report_Exception (Error);
end Range_Iterators;
procedure Rank (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Rank function");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
procedure Test_Rank
(Cursor : in Test_Maps.Cursor;
Expected : in Ada.Containers.Count_Type;
Name : in String);
procedure Test_Rank
(Cursor : in Test_Maps.Cursor;
Expected : in Ada.Containers.Count_Type;
Name : in String)
is
use type Ada.Containers.Count_Type;
Actual : constant Ada.Containers.Count_Type
:= Test_Maps.Rank (Cursor);
begin
if Actual /= Expected then
Test.Fail ("Expected rank"
& Ada.Containers.Count_Type'Image (Expected)
& " for " & Name & ", found"
& Ada.Containers.Count_Type'Image (Actual));
end if;
end Test_Rank;
begin
Test_Rank (Test_Maps.No_Element, 0, "No_Element");
Test_Rank (Map.First, 1, "Map.First");
Test_Rank (Map.Last, 20, "Map.Last");
Test_Rank (Test_Maps.Next (Map.First), 2, "Next (Map.First)");
Test_Rank (Test_Maps.Next (Map.Last), 0, "Next (Map.Last)");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Rank;
procedure Unsafe_Map_Roundtrip (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Constant_Map <-> Unsafe_Map roundtrip");
begin
declare
use type Test_Maps.Unsafe_Maps.Map;
Unsafe : constant Test_Maps.Unsafe_Maps.Map := Sample_Map;
Safe : constant Test_Maps.Updatable_Map := Test_Maps.Create (Unsafe);
Roundtrip : constant Test_Maps.Unsafe_Maps.Map := Safe.To_Unsafe_Map;
begin
if Unsafe /= Roundtrip then
Test.Fail;
Test.Info ("Original: " & Image (Unsafe));
Test.Info ("Roundtrip: " & Image (Roundtrip));
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Unsafe_Map_Roundtrip;
procedure Update_Constructors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("""Update"" constructors");
procedure Check_Map
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Dump : out Boolean);
-- Base map consistency check
procedure Check_Map_Not_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String);
-- Check consistency and that Key does not exist
procedure Check_Map_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String;
Value : in Integer);
-- Check consistency and that Key exists and is associated with Value
procedure Check_Map
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Dump : out Boolean)
is
use type Ada.Containers.Count_Type;
I : Integer;
Current : Test_Maps.Cursor := Map.First;
Previous : Test_Maps.Cursor;
begin
Dump := False;
if Map.Length /= Expected_Length then
Test.Fail (Context & ": found length"
& Ada.Containers.Count_Type'Image (Map.Length)
& ", expected:"
& Ada.Containers.Count_Type'Image (Expected_Length));
Dump := True;
end if;
if not Test_Maps.Has_Element (Current) then
return;
end if;
loop
begin
I := Integer'Value (Test_Maps.Key (Current));
exception
when Constraint_Error =>
Test.Fail (Context & ": Invalid key """
& Test_Maps.Key (Current) & '"');
Dump := True;
exit;
end;
if I /= abs Test_Maps.Element (Current) then
Test.Fail (Context & ": Inconsistent key """
& Test_Maps.Key (Current) & """ and value "
& Integer'Image (Test_Maps.Element (Current)));
Dump := True;
end if;
Previous := Current;
Test_Maps.Next (Current);
exit when not Test_Maps.Has_Element (Current);
if Test_Maps.Key (Previous) >= Test_Maps.Key (Current) then
Test.Fail (Context & ": Inconsistent ordering of keys """
& Test_Maps.Key (Previous) & """ and """
& Test_Maps.Key (Current));
Dump := True;
end if;
end loop;
end Check_Map;
procedure Check_Map_Not_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String)
is
Dump : Boolean;
Position : constant Test_Maps.Cursor := Map.Find (Key);
begin
Check_Map (Map, Context, Expected_Length, Dump);
if Test_Maps.Has_Element (Position) then
Test.Fail (Context & ": unexpected key """
& Test_Maps.Key (Position) & """ found with value "
& Integer'Image (Test_Maps.Element (Position)));
Dump := True;
end if;
if Dump then
Test.Info (Context & ": Map dump " & Image (Map));
end if;
end Check_Map_Not_Value;
procedure Check_Map_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String;
Value : in Integer)
is
Dump : Boolean;
Position : constant Test_Maps.Cursor := Map.Find (Key);
begin
Check_Map (Map, Context, Expected_Length, Dump);
if not Test_Maps.Has_Element (Position) then
Test.Fail (Context & ": key """ & Key & """ not found");
Dump := True;
elsif Test_Maps.Element (Position) /= Value then
Test.Fail (Context & ": key """ & Key & """ found with value "
& Integer'Image (Test_Maps.Element (Position))
& " instead of "
& Integer'Image (Value));
Dump := True;
end if;
if Dump then
Test.Info (Context & ": Map dump " & Image (Map));
end if;
end Check_Map_Value;
begin
declare
Base : constant Test_Maps.Updatable_Map := Sample_Map;
Position : Test_Maps.Cursor;
begin
Check_Map_Not_Value (Base, "Base", 20, "152");
Check_Map_Value
(Test_Maps.Insert (Test_Maps.Empty_Updatable_Map, "1", -1),
"Insert on empty map", 1,
"1", -1);
Check_Map_Value
(Test_Maps.Insert (Base, "152", 152),
"Insert", 21,
"152", 152);
Check_Map_Value
(Base.Include ("21 ", 21),
"Inserting Include", 21,
"21 ", 21);
Check_Map_Value
(Base.Include ("21", -21),
"Replacing Include", 20,
"21", -21);
Check_Map_Value
(Base.Replace ("28", -28),
"Replace", 20,
"28", -28);
Check_Map_Not_Value
(Test_Maps.Delete (Base, "11"),
"Delete", 19, "11");
Check_Map_Not_Value
(Test_Maps.Exclude (Base, "27"),
"Exclude", 19, "27");
Check_Map_Not_Value
(Test_Maps.Exclude (Test_Maps.Empty_Updatable_Map, "23"),
"Empty Exclude", 0, "23");
Check_Map_Value
(Test_Maps.Replace_Element (Base, Base.Find ("12"), -12, Position),
"Replace_Element", 20,
"12", -12);
if Test_Maps.Key (Position) /= "12" then
Test.Fail ("Output Position key is """
& Test_Maps.Key (Position) & """, expected ""12""");
end if;
if Test_Maps.Element (Position) /= -12 then
Test.Fail ("Output Position element is "
& Integer'Image (Test_Maps.Element (Position))
& ", expected -12");
end if;
declare
use type Test_Maps.Updatable_Map;
Derived : constant Test_Maps.Updatable_Map := Base.Exclude ("foo");
begin
if Derived /= Base then
Test.Fail ("No-op Exclude return differing maps");
Test.Info ("Base: " & Image (Base));
Test.Info ("Excluded: " & Image (Derived));
end if;
end;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Update_Constructors;
procedure Update_Constructor_Exceptions
(Report : in out NT.Reporter'Class)
is
Test : NT.Test := Report.Item
("Exceptions raised in ""Update"" constructors");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Unrelated_Map : constant Test_Maps.Updatable_Map := Sample_Map;
Unrelated_Position : constant Test_Maps.Cursor
:= Unrelated_Map.Find ("19");
Output : Test_Maps.Updatable_Map;
begin
Insert :
declare
Name : constant String := "Insert with used key";
begin
Output := Test_Maps.Insert (Map, "14", -14);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Insert;
Empty_Replace :
declare
Name : constant String := "Replace on empty map";
begin
Output := Test_Maps.Empty_Updatable_Map.Replace ("14", -14);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Empty_Replace;
Replace :
declare
Name : constant String := "Replace with non-existent key";
begin
Output := Map.Replace ("-14", -14);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Replace;
Replace_Element :
declare
Name : constant String := "Replace_Element with empty cursor";
Position : constant Test_Maps.Cursor := Map.Find ("-18");
begin
Output := Test_Maps.Replace_Element (Map, Position, -18);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Replace_Element;
Unrelated_Replace_Element :
declare
Name : constant String := "Replace_Element with unrelated cursor";
begin
Output := Test_Maps.Replace_Element (Map, Unrelated_Position, -1);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Program_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Unrelated_Replace_Element;
Empty_Delete_Key :
declare
Name : constant String := "Delete on empty map";
begin
Output := Test_Maps.Delete (Test_Maps.Empty_Updatable_Map, "24");
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Empty_Delete_Key;
Delete_Key :
declare
Name : constant String := "Delete with non-existent key";
begin
Output := Test_Maps.Delete (Map, "-24");
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Delete_Key;
Delete_Empty_Cursor :
declare
Name : constant String := "Delete with empty cursor";
begin
Output := Test_Maps.Delete (Map, Test_Maps.No_Element);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Delete_Empty_Cursor;
Delete_Unrelated_Cursor :
declare
Name : constant String := "Delete with unrelated cursor";
begin
Output := Test_Maps.Delete (Map, Unrelated_Position);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Program_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Delete_Unrelated_Cursor;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Update_Constructor_Exceptions;
end Natools.Constant_Indefinite_Ordered_Map_Tests;
|
python36/0xfa | Ada | 1,644 | adb | package body labels is
function last_label return label_t is
begin
return last;
end last_label;
function get_by_name (str : string) return label_t is
cur : labels_t.cursor := labels_t.find(labels, str);
begin
if cur = labels_t.no_element then
return null_label;
end if;
return (cursor => cur);
end get_by_name;
function create (str : string; addr : pos_addr_t := null_pos_addr) return label_t is
cur : labels_t.cursor;
tb : boolean;
begin
labels_t.insert(labels, str, addr, cur, tb);
if not tb then
raise error_label_exist;
end if;
last := (cursor => cur);
return last_label;
end create;
procedure create (str : string; addr : pos_addr_t := null_pos_addr) is
begin
void(create(str, addr));
end create;
procedure set (label : label_t; addr : pos_addr_t) is
begin
if label.cursor = labels_t.no_element then
raise error_label_is_null;
end if;
labels_t.replace_element(labels, label.cursor, addr);
end set;
function set (label : label_t; addr : pos_addr_t) return label_t is
begin
set(label, addr);
return label;
end set;
function get (label : label_t) return pos_addr_t is
begin
if label.cursor = labels_t.no_element then
raise error_label_is_null;
end if;
return labels_t.element(label.cursor);
end get;
function name (label : label_t) return string is
begin
if label.cursor = labels_t.no_element then
raise error_label_is_null;
end if;
return labels_t.key(label.cursor);
end name;
procedure void (label : label_t) is
begin
null;
end void;
end labels; |
mfkiwl/ewok-kernel-security-OS | Ada | 1,839 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with config.applications; use config.applications;
with ewok.tasks;
with m4.systick;
package ewok.alarm
with spark_mode => on
is
count_alarms : unsigned_32 := 0;
type t_alarm_state is record
time : m4.systick.t_tick;
handler : system_address;
end record;
alarm_state : array (t_real_task_id'range) of t_alarm_state
:= (others => (0, 0));
procedure set_alarm
(task_id : in t_real_task_id;
ms : in milliseconds;
handler : in system_address)
with
global => (Output => alarm_state);
procedure unset_alarm
(task_id : in t_real_task_id)
with
global => (Output => alarm_state);
-- For a task, check if it's alarming time is over
procedure check_alarm
(task_id : in t_real_task_id)
with
global => (In_Out => (alarm_state, ewok.tasks.tasks_list));
-- For each task, check if it's alarming time is over
procedure check_alarms
with
global => (In_Out => (alarm_state, ewok.tasks.tasks_list));
end ewok.alarm;
|
zhmu/ananas | Ada | 408 | adb | -- { dg-do compile }
-- { dg-options "-gnata" }
with System.Assertions; use System.Assertions;
with Predicate4_Pkg;
procedure Predicate4 is
type V is new Float;
package MXI2 is new Predicate4_Pkg (V);
use MXI2;
OK : Lt := (Has => False);
begin
declare
Wrong : Lt := (Has => True, MX => 3.14);
begin
raise Program_Error;
end;
exception
when Assert_Failure => null;
end;
|
tum-ei-rcs/StratoX | Ada | 3,413 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- A D A . N U M E R I C S . E L E M E N T A R Y _ F U N C T I O N S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2014, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- @llrset a-nuelfu.ads
-- Generic_Elementary_Functions
-- ============================
-- This is the Ada Cert Math specific version of a-nuelfu.ads
with System.Generic_C_Math_Interface;
with System.Libm_Single;
package Ada.Numerics.Elementary_Functions is
new System.Generic_C_Math_Interface
(Float_Type => Float,
C_Sqrt => System.Libm_Single.Sqrt,
C_Log => System.Libm_Single.Log,
C_Exp => System.Libm_Single.Exp,
C_Pow => System.Libm_Single.Pow,
C_Sin => System.Libm_Single.Sin,
C_Cos => System.Libm_Single.Cos,
C_Tan => System.Libm_Single.Tan,
C_Asin => System.Libm_Single.Asin,
C_Acos => System.Libm_Single.Acos,
C_Atan2 => System.Libm_Single.Atan2,
C_Sinh => System.Libm_Single.Sinh,
C_Cosh => System.Libm_Single.Cosh,
C_Tanh => System.Libm_Single.Tanh,
C_Asinh => System.Libm_Single.Asinh,
C_Acosh => System.Libm_Single.Acosh,
C_Atanh => System.Libm_Single.Atanh);
pragma Pure (Elementary_Functions);
|
yannickmoy/SPARKNaCl | Ada | 1,392 | ads | package SPARKNaCl.Core
with Pure,
SPARK_Mode => On
is
-- Limited, so no assignment or comparison, and always
-- pass-by-reference.
type Salsa20_Key is limited private;
function Construct (K : in Bytes_32) return Salsa20_Key
with Global => null;
procedure Construct (K : out Salsa20_Key;
X : in Bytes_32)
with Global => null;
function Serialize (K : in Salsa20_Key) return Bytes_32
with Global => null;
procedure Sanitize (K : out Salsa20_Key)
with Global => null;
--------------------------------------------------------
-- Salsa20 Core functions
--------------------------------------------------------
procedure Salsa20 (Output : out Bytes_64;
Input : in Bytes_16;
K : in Salsa20_Key;
C : in Bytes_16) -- Counter
with Global => null;
procedure HSalsa20 (Output : out Bytes_32;
Input : in Bytes_16;
K : in Salsa20_Key;
C : in Bytes_16) -- Counter
with Global => null;
private
-- Note - also limited here in the full view to ensure
-- no assignment and pass-by-reference in the body.
type Salsa20_Key is limited record
F : Bytes_32;
end record;
end SPARKNaCl.Core;
|
AdaCore/Ada_Drivers_Library | Ada | 45,989 | ads | -- This spec has been automatically generated from STM32F7x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.Ethernet is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype DMABMR_DSL_Field is HAL.UInt5;
subtype DMABMR_PBL_Field is HAL.UInt6;
subtype DMABMR_RTPR_Field is HAL.UInt2;
subtype DMABMR_RDP_Field is HAL.UInt6;
-- Ethernet DMA bus mode register
type DMABMR_Register is record
-- no description available
SR : Boolean := True;
-- no description available
DA : Boolean := False;
-- no description available
DSL : DMABMR_DSL_Field := 16#0#;
-- no description available
EDFE : Boolean := False;
-- no description available
PBL : DMABMR_PBL_Field := 16#21#;
-- no description available
RTPR : DMABMR_RTPR_Field := 16#0#;
-- no description available
FB : Boolean := False;
-- no description available
RDP : DMABMR_RDP_Field := 16#0#;
-- no description available
USP : Boolean := False;
-- no description available
FPM : Boolean := False;
-- no description available
AAB : Boolean := False;
-- no description available
MB : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMABMR_Register use record
SR at 0 range 0 .. 0;
DA at 0 range 1 .. 1;
DSL at 0 range 2 .. 6;
EDFE at 0 range 7 .. 7;
PBL at 0 range 8 .. 13;
RTPR at 0 range 14 .. 15;
FB at 0 range 16 .. 16;
RDP at 0 range 17 .. 22;
USP at 0 range 23 .. 23;
FPM at 0 range 24 .. 24;
AAB at 0 range 25 .. 25;
MB at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype DMASR_RPS_Field is HAL.UInt3;
subtype DMASR_TPS_Field is HAL.UInt3;
subtype DMASR_EBS_Field is HAL.UInt3;
-- Ethernet DMA status register
type DMASR_Register is record
-- no description available
TS : Boolean := False;
-- no description available
TPSS : Boolean := False;
-- no description available
TBUS : Boolean := False;
-- no description available
TJTS : Boolean := False;
-- no description available
ROS : Boolean := False;
-- no description available
TUS : Boolean := False;
-- no description available
RS : Boolean := False;
-- no description available
RBUS : Boolean := False;
-- no description available
RPSS : Boolean := False;
-- no description available
PWTS : Boolean := False;
-- no description available
ETS : Boolean := False;
-- unspecified
Reserved_11_12 : HAL.UInt2 := 16#0#;
-- no description available
FBES : Boolean := False;
-- no description available
ERS : Boolean := False;
-- no description available
AIS : Boolean := False;
-- no description available
NIS : Boolean := False;
-- Read-only. no description available
RPS : DMASR_RPS_Field := 16#0#;
-- Read-only. no description available
TPS : DMASR_TPS_Field := 16#0#;
-- Read-only. no description available
EBS : DMASR_EBS_Field := 16#0#;
-- unspecified
Reserved_26_26 : HAL.Bit := 16#0#;
-- Read-only. no description available
MMCS : Boolean := False;
-- Read-only. no description available
PMTS : Boolean := False;
-- Read-only. no description available
TSTS : Boolean := False;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMASR_Register use record
TS at 0 range 0 .. 0;
TPSS at 0 range 1 .. 1;
TBUS at 0 range 2 .. 2;
TJTS at 0 range 3 .. 3;
ROS at 0 range 4 .. 4;
TUS at 0 range 5 .. 5;
RS at 0 range 6 .. 6;
RBUS at 0 range 7 .. 7;
RPSS at 0 range 8 .. 8;
PWTS at 0 range 9 .. 9;
ETS at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
FBES at 0 range 13 .. 13;
ERS at 0 range 14 .. 14;
AIS at 0 range 15 .. 15;
NIS at 0 range 16 .. 16;
RPS at 0 range 17 .. 19;
TPS at 0 range 20 .. 22;
EBS at 0 range 23 .. 25;
Reserved_26_26 at 0 range 26 .. 26;
MMCS at 0 range 27 .. 27;
PMTS at 0 range 28 .. 28;
TSTS at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype DMAOMR_RTC_Field is HAL.UInt2;
subtype DMAOMR_TTC_Field is HAL.UInt3;
-- Ethernet DMA operation mode register
type DMAOMR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- SR
SR : Boolean := False;
-- OSF
OSF : Boolean := False;
-- RTC
RTC : DMAOMR_RTC_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- FUGF
FUGF : Boolean := False;
-- FEF
FEF : Boolean := False;
-- unspecified
Reserved_8_12 : HAL.UInt5 := 16#0#;
-- ST
ST : Boolean := False;
-- TTC
TTC : DMAOMR_TTC_Field := 16#0#;
-- unspecified
Reserved_17_19 : HAL.UInt3 := 16#0#;
-- FTF
FTF : Boolean := False;
-- TSF
TSF : Boolean := False;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- DFRF
DFRF : Boolean := False;
-- RSF
RSF : Boolean := False;
-- DTCEFD
DTCEFD : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAOMR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
SR at 0 range 1 .. 1;
OSF at 0 range 2 .. 2;
RTC at 0 range 3 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
FUGF at 0 range 6 .. 6;
FEF at 0 range 7 .. 7;
Reserved_8_12 at 0 range 8 .. 12;
ST at 0 range 13 .. 13;
TTC at 0 range 14 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
FTF at 0 range 20 .. 20;
TSF at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
DFRF at 0 range 24 .. 24;
RSF at 0 range 25 .. 25;
DTCEFD at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-- Ethernet DMA interrupt enable register
type DMAIER_Register is record
-- no description available
TIE : Boolean := False;
-- no description available
TPSIE : Boolean := False;
-- no description available
TBUIE : Boolean := False;
-- no description available
TJTIE : Boolean := False;
-- no description available
ROIE : Boolean := False;
-- no description available
TUIE : Boolean := False;
-- no description available
RIE : Boolean := False;
-- no description available
RBUIE : Boolean := False;
-- no description available
RPSIE : Boolean := False;
-- no description available
RWTIE : Boolean := False;
-- no description available
ETIE : Boolean := False;
-- unspecified
Reserved_11_12 : HAL.UInt2 := 16#0#;
-- no description available
FBEIE : Boolean := False;
-- no description available
ERIE : Boolean := False;
-- no description available
AISE : Boolean := False;
-- no description available
NISE : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAIER_Register use record
TIE at 0 range 0 .. 0;
TPSIE at 0 range 1 .. 1;
TBUIE at 0 range 2 .. 2;
TJTIE at 0 range 3 .. 3;
ROIE at 0 range 4 .. 4;
TUIE at 0 range 5 .. 5;
RIE at 0 range 6 .. 6;
RBUIE at 0 range 7 .. 7;
RPSIE at 0 range 8 .. 8;
RWTIE at 0 range 9 .. 9;
ETIE at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
FBEIE at 0 range 13 .. 13;
ERIE at 0 range 14 .. 14;
AISE at 0 range 15 .. 15;
NISE at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype DMAMFBOCR_MFC_Field is HAL.UInt16;
subtype DMAMFBOCR_MFA_Field is HAL.UInt11;
-- Ethernet DMA missed frame and buffer overflow counter register
type DMAMFBOCR_Register is record
-- no description available
MFC : DMAMFBOCR_MFC_Field := 16#0#;
-- no description available
OMFC : Boolean := False;
-- no description available
MFA : DMAMFBOCR_MFA_Field := 16#0#;
-- no description available
OFOC : Boolean := False;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAMFBOCR_Register use record
MFC at 0 range 0 .. 15;
OMFC at 0 range 16 .. 16;
MFA at 0 range 17 .. 27;
OFOC at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype DMARSWTR_RSWTC_Field is HAL.UInt8;
-- Ethernet DMA receive status watchdog timer register
type DMARSWTR_Register is record
-- RSWTC
RSWTC : DMARSWTR_RSWTC_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMARSWTR_Register use record
RSWTC at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype MACCR_BL_Field is HAL.UInt2;
subtype MACCR_IFG_Field is HAL.UInt3;
-- Ethernet MAC configuration register
type MACCR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- RE
RE : Boolean := False;
-- TE
TE : Boolean := False;
-- DC
DC : Boolean := False;
-- BL
BL : MACCR_BL_Field := 16#0#;
-- APCS
APCS : Boolean := False;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- RD
RD : Boolean := False;
-- IPCO
IPCO : Boolean := False;
-- DM
DM : Boolean := False;
-- LM
LM : Boolean := False;
-- ROD
ROD : Boolean := False;
-- FES
FES : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#1#;
-- CSD
CSD : Boolean := False;
-- IFG
IFG : MACCR_IFG_Field := 16#0#;
-- unspecified
Reserved_20_21 : HAL.UInt2 := 16#0#;
-- JD
JD : Boolean := False;
-- WD
WD : Boolean := False;
-- unspecified
Reserved_24_24 : HAL.Bit := 16#0#;
-- CSTF
CSTF : Boolean := False;
-- unspecified
Reserved_26_31 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACCR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
DC at 0 range 4 .. 4;
BL at 0 range 5 .. 6;
APCS at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
RD at 0 range 9 .. 9;
IPCO at 0 range 10 .. 10;
DM at 0 range 11 .. 11;
LM at 0 range 12 .. 12;
ROD at 0 range 13 .. 13;
FES at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
CSD at 0 range 16 .. 16;
IFG at 0 range 17 .. 19;
Reserved_20_21 at 0 range 20 .. 21;
JD at 0 range 22 .. 22;
WD at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CSTF at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
-- Ethernet MAC frame filter register
type MACFFR_Register is record
-- no description available
PM : Boolean := False;
-- no description available
HU : Boolean := False;
-- no description available
HM : Boolean := False;
-- no description available
DAIF : Boolean := False;
-- no description available
RAM : Boolean := False;
-- no description available
BFD : Boolean := False;
-- no description available
PCF : Boolean := False;
-- no description available
SAIF : Boolean := False;
-- no description available
SAF : Boolean := False;
-- no description available
HPF : Boolean := False;
-- unspecified
Reserved_10_30 : HAL.UInt21 := 16#0#;
-- no description available
RA : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACFFR_Register use record
PM at 0 range 0 .. 0;
HU at 0 range 1 .. 1;
HM at 0 range 2 .. 2;
DAIF at 0 range 3 .. 3;
RAM at 0 range 4 .. 4;
BFD at 0 range 5 .. 5;
PCF at 0 range 6 .. 6;
SAIF at 0 range 7 .. 7;
SAF at 0 range 8 .. 8;
HPF at 0 range 9 .. 9;
Reserved_10_30 at 0 range 10 .. 30;
RA at 0 range 31 .. 31;
end record;
subtype MACMIIAR_CR_Field is HAL.UInt3;
subtype MACMIIAR_MR_Field is HAL.UInt5;
subtype MACMIIAR_PA_Field is HAL.UInt5;
-- Ethernet MAC MII address register
type MACMIIAR_Register is record
-- no description available
MB : Boolean := False;
-- no description available
MW : Boolean := False;
-- no description available
CR : MACMIIAR_CR_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- no description available
MR : MACMIIAR_MR_Field := 16#0#;
-- no description available
PA : MACMIIAR_PA_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACMIIAR_Register use record
MB at 0 range 0 .. 0;
MW at 0 range 1 .. 1;
CR at 0 range 2 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
MR at 0 range 6 .. 10;
PA at 0 range 11 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype MACMIIDR_TD_Field is HAL.UInt16;
-- Ethernet MAC MII data register
type MACMIIDR_Register is record
-- no description available
TD : MACMIIDR_TD_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACMIIDR_Register use record
TD at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype MACFCR_PLT_Field is HAL.UInt2;
subtype MACFCR_PT_Field is HAL.UInt16;
-- Ethernet MAC flow control register
type MACFCR_Register is record
-- no description available
FCB : Boolean := False;
-- no description available
TFCE : Boolean := False;
-- no description available
RFCE : Boolean := False;
-- no description available
UPFD : Boolean := False;
-- no description available
PLT : MACFCR_PLT_Field := 16#0#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- no description available
ZQPD : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- no description available
PT : MACFCR_PT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACFCR_Register use record
FCB at 0 range 0 .. 0;
TFCE at 0 range 1 .. 1;
RFCE at 0 range 2 .. 2;
UPFD at 0 range 3 .. 3;
PLT at 0 range 4 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
ZQPD at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
PT at 0 range 16 .. 31;
end record;
subtype MACVLANTR_VLANTI_Field is HAL.UInt16;
-- Ethernet MAC VLAN tag register
type MACVLANTR_Register is record
-- no description available
VLANTI : MACVLANTR_VLANTI_Field := 16#0#;
-- no description available
VLANTC : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACVLANTR_Register use record
VLANTI at 0 range 0 .. 15;
VLANTC at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- Ethernet MAC PMT control and status register
type MACPMTCSR_Register is record
-- no description available
PD : Boolean := False;
-- no description available
MPE : Boolean := False;
-- no description available
WFE : Boolean := False;
-- unspecified
Reserved_3_4 : HAL.UInt2 := 16#0#;
-- no description available
MPR : Boolean := False;
-- no description available
WFR : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- no description available
GU : Boolean := False;
-- unspecified
Reserved_10_30 : HAL.UInt21 := 16#0#;
-- no description available
WFFRPR : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACPMTCSR_Register use record
PD at 0 range 0 .. 0;
MPE at 0 range 1 .. 1;
WFE at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
MPR at 0 range 5 .. 5;
WFR at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
GU at 0 range 9 .. 9;
Reserved_10_30 at 0 range 10 .. 30;
WFFRPR at 0 range 31 .. 31;
end record;
-- Ethernet MAC debug register
type MACDBGR_Register is record
-- Read-only. CR
CR : Boolean;
-- Read-only. CSR
CSR : Boolean;
-- Read-only. ROR
ROR : Boolean;
-- Read-only. MCF
MCF : Boolean;
-- Read-only. MCP
MCP : Boolean;
-- Read-only. MCFHP
MCFHP : Boolean;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACDBGR_Register use record
CR at 0 range 0 .. 0;
CSR at 0 range 1 .. 1;
ROR at 0 range 2 .. 2;
MCF at 0 range 3 .. 3;
MCP at 0 range 4 .. 4;
MCFHP at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Ethernet MAC interrupt status register
type MACSR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Read-only. no description available
PMTS : Boolean := False;
-- Read-only. no description available
MMCS : Boolean := False;
-- Read-only. no description available
MMCRS : Boolean := False;
-- Read-only. no description available
MMCTS : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- no description available
TSTS : Boolean := False;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACSR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
PMTS at 0 range 3 .. 3;
MMCS at 0 range 4 .. 4;
MMCRS at 0 range 5 .. 5;
MMCTS at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
TSTS at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
-- Ethernet MAC interrupt mask register
type MACIMR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- no description available
PMTIM : Boolean := False;
-- unspecified
Reserved_4_8 : HAL.UInt5 := 16#0#;
-- no description available
TSTIM : Boolean := False;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACIMR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
PMTIM at 0 range 3 .. 3;
Reserved_4_8 at 0 range 4 .. 8;
TSTIM at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
subtype MACA0HR_MACA0H_Field is HAL.UInt16;
-- Ethernet MAC address 0 high register
type MACA0HR_Register is record
-- MAC address0 high
MACA0H : MACA0HR_MACA0H_Field := 16#FFFF#;
-- unspecified
Reserved_16_30 : HAL.UInt15 := 16#10#;
-- Read-only. Always 1
MO : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA0HR_Register use record
MACA0H at 0 range 0 .. 15;
Reserved_16_30 at 0 range 16 .. 30;
MO at 0 range 31 .. 31;
end record;
subtype MACA1HR_MACA1H_Field is HAL.UInt16;
subtype MACA1HR_MBC_Field is HAL.UInt6;
-- Ethernet MAC address 1 high register
type MACA1HR_Register is record
-- no description available
MACA1H : MACA1HR_MACA1H_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : HAL.UInt8 := 16#0#;
-- no description available
MBC : MACA1HR_MBC_Field := 16#0#;
-- no description available
SA : Boolean := False;
-- no description available
AE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA1HR_Register use record
MACA1H at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
subtype MACA2HR_MAC2AH_Field is HAL.UInt16;
subtype MACA2HR_MBC_Field is HAL.UInt6;
-- Ethernet MAC address 2 high register
type MACA2HR_Register is record
-- no description available
MAC2AH : MACA2HR_MAC2AH_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : HAL.UInt8 := 16#0#;
-- no description available
MBC : MACA2HR_MBC_Field := 16#0#;
-- no description available
SA : Boolean := False;
-- no description available
AE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA2HR_Register use record
MAC2AH at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
subtype MACA2LR_MACA2L_Field is HAL.UInt31;
-- Ethernet MAC address 2 low register
type MACA2LR_Register is record
-- no description available
MACA2L : MACA2LR_MACA2L_Field := 16#7FFFFFFF#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#1#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA2LR_Register use record
MACA2L at 0 range 0 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype MACA3HR_MACA3H_Field is HAL.UInt16;
subtype MACA3HR_MBC_Field is HAL.UInt6;
-- Ethernet MAC address 3 high register
type MACA3HR_Register is record
-- no description available
MACA3H : MACA3HR_MACA3H_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : HAL.UInt8 := 16#0#;
-- no description available
MBC : MACA3HR_MBC_Field := 16#0#;
-- no description available
SA : Boolean := False;
-- no description available
AE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA3HR_Register use record
MACA3H at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
-- Ethernet MMC control register
type MMCCR_Register is record
-- no description available
CR : Boolean := False;
-- no description available
CSR : Boolean := False;
-- no description available
ROR : Boolean := False;
-- no description available
MCF : Boolean := False;
-- no description available
MCP : Boolean := False;
-- no description available
MCFHP : Boolean := False;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCCR_Register use record
CR at 0 range 0 .. 0;
CSR at 0 range 1 .. 1;
ROR at 0 range 2 .. 2;
MCF at 0 range 3 .. 3;
MCP at 0 range 4 .. 4;
MCFHP at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Ethernet MMC receive interrupt register
type MMCRIR_Register is record
-- unspecified
Reserved_0_4 : HAL.UInt5 := 16#0#;
-- no description available
RFCES : Boolean := False;
-- no description available
RFAES : Boolean := False;
-- unspecified
Reserved_7_16 : HAL.UInt10 := 16#0#;
-- no description available
RGUFS : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCRIR_Register use record
Reserved_0_4 at 0 range 0 .. 4;
RFCES at 0 range 5 .. 5;
RFAES at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
RGUFS at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Ethernet MMC transmit interrupt register
type MMCTIR_Register is record
-- unspecified
Reserved_0_13 : HAL.UInt14;
-- Read-only. no description available
TGFSCS : Boolean;
-- Read-only. no description available
TGFMSCS : Boolean;
-- unspecified
Reserved_16_20 : HAL.UInt5;
-- Read-only. no description available
TGFS : Boolean;
-- unspecified
Reserved_22_31 : HAL.UInt10;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCTIR_Register use record
Reserved_0_13 at 0 range 0 .. 13;
TGFSCS at 0 range 14 .. 14;
TGFMSCS at 0 range 15 .. 15;
Reserved_16_20 at 0 range 16 .. 20;
TGFS at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Ethernet MMC receive interrupt mask register
type MMCRIMR_Register is record
-- unspecified
Reserved_0_4 : HAL.UInt5 := 16#0#;
-- no description available
RFCEM : Boolean := False;
-- no description available
RFAEM : Boolean := False;
-- unspecified
Reserved_7_16 : HAL.UInt10 := 16#0#;
-- no description available
RGUFM : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCRIMR_Register use record
Reserved_0_4 at 0 range 0 .. 4;
RFCEM at 0 range 5 .. 5;
RFAEM at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
RGUFM at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Ethernet MMC transmit interrupt mask register
type MMCTIMR_Register is record
-- unspecified
Reserved_0_13 : HAL.UInt14 := 16#0#;
-- no description available
TGFSCM : Boolean := False;
-- no description available
TGFMSCM : Boolean := False;
-- no description available
TGFM : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCTIMR_Register use record
Reserved_0_13 at 0 range 0 .. 13;
TGFSCM at 0 range 14 .. 14;
TGFMSCM at 0 range 15 .. 15;
TGFM at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype PTPTSCR_TSCNT_Field is HAL.UInt2;
-- Ethernet PTP time stamp control register
type PTPTSCR_Register is record
-- no description available
TSE : Boolean := False;
-- no description available
TSFCU : Boolean := False;
-- no description available
TSSTI : Boolean := False;
-- no description available
TSSTU : Boolean := False;
-- no description available
TSITE : Boolean := False;
-- no description available
TTSARU : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- no description available
TSSARFE : Boolean := False;
-- no description available
TSSSR : Boolean := False;
-- no description available
TSPTPPSV2E : Boolean := False;
-- no description available
TSSPTPOEFE : Boolean := False;
-- no description available
TSSIPV6FE : Boolean := False;
-- no description available
TSSIPV4FE : Boolean := True;
-- no description available
TSSEME : Boolean := False;
-- no description available
TSSMRME : Boolean := False;
-- no description available
TSCNT : PTPTSCR_TSCNT_Field := 16#0#;
-- no description available
TSPFFMAE : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSCR_Register use record
TSE at 0 range 0 .. 0;
TSFCU at 0 range 1 .. 1;
TSSTI at 0 range 2 .. 2;
TSSTU at 0 range 3 .. 3;
TSITE at 0 range 4 .. 4;
TTSARU at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
TSSARFE at 0 range 8 .. 8;
TSSSR at 0 range 9 .. 9;
TSPTPPSV2E at 0 range 10 .. 10;
TSSPTPOEFE at 0 range 11 .. 11;
TSSIPV6FE at 0 range 12 .. 12;
TSSIPV4FE at 0 range 13 .. 13;
TSSEME at 0 range 14 .. 14;
TSSMRME at 0 range 15 .. 15;
TSCNT at 0 range 16 .. 17;
TSPFFMAE at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype PTPSSIR_STSSI_Field is HAL.UInt8;
-- Ethernet PTP subsecond increment register
type PTPSSIR_Register is record
-- no description available
STSSI : PTPSSIR_STSSI_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPSSIR_Register use record
STSSI at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype PTPTSLR_STSS_Field is HAL.UInt31;
-- Ethernet PTP time stamp low register
type PTPTSLR_Register is record
-- Read-only. no description available
STSS : PTPTSLR_STSS_Field;
-- Read-only. no description available
STPNS : Boolean;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSLR_Register use record
STSS at 0 range 0 .. 30;
STPNS at 0 range 31 .. 31;
end record;
subtype PTPTSLUR_TSUSS_Field is HAL.UInt31;
-- Ethernet PTP time stamp low update register
type PTPTSLUR_Register is record
-- no description available
TSUSS : PTPTSLUR_TSUSS_Field := 16#0#;
-- no description available
TSUPNS : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSLUR_Register use record
TSUSS at 0 range 0 .. 30;
TSUPNS at 0 range 31 .. 31;
end record;
-- Ethernet PTP time stamp status register
type PTPTSSR_Register is record
-- Read-only. no description available
TSSO : Boolean;
-- Read-only. no description available
TSTTR : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSSR_Register use record
TSSO at 0 range 0 .. 0;
TSTTR at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Ethernet PTP PPS control register
type PTPPPSCR_Register is record
-- Read-only. TSSO
TSSO : Boolean;
-- Read-only. TSTTR
TSTTR : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPPPSCR_Register use record
TSSO at 0 range 0 .. 0;
TSTTR at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Ethernet: DMA controller operation
type Ethernet_DMA_Peripheral is record
-- Ethernet DMA bus mode register
DMABMR : aliased DMABMR_Register;
-- Ethernet DMA transmit poll demand register
DMATPDR : aliased HAL.UInt32;
-- EHERNET DMA receive poll demand register
DMARPDR : aliased HAL.UInt32;
-- Ethernet DMA receive descriptor list address register
DMARDLAR : aliased HAL.UInt32;
-- Ethernet DMA transmit descriptor list address register
DMATDLAR : aliased HAL.UInt32;
-- Ethernet DMA status register
DMASR : aliased DMASR_Register;
-- Ethernet DMA operation mode register
DMAOMR : aliased DMAOMR_Register;
-- Ethernet DMA interrupt enable register
DMAIER : aliased DMAIER_Register;
-- Ethernet DMA missed frame and buffer overflow counter register
DMAMFBOCR : aliased DMAMFBOCR_Register;
-- Ethernet DMA receive status watchdog timer register
DMARSWTR : aliased DMARSWTR_Register;
-- Ethernet DMA current host transmit descriptor register
DMACHTDR : aliased HAL.UInt32;
-- Ethernet DMA current host receive descriptor register
DMACHRDR : aliased HAL.UInt32;
-- Ethernet DMA current host transmit buffer address register
DMACHTBAR : aliased HAL.UInt32;
-- Ethernet DMA current host receive buffer address register
DMACHRBAR : aliased HAL.UInt32;
end record
with Volatile;
for Ethernet_DMA_Peripheral use record
DMABMR at 16#0# range 0 .. 31;
DMATPDR at 16#4# range 0 .. 31;
DMARPDR at 16#8# range 0 .. 31;
DMARDLAR at 16#C# range 0 .. 31;
DMATDLAR at 16#10# range 0 .. 31;
DMASR at 16#14# range 0 .. 31;
DMAOMR at 16#18# range 0 .. 31;
DMAIER at 16#1C# range 0 .. 31;
DMAMFBOCR at 16#20# range 0 .. 31;
DMARSWTR at 16#24# range 0 .. 31;
DMACHTDR at 16#48# range 0 .. 31;
DMACHRDR at 16#4C# range 0 .. 31;
DMACHTBAR at 16#50# range 0 .. 31;
DMACHRBAR at 16#54# range 0 .. 31;
end record;
-- Ethernet: DMA controller operation
Ethernet_DMA_Periph : aliased Ethernet_DMA_Peripheral
with Import, Address => System'To_Address (16#40029000#);
-- Ethernet: media access control (MAC)
type Ethernet_MAC_Peripheral is record
-- Ethernet MAC configuration register
MACCR : aliased MACCR_Register;
-- Ethernet MAC frame filter register
MACFFR : aliased MACFFR_Register;
-- Ethernet MAC hash table high register
MACHTHR : aliased HAL.UInt32;
-- Ethernet MAC hash table low register
MACHTLR : aliased HAL.UInt32;
-- Ethernet MAC MII address register
MACMIIAR : aliased MACMIIAR_Register;
-- Ethernet MAC MII data register
MACMIIDR : aliased MACMIIDR_Register;
-- Ethernet MAC flow control register
MACFCR : aliased MACFCR_Register;
-- Ethernet MAC VLAN tag register
MACVLANTR : aliased MACVLANTR_Register;
-- Ethernet MAC PMT control and status register
MACPMTCSR : aliased MACPMTCSR_Register;
-- Ethernet MAC debug register
MACDBGR : aliased MACDBGR_Register;
-- Ethernet MAC interrupt status register
MACSR : aliased MACSR_Register;
-- Ethernet MAC interrupt mask register
MACIMR : aliased MACIMR_Register;
-- Ethernet MAC address 0 high register
MACA0HR : aliased MACA0HR_Register;
-- Ethernet MAC address 0 low register
MACA0LR : aliased HAL.UInt32;
-- Ethernet MAC address 1 high register
MACA1HR : aliased MACA1HR_Register;
-- Ethernet MAC address1 low register
MACA1LR : aliased HAL.UInt32;
-- Ethernet MAC address 2 high register
MACA2HR : aliased MACA2HR_Register;
-- Ethernet MAC address 2 low register
MACA2LR : aliased MACA2LR_Register;
-- Ethernet MAC address 3 high register
MACA3HR : aliased MACA3HR_Register;
-- Ethernet MAC address 3 low register
MACA3LR : aliased HAL.UInt32;
-- Ethernet MAC remote wakeup frame filter register
MACRWUFFER : aliased HAL.UInt32;
end record
with Volatile;
for Ethernet_MAC_Peripheral use record
MACCR at 16#0# range 0 .. 31;
MACFFR at 16#4# range 0 .. 31;
MACHTHR at 16#8# range 0 .. 31;
MACHTLR at 16#C# range 0 .. 31;
MACMIIAR at 16#10# range 0 .. 31;
MACMIIDR at 16#14# range 0 .. 31;
MACFCR at 16#18# range 0 .. 31;
MACVLANTR at 16#1C# range 0 .. 31;
MACPMTCSR at 16#2C# range 0 .. 31;
MACDBGR at 16#34# range 0 .. 31;
MACSR at 16#38# range 0 .. 31;
MACIMR at 16#3C# range 0 .. 31;
MACA0HR at 16#40# range 0 .. 31;
MACA0LR at 16#44# range 0 .. 31;
MACA1HR at 16#48# range 0 .. 31;
MACA1LR at 16#4C# range 0 .. 31;
MACA2HR at 16#50# range 0 .. 31;
MACA2LR at 16#54# range 0 .. 31;
MACA3HR at 16#58# range 0 .. 31;
MACA3LR at 16#5C# range 0 .. 31;
MACRWUFFER at 16#60# range 0 .. 31;
end record;
-- Ethernet: media access control (MAC)
Ethernet_MAC_Periph : aliased Ethernet_MAC_Peripheral
with Import, Address => System'To_Address (16#40028000#);
-- Ethernet: MAC management counters
type Ethernet_MMC_Peripheral is record
-- Ethernet MMC control register
MMCCR : aliased MMCCR_Register;
-- Ethernet MMC receive interrupt register
MMCRIR : aliased MMCRIR_Register;
-- Ethernet MMC transmit interrupt register
MMCTIR : aliased MMCTIR_Register;
-- Ethernet MMC receive interrupt mask register
MMCRIMR : aliased MMCRIMR_Register;
-- Ethernet MMC transmit interrupt mask register
MMCTIMR : aliased MMCTIMR_Register;
-- Ethernet MMC transmitted good frames after a single collision counter
MMCTGFSCCR : aliased HAL.UInt32;
-- Ethernet MMC transmitted good frames after more than a single
-- collision
MMCTGFMSCCR : aliased HAL.UInt32;
-- Ethernet MMC transmitted good frames counter register
MMCTGFCR : aliased HAL.UInt32;
-- Ethernet MMC received frames with CRC error counter register
MMCRFCECR : aliased HAL.UInt32;
-- Ethernet MMC received frames with alignment error counter register
MMCRFAECR : aliased HAL.UInt32;
-- MMC received good unicast frames counter register
MMCRGUFCR : aliased HAL.UInt32;
end record
with Volatile;
for Ethernet_MMC_Peripheral use record
MMCCR at 16#0# range 0 .. 31;
MMCRIR at 16#4# range 0 .. 31;
MMCTIR at 16#8# range 0 .. 31;
MMCRIMR at 16#C# range 0 .. 31;
MMCTIMR at 16#10# range 0 .. 31;
MMCTGFSCCR at 16#4C# range 0 .. 31;
MMCTGFMSCCR at 16#50# range 0 .. 31;
MMCTGFCR at 16#68# range 0 .. 31;
MMCRFCECR at 16#94# range 0 .. 31;
MMCRFAECR at 16#98# range 0 .. 31;
MMCRGUFCR at 16#C4# range 0 .. 31;
end record;
-- Ethernet: MAC management counters
Ethernet_MMC_Periph : aliased Ethernet_MMC_Peripheral
with Import, Address => System'To_Address (16#40028100#);
-- Ethernet: Precision time protocol
type Ethernet_PTP_Peripheral is record
-- Ethernet PTP time stamp control register
PTPTSCR : aliased PTPTSCR_Register;
-- Ethernet PTP subsecond increment register
PTPSSIR : aliased PTPSSIR_Register;
-- Ethernet PTP time stamp high register
PTPTSHR : aliased HAL.UInt32;
-- Ethernet PTP time stamp low register
PTPTSLR : aliased PTPTSLR_Register;
-- Ethernet PTP time stamp high update register
PTPTSHUR : aliased HAL.UInt32;
-- Ethernet PTP time stamp low update register
PTPTSLUR : aliased PTPTSLUR_Register;
-- Ethernet PTP time stamp addend register
PTPTSAR : aliased HAL.UInt32;
-- Ethernet PTP target time high register
PTPTTHR : aliased HAL.UInt32;
-- Ethernet PTP target time low register
PTPTTLR : aliased HAL.UInt32;
-- Ethernet PTP time stamp status register
PTPTSSR : aliased PTPTSSR_Register;
-- Ethernet PTP PPS control register
PTPPPSCR : aliased PTPPPSCR_Register;
end record
with Volatile;
for Ethernet_PTP_Peripheral use record
PTPTSCR at 16#0# range 0 .. 31;
PTPSSIR at 16#4# range 0 .. 31;
PTPTSHR at 16#8# range 0 .. 31;
PTPTSLR at 16#C# range 0 .. 31;
PTPTSHUR at 16#10# range 0 .. 31;
PTPTSLUR at 16#14# range 0 .. 31;
PTPTSAR at 16#18# range 0 .. 31;
PTPTTHR at 16#1C# range 0 .. 31;
PTPTTLR at 16#20# range 0 .. 31;
PTPTSSR at 16#28# range 0 .. 31;
PTPPPSCR at 16#2C# range 0 .. 31;
end record;
-- Ethernet: Precision time protocol
Ethernet_PTP_Periph : aliased Ethernet_PTP_Peripheral
with Import, Address => System'To_Address (16#40028700#);
end STM32_SVD.Ethernet;
|
charlie5/cBound | Ada | 1,504 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_render_indexvalue_t is
-- Item
--
type Item is record
pixel : aliased Interfaces.Unsigned_32;
red : aliased Interfaces.Unsigned_16;
green : aliased Interfaces.Unsigned_16;
blue : aliased Interfaces.Unsigned_16;
alpha : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_render_indexvalue_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_indexvalue_t.Item,
Element_Array => xcb.xcb_render_indexvalue_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_render_indexvalue_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_indexvalue_t.Pointer,
Element_Array => xcb.xcb_render_indexvalue_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_indexvalue_t;
|
charlie5/dynamic_distributed_computing | Ada | 4,862 | adb | with
Ada.Containers.Vectors,
Ada.Text_IO;
package body DDC.Boss
is
use DDC.Worker,
Ada.Text_IO;
----------
-- Workers
--
package Worker_vectors is new Ada.Containers.Vectors (Positive, remote_Worker);
use worker_Vectors;
subtype Worker_vector is Worker_vectors.Vector;
protected ready_Workers
is
procedure get_next_Available (the_Worker : out remote_Worker);
procedure add (the_Worker : in remote_Worker);
procedure rid (the_Worker : in remote_Worker);
private
Workers : Worker_vector;
end ready_Workers;
protected body ready_Workers
is
procedure get_next_Available (the_Worker : out remote_Worker)
is
begin
if Workers.Is_Empty
then
the_Worker := null;
return;
end if;
the_Worker := Workers.last_Element;
Workers.delete_Last;
end get_next_Available;
procedure add (the_Worker : in remote_Worker)
is
begin
Workers.prepend (the_Worker);
end add;
procedure rid (the_Worker : in remote_Worker)
is
begin
Workers.delete (Workers.find_Index (the_Worker));
end rid;
end ready_Workers;
function next_available_Worker return remote_Worker
is
use Ada.Containers;
the_Worker : remote_Worker;
begin
loop
ready_Workers.get_next_Available (the_Worker);
if the_Worker /= null
then
return the_Worker;
end if;
end loop;
end next_available_Worker;
--------------
-- Calculation
--
protected current_Average
is
function Value return Float;
procedure add (Partial : in Float);
function Count return Natural;
private
Average : Float := 0.0;
partial_Count : Natural := 0;
end current_Average;
protected body current_Average
is
function Value return Float
is
begin
return Average / Float (partial_Count);
end Value;
procedure add (Partial : in Float)
is
begin
Average := Average + Partial;
partial_Count := partial_Count + 1;
end add;
function Count return Natural
is
begin
return partial_Count;
end Count;
end current_Average;
-- Samples
--
total_sample_Count : constant := 10_000_000;
all_Samples : Samples (1 .. total_sample_Count);
-- Job Samples
--
job_samples_Count : constant := 1_000;
subtype job_Samples is Samples (1 .. job_samples_Count);
-- Jobs
--
job_Count : constant := total_sample_Count / job_samples_Count;
next_Job : Positive := 1; -- Index of the next job to be done.
-------------
-- Operations
--
procedure calculate
is
the_final_Average : Float;
begin
put_Line ("Boss begins 'Average' calculation.");
-- Distribute the jobs.
--
loop
declare
available_Worker : constant remote_Worker := next_available_Worker;
First : constant Integer := 1 + (next_Job - 1) * job_samples_Count;
Last : constant Integer := next_Job * job_samples_Count;
the_Samples : constant job_Samples := all_Samples (First .. Last);
begin
available_Worker.process (the_Samples);
end;
next_Job := next_Job + 1;
exit when next_Job > job_Count;
end loop;
-- Wait until all jobs are completed.
--
while current_Average.Count < job_Count
loop
delay 0.1;
end loop;
-- Calculate the final result.
--
the_final_Average := current_Average.Value;
put_Line ("Boss: Average is" & Float'Image (the_final_Average));
end calculate;
procedure accept_partial (Result : in Float;
From : in remote_Worker)
is
begin
current_Average.add (Partial => Result);
ready_Workers .add (From);
end accept_partial;
protected next_Id
is
procedure get (Id : out worker_Id);
private
Next : worker_Id := 1;
end next_Id;
protected body next_Id
is
procedure get (Id : out worker_Id)
is
begin
Id := Next;
Next := Next + 1;
end get;
end next_Id;
procedure add (the_Worker : in remote_Worker;
Id : out worker_Id)
is
begin
next_Id.get (Id);
ready_Workers.add (the_Worker);
end add;
procedure rid (the_Worker : in remote_Worker)
is
begin
ready_Workers.rid (the_Worker);
end rid;
begin
-- Initialise the value of each sample.
--
for i in all_Samples'Range
loop
all_Samples (i) := Float (i);
end loop;
end DDC.Boss;
|
reznikmm/matreshka | Ada | 4,257 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes;
with XML.DOM.Elements.Internals;
package body ODF.DOM.Elements.Style.Footer_Style.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Elements.Style.Footer_Style.Style_Footer_Style_Access)
return ODF.DOM.Elements.Style.Footer_Style.ODF_Style_Footer_Style is
begin
return
(XML.DOM.Elements.Internals.Create
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Elements.Style.Footer_Style.Style_Footer_Style_Access)
return ODF.DOM.Elements.Style.Footer_Style.ODF_Style_Footer_Style is
begin
return
(XML.DOM.Elements.Internals.Wrap
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Elements.Style.Footer_Style.Internals;
|
reznikmm/matreshka | Ada | 4,005 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Office_Dde_Item_Attributes;
package Matreshka.ODF_Office.Dde_Item_Attributes is
type Office_Dde_Item_Attribute_Node is
new Matreshka.ODF_Office.Abstract_Office_Attribute_Node
and ODF.DOM.Office_Dde_Item_Attributes.ODF_Office_Dde_Item_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Office_Dde_Item_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Dde_Item_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Office.Dde_Item_Attributes;
|
reznikmm/matreshka | Ada | 4,017 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Howpublished_Attributes;
package Matreshka.ODF_Text.Howpublished_Attributes is
type Text_Howpublished_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Howpublished_Attributes.ODF_Text_Howpublished_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Howpublished_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Howpublished_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Howpublished_Attributes;
|
reznikmm/matreshka | Ada | 5,589 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
limited with AMF.UML.Namespaces;
limited with AMF.UML.Properties;
limited with AMF.UML.Value_Specifications;
with League.Strings;
package AMF.Utp.Coding_Rules is
pragma Preelaborate;
type Utp_Coding_Rule is limited interface;
type Utp_Coding_Rule_Access is
access all Utp_Coding_Rule'Class;
for Utp_Coding_Rule_Access'Storage_Size use 0;
not overriding function Get_Base_Value_Specification
(Self : not null access constant Utp_Coding_Rule)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access is abstract;
-- Getter of CodingRule::base_ValueSpecification.
--
not overriding procedure Set_Base_Value_Specification
(Self : not null access Utp_Coding_Rule;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is abstract;
-- Setter of CodingRule::base_ValueSpecification.
--
not overriding function Get_Base_Namespace
(Self : not null access constant Utp_Coding_Rule)
return AMF.UML.Namespaces.UML_Namespace_Access is abstract;
-- Getter of CodingRule::base_Namespace.
--
not overriding procedure Set_Base_Namespace
(Self : not null access Utp_Coding_Rule;
To : AMF.UML.Namespaces.UML_Namespace_Access) is abstract;
-- Setter of CodingRule::base_Namespace.
--
not overriding function Get_Base_Property
(Self : not null access constant Utp_Coding_Rule)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Getter of CodingRule::base_Property.
--
not overriding procedure Set_Base_Property
(Self : not null access Utp_Coding_Rule;
To : AMF.UML.Properties.UML_Property_Access) is abstract;
-- Setter of CodingRule::base_Property.
--
not overriding function Get_Coding
(Self : not null access constant Utp_Coding_Rule)
return League.Strings.Universal_String is abstract;
-- Getter of CodingRule::coding.
--
not overriding procedure Set_Coding
(Self : not null access Utp_Coding_Rule;
To : League.Strings.Universal_String) is abstract;
-- Setter of CodingRule::coding.
--
end AMF.Utp.Coding_Rules;
|
reznikmm/matreshka | Ada | 3,647 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Attributes.Text.Line_Number is
type ODF_Text_Line_Number is
new XML.DOM.Attributes.DOM_Attribute with private;
private
type ODF_Text_Line_Number is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.Text.Line_Number;
|
redparavoz/ada-wiki | Ada | 4,326 | adb | -----------------------------------------------------------------------
-- wiki-plugins-conditions -- Condition Plugin
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Wiki.Plugins.Conditions is
-- ------------------------------
-- Append the attribute name/value to the condition plugin parameter list.
-- ------------------------------
procedure Append (Plugin : in out Condition_Plugin;
Name : in Wiki.Strings.WString;
Value : in Wiki.Strings.WString) is
begin
Attributes.Append (Plugin.Params, Name, Value);
end Append;
-- ------------------------------
-- Evaluate the condition and return it as a boolean status.
-- ------------------------------
function Evaluate (Plugin : in Condition_Plugin;
Params : in Wiki.Attributes.Attribute_List) return Boolean is
procedure Check (Name : in String;
Value : in Wiki.Strings.WString);
Result : Boolean := False;
Index : Natural := 0;
procedure Check (Name : in String;
Value : in Wiki.Strings.WString) is
pragma Unreferenced (Name);
Pos : Wiki.Attributes.Cursor;
begin
Index := Index + 1;
if Index > 1 and not Result then
Pos := Attributes.Find (Plugin.Params, Wiki.Strings.To_String (Value));
Result := Attributes.Has_Element (Pos);
end if;
end Check;
begin
Attributes.Iterate (Params, Check'Access);
return Result;
end Evaluate;
-- ------------------------------
-- Get the type of condition (IF, ELSE, ELSIF, END) represented by the plugin.
-- ------------------------------
function Get_Condition_Kind (Plugin : in Condition_Plugin;
Params : in Wiki.Attributes.Attribute_List)
return Condition_Type is
pragma Unreferenced (Plugin);
Name : constant Strings.WString := Attributes.Get_Attribute (Params, "name");
begin
if Name = "if" then
return CONDITION_IF;
elsif Name = "else" then
return CONDITION_ELSE;
elsif Name = "elsif" then
return CONDITION_ELSIF;
elsif Name = "end" then
return CONDITION_END;
else
return CONDITION_IF;
end if;
end Get_Condition_Kind;
-- ------------------------------
-- Evaluate the condition described by the parameters and hide or show the wiki
-- content.
-- ------------------------------
overriding
procedure Expand (Plugin : in out Condition_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in Plugin_Context) is
pragma Unreferenced (Document);
Kind : constant Condition_Type
:= Condition_Plugin'Class (Plugin).Get_Condition_Kind (Params);
begin
case Kind is
when CONDITION_IF =>
Plugin.Depth := Plugin.Depth + 1;
Plugin.Values (Plugin.Depth) := not Condition_Plugin'Class (Plugin).Evaluate (Params);
when CONDITION_ELSIF =>
Plugin.Values (Plugin.Depth) := not Condition_Plugin'Class (Plugin).Evaluate (Params);
when CONDITION_ELSE =>
Plugin.Values (Plugin.Depth) := not Plugin.Values (Plugin.Depth);
when CONDITION_END =>
Plugin.Depth := Plugin.Depth - 1;
end case;
Context.Previous.Is_Hidden := Plugin.Values (Plugin.Depth);
end Expand;
end Wiki.Plugins.Conditions;
|
Fabien-Chouteau/lvgl-ada | Ada | 22,574 | ads | with Lv.Area;
with Lv.Style;
with Lv.Color; use Lv.Color;
package Lv.Objx is
type Obj_T is new System.Address;
No_Obj : constant Obj_T := Obj_T (System.Null_Address);
Anim_In : constant := 16#00#;
Anim_Out : constant := 16#80#;
Anim_Dir_Mask : constant := 16#80#;
Lv_Max_Ancestor_Num : constant := 8;
Res_Inv : constant := 0;
Res_Ok : constant := 1;
type Align_T is
(Align_Center,
Align_In_Top_Left,
Align_In_Top_Mid,
Align_In_Top_Right,
Align_In_Bottom_Left,
Align_In_Bottom_Mid,
Align_In_Bottom_Right,
Align_In_Left_Mid,
Align_In_Right_Mid,
Align_Out_Top_Left,
Align_Out_Top_Mid,
Align_Out_Top_Right,
Align_Out_Bottom_Left,
Align_Out_Bottom_Mid,
Align_Out_Bottom_Right,
Align_Out_Left_Top,
Align_Out_Left_Mid,
Align_Out_Left_Bottom,
Align_Out_Right_Top,
Align_Out_Right_Mid,
Align_Out_Right_Bottom) with
Size => 8;
for Align_T use
(Align_Center => 0,
Align_In_Top_Left => 1,
Align_In_Top_Mid => 2,
Align_In_Top_Right => 3,
Align_In_Bottom_Left => 4,
Align_In_Bottom_Mid => 5,
Align_In_Bottom_Right => 6,
Align_In_Left_Mid => 7,
Align_In_Right_Mid => 8,
Align_Out_Top_Left => 9,
Align_Out_Top_Mid => 10,
Align_Out_Top_Right => 11,
Align_Out_Bottom_Left => 12,
Align_Out_Bottom_Mid => 13,
Align_Out_Bottom_Right => 14,
Align_Out_Left_Top => 15,
Align_Out_Left_Mid => 16,
Align_Out_Left_Bottom => 17,
Align_Out_Right_Top => 18,
Align_Out_Right_Mid => 19,
Align_Out_Right_Bottom => 20);
subtype Design_Mode_T is Uint8_T;
type Design_Func_T is access function
(Arg1 : System.Address;
Arg2 : access constant Lv.Area.Area_T;
Arg3 : Design_Mode_T) return U_Bool;
pragma Convention (C, Design_Func_T);
subtype Res_T is Uint8_T;
subtype Signal_T is Uint8_T;
type Signal_Func_T is access function
(Arg1 : System.Address;
Arg2 : Signal_T;
Arg3 : System.Address) return Res_T;
pragma Convention (C, Signal_Func_T);
type Action_Func_T is access function (Arg1 : Obj_T) return Res_T;
pragma Convention (C, Action_Func_T);
subtype Protect_T is Uint8_T;
type Obj_Type_T_C_Type_Array is
array (0 .. 7) of C_String_Ptr;
type Obj_Type_T is record
C_Type : Obj_Type_T_C_Type_Array;
end record;
pragma Convention (C_Pass_By_Copy, Obj_Type_T);
subtype Anim_Builtin_T is Uint8_T;
Anim_None : constant Anim_Builtin_T := 0;
Anim_Float_Top : constant Anim_Builtin_T := 1;
Anim_Float_Left : constant Anim_Builtin_T := 2;
Anim_Float_Bottom : constant Anim_Builtin_T := 3;
Anim_Float_Right : constant Anim_Builtin_T := 4;
Anim_Grow_H : constant Anim_Builtin_T := 5;
Anim_Grow_V : constant Anim_Builtin_T := 6;
-----------------------
-- Create and delete --
-----------------------
-- Create a basic object
-- @param parent pointer to a parent object.
-- If NULL then a screen will be created
-- @param copy pointer to a base object, if not NULL then the new object will be copied from it
-- @return pointer to the new object
function Create (Parent : Obj_T; Copy : Obj_T) return Obj_T;
-- Delete 'obj' and all of its children
-- @param self pointer to an object to delete
-- @return LV_RES_INV because the object is deleted
function Del (Self : Obj_T) return Res_T;
-- Delete all children of an object
-- @param self pointer to an object
procedure Clean (Self : Obj_T);
-- Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
-- @param self pointer to an object
procedure Invalidate (Self : Obj_T);
-- Load a new screen
-- @param scr pointer to a screen
procedure Scr_Load (Scr : Obj_T);
----------------------
-- Setter functions --
----------------------
-------------------------
-- Parent/children set --
-------------------------
-- Set a new parent for an object. Its relative position will be the same.
-- @param self pointer to an object. Can't be a screen.
-- @param parent pointer to the new parent object. (Can't be NULL)
procedure Set_Parent (Self : Obj_T; Parent : Obj_T);
--------------------
-- Coordinate set --
--------------------
-- Set relative the position of an object (relative to the parent)
-- @param self pointer to an object
-- @param x new distance from the left side of the parent
-- @param y new distance from the top of the parent
procedure Set_Pos
(Self : Obj_T;
X : Lv.Area.Coord_T;
Y : Lv.Area.Coord_T);
-- Set the x coordinate of a object
-- @param self pointer to an object
-- @param x new distance from the left side from the parent
procedure Set_X (Self : Obj_T; X : Lv.Area.Coord_T);
-- Set the y coordinate of a object
-- @param self pointer to an object
-- @param y new distance from the top of the parent
procedure Set_Y (Self : Obj_T; Y : Lv.Area.Coord_T);
-- Set the size of an object
-- @param self pointer to an object
-- @param w new width
-- @param h new height
procedure Set_Size (Self : Obj_T; X : Lv.Area.Coord_T; Y : Lv.Area.Coord_T);
-- Set the width of an object
-- @param self pointer to an object
-- @param w new width
procedure Set_Width (Self : Obj_T; W : Lv.Area.Coord_T);
-- Set the height of an object
-- @param self pointer to an object
-- @param h new height
procedure Set_Height (Self : Obj_T; H : Lv.Area.Coord_T);
-- Align an object to an other object.
-- @param self pointer to an object to align
-- @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
-- @param align type of alignment (see 'lv_align_t' enum)
-- @param x_mod x coordinate shift after alignment
-- @param y_mod y coordinate shift after alignment
procedure Align
(Self : Obj_T;
Base : Obj_T;
Align : Align_T;
X_Mod : Lv.Area.Coord_T;
Y_Mod : Lv.Area.Coord_T);
--------------------
-- Appearance set --
--------------------
-- Set a new style for an object
-- @param self pointer to an object
-- @param style_p pointer to the new style
procedure Set_Style (Self : Obj_T; Style_P : Lv.Style.Style);
-- Notify an object about its style is modified
-- @param obj pointer to an object
procedure Refresh_Style (Self : Obj_T);
-- Notify all object if a style is modified
-- @param style pointer to a style. Only the objects with this style will be notified
-- (NULL to notify all objects)
procedure Report_Style_Mod (Style_P : Lv.Style.Style);
-------------------
-- Attribute set --
-------------------
-- Hide an object. It won't be visible and clickable.
-- @param self pointer to an object
-- @param en true: hide the object
procedure Set_Hidden (Self : Obj_T; En: U_Bool);
-- Enable or disable the clicking of an object
-- @param self pointer to an object
-- @param en true: make the object clickable
procedure Set_Click (Self : Obj_T; En : U_Bool);
-- Enable to bring this object to the foreground if it
-- or any of its children is clicked
-- @param self pointer to an object
-- @param en true: enable the auto top feature
procedure Set_Top (Self : Obj_T; En : U_Bool);
-- Enable the dragging of an object
-- @param self pointer to an object
-- @param en true: make the object dragable
procedure Set_Drag (Self : Obj_T; En : U_Bool);
-- Enable the throwing of an object after is is dragged
-- @param self pointer to an object
-- @param en true: enable the drag throw
procedure Set_Drag_Throw (Self : Obj_T; En : U_Bool);
-- Enable to use parent for drag related operations.
-- If trying to drag the object the parent will be moved instead
-- @param self pointer to an object
-- @param en true: enable the 'drag parent' for the object
procedure Set_Drag_Parent (Self : Obj_T; En : U_Bool);
-- Set editable parameter Used by groups and keyboard/encoder control.
-- Editable object has something inside to choose (the elements of a list)
-- @param self pointer to an object
-- @param en true: enable editing
procedure Set_Editable (Self : Obj_T; En : U_Bool);
-- Set the opa scale enable parameter (required to set opa_scale with `lv_obj_set_opa_scale()`)
-- @param self pointer to an object
-- @param en true: opa scaling is enabled for this object and all children; false: no opa scaling
procedure Set_Opa_Scale_Enable (Self : Obj_T; En : U_Bool);
-- Set the opa scale of an object
-- @param self pointer to an object
-- @param opa_scale a factor to scale down opacity [0..255]
procedure Set_Opa_Scale (Self : Obj_T; Opa_Scale : Lv.Color.Opa_T);
-- Set a bit or bits in the protect filed
-- @param self pointer to an object
-- @param prot 'OR'-ed values from `lv_protect_t`
procedure Set_Protect (Self : Obj_T; Prot : Protect_T);
-- Clear a bit or bits in the protect filed
-- @param self pointer to an object
-- @param prot 'OR'-ed values from `lv_protect_t`
procedure Clear_Protect (Self : Obj_T; Prot : Protect_T);
-- Set the signal function of an object.
-- Always call the previous signal function in the new.
-- @param self pointer to an object
-- @param fp the new signal function
procedure Set_Signal_Func (Self : Obj_T; Fp : Signal_Func_T);
-- Set a new design function for an object
-- @param self pointer to an object
-- @param fp the new design function
procedure Set_Design_Func (Self : Obj_T; Fp : Design_Func_T);
---------------
-- Other set --
---------------
-- Allocate a new ext. data for an object
-- @param self pointer to an object
-- @param ext_size the size of the new ext. data
-- @return pointer to the allocated ext
function Allocate_Ext_Attr
(Self : Obj_T;
Ext_Size : Uint16_T) return System.Address;
-- Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
-- @param self pointer to an object
procedure Refresh_Ext_Size (Self : Obj_T);
-- Set an application specific number for an object.
-- It can help to identify objects in the application.
-- @param self pointer to an object
-- @param free_num the new free number
procedure Set_Free_Num (Self : Obj_T; Free_Num : Uint32_T);
-- Set an application specific pointer for an object.
-- It can help to identify objects in the application.
-- @param self pointer to an object
-- @param free_p the new free pinter
procedure Set_Free_Ptr (Self : Obj_T; Free_P : System.Address);
-- Animate an object
-- @param self pointer to an object to animate
-- @param type_p type of animation from 'lv_anim_builtin_t'. 'OR' it with ANIM_IN or ANIM_OUT
-- @param time time of animation in milliseconds
-- @param delay_p delay before the animation in milliseconds
-- @param cb a function to call when the animation is ready
procedure Animate
(Self : Obj_T;
Type_P : Anim_Builtin_T;
Time : Uint16_T;
Delay_P : Uint16_T;
Cb : access procedure (Arg1 : Obj_T));
----------------------
-- Getter functions --
----------------------
----------------
-- Screen get --
----------------
-- Return with a pointer to the active screen
-- @return pointer to the active screen object (loaded by 'lv_scr_load()')
function Scr_Act return Obj_T;
-- Return with the top layer. (Same on every screen and it is above the normal screen layer)
-- @return pointer to the top layer object (transparent screen sized lv_obj)
function Layer_Top return Obj_T;
-- Return with the system layer. (Same on every screen and it is above the all other layers)
-- It is used for example by the cursor
-- @return pointer to the system layer object (transparent screen sized lv_obj)
function Layer_Sys return Obj_T;
-- Return with the screen of an object
-- @param obj pointer to an object
-- @return pointer to a screen
function Screen (Arg1 : Obj_T) return Obj_T;
-------------------------
-- Parent/children get --
-------------------------
-- Returns with the parent of an object
-- @param self pointer to an object
-- @return pointer to the parent of 'obj'
function Parent (Self : Obj_T) return Obj_T;
-- Iterate through the children of an object (start from the "youngest, lastly created")
-- @param self pointer to an object
-- @param child NULL at first call to get the next children
-- and the previous return value later
-- @return the child after 'act_child' or NULL if no more child
function Child (Self : Obj_T; Child : Obj_T) return Obj_T;
-- Iterate through the children of an object (start from the "oldest", firstly created)
-- @param self pointer to an object
-- @param child NULL at first call to get the next children
-- and the previous return value later
-- @return the child after 'act_child' or NULL if no more child
function Child_Back (Self : Obj_T; Child : Obj_T) return Obj_T;
-- Count the children of an object (only children directly on 'obj')
-- @param self pointer to an object
-- @return children number of 'obj'
function Count_Children (Self : Obj_T) return Uint16_T;
--------------------
-- Coordinate get --
--------------------
-- Copy the coordinates of an object to an area
-- @param self pointer to an object
-- @param cords_p pointer to an area to store the coordinates
procedure Coords (Self : Obj_T; Cords_P : access Lv.Area.Area_T);
-- Get the x coordinate of object
-- @param self pointer to an object
-- @return distance of 'obj' from the left side of its parent
function X (Self : Obj_T) return Lv.Area.Coord_T;
-- Get the y coordinate of object
-- @param self pointer to an object
-- @return distance of 'obj' from the top of its parent
function Y (Self : Obj_T) return Lv.Area.Coord_T;
-- Get the width of an object
-- @param self pointer to an object
-- @return the width
function Width (Self : Obj_T) return Lv.Area.Coord_T;
-- Get the height of an object
-- @param self pointer to an object
-- @return the height
function Height (Self : Obj_T) return Lv.Area.Coord_T;
-- Get the extended size attribute of an object
-- @param self pointer to an object
-- @return the extended size attribute
function Ext_Size (Self : Obj_T) return Lv.Area.Coord_T;
--------------------
-- Appearance get --
--------------------
-- Get the style pointer of an object (if NULL get style of the parent)
-- @param self pointer to an object
-- @return pointer to a style
function Style (Self : Obj_T) return Lv.Style.Style;
-------------------
-- Attribute get --
-------------------
-- Get the hidden attribute of an object
-- @param self pointer to an object
-- @return true: the object is hidden
function Hidden (Self : Obj_T) return U_Bool;
-- Get the click enable attribute of an object
-- @param self pointer to an object
-- @return true: the object is clickable
function Click (Self : Obj_T) return U_Bool;
-- Get the top enable attribute of an object
-- @param self pointer to an object
-- @return true: the auto top feture is enabled
function Top (Self : Obj_T) return U_Bool;
-- Get the drag enable attribute of an object
-- @param self pointer to an object
-- @return true: the object is dragable
function Drag (Self : Obj_T) return U_Bool;
-- Get the drag thow enable attribute of an object
-- @param self pointer to an object
-- @return true: drag throw is enabled
function Drag_Throw (Self : Obj_T) return U_Bool;
-- Get the drag parent attribute of an object
-- @param self pointer to an object
-- @return true: drag parent is enabled
function Drag_Parent (Self : Obj_T) return U_Bool;
-- Get the opa scale parameter of an object
-- @param self pointer to an object
-- @return opa scale [0..255]
function Opa_Scale (Self : Obj_T) return Lv.Color.Opa_T;
-- Get the protect field of an object
-- @param self pointer to an object
-- @return protect field ('OR'ed values of `lv_protect_t`)
function Protect (Self : Obj_T) return Uint8_T;
-- Check at least one bit of a given protect bitfield is set
-- @param self pointer to an object
-- @param prot protect bits to test ('OR'ed values of `lv_protect_t`)
-- @return false: none of the given bits are set, true: at least one bit is set
function Is_Protected (Self : Obj_T; Prot : Protect_T) return U_Bool;
-- Get the signal function of an object
-- @param self pointer to an object
-- @return the signal function
function Signal_Func (Self : Obj_T) return Signal_Func_T;
-- Get the design function of an object
-- @param self pointer to an object
-- @return the design function
function Design_Func (Self : Obj_T) return Design_Func_T;
---------------
-- Other get --
---------------
-- Get the ext pointer
-- @param self pointer to an object
-- @return the ext pointer but not the dynamic version
-- Use it as ext->data1, and NOT da(ext)->data1
function Ext_Attr (Self : Obj_T) return System.Address;
-- Get object's and its ancestors type. Put their name in `type_buf` starting with the current type.
-- E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
-- @param self pointer to an object which type should be get
-- @param buf pointer to an `lv_obj_type_t` buffer to store the types
procedure Obj_Type (Self : Obj_T; Buf : access Obj_Type_T);
-- Get the free number
-- @param self pointer to an object
-- @return the free number
function Free_Num (Self : Obj_T) return Uint32_T;
-- Get the free pointer
-- @param self pointer to an object
-- @return the free pointer
function Free_Ptr (Self : Obj_T) return System.Address;
-- Get the group of the object
-- @param self pointer to an object
-- @return the pointer to group of the object
function Group (Self : Obj_T) return System.Address;
-- Tell whether the ohe object is the focused object of a group or not.
-- @param self pointer to an object
-- @return true: the object is focused, false: the object is not focused or not in a group
function Is_Focused (Self : Obj_T) return U_Bool;
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_obj_create");
pragma Import (C, Del, "lv_obj_del");
pragma Import (C, Clean, "lv_obj_clean");
pragma Import (C, Invalidate, "lv_obj_invalidate");
pragma Import (C, Scr_Load, "lv_scr_load");
pragma Import (C, Set_Parent, "lv_obj_set_parent");
pragma Import (C, Set_Pos, "lv_obj_set_pos");
pragma Import (C, Set_X, "lv_obj_set_x");
pragma Import (C, Set_Y, "lv_obj_set_y");
pragma Import (C, Set_Size, "lv_obj_set_size");
pragma Import (C, Set_Width, "lv_obj_set_width");
pragma Import (C, Set_Height, "lv_obj_set_height");
pragma Import (C, Align, "lv_obj_align");
pragma Import (C, Set_Style, "lv_obj_set_style");
pragma Import (C, Refresh_Style, "lv_obj_refresh_style");
pragma Import (C, Report_Style_Mod, "lv_obj_report_style_mod");
pragma Import (C, Set_Hidden, "lv_obj_set_hidden");
pragma Import (C, Set_Click, "lv_obj_set_click");
pragma Import (C, Set_Top, "lv_obj_set_top");
pragma Import (C, Set_Drag, "lv_obj_set_drag");
pragma Import (C, Set_Drag_Throw, "lv_obj_set_drag_throw");
pragma Import (C, Set_Drag_Parent, "lv_obj_set_drag_parent");
pragma Import (C, Set_Editable, "lv_obj_set_editable");
pragma Import (C, Set_Opa_Scale_Enable, "lv_obj_set_opa_scale_enable");
pragma Import (C, Set_Opa_Scale, "lv_obj_set_opa_scale");
pragma Import (C, Set_Protect, "lv_obj_set_protect");
pragma Import (C, Clear_Protect, "lv_obj_clear_protect");
pragma Import (C, Set_Signal_Func, "lv_obj_set_signal_func");
pragma Import (C, Set_Design_Func, "lv_obj_set_design_func");
pragma Import (C, Allocate_Ext_Attr, "lv_obj_allocate_ext_attr");
pragma Import (C, Refresh_Ext_Size, "lv_obj_refresh_ext_size");
pragma Import (C, Set_Free_Num, "lv_obj_set_free_num");
pragma Import (C, Set_Free_Ptr, "lv_obj_set_free_ptr");
pragma Import (C, Animate, "lv_obj_animate");
pragma Import (C, Scr_Act, "lv_scr_act");
pragma Import (C, Layer_Top, "lv_layer_top");
pragma Import (C, Layer_Sys, "lv_layer_sys");
pragma Import (C, Screen, "lv_obj_get_screen");
pragma Import (C, Parent, "lv_obj_get_parent");
pragma Import (C, Child, "lv_obj_get_child");
pragma Import (C, Child_Back, "lv_obj_get_child_back");
pragma Import (C, Count_Children, "lv_obj_count_children");
pragma Import (C, Coords, "lv_obj_get_coords");
pragma Import (C, X, "lv_obj_get_x");
pragma Import (C, Y, "lv_obj_get_y");
pragma Import (C, Width, "lv_obj_get_width");
pragma Import (C, Height, "lv_obj_get_height");
pragma Import (C, Ext_Size, "lv_obj_get_ext_size");
pragma Import (C, Style, "lv_obj_get_style");
pragma Import (C, Hidden, "lv_obj_get_hidden");
pragma Import (C, Click, "lv_obj_get_click");
pragma Import (C, Top, "lv_obj_get_top");
pragma Import (C, Drag, "lv_obj_get_drag");
pragma Import (C, Drag_Throw, "lv_obj_get_drag_throw");
pragma Import (C, Drag_Parent, "lv_obj_get_drag_parent");
pragma Import (C, Opa_Scale, "lv_obj_get_opa_scale");
pragma Import (C, Protect, "lv_obj_get_protect");
pragma Import (C, Is_Protected, "lv_obj_is_protected");
pragma Import (C, Signal_Func, "lv_obj_get_signal_func");
pragma Import (C, Design_Func, "lv_obj_get_design_func");
pragma Import (C, Ext_Attr, "lv_obj_get_ext_attr");
pragma Import (C, Obj_Type, "lv_obj_get_type");
pragma Import (C, Free_Num, "lv_obj_get_free_num");
pragma Import (C, Free_Ptr, "lv_obj_get_free_ptr");
pragma Import (C, Group, "lv_obj_get_group");
pragma Import (C, Is_Focused, "lv_obj_is_focused");
end Lv.Objx;
|
ZinebZaad/ENSEEIHT | Ada | 2,368 | adb | with Ada.Unchecked_Deallocation;
with SDA_Exceptions; use SDA_Exceptions;
package body LCA is
procedure Free is
new Ada.Unchecked_Deallocation (Object => T_Cellule, Name => T_LCA);
procedure Initialiser(Sda: out T_LCA) is
begin
Sda := null;
end Initialiser;
function Est_Vide (Sda : T_LCA) return Boolean is
begin
return Sda = null;
end Est_Vide;
function Cellule(Sda: in T_LCA; Cle: in T_Cle) return T_LCA is
Temp: T_LCA;
begin
Temp := Sda;
while not Est_Vide(Temp) loop
if Temp.all.Cle = Cle then
return Temp;
end if;
Temp := Temp.Suivant;
end loop;
return null;
end Cellule;
function Taille (Sda : in T_LCA) return Integer is
Temp: T_LCA;
Taille: Integer;
begin
Temp := Sda;
Taille := 0;
while not Est_Vide(Temp) loop
Taille := Taille + 1;
Temp := Temp.Suivant;
end loop;
return Taille;
end Taille;
procedure Enregistrer (Sda : in out T_LCA ; Cle : in T_Cle ; Donnee : in T_Donnee) is
Temp: T_LCA;
begin
Temp := Cellule(Sda, Cle);
if Temp /= null then
Temp.all.Donnee := Donnee;
else
Temp := Sda;
Sda := new T_Cellule;
Sda.all.Cle := Cle;
Sda.all.Donnee := Donnee;
Sda.all.Suivant := Temp;
end if;
end Enregistrer;
function Cle_Presente (Sda : in T_LCA ; Cle : in T_Cle) return Boolean is
begin
return Cellule(Sda, Cle) /= null;
end Cle_Presente;
function La_Donnee (Sda : in T_LCA ; Cle : in T_Cle) return T_Donnee is
Temp: T_LCA;
begin
Temp := Cellule(Sda, Cle);
if Temp = null then
raise Cle_Absente_Exception;
end if;
return Temp.all.Donnee;
end La_Donnee;
procedure Supprimer (Sda : in out T_LCA ; Cle : in T_Cle) is
Temp: T_LCA;
begin
if Est_Vide(Sda) then
raise Cle_Absente_Exception;
elsif Sda.all.Cle = Cle then
Temp := Sda;
Sda := Sda.all.Suivant;
Free(Temp);
else
Supprimer(Sda.all.Suivant, Cle);
end if;
end Supprimer;
procedure Vider (Sda : in out T_LCA) is
Temp: T_LCA;
begin
while not Est_Vide(Sda) loop
Temp := Sda;
Sda := Sda.all.Suivant;
Free(Temp);
end loop;
end Vider;
procedure Pour_Chaque (Sda : in T_LCA) is
Temp: T_LCA;
begin
Temp := Sda;
while not Est_Vide(Temp) loop
begin
Traiter(Temp.all.Cle, Temp.all.Donnee);
exception
when others => null;
end;
Temp := Temp.Suivant;
end loop;
end Pour_Chaque;
end LCA;
|
rguilloteau/pok | Ada | 3,257 | ads | -- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2020 POK team
-- ---------------------------------------------------------------------------
-- --
-- SAMPLING PORT constant and type definitions and management services --
-- --
-- ---------------------------------------------------------------------------
package APEX.Sampling_Ports is
Max_Number_Of_Sampling_Ports : constant :=
System_Limit_Number_Of_Sampling_Ports;
subtype Sampling_Port_Name_Type is Name_Type;
type Sampling_Port_Id_Type is private;
Null_Sampling_Port_Id : constant Sampling_Port_Id_Type;
type Validity_Type is (Invalid, Valid);
type Sampling_Port_Status_Type is record
Refresh_Period : System_Time_Type;
Max_Message_Size : Message_Size_Type;
Port_Direction : Port_Direction_Type;
Last_Msg_Validity : Validity_Type;
end record;
procedure Create_Sampling_Port
(Sampling_Port_Name : in Sampling_Port_Name_Type;
Max_Message_Size : in Message_Size_Type;
Port_Direction : in Port_Direction_Type;
Refresh_Period : in System_Time_Type;
Sampling_Port_Id : out Sampling_Port_Id_Type;
Return_Code : out Return_Code_Type);
procedure Write_Sampling_Message
(Sampling_Port_Id : in Sampling_Port_Id_Type;
Message_Addr : in Message_Addr_Type;
Length : in Message_Size_Type;
Return_Code : out Return_Code_Type);
procedure Read_Sampling_Message
(Sampling_Port_Id : in Sampling_Port_Id_Type;
Message_Addr : in Message_Addr_Type;
-- The message address is passed IN, although the respective message is
-- passed OUT
Length : out Message_Size_Type;
Validity : out Validity_Type;
Return_Code : out Return_Code_Type);
procedure Get_Sampling_Port_Id
(Sampling_Port_Name : in Sampling_Port_Name_Type;
Sampling_Port_Id : out Sampling_Port_Id_Type;
Return_Code : out Return_Code_Type);
procedure Get_Sampling_Port_Status
(Sampling_Port_Id : in Sampling_Port_Id_Type;
Sampling_Port_Status : out Sampling_Port_Status_Type;
Return_Code : out Return_Code_Type);
private
type Sampling_Port_Id_Type is new APEX_Integer;
Null_Sampling_Port_Id : constant Sampling_Port_Id_Type := 0;
pragma Convention (C, Validity_Type);
pragma Convention (C, Sampling_Port_Status_Type);
-- POK BINDINGS
pragma Import (C, Create_Sampling_Port, "CREATE_SAMPLING_PORT");
pragma Import (C, Write_Sampling_Message, "WRITE_SAMPLING_MESSAGE");
pragma Import (C, Read_Sampling_Message, "READ_SAMPLING_MESSAGE");
pragma Import (C, Get_Sampling_Port_Id, "GET_SAMPLING_PORT_ID");
pragma Import (C, Get_Sampling_Port_Status, "GET_SAMPLING_PORT_STATUS");
-- END OF POK BINDINGS
end APEX.Sampling_Ports;
|
reznikmm/matreshka | Ada | 4,023 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- The most general class for UMLDiagrams depicting structural elements.
------------------------------------------------------------------------------
with AMF.UMLDI.UML_Diagrams;
package AMF.UMLDI.UML_Structure_Diagrams is
pragma Preelaborate;
type UMLDI_UML_Structure_Diagram is limited interface
and AMF.UMLDI.UML_Diagrams.UMLDI_UML_Diagram;
type UMLDI_UML_Structure_Diagram_Access is
access all UMLDI_UML_Structure_Diagram'Class;
for UMLDI_UML_Structure_Diagram_Access'Storage_Size use 0;
end AMF.UMLDI.UML_Structure_Diagrams;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Table_Name_Attributes is
pragma Preelaborate;
type ODF_Table_Table_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Table_Name_Attribute_Access is
access all ODF_Table_Table_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Table_Name_Attributes;
|
stcarrez/ada-util | Ada | 1,460 | ads | -----------------------------------------------------------------------
-- AUnit utils - Helper for writing unit tests
-- Copyright (C) 2009, 2010 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with AUnit.Assertions;
with GNAT.Source_Info;
package Util.Assertions is
-- Check that the value matches what we expect.
generic
type Value_Type is (<>);
procedure Assert_Equals_T (T : in AUnit.Assertions.Test'Class;
Expect : in Value_Type;
Value : in Value_Type;
Message : in String := "Test failed";
Source : in String := GNAT.Source_Info.File;
Line : in Natural := GNAT.Source_Info.Line);
end Util.Assertions;
|
AdaCore/libadalang | Ada | 166 | ads | package Pkg is
type T is tagged null record;
procedure Classic_Prim (X : access T'Class);
private
procedure Private_Prim (X : access T'Class);
end Pkg;
|
reznikmm/matreshka | Ada | 3,669 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Clear_Structural_Feature_Actions.Hash is
new AMF.Elements.Generic_Hash (UML_Clear_Structural_Feature_Action, UML_Clear_Structural_Feature_Action_Access);
|
reznikmm/matreshka | Ada | 13,781 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings.Internals;
with Matreshka.Internals.Strings.Operations;
package body League.Strings.Cursors.Grapheme_Clusters is
use League.Strings.Internals;
use Matreshka.Internals.Strings;
use Matreshka.Internals.Strings.Operations;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Unicode.Ucd;
use Matreshka.Internals.Utf16;
Break_Machine : constant
array (Grapheme_Cluster_Break, Grapheme_Cluster_Break) of Boolean
:= (Other =>
(Extend | Spacing_Mark => False, others => True),
CR =>
(LF => False, others => True),
LF =>
(others => True),
Control =>
(others => True),
Prepend =>
(Other | Prepend | Extend | Spacing_Mark | L | V | T | LV | LVT =>
False,
others => True),
Extend =>
(Extend | Spacing_Mark => False, others => True),
Spacing_Mark =>
(Extend | Spacing_Mark => False, others => True),
L =>
(Extend | Spacing_Mark | L | V | LV | LVT => False,
others => True),
V =>
(Extend | Spacing_Mark | V | T => False, others => True),
T =>
(Extend | Spacing_Mark | T => False, others => True),
LV =>
(Extend | Spacing_Mark | V | T => False, others => True),
LVT =>
(Extend | Spacing_Mark | T => False, others => True),
Regional_Indicator =>
(Extend | Spacing_Mark | Regional_Indicator => False,
others => True));
-- overriding procedure On_Changed
-- (Self : not null access Character_Cursor;
-- Changed_First : Positive;
-- Removed_Last : Natural;
-- Inserted_Last : Natural);
procedure Unchecked_Next
(Item : Utf16_String;
Position : in out Utf16_String_Index;
Property : out Grapheme_Cluster_Break;
Locale : not null Matreshka.Internals.Locales.Locale_Data_Access);
pragma Inline (Unchecked_Next);
-- Returns value of the break property for the character at the specified
-- position and move position to the next character.
procedure Unchecked_Previous
(Item : Utf16_String;
Position : in out Utf16_String_Index;
Property : out Grapheme_Cluster_Break;
Locale : not null Matreshka.Internals.Locales.Locale_Data_Access);
pragma Inline (Unchecked_Previous);
-- Moves specified position to the previous character and returns value
-- of the break property for this character.
procedure Find_Next (Self : in out Grapheme_Cluster_Cursor'Class);
-- Finds the next break point and set Current_State, Current_Length,
-- Next_Position, Next_State members.
--
-- Preconditions: Next_Position = Current_Position
procedure Find_Previous (Self : in out Grapheme_Cluster_Cursor'Class);
-- Finds the next break point and set Previous_Position, Previous_State,
-- Previuos_Length members.
--
-- Preconditions: Current_Position = Previous_Position
-------------
-- Element --
-------------
function Element (Self : Grapheme_Cluster_Cursor'Class)
return Universal_String is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
if Self.Current_Position >= Self.Object.Data.Unused then
raise Constraint_Error with "Cursor out of range";
end if;
return
Wrap
(Slice
(Self.Object.Data,
Self.Current_Position,
Self.Next_Position - Self.Current_Position,
Self.Current_Length));
end Element;
---------------
-- Find_Next --
---------------
procedure Find_Next (Self : in out Grapheme_Cluster_Cursor'Class) is
D : constant not null Shared_String_Access := Self.Object.Data;
begin
if Self.Current_Position < D.Unused then
Unchecked_Next
(D.Value, Self.Next_Position, Self.Current_State, Self.Locale);
Self.Current_Length := 1;
declare
Aux_Position : Utf16_String_Index := Self.Next_Position;
Aux_State : Grapheme_Cluster_Break := Self.Current_State;
begin
while Self.Next_Position < D.Unused loop
Unchecked_Next
(D.Value, Aux_Position, Self.Next_State, Self.Locale);
exit when Break_Machine (Aux_State, Self.Next_State);
Self.Current_Length := Self.Current_Length + 1;
Self.Next_Position := Aux_Position;
Aux_State := Self.Next_State;
end loop;
end;
else
Self.Current_Length := 0;
end if;
end Find_Next;
-------------------
-- Find_Previous --
-------------------
procedure Find_Previous (Self : in out Grapheme_Cluster_Cursor'Class) is
D : constant not null Shared_String_Access := Self.Object.Data;
begin
if Self.Current_Position /= Utf16_String_Index'Last then
if Self.Current_Position /= 0 then
Unchecked_Previous
(D.Value,
Self.Previous_Position,
Self.Previous_State,
Self.Locale);
Self.Previous_Length := 1;
while Self.Previous_Position /= 0 loop
declare
Aux_Position : Utf16_String_Index := Self.Previous_Position;
Aux_State : Grapheme_Cluster_Break;
begin
Unchecked_Previous
(D.Value, Aux_Position, Aux_State, Self.Locale);
exit when Break_Machine (Aux_State, Self.Previous_State);
Self.Previous_Position := Aux_Position;
Self.Previous_State := Aux_State;
Self.Previous_Length := Self.Previous_Length + 1;
end;
end loop;
else
Self.Previous_Position := Utf16_String_Index'Last;
Self.Previous_Length := 0;
end if;
end if;
end Find_Previous;
-----------
-- First --
-----------
procedure First
(Self : in out Grapheme_Cluster_Cursor'Class;
Item : in out Universal_String)
is
begin
Self.Attach (Item);
Self.Set_Locale;
Self.Current_Position := Self.Object.Data.Value'First;
Self.Previous_Position := Self.Current_Position - 1;
Self.Next_Position := Self.Current_Position;
Find_Next (Self);
end First;
-----------------
-- Has_Element --
-----------------
function Has_Element (Self : Grapheme_Cluster_Cursor'Class)
return Boolean
is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
return Self.Current_Position < Self.Object.Data.Unused;
end Has_Element;
----------
-- Last --
----------
procedure Last
(Self : in out Grapheme_Cluster_Cursor'Class;
Item : in out Universal_String)
is
begin
Self.Attach (Item);
Self.Set_Locale;
Self.Next_Position := Self.Object.Data.Unused;
Self.Current_Position := Self.Next_Position;
Self.Previous_Position := Self.Current_Position;
if Self.Object.Data.Length /= 0 then
Find_Previous (Self);
Self.Current_Position := Self.Previous_Position;
Self.Current_Length := Self.Previous_Length;
Self.Current_State := Self.Previous_State;
Find_Previous (Self);
end if;
end Last;
----------
-- Next --
----------
procedure Next (Self : in out Grapheme_Cluster_Cursor'Class) is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
if Self.Current_Position < Self.Object.Data.Unused then
Self.Previous_Position := Self.Current_Position;
Self.Previous_Length := Self.Current_Length;
Self.Previous_State := Self.Current_State;
Self.Current_Position := Self.Next_Position;
Self.Current_State := Self.Next_State;
Find_Next (Self);
end if;
end Next;
-- ----------------
-- -- On_Changed --
-- ----------------
--
-- overriding procedure On_Changed
-- (Self : not null access Character_Cursor;
-- Changed_First : Positive;
-- Removed_Last : Natural;
-- Inserted_Last : Natural)
-- is
-- begin
-- if Self.Current in Changed_First .. Removed_Last then
-- Dereference (Self.Data, Self.all'Unchecked_Access);
--
-- elsif Self.Current > Removed_Last then
-- Self.Current := Self.Current + Inserted_Last - Removed_Last;
-- end if;
-- end On_Changed;
--------------
-- Previous --
--------------
procedure Previous (Self : in out Grapheme_Cluster_Cursor'Class) is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
if Self.Current_Position <= Self.Object.Data.Unused then
Self.Next_Position := Self.Current_Position;
Self.Next_State := Self.Current_State;
Self.Current_Position := Self.Previous_Position;
Self.Current_Length := Self.Previous_Length;
Self.Current_State := Self.Previous_State;
Find_Previous (Self);
end if;
end Previous;
--------------------
-- Unchecked_Next --
--------------------
procedure Unchecked_Next
(Item : Utf16_String;
Position : in out Utf16_String_Index;
Property : out Grapheme_Cluster_Break;
Locale : not null Matreshka.Internals.Locales.Locale_Data_Access)
is
C : Code_Point;
begin
Unchecked_Next (Item, Position, C);
Property := Locale.Get_Core (C).GCB;
end Unchecked_Next;
------------------------
-- Unchecked_Previous --
------------------------
procedure Unchecked_Previous
(Item : Utf16_String;
Position : in out Utf16_String_Index;
Property : out Grapheme_Cluster_Break;
Locale : not null Matreshka.Internals.Locales.Locale_Data_Access)
is
C : Code_Point;
begin
Unchecked_Previous (Item, Position, C);
Property := Locale.Get_Core (C).GCB;
end Unchecked_Previous;
end League.Strings.Cursors.Grapheme_Clusters;
|
AdaCore/Ada_Drivers_Library | Ada | 58,418 | ads | -- This spec has been automatically generated from STM32F46_79x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.DMA is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- low interrupt status register
type LISR_Register is record
-- Read-only. Stream x FIFO error interrupt flag (x=3..0)
FEIF0 : Boolean;
-- unspecified
Reserved_1_1 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=3..0)
DMEIF0 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=3..0)
TEIF0 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=3..0)
HTIF0 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x = 3..0)
TCIF0 : Boolean;
-- Read-only. Stream x FIFO error interrupt flag (x=3..0)
FEIF1 : Boolean;
-- unspecified
Reserved_7_7 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=3..0)
DMEIF1 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=3..0)
TEIF1 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=3..0)
HTIF1 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x = 3..0)
TCIF1 : Boolean;
-- unspecified
Reserved_12_15 : HAL.UInt4;
-- Read-only. Stream x FIFO error interrupt flag (x=3..0)
FEIF2 : Boolean;
-- unspecified
Reserved_17_17 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=3..0)
DMEIF2 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=3..0)
TEIF2 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=3..0)
HTIF2 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x = 3..0)
TCIF2 : Boolean;
-- Read-only. Stream x FIFO error interrupt flag (x=3..0)
FEIF3 : Boolean;
-- unspecified
Reserved_23_23 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=3..0)
DMEIF3 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=3..0)
TEIF3 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=3..0)
HTIF3 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x = 3..0)
TCIF3 : Boolean;
-- unspecified
Reserved_28_31 : HAL.UInt4;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LISR_Register use record
FEIF0 at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
DMEIF0 at 0 range 2 .. 2;
TEIF0 at 0 range 3 .. 3;
HTIF0 at 0 range 4 .. 4;
TCIF0 at 0 range 5 .. 5;
FEIF1 at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
DMEIF1 at 0 range 8 .. 8;
TEIF1 at 0 range 9 .. 9;
HTIF1 at 0 range 10 .. 10;
TCIF1 at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
FEIF2 at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
DMEIF2 at 0 range 18 .. 18;
TEIF2 at 0 range 19 .. 19;
HTIF2 at 0 range 20 .. 20;
TCIF2 at 0 range 21 .. 21;
FEIF3 at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
DMEIF3 at 0 range 24 .. 24;
TEIF3 at 0 range 25 .. 25;
HTIF3 at 0 range 26 .. 26;
TCIF3 at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- high interrupt status register
type HISR_Register is record
-- Read-only. Stream x FIFO error interrupt flag (x=7..4)
FEIF4 : Boolean;
-- unspecified
Reserved_1_1 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=7..4)
DMEIF4 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=7..4)
TEIF4 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=7..4)
HTIF4 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x=7..4)
TCIF4 : Boolean;
-- Read-only. Stream x FIFO error interrupt flag (x=7..4)
FEIF5 : Boolean;
-- unspecified
Reserved_7_7 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=7..4)
DMEIF5 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=7..4)
TEIF5 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=7..4)
HTIF5 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x=7..4)
TCIF5 : Boolean;
-- unspecified
Reserved_12_15 : HAL.UInt4;
-- Read-only. Stream x FIFO error interrupt flag (x=7..4)
FEIF6 : Boolean;
-- unspecified
Reserved_17_17 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=7..4)
DMEIF6 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=7..4)
TEIF6 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=7..4)
HTIF6 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x=7..4)
TCIF6 : Boolean;
-- Read-only. Stream x FIFO error interrupt flag (x=7..4)
FEIF7 : Boolean;
-- unspecified
Reserved_23_23 : HAL.Bit;
-- Read-only. Stream x direct mode error interrupt flag (x=7..4)
DMEIF7 : Boolean;
-- Read-only. Stream x transfer error interrupt flag (x=7..4)
TEIF7 : Boolean;
-- Read-only. Stream x half transfer interrupt flag (x=7..4)
HTIF7 : Boolean;
-- Read-only. Stream x transfer complete interrupt flag (x=7..4)
TCIF7 : Boolean;
-- unspecified
Reserved_28_31 : HAL.UInt4;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HISR_Register use record
FEIF4 at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
DMEIF4 at 0 range 2 .. 2;
TEIF4 at 0 range 3 .. 3;
HTIF4 at 0 range 4 .. 4;
TCIF4 at 0 range 5 .. 5;
FEIF5 at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
DMEIF5 at 0 range 8 .. 8;
TEIF5 at 0 range 9 .. 9;
HTIF5 at 0 range 10 .. 10;
TCIF5 at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
FEIF6 at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
DMEIF6 at 0 range 18 .. 18;
TEIF6 at 0 range 19 .. 19;
HTIF6 at 0 range 20 .. 20;
TCIF6 at 0 range 21 .. 21;
FEIF7 at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
DMEIF7 at 0 range 24 .. 24;
TEIF7 at 0 range 25 .. 25;
HTIF7 at 0 range 26 .. 26;
TCIF7 at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- low interrupt flag clear register
type LIFCR_Register is record
-- Stream x clear FIFO error interrupt flag (x = 3..0)
CFEIF0 : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 3..0)
CDMEIF0 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 3..0)
CTEIF0 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 3..0)
CHTIF0 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 3..0)
CTCIF0 : Boolean := False;
-- Stream x clear FIFO error interrupt flag (x = 3..0)
CFEIF1 : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 3..0)
CDMEIF1 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 3..0)
CTEIF1 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 3..0)
CHTIF1 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 3..0)
CTCIF1 : Boolean := False;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Stream x clear FIFO error interrupt flag (x = 3..0)
CFEIF2 : Boolean := False;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 3..0)
CDMEIF2 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 3..0)
CTEIF2 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 3..0)
CHTIF2 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 3..0)
CTCIF2 : Boolean := False;
-- Stream x clear FIFO error interrupt flag (x = 3..0)
CFEIF3 : Boolean := False;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 3..0)
CDMEIF3 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 3..0)
CTEIF3 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 3..0)
CHTIF3 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 3..0)
CTCIF3 : Boolean := False;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LIFCR_Register use record
CFEIF0 at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CDMEIF0 at 0 range 2 .. 2;
CTEIF0 at 0 range 3 .. 3;
CHTIF0 at 0 range 4 .. 4;
CTCIF0 at 0 range 5 .. 5;
CFEIF1 at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CDMEIF1 at 0 range 8 .. 8;
CTEIF1 at 0 range 9 .. 9;
CHTIF1 at 0 range 10 .. 10;
CTCIF1 at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
CFEIF2 at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
CDMEIF2 at 0 range 18 .. 18;
CTEIF2 at 0 range 19 .. 19;
CHTIF2 at 0 range 20 .. 20;
CTCIF2 at 0 range 21 .. 21;
CFEIF3 at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
CDMEIF3 at 0 range 24 .. 24;
CTEIF3 at 0 range 25 .. 25;
CHTIF3 at 0 range 26 .. 26;
CTCIF3 at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- high interrupt flag clear register
type HIFCR_Register is record
-- Stream x clear FIFO error interrupt flag (x = 7..4)
CFEIF4 : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 7..4)
CDMEIF4 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 7..4)
CTEIF4 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 7..4)
CHTIF4 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 7..4)
CTCIF4 : Boolean := False;
-- Stream x clear FIFO error interrupt flag (x = 7..4)
CFEIF5 : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 7..4)
CDMEIF5 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 7..4)
CTEIF5 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 7..4)
CHTIF5 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 7..4)
CTCIF5 : Boolean := False;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Stream x clear FIFO error interrupt flag (x = 7..4)
CFEIF6 : Boolean := False;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 7..4)
CDMEIF6 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 7..4)
CTEIF6 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 7..4)
CHTIF6 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 7..4)
CTCIF6 : Boolean := False;
-- Stream x clear FIFO error interrupt flag (x = 7..4)
CFEIF7 : Boolean := False;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- Stream x clear direct mode error interrupt flag (x = 7..4)
CDMEIF7 : Boolean := False;
-- Stream x clear transfer error interrupt flag (x = 7..4)
CTEIF7 : Boolean := False;
-- Stream x clear half transfer interrupt flag (x = 7..4)
CHTIF7 : Boolean := False;
-- Stream x clear transfer complete interrupt flag (x = 7..4)
CTCIF7 : Boolean := False;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HIFCR_Register use record
CFEIF4 at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CDMEIF4 at 0 range 2 .. 2;
CTEIF4 at 0 range 3 .. 3;
CHTIF4 at 0 range 4 .. 4;
CTCIF4 at 0 range 5 .. 5;
CFEIF5 at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CDMEIF5 at 0 range 8 .. 8;
CTEIF5 at 0 range 9 .. 9;
CHTIF5 at 0 range 10 .. 10;
CTCIF5 at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
CFEIF6 at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
CDMEIF6 at 0 range 18 .. 18;
CTEIF6 at 0 range 19 .. 19;
CHTIF6 at 0 range 20 .. 20;
CTCIF6 at 0 range 21 .. 21;
CFEIF7 at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
CDMEIF7 at 0 range 24 .. 24;
CTEIF7 at 0 range 25 .. 25;
CHTIF7 at 0 range 26 .. 26;
CTCIF7 at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S0CR_DIR_Field is HAL.UInt2;
subtype S0CR_PSIZE_Field is HAL.UInt2;
subtype S0CR_MSIZE_Field is HAL.UInt2;
subtype S0CR_PL_Field is HAL.UInt2;
subtype S0CR_PBURST_Field is HAL.UInt2;
subtype S0CR_MBURST_Field is HAL.UInt2;
subtype S0CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S0CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S0CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S0CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S0CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S0CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- unspecified
Reserved_20_20 : HAL.Bit := 16#0#;
-- Peripheral burst transfer configuration
PBURST : S0CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S0CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S0CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S0CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S0NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S0NDTR_Register is record
-- Number of data items to transfer
NDT : S0NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S0NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S0FCR_FTH_Field is HAL.UInt2;
subtype S0FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S0FCR_Register is record
-- FIFO threshold selection
FTH : S0FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S0FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S0FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S1CR_DIR_Field is HAL.UInt2;
subtype S1CR_PSIZE_Field is HAL.UInt2;
subtype S1CR_MSIZE_Field is HAL.UInt2;
subtype S1CR_PL_Field is HAL.UInt2;
subtype S1CR_PBURST_Field is HAL.UInt2;
subtype S1CR_MBURST_Field is HAL.UInt2;
subtype S1CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S1CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S1CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S1CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S1CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S1CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S1CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S1CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S1CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S1CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S1NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S1NDTR_Register is record
-- Number of data items to transfer
NDT : S1NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S1NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S1FCR_FTH_Field is HAL.UInt2;
subtype S1FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S1FCR_Register is record
-- FIFO threshold selection
FTH : S1FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S1FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S1FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S2CR_DIR_Field is HAL.UInt2;
subtype S2CR_PSIZE_Field is HAL.UInt2;
subtype S2CR_MSIZE_Field is HAL.UInt2;
subtype S2CR_PL_Field is HAL.UInt2;
subtype S2CR_PBURST_Field is HAL.UInt2;
subtype S2CR_MBURST_Field is HAL.UInt2;
subtype S2CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S2CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S2CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S2CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S2CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S2CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S2CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S2CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S2CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S2CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S2NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S2NDTR_Register is record
-- Number of data items to transfer
NDT : S2NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S2NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S2FCR_FTH_Field is HAL.UInt2;
subtype S2FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S2FCR_Register is record
-- FIFO threshold selection
FTH : S2FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S2FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S2FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S3CR_DIR_Field is HAL.UInt2;
subtype S3CR_PSIZE_Field is HAL.UInt2;
subtype S3CR_MSIZE_Field is HAL.UInt2;
subtype S3CR_PL_Field is HAL.UInt2;
subtype S3CR_PBURST_Field is HAL.UInt2;
subtype S3CR_MBURST_Field is HAL.UInt2;
subtype S3CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S3CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S3CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S3CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S3CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S3CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S3CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S3CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S3CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S3CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S3NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S3NDTR_Register is record
-- Number of data items to transfer
NDT : S3NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S3NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S3FCR_FTH_Field is HAL.UInt2;
subtype S3FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S3FCR_Register is record
-- FIFO threshold selection
FTH : S3FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S3FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S3FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S4CR_DIR_Field is HAL.UInt2;
subtype S4CR_PSIZE_Field is HAL.UInt2;
subtype S4CR_MSIZE_Field is HAL.UInt2;
subtype S4CR_PL_Field is HAL.UInt2;
subtype S4CR_PBURST_Field is HAL.UInt2;
subtype S4CR_MBURST_Field is HAL.UInt2;
subtype S4CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S4CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S4CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S4CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S4CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S4CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S4CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S4CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S4CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S4CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S4NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S4NDTR_Register is record
-- Number of data items to transfer
NDT : S4NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S4NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S4FCR_FTH_Field is HAL.UInt2;
subtype S4FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S4FCR_Register is record
-- FIFO threshold selection
FTH : S4FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S4FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S4FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S5CR_DIR_Field is HAL.UInt2;
subtype S5CR_PSIZE_Field is HAL.UInt2;
subtype S5CR_MSIZE_Field is HAL.UInt2;
subtype S5CR_PL_Field is HAL.UInt2;
subtype S5CR_PBURST_Field is HAL.UInt2;
subtype S5CR_MBURST_Field is HAL.UInt2;
subtype S5CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S5CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S5CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S5CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S5CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S5CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S5CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S5CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S5CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S5CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S5NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S5NDTR_Register is record
-- Number of data items to transfer
NDT : S5NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S5NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S5FCR_FTH_Field is HAL.UInt2;
subtype S5FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S5FCR_Register is record
-- FIFO threshold selection
FTH : S5FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S5FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S5FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S6CR_DIR_Field is HAL.UInt2;
subtype S6CR_PSIZE_Field is HAL.UInt2;
subtype S6CR_MSIZE_Field is HAL.UInt2;
subtype S6CR_PL_Field is HAL.UInt2;
subtype S6CR_PBURST_Field is HAL.UInt2;
subtype S6CR_MBURST_Field is HAL.UInt2;
subtype S6CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S6CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S6CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S6CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S6CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S6CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S6CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S6CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S6CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S6CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S6NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S6NDTR_Register is record
-- Number of data items to transfer
NDT : S6NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S6NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S6FCR_FTH_Field is HAL.UInt2;
subtype S6FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S6FCR_Register is record
-- FIFO threshold selection
FTH : S6FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S6FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S6FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype S7CR_DIR_Field is HAL.UInt2;
subtype S7CR_PSIZE_Field is HAL.UInt2;
subtype S7CR_MSIZE_Field is HAL.UInt2;
subtype S7CR_PL_Field is HAL.UInt2;
subtype S7CR_PBURST_Field is HAL.UInt2;
subtype S7CR_MBURST_Field is HAL.UInt2;
subtype S7CR_CHSEL_Field is HAL.UInt3;
-- stream x configuration register
type S7CR_Register is record
-- Stream enable / flag stream ready when read low
EN : Boolean := False;
-- Direct mode error interrupt enable
DMEIE : Boolean := False;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Half transfer interrupt enable
HTIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Peripheral flow controller
PFCTRL : Boolean := False;
-- Data transfer direction
DIR : S7CR_DIR_Field := 16#0#;
-- Circular mode
CIRC : Boolean := False;
-- Peripheral increment mode
PINC : Boolean := False;
-- Memory increment mode
MINC : Boolean := False;
-- Peripheral data size
PSIZE : S7CR_PSIZE_Field := 16#0#;
-- Memory data size
MSIZE : S7CR_MSIZE_Field := 16#0#;
-- Peripheral increment offset size
PINCOS : Boolean := False;
-- Priority level
PL : S7CR_PL_Field := 16#0#;
-- Double buffer mode
DBM : Boolean := False;
-- Current target (only in double buffer mode)
CT : Boolean := False;
-- ACK
ACK : Boolean := False;
-- Peripheral burst transfer configuration
PBURST : S7CR_PBURST_Field := 16#0#;
-- Memory burst transfer configuration
MBURST : S7CR_MBURST_Field := 16#0#;
-- Channel selection
CHSEL : S7CR_CHSEL_Field := 16#0#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S7CR_Register use record
EN at 0 range 0 .. 0;
DMEIE at 0 range 1 .. 1;
TEIE at 0 range 2 .. 2;
HTIE at 0 range 3 .. 3;
TCIE at 0 range 4 .. 4;
PFCTRL at 0 range 5 .. 5;
DIR at 0 range 6 .. 7;
CIRC at 0 range 8 .. 8;
PINC at 0 range 9 .. 9;
MINC at 0 range 10 .. 10;
PSIZE at 0 range 11 .. 12;
MSIZE at 0 range 13 .. 14;
PINCOS at 0 range 15 .. 15;
PL at 0 range 16 .. 17;
DBM at 0 range 18 .. 18;
CT at 0 range 19 .. 19;
ACK at 0 range 20 .. 20;
PBURST at 0 range 21 .. 22;
MBURST at 0 range 23 .. 24;
CHSEL at 0 range 25 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype S7NDTR_NDT_Field is HAL.UInt16;
-- stream x number of data register
type S7NDTR_Register is record
-- Number of data items to transfer
NDT : S7NDTR_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S7NDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype S7FCR_FTH_Field is HAL.UInt2;
subtype S7FCR_FS_Field is HAL.UInt3;
-- stream x FIFO control register
type S7FCR_Register is record
-- FIFO threshold selection
FTH : S7FCR_FTH_Field := 16#1#;
-- Direct mode disable
DMDIS : Boolean := False;
-- Read-only. FIFO status
FS : S7FCR_FS_Field := 16#4#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- FIFO error interrupt enable
FEIE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for S7FCR_Register use record
FTH at 0 range 0 .. 1;
DMDIS at 0 range 2 .. 2;
FS at 0 range 3 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
FEIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- DMA controller
type DMA_Peripheral is record
-- low interrupt status register
LISR : aliased LISR_Register;
-- high interrupt status register
HISR : aliased HISR_Register;
-- low interrupt flag clear register
LIFCR : aliased LIFCR_Register;
-- high interrupt flag clear register
HIFCR : aliased HIFCR_Register;
-- stream x configuration register
S0CR : aliased S0CR_Register;
-- stream x number of data register
S0NDTR : aliased S0NDTR_Register;
-- stream x peripheral address register
S0PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S0M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S0M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S0FCR : aliased S0FCR_Register;
-- stream x configuration register
S1CR : aliased S1CR_Register;
-- stream x number of data register
S1NDTR : aliased S1NDTR_Register;
-- stream x peripheral address register
S1PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S1M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S1M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S1FCR : aliased S1FCR_Register;
-- stream x configuration register
S2CR : aliased S2CR_Register;
-- stream x number of data register
S2NDTR : aliased S2NDTR_Register;
-- stream x peripheral address register
S2PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S2M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S2M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S2FCR : aliased S2FCR_Register;
-- stream x configuration register
S3CR : aliased S3CR_Register;
-- stream x number of data register
S3NDTR : aliased S3NDTR_Register;
-- stream x peripheral address register
S3PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S3M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S3M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S3FCR : aliased S3FCR_Register;
-- stream x configuration register
S4CR : aliased S4CR_Register;
-- stream x number of data register
S4NDTR : aliased S4NDTR_Register;
-- stream x peripheral address register
S4PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S4M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S4M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S4FCR : aliased S4FCR_Register;
-- stream x configuration register
S5CR : aliased S5CR_Register;
-- stream x number of data register
S5NDTR : aliased S5NDTR_Register;
-- stream x peripheral address register
S5PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S5M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S5M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S5FCR : aliased S5FCR_Register;
-- stream x configuration register
S6CR : aliased S6CR_Register;
-- stream x number of data register
S6NDTR : aliased S6NDTR_Register;
-- stream x peripheral address register
S6PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S6M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S6M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S6FCR : aliased S6FCR_Register;
-- stream x configuration register
S7CR : aliased S7CR_Register;
-- stream x number of data register
S7NDTR : aliased S7NDTR_Register;
-- stream x peripheral address register
S7PAR : aliased HAL.UInt32;
-- stream x memory 0 address register
S7M0AR : aliased HAL.UInt32;
-- stream x memory 1 address register
S7M1AR : aliased HAL.UInt32;
-- stream x FIFO control register
S7FCR : aliased S7FCR_Register;
end record
with Volatile;
for DMA_Peripheral use record
LISR at 16#0# range 0 .. 31;
HISR at 16#4# range 0 .. 31;
LIFCR at 16#8# range 0 .. 31;
HIFCR at 16#C# range 0 .. 31;
S0CR at 16#10# range 0 .. 31;
S0NDTR at 16#14# range 0 .. 31;
S0PAR at 16#18# range 0 .. 31;
S0M0AR at 16#1C# range 0 .. 31;
S0M1AR at 16#20# range 0 .. 31;
S0FCR at 16#24# range 0 .. 31;
S1CR at 16#28# range 0 .. 31;
S1NDTR at 16#2C# range 0 .. 31;
S1PAR at 16#30# range 0 .. 31;
S1M0AR at 16#34# range 0 .. 31;
S1M1AR at 16#38# range 0 .. 31;
S1FCR at 16#3C# range 0 .. 31;
S2CR at 16#40# range 0 .. 31;
S2NDTR at 16#44# range 0 .. 31;
S2PAR at 16#48# range 0 .. 31;
S2M0AR at 16#4C# range 0 .. 31;
S2M1AR at 16#50# range 0 .. 31;
S2FCR at 16#54# range 0 .. 31;
S3CR at 16#58# range 0 .. 31;
S3NDTR at 16#5C# range 0 .. 31;
S3PAR at 16#60# range 0 .. 31;
S3M0AR at 16#64# range 0 .. 31;
S3M1AR at 16#68# range 0 .. 31;
S3FCR at 16#6C# range 0 .. 31;
S4CR at 16#70# range 0 .. 31;
S4NDTR at 16#74# range 0 .. 31;
S4PAR at 16#78# range 0 .. 31;
S4M0AR at 16#7C# range 0 .. 31;
S4M1AR at 16#80# range 0 .. 31;
S4FCR at 16#84# range 0 .. 31;
S5CR at 16#88# range 0 .. 31;
S5NDTR at 16#8C# range 0 .. 31;
S5PAR at 16#90# range 0 .. 31;
S5M0AR at 16#94# range 0 .. 31;
S5M1AR at 16#98# range 0 .. 31;
S5FCR at 16#9C# range 0 .. 31;
S6CR at 16#A0# range 0 .. 31;
S6NDTR at 16#A4# range 0 .. 31;
S6PAR at 16#A8# range 0 .. 31;
S6M0AR at 16#AC# range 0 .. 31;
S6M1AR at 16#B0# range 0 .. 31;
S6FCR at 16#B4# range 0 .. 31;
S7CR at 16#B8# range 0 .. 31;
S7NDTR at 16#BC# range 0 .. 31;
S7PAR at 16#C0# range 0 .. 31;
S7M0AR at 16#C4# range 0 .. 31;
S7M1AR at 16#C8# range 0 .. 31;
S7FCR at 16#CC# range 0 .. 31;
end record;
-- DMA controller
DMA1_Periph : aliased DMA_Peripheral
with Import, Address => System'To_Address (16#40026000#);
-- DMA controller
DMA2_Periph : aliased DMA_Peripheral
with Import, Address => System'To_Address (16#40026400#);
end STM32_SVD.DMA;
|
reznikmm/matreshka | Ada | 7,151 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.Internals.XML is
pragma Pure;
type Attribute_Identifier is private;
No_Attribute : constant Attribute_Identifier;
-- Internal identifier of attribute type declaration.
type Element_Identifier is private;
No_Element : constant Element_Identifier;
-- Internal identifier of element declaration.
type Entity_Identifier is private;
No_Entity : constant Entity_Identifier;
Entity_lt : constant Entity_Identifier;
Entity_gt : constant Entity_Identifier;
Entity_amp : constant Entity_Identifier;
Entity_apos : constant Entity_Identifier;
Entity_quot : constant Entity_Identifier;
-- Internal identifier of entity.
type Notation_Identifier is private;
No_Notation : constant Notation_Identifier;
-- Internal identifier of notation.
type Symbol_Identifier is private;
No_Symbol : constant Symbol_Identifier;
Symbol_lt : constant Symbol_Identifier;
Symbol_gt : constant Symbol_Identifier;
Symbol_amp : constant Symbol_Identifier;
Symbol_apos : constant Symbol_Identifier;
Symbol_quot : constant Symbol_Identifier;
Symbol_CDATA : constant Symbol_Identifier;
Symbol_ID : constant Symbol_Identifier;
Symbol_IDREF : constant Symbol_Identifier;
Symbol_IDREFS : constant Symbol_Identifier;
Symbol_NMTOKEN : constant Symbol_Identifier;
Symbol_NMTOKENS : constant Symbol_Identifier;
Symbol_ENTITY : constant Symbol_Identifier;
Symbol_ENTITIES : constant Symbol_Identifier;
Symbol_NOTATION : constant Symbol_Identifier;
Symbol_xml : constant Symbol_Identifier;
Symbol_xmlns : constant Symbol_Identifier;
Symbol_xml_NS : constant Symbol_Identifier;
Symbol_xmlns_NS : constant Symbol_Identifier;
Symbol_xml_base : constant Symbol_Identifier;
-- Internal identifier of symbol. Symbols are used to associate different
-- kinds of items with name, and to minimize amount of used memory to store
-- names.
private
type Attribute_Identifier is mod 2 ** 32;
No_Attribute : constant Attribute_Identifier := 0;
type Element_Identifier is mod 2 ** 32;
No_Element : constant Element_Identifier := 0;
type Entity_Identifier is mod 2 ** 32;
No_Entity : constant Entity_Identifier := 0;
Entity_lt : constant Entity_Identifier := 1;
Entity_gt : constant Entity_Identifier := 2;
Entity_amp : constant Entity_Identifier := 3;
Entity_apos : constant Entity_Identifier := 4;
Entity_quot : constant Entity_Identifier := 5;
type Notation_Identifier is mod 2 ** 32;
No_Notation : constant Notation_Identifier := 0;
type Symbol_Identifier is mod 2 ** 32;
No_Symbol : constant Symbol_Identifier := 0;
Symbol_lt : constant Symbol_Identifier := 1;
Symbol_gt : constant Symbol_Identifier := 2;
Symbol_amp : constant Symbol_Identifier := 3;
Symbol_apos : constant Symbol_Identifier := 4;
Symbol_quot : constant Symbol_Identifier := 5;
Symbol_CDATA : constant Symbol_Identifier := 6;
Symbol_ID : constant Symbol_Identifier := 7;
Symbol_IDREF : constant Symbol_Identifier := 8;
Symbol_IDREFS : constant Symbol_Identifier := 9;
Symbol_NMTOKEN : constant Symbol_Identifier := 10;
Symbol_NMTOKENS : constant Symbol_Identifier := 11;
Symbol_ENTITY : constant Symbol_Identifier := 12;
Symbol_ENTITIES : constant Symbol_Identifier := 13;
Symbol_NOTATION : constant Symbol_Identifier := 14;
Symbol_xml : constant Symbol_Identifier := 15;
Symbol_xmlns : constant Symbol_Identifier := 16;
Symbol_xml_NS : constant Symbol_Identifier := 17;
Symbol_xmlns_NS : constant Symbol_Identifier := 18;
Symbol_xml_base : constant Symbol_Identifier := 19;
end Matreshka.Internals.XML;
|
burratoo/Acton | Ada | 1,145 | ads | ------------------------------------------------------------------------------------------
-- --
-- ACTON ANALYSER --
-- --
-- PROGRAM_STATISTICS --
-- --
-- Copyright (C) 2016-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
package Program_Statistics is
procedure Calculate_Statistics;
procedure Print_Statistics;
private
Number_Of_Task_Units : Integer;
Number_Of_Task_Objects : Integer;
Number_Of_Protected_Units : Integer;
Number_Of_Protected_Objects : Integer;
Program_Stack_Size : Integer;
end Program_Statistics;
|
zhmu/ananas | Ada | 28,054 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.NUMERICS.GENERIC_REAL_ARRAYS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2022, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This version of Generic_Real_Arrays avoids the use of BLAS and LAPACK. One
-- reason for this is new Ada 2012 requirements that prohibit algorithms such
-- as Strassen's algorithm, which may be used by some BLAS implementations. In
-- addition, some platforms lacked suitable compilers to compile the reference
-- BLAS/LAPACK implementation. Finally, on some platforms there are more
-- floating point types than supported by BLAS/LAPACK.
-- Preconditions, postconditions, ghost code, loop invariants and assertions
-- in this unit are meant for analysis only, not for run-time checking, as it
-- would be too costly otherwise. This is enforced by setting the assertion
-- policy to Ignore.
pragma Assertion_Policy (Pre => Ignore,
Post => Ignore,
Ghost => Ignore,
Loop_Invariant => Ignore,
Assert => Ignore);
with Ada.Containers.Generic_Anonymous_Array_Sort; use Ada.Containers;
with System; use System;
with System.Generic_Array_Operations; use System.Generic_Array_Operations;
package body Ada.Numerics.Generic_Real_Arrays is
package Ops renames System.Generic_Array_Operations;
function Is_Non_Zero (X : Real'Base) return Boolean is (X /= 0.0);
procedure Back_Substitute is new Ops.Back_Substitute
(Scalar => Real'Base,
Matrix => Real_Matrix,
Is_Non_Zero => Is_Non_Zero);
function Diagonal is new Ops.Diagonal
(Scalar => Real'Base,
Vector => Real_Vector,
Matrix => Real_Matrix);
procedure Forward_Eliminate is new Ops.Forward_Eliminate
(Scalar => Real'Base,
Real => Real'Base,
Matrix => Real_Matrix,
Zero => 0.0,
One => 1.0);
procedure Swap_Column is new Ops.Swap_Column
(Scalar => Real'Base,
Matrix => Real_Matrix);
procedure Transpose is new Ops.Transpose
(Scalar => Real'Base,
Matrix => Real_Matrix);
function Is_Symmetric (A : Real_Matrix) return Boolean is
(Transpose (A) = A);
-- Return True iff A is symmetric, see RM G.3.1 (90).
function Is_Tiny (Value, Compared_To : Real) return Boolean is
(abs Compared_To + 100.0 * abs (Value) = abs Compared_To);
-- Return True iff the Value is much smaller in magnitude than the least
-- significant digit of Compared_To.
procedure Jacobi
(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix;
Compute_Vectors : Boolean := True);
-- Perform Jacobi's eigensystem algorithm on real symmetric matrix A
function Length is new Square_Matrix_Length (Real'Base, Real_Matrix);
-- Helper function that raises a Constraint_Error is the argument is
-- not a square matrix, and otherwise returns its length.
procedure Rotate (X, Y : in out Real; Sin, Tau : Real);
-- Perform a Givens rotation
procedure Sort_Eigensystem
(Values : in out Real_Vector;
Vectors : in out Real_Matrix);
-- Sort Values and associated Vectors by decreasing absolute value
procedure Swap (Left, Right : in out Real);
-- Exchange Left and Right
function Sqrt is new Ops.Sqrt (Real);
-- Instant a generic square root implementation here, in order to avoid
-- instantiating a complete copy of Generic_Elementary_Functions.
-- Speed of the square root is not a big concern here.
------------
-- Rotate --
------------
procedure Rotate (X, Y : in out Real; Sin, Tau : Real) is
Old_X : constant Real := X;
Old_Y : constant Real := Y;
begin
X := Old_X - Sin * (Old_Y + Old_X * Tau);
Y := Old_Y + Sin * (Old_X - Old_Y * Tau);
end Rotate;
----------
-- Swap --
----------
procedure Swap (Left, Right : in out Real) is
Temp : constant Real := Left;
begin
Left := Right;
Right := Temp;
end Swap;
-- Instantiating the following subprograms directly would lead to
-- name clashes, so use a local package.
package Instantiations is
function "+" is new
Vector_Elementwise_Operation
(X_Scalar => Real'Base,
Result_Scalar => Real'Base,
X_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "+");
function "+" is new
Matrix_Elementwise_Operation
(X_Scalar => Real'Base,
Result_Scalar => Real'Base,
X_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "+");
function "+" is new
Vector_Vector_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Right_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "+");
function "+" is new
Matrix_Matrix_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Matrix => Real_Matrix,
Right_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "+");
function "-" is new
Vector_Elementwise_Operation
(X_Scalar => Real'Base,
Result_Scalar => Real'Base,
X_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "-");
function "-" is new
Matrix_Elementwise_Operation
(X_Scalar => Real'Base,
Result_Scalar => Real'Base,
X_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "-");
function "-" is new
Vector_Vector_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Right_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "-");
function "-" is new
Matrix_Matrix_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Matrix => Real_Matrix,
Right_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "-");
function "*" is new
Scalar_Vector_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Right_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "*");
function "*" is new
Scalar_Matrix_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Right_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "*");
function "*" is new
Vector_Scalar_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "*");
function "*" is new
Matrix_Scalar_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "*");
function "*" is new
Outer_Product
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Right_Vector => Real_Vector,
Matrix => Real_Matrix);
function "*" is new
Inner_Product
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Right_Vector => Real_Vector,
Zero => 0.0);
function "*" is new
Matrix_Vector_Product
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Matrix => Real_Matrix,
Right_Vector => Real_Vector,
Result_Vector => Real_Vector,
Zero => 0.0);
function "*" is new
Vector_Matrix_Product
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Matrix => Real_Matrix,
Result_Vector => Real_Vector,
Zero => 0.0);
function "*" is new
Matrix_Matrix_Product
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Matrix => Real_Matrix,
Right_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Zero => 0.0);
function "/" is new
Vector_Scalar_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "/");
function "/" is new
Matrix_Scalar_Elementwise_Operation
(Left_Scalar => Real'Base,
Right_Scalar => Real'Base,
Result_Scalar => Real'Base,
Left_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "/");
function "abs" is new
L2_Norm
(X_Scalar => Real'Base,
Result_Real => Real'Base,
X_Vector => Real_Vector,
"abs" => "+");
-- While the L2_Norm by definition uses the absolute values of the
-- elements of X_Vector, for real values the subsequent squaring
-- makes this unnecessary, so we substitute the "+" identity function
-- instead.
function "abs" is new
Vector_Elementwise_Operation
(X_Scalar => Real'Base,
Result_Scalar => Real'Base,
X_Vector => Real_Vector,
Result_Vector => Real_Vector,
Operation => "abs");
function "abs" is new
Matrix_Elementwise_Operation
(X_Scalar => Real'Base,
Result_Scalar => Real'Base,
X_Matrix => Real_Matrix,
Result_Matrix => Real_Matrix,
Operation => "abs");
function Solve is new
Matrix_Vector_Solution (Real'Base, 0.0, Real_Vector, Real_Matrix);
function Solve is new
Matrix_Matrix_Solution (Real'Base, 0.0, Real_Matrix);
function Unit_Matrix is new
Generic_Array_Operations.Unit_Matrix
(Scalar => Real'Base,
Matrix => Real_Matrix,
Zero => 0.0,
One => 1.0);
function Unit_Vector is new
Generic_Array_Operations.Unit_Vector
(Scalar => Real'Base,
Vector => Real_Vector,
Zero => 0.0,
One => 1.0);
end Instantiations;
---------
-- "+" --
---------
function "+" (Right : Real_Vector) return Real_Vector
renames Instantiations."+";
function "+" (Right : Real_Matrix) return Real_Matrix
renames Instantiations."+";
function "+" (Left, Right : Real_Vector) return Real_Vector
renames Instantiations."+";
function "+" (Left, Right : Real_Matrix) return Real_Matrix
renames Instantiations."+";
---------
-- "-" --
---------
function "-" (Right : Real_Vector) return Real_Vector
renames Instantiations."-";
function "-" (Right : Real_Matrix) return Real_Matrix
renames Instantiations."-";
function "-" (Left, Right : Real_Vector) return Real_Vector
renames Instantiations."-";
function "-" (Left, Right : Real_Matrix) return Real_Matrix
renames Instantiations."-";
---------
-- "*" --
---------
-- Scalar multiplication
function "*" (Left : Real'Base; Right : Real_Vector) return Real_Vector
renames Instantiations."*";
function "*" (Left : Real_Vector; Right : Real'Base) return Real_Vector
renames Instantiations."*";
function "*" (Left : Real'Base; Right : Real_Matrix) return Real_Matrix
renames Instantiations."*";
function "*" (Left : Real_Matrix; Right : Real'Base) return Real_Matrix
renames Instantiations."*";
-- Vector multiplication
function "*" (Left, Right : Real_Vector) return Real'Base
renames Instantiations."*";
function "*" (Left, Right : Real_Vector) return Real_Matrix
renames Instantiations."*";
function "*" (Left : Real_Vector; Right : Real_Matrix) return Real_Vector
renames Instantiations."*";
function "*" (Left : Real_Matrix; Right : Real_Vector) return Real_Vector
renames Instantiations."*";
-- Matrix Multiplication
function "*" (Left, Right : Real_Matrix) return Real_Matrix
renames Instantiations."*";
---------
-- "/" --
---------
function "/" (Left : Real_Vector; Right : Real'Base) return Real_Vector
renames Instantiations."/";
function "/" (Left : Real_Matrix; Right : Real'Base) return Real_Matrix
renames Instantiations."/";
-----------
-- "abs" --
-----------
function "abs" (Right : Real_Vector) return Real'Base
renames Instantiations."abs";
function "abs" (Right : Real_Vector) return Real_Vector
renames Instantiations."abs";
function "abs" (Right : Real_Matrix) return Real_Matrix
renames Instantiations."abs";
-----------------
-- Determinant --
-----------------
function Determinant (A : Real_Matrix) return Real'Base is
M : Real_Matrix := A;
B : Real_Matrix (A'Range (1), 1 .. 0);
R : Real'Base;
begin
Forward_Eliminate (M, B, R);
return R;
end Determinant;
-----------------
-- Eigensystem --
-----------------
procedure Eigensystem
(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix)
is
begin
Jacobi (A, Values, Vectors, Compute_Vectors => True);
Sort_Eigensystem (Values, Vectors);
end Eigensystem;
-----------------
-- Eigenvalues --
-----------------
function Eigenvalues (A : Real_Matrix) return Real_Vector is
begin
return Values : Real_Vector (A'Range (1)) do
declare
Vectors : Real_Matrix (1 .. 0, 1 .. 0);
begin
Jacobi (A, Values, Vectors, Compute_Vectors => False);
Sort_Eigensystem (Values, Vectors);
end;
end return;
end Eigenvalues;
-------------
-- Inverse --
-------------
function Inverse (A : Real_Matrix) return Real_Matrix is
(Solve (A, Unit_Matrix (Length (A),
First_1 => A'First (2),
First_2 => A'First (1))));
------------
-- Jacobi --
------------
procedure Jacobi
(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix;
Compute_Vectors : Boolean := True)
is
-- This subprogram uses Carl Gustav Jacob Jacobi's iterative method
-- for computing eigenvalues and eigenvectors and is based on
-- Rutishauser's implementation.
-- The given real symmetric matrix is transformed iteratively to
-- diagonal form through a sequence of appropriately chosen elementary
-- orthogonal transformations, called Jacobi rotations here.
-- The Jacobi method produces a systematic decrease of the sum of the
-- squares of off-diagonal elements. Convergence to zero is quadratic,
-- both for this implementation, as for the classic method that doesn't
-- use row-wise scanning for pivot selection.
-- The numerical stability and accuracy of Jacobi's method make it the
-- best choice here, even though for large matrices other methods will
-- be significantly more efficient in both time and space.
-- While the eigensystem computations are absolutely foolproof for all
-- real symmetric matrices, in presence of invalid values, or similar
-- exceptional situations it might not. In such cases the results cannot
-- be trusted and Constraint_Error is raised.
-- Note: this implementation needs temporary storage for 2 * N + N**2
-- values of type Real.
Max_Iterations : constant := 50;
N : constant Natural := Length (A);
subtype Square_Matrix is Real_Matrix (1 .. N, 1 .. N);
-- In order to annihilate the M (Row, Col) element, the
-- rotation parameters Cos and Sin are computed as
-- follows:
-- Theta = Cot (2.0 * Phi)
-- = (Diag (Col) - Diag (Row)) / (2.0 * M (Row, Col))
-- Then Tan (Phi) as the smaller root (in modulus) of
-- T**2 + 2 * T * Theta = 1 (or 0.5 / Theta, if Theta is large)
function Compute_Tan (Theta : Real) return Real is
(Real'Copy_Sign (1.0 / (abs Theta + Sqrt (1.0 + Theta**2)), Theta));
function Compute_Tan (P, H : Real) return Real is
(if Is_Tiny (P, Compared_To => H) then P / H
else Compute_Tan (Theta => H / (2.0 * P)));
pragma Annotate
(CodePeer, False_Positive, "divide by zero", "H, P /= 0");
function Sum_Strict_Upper (M : Square_Matrix) return Real;
-- Return the sum of all elements in the strict upper triangle of M
----------------------
-- Sum_Strict_Upper --
----------------------
function Sum_Strict_Upper (M : Square_Matrix) return Real is
Sum : Real := 0.0;
begin
for Row in 1 .. N - 1 loop
for Col in Row + 1 .. N loop
Sum := Sum + abs M (Row, Col);
end loop;
end loop;
return Sum;
end Sum_Strict_Upper;
M : Square_Matrix := A; -- Work space for solving eigensystem
Threshold : Real;
Sum : Real;
Diag : Real_Vector (1 .. N);
Diag_Adj : Real_Vector (1 .. N);
-- The vector Diag_Adj indicates the amount of change in each value,
-- while Diag tracks the value itself and Values holds the values as
-- they were at the beginning. As the changes typically will be small
-- compared to the absolute value of Diag, at the end of each iteration
-- Diag is computed as Diag + Diag_Adj thus avoiding accumulating
-- rounding errors. This technique is due to Rutishauser.
begin
if Compute_Vectors
and then (Vectors'Length (1) /= N or else Vectors'Length (2) /= N)
then
raise Constraint_Error with "incompatible matrix dimensions";
elsif Values'Length /= N then
raise Constraint_Error with "incompatible vector length";
elsif not Is_Symmetric (M) then
raise Constraint_Error with "matrix not symmetric";
end if;
-- Note: Only the locally declared matrix M and vectors (Diag, Diag_Adj)
-- have lower bound equal to 1. The Vectors matrix may have
-- different bounds, so take care indexing elements. Assignment
-- as a whole is fine as sliding is automatic in that case.
Vectors := (if not Compute_Vectors then [1 .. 0 => [1 .. 0 => 0.0]]
else Unit_Matrix (Vectors'Length (1), Vectors'Length (2)));
Values := Diagonal (M);
Sweep : for Iteration in 1 .. Max_Iterations loop
-- The first three iterations, perform rotation for any non-zero
-- element. After this, rotate only for those that are not much
-- smaller than the average off-diagnal element. After the fifth
-- iteration, additionally zero out off-diagonal elements that are
-- very small compared to elements on the diagonal with the same
-- column or row index.
Sum := Sum_Strict_Upper (M);
exit Sweep when Sum = 0.0;
Threshold := (if Iteration < 4 then 0.2 * Sum / Real (N**2) else 0.0);
-- Iterate over all off-diagonal elements, rotating any that have
-- an absolute value that exceeds the threshold.
Diag := Values;
Diag_Adj := [others => 0.0]; -- Accumulates adjustments to Diag
for Row in 1 .. N - 1 loop
for Col in Row + 1 .. N loop
-- If, before the rotation M (Row, Col) is tiny compared to
-- Diag (Row) and Diag (Col), rotation is skipped. This is
-- meaningful, as it produces no larger error than would be
-- produced anyhow if the rotation had been performed.
-- Suppress this optimization in the first four sweeps, so
-- that this procedure can be used for computing eigenvectors
-- of perturbed diagonal matrices.
if Iteration > 4
and then Is_Tiny (M (Row, Col), Compared_To => Diag (Row))
and then Is_Tiny (M (Row, Col), Compared_To => Diag (Col))
then
M (Row, Col) := 0.0;
elsif abs M (Row, Col) > Threshold then
Perform_Rotation : declare
Tan : constant Real := Compute_Tan (M (Row, Col),
Diag (Col) - Diag (Row));
Cos : constant Real := 1.0 / Sqrt (1.0 + Tan**2);
Sin : constant Real := Tan * Cos;
Tau : constant Real := Sin / (1.0 + Cos);
Adj : constant Real := Tan * M (Row, Col);
begin
Diag_Adj (Row) := Diag_Adj (Row) - Adj;
Diag_Adj (Col) := Diag_Adj (Col) + Adj;
Diag (Row) := Diag (Row) - Adj;
Diag (Col) := Diag (Col) + Adj;
M (Row, Col) := 0.0;
for J in 1 .. Row - 1 loop -- 1 <= J < Row
Rotate (M (J, Row), M (J, Col), Sin, Tau);
end loop;
for J in Row + 1 .. Col - 1 loop -- Row < J < Col
Rotate (M (Row, J), M (J, Col), Sin, Tau);
end loop;
for J in Col + 1 .. N loop -- Col < J <= N
Rotate (M (Row, J), M (Col, J), Sin, Tau);
end loop;
for J in Vectors'Range (1) loop
Rotate (Vectors (J, Row - 1 + Vectors'First (2)),
Vectors (J, Col - 1 + Vectors'First (2)),
Sin, Tau);
end loop;
end Perform_Rotation;
end if;
end loop;
end loop;
Values := Values + Diag_Adj;
end loop Sweep;
-- All normal matrices with valid values should converge perfectly.
if Sum /= 0.0 then
raise Constraint_Error with "eigensystem solution does not converge";
end if;
end Jacobi;
-----------
-- Solve --
-----------
function Solve (A : Real_Matrix; X : Real_Vector) return Real_Vector
renames Instantiations.Solve;
function Solve (A, X : Real_Matrix) return Real_Matrix
renames Instantiations.Solve;
----------------------
-- Sort_Eigensystem --
----------------------
procedure Sort_Eigensystem
(Values : in out Real_Vector;
Vectors : in out Real_Matrix)
is
procedure Swap (Left, Right : Integer);
-- Swap Values (Left) with Values (Right), and also swap the
-- corresponding eigenvectors. Note that lowerbounds may differ.
function Less (Left, Right : Integer) return Boolean is
(Values (Left) > Values (Right));
-- Sort by decreasing eigenvalue, see RM G.3.1 (76).
procedure Sort is new Generic_Anonymous_Array_Sort (Integer);
-- Sorts eigenvalues and eigenvectors by decreasing value
procedure Swap (Left, Right : Integer) is
begin
Swap (Values (Left), Values (Right));
Swap_Column (Vectors, Left - Values'First + Vectors'First (2),
Right - Values'First + Vectors'First (2));
end Swap;
begin
Sort (Values'First, Values'Last);
end Sort_Eigensystem;
---------------
-- Transpose --
---------------
function Transpose (X : Real_Matrix) return Real_Matrix is
begin
return R : Real_Matrix (X'Range (2), X'Range (1)) do
Transpose (X, R);
end return;
end Transpose;
-----------------
-- Unit_Matrix --
-----------------
function Unit_Matrix
(Order : Positive;
First_1 : Integer := 1;
First_2 : Integer := 1) return Real_Matrix
renames Instantiations.Unit_Matrix;
-----------------
-- Unit_Vector --
-----------------
function Unit_Vector
(Index : Integer;
Order : Positive;
First : Integer := 1) return Real_Vector
renames Instantiations.Unit_Vector;
end Ada.Numerics.Generic_Real_Arrays;
|
reznikmm/matreshka | Ada | 13,762 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Wide_Wide_Text_IO;
with Matreshka.XML_Schema.AST.Attribute_Declarations;
with Matreshka.XML_Schema.AST.Attribute_Uses;
with Matreshka.XML_Schema.AST.Element_Declarations;
with Matreshka.XML_Schema.AST.Complex_Types;
with Matreshka.XML_Schema.AST.Constraining_Facets;
with Matreshka.XML_Schema.AST.Models;
with Matreshka.XML_Schema.AST.Namespaces;
with Matreshka.XML_Schema.AST.Particles;
with Matreshka.XML_Schema.AST.Simple_Types;
with Matreshka.XML_Schema.AST.Types;
package body Matreshka.XML_Schema.Name_Resolvers is
---------------------------------
-- Enter_Attribute_Declaration --
---------------------------------
overriding procedure Enter_Attribute_Declaration
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Attribute_Declaration_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control)
is
use type Matreshka.XML_Schema.AST.Types.Scope_Variety;
use type Matreshka.XML_Schema.AST.Type_Definition_Access;
use type Matreshka.XML_Schema.AST.Simple_Type_Definition_Access;
Type_Definition : Matreshka.XML_Schema.AST.Type_Definition_Access;
begin
if AST.Is_Empty (Node.Type_Name) then
if Node.Type_Definition = null then
-- XXX default ·xs:anySimpleType· not implemented yet
Ada.Wide_Wide_Text_IO.Put_Line
(Ada.Wide_Wide_Text_IO.Standard_Error,
"Name_Resolver Attribute_Declaration no type for attr for '"
& Node.Name.To_Wide_Wide_String
& "' !!!");
-- raise Program_Error;
end if;
else
-- XXX should we check Node.Type_Definition = null here?
Type_Definition := Self.Resolve_Type (Node.Type_Name);
Node.Type_Definition := Self.Resolve_Simple_Type (Node.Type_Name);
end if;
end Enter_Attribute_Declaration;
-------------------------
-- Enter_Attribute_Use --
-------------------------
overriding procedure Enter_Attribute_Use
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Attribute_Use_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is
begin
if not AST.Is_Empty (Node.Ref) then
-- XXX should we check Node.Attribute_Declaration = null here?
Node.Attribute_Declaration := Self.Resolve_Attribute (Node.Ref);
end if;
end Enter_Attribute_Use;
-----------------------------------
-- Enter_Complex_Type_Definition --
-----------------------------------
overriding procedure Enter_Complex_Type_Definition
(Self : in out Name_Resolver;
Node :
not null Matreshka.XML_Schema.AST.Complex_Type_Definition_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is
begin
if not AST.Is_Empty (Node.Restriction_Base) then
-- XXX should we check Node.Base_Type_Definition = null here?
Node.Base_Type_Definition :=
Self.Resolve_Type (Node.Restriction_Base);
elsif not AST.Is_Empty (Node.Extension_Base) then
-- XXX should we check Node.Base_Type_Definition = null here?
Node.Base_Type_Definition :=
Self.Resolve_Type (Node.Extension_Base);
end if;
end Enter_Complex_Type_Definition;
-------------------------------
-- Enter_Element_Declaration --
-------------------------------
overriding procedure Enter_Element_Declaration
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Element_Declaration_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control)
is
use type Matreshka.XML_Schema.AST.Types.Scope_Variety;
use type Matreshka.XML_Schema.AST.Type_Definition_Access;
begin
if Node.Type_Definition = null
and then not (Node.Type_Name.Namespace_URI.Is_Empty
and Node.Type_Name.Local_Name.Is_Empty)
then
-- Type of element declaration is not defined inside
-- element declaration itself and need to be resolved when 'type'
-- attribute is present.
--
-- XXX Check for namespaceURI is added to process 'facet' element
-- decalration only. Can non-abstract element declarations be used
-- without type declaration?
Node.Type_Definition := Self.Resolve_Type (Node.Type_Name);
end if;
end Enter_Element_Declaration;
-----------------------
-- Enter_Enumeration --
-----------------------
overriding procedure Enter_Enumeration
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Enumeration_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is
begin
Self.STD.Lexical_Enumeration.Append (Node.Value);
end Enter_Enumeration;
-----------------
-- Enter_Model --
-----------------
overriding procedure Enter_Model
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Model_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is
begin
Self.Model := Node;
end Enter_Model;
--------------------
-- Enter_Particle --
--------------------
overriding procedure Enter_Particle
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Particle_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control)
is
Element : Matreshka.XML_Schema.AST.Element_Declaration_Access;
begin
if not AST.Is_Empty (Node.Element_Ref) then
-- XXX should we check Node.Term = null here?
Element := Self.Resolve_Element (Node.Element_Ref);
Node.Term := AST.Types.Term_Access (Element);
end if;
end Enter_Particle;
----------------------------------
-- Enter_Simple_Type_Definition --
----------------------------------
overriding procedure Enter_Simple_Type_Definition
(Self : in out Name_Resolver;
Node : not null Matreshka.XML_Schema.AST.Simple_Type_Definition_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control)
is
Type_Definition : Matreshka.XML_Schema.AST.Simple_Type_Definition_Access;
begin
if not AST.Is_Empty (Node.Restriction_Base) then
-- XXX should we check Node.Base_Type_Definition = null here?
Node.Base_Type_Definition :=
Self.Resolve_Type (Node.Restriction_Base);
end if;
for Item of Node.Member_Types loop
Type_Definition := Self.Resolve_Simple_Type (Item);
Node.Member_Type_Definitions.Append
(Matreshka.XML_Schema.AST.Object_Access (Type_Definition));
end loop;
if not AST.Is_Empty (Node.Item_Type) then
Node.Item_Type_Definition :=
Self.Resolve_Simple_Type (Node.Item_Type);
end if;
Self.STD := Node;
end Enter_Simple_Type_Definition;
-----------------------
-- Resolve_Attribute --
-----------------------
not overriding function Resolve_Attribute
(Self : in out Name_Resolver;
Name : Matreshka.XML_Schema.AST.Qualified_Name)
return Matreshka.XML_Schema.AST.Attribute_Declaration_Access
is
use type Matreshka.XML_Schema.AST.Namespace_Access;
use type Matreshka.XML_Schema.AST.Attribute_Declaration_Access;
Result : Matreshka.XML_Schema.AST.Attribute_Declaration_Access;
Namespace : constant Matreshka.XML_Schema.AST.Namespace_Access :=
Self.Model.Get_Namespace (Name.Namespace_URI);
begin
if Namespace = null then
raise Program_Error;
end if;
Result := Namespace.Get_Attribute_Declaration (Name.Local_Name);
if Result = null then
raise Program_Error;
end if;
return Result;
end Resolve_Attribute;
---------------------
-- Resolve_Element --
---------------------
not overriding function Resolve_Element
(Self : in out Name_Resolver;
Name : Matreshka.XML_Schema.AST.Qualified_Name)
return Matreshka.XML_Schema.AST.Element_Declaration_Access
is
use type Matreshka.XML_Schema.AST.Namespace_Access;
use type Matreshka.XML_Schema.AST.Element_Declaration_Access;
Result : Matreshka.XML_Schema.AST.Element_Declaration_Access;
Namespace : constant Matreshka.XML_Schema.AST.Namespace_Access :=
Self.Model.Get_Namespace (Name.Namespace_URI);
begin
if Namespace = null then
raise Program_Error;
end if;
Result := Namespace.Get_Element_Declaration (Name.Local_Name);
if Result = null then
raise Program_Error;
end if;
return Result;
end Resolve_Element;
-------------------------
-- Resolve_Simple_Type --
-------------------------
not overriding function Resolve_Simple_Type
(Self : in out Name_Resolver;
Name : Matreshka.XML_Schema.AST.Qualified_Name)
return Matreshka.XML_Schema.AST.Simple_Type_Definition_Access
is
Result : Matreshka.XML_Schema.AST.Type_Definition_Access
:= Self.Resolve_Type (Name);
begin
if Result.all
in Matreshka.XML_Schema.AST.Simple_Types
.Simple_Type_Definition_Node'Class
then
return
Matreshka.XML_Schema.AST.Simple_Type_Definition_Access
(Result);
else
raise Constraint_Error
with "Unable to resolve type to simple type";
end if;
end Resolve_Simple_Type;
------------------
-- Resolve_Type --
------------------
not overriding function Resolve_Type
(Self : in out Name_Resolver;
Name : Matreshka.XML_Schema.AST.Qualified_Name)
return Matreshka.XML_Schema.AST.Type_Definition_Access
is
use type Matreshka.XML_Schema.AST.Namespace_Access;
use type Matreshka.XML_Schema.AST.Type_Definition_Access;
Result : Matreshka.XML_Schema.AST.Type_Definition_Access;
Namespace : constant Matreshka.XML_Schema.AST.Namespace_Access :=
Self.Model.Get_Namespace (Name.Namespace_URI);
begin
if Namespace = null then
raise Program_Error;
end if;
Result := Namespace.Get_Type_Definition (Name.Local_Name);
if Result = null then
raise Program_Error;
end if;
return Result;
end Resolve_Type;
end Matreshka.XML_Schema.Name_Resolvers;
|
jhumphry/PRNG_Zoo | Ada | 4,089 | adb |
--
-- PRNG Zoo
-- Copyright (c) 2014 - 2015, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
package body PRNG_Zoo.Filters is
--------------
-- Generate --
--------------
function Generate (G: in out Split_32) return U32 is
V : U64;
begin
if G.Loaded then
G.Loaded := False;
return G.Next_Value;
else
V := G.IG.Generate;
G.Loaded := True;
G.Next_Value := U32(Shift_Right(V,32));
return U32(V and 16#FFFFFFFF#);
end if;
end Generate;
--------------
-- Generate --
--------------
function Generate (G: in out Bit_Reverse) return U64 is
V : U64;
begin
V := G.IG.Generate;
V := (Shift_Right(V, 1) and 16#5555555555555555#)
or Shift_Left((V and 16#5555555555555555#), 1);
V := (Shift_Right(V, 2) and 16#3333333333333333#)
or Shift_Left((V and 16#3333333333333333#), 2);
V := (Shift_Right(V, 4) and 16#0F0F0F0F0F0F0F0F#)
or Shift_Left((V and 16#0F0F0F0F0F0F0F0F#), 4);
V := (Shift_Right(V, 8) and 16#00FF00FF00FF00FF#)
or Shift_Left((V and 16#00FF00FF00FF00FF#), 8);
V := (Shift_Right(V, 16) and 16#0000FFFF0000FFFF#)
or Shift_Left((V and 16#0000FFFF0000FFFF#), 16);
V := Shift_Right(V, 32) or Shift_Left(V, 32);
return V;
end Generate;
---------------------
-- Generate_Padded --
---------------------
function Generate_Padded (G: in out Bit_Reverse) return U64 is
V : U64;
begin
V := G.IG.Generate_Padded;
V := (Shift_Right(V, 1) and 16#5555555555555555#)
or Shift_Left((V and 16#5555555555555555#), 1);
V := (Shift_Right(V, 2) and 16#3333333333333333#)
or Shift_Left((V and 16#3333333333333333#), 2);
V := (Shift_Right(V, 4) and 16#0F0F0F0F0F0F0F0F#)
or Shift_Left((V and 16#0F0F0F0F0F0F0F0F#), 4);
V := (Shift_Right(V, 8) and 16#00FF00FF00FF00FF#)
or Shift_Left((V and 16#00FF00FF00FF00FF#), 8);
V := (Shift_Right(V, 16) and 16#0000FFFF0000FFFF#)
or Shift_Left((V and 16#0000FFFF0000FFFF#), 16);
V := Shift_Right(V, 32) or Shift_Left(V, 32);
return V;
end Generate_Padded;
--------------
-- Generate --
--------------
function Generate (G: in out Bit_Reverse) return U32 is
V : U32;
begin
V := G.IG.Generate;
V := (Shift_Right(V, 1) and 16#55555555#)
or Shift_Left((V and 16#55555555#), 1);
V := (Shift_Right(V, 2) and 16#33333333#)
or Shift_Left((V and 16#33333333#), 2);
V := (Shift_Right(V, 4) and 16#0F0F0F0F#)
or Shift_Left((V and 16#0F0F0F0F#), 4);
V := (Shift_Right(V, 8) and 16#00FF00FF#)
or Shift_Left((V and 16#00FF00FF#), 8);
V := Shift_Right(V, 16) or Shift_Left(V, 16);
return V;
end Generate;
-----------
-- Reset --
-----------
procedure Reset(G: in out Incrementer; S: in U64) is
begin
G.S := S;
end Reset;
--------------
-- Generate --
--------------
function Generate(G: in out Incrementer) return U64 is
begin
G.S := G.S + G.Incr;
return G.S;
end Generate;
--------------
-- Generate --
--------------
function Generate(G: in out Incrementer) return U32 is
begin
G.S := G.S + G.Incr;
return U32(G.S and 16#FFFFFFFF#);
end Generate;
end PRNG_Zoo.Filters;
|
reznikmm/matreshka | Ada | 5,460 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Create_Link_Object_Actions.Collections is
pragma Preelaborate;
package UML_Create_Link_Object_Action_Collections is
new AMF.Generic_Collections
(UML_Create_Link_Object_Action,
UML_Create_Link_Object_Action_Access);
type Set_Of_UML_Create_Link_Object_Action is
new UML_Create_Link_Object_Action_Collections.Set with null record;
Empty_Set_Of_UML_Create_Link_Object_Action : constant Set_Of_UML_Create_Link_Object_Action;
type Ordered_Set_Of_UML_Create_Link_Object_Action is
new UML_Create_Link_Object_Action_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Create_Link_Object_Action : constant Ordered_Set_Of_UML_Create_Link_Object_Action;
type Bag_Of_UML_Create_Link_Object_Action is
new UML_Create_Link_Object_Action_Collections.Bag with null record;
Empty_Bag_Of_UML_Create_Link_Object_Action : constant Bag_Of_UML_Create_Link_Object_Action;
type Sequence_Of_UML_Create_Link_Object_Action is
new UML_Create_Link_Object_Action_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Create_Link_Object_Action : constant Sequence_Of_UML_Create_Link_Object_Action;
private
Empty_Set_Of_UML_Create_Link_Object_Action : constant Set_Of_UML_Create_Link_Object_Action
:= (UML_Create_Link_Object_Action_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Create_Link_Object_Action : constant Ordered_Set_Of_UML_Create_Link_Object_Action
:= (UML_Create_Link_Object_Action_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Create_Link_Object_Action : constant Bag_Of_UML_Create_Link_Object_Action
:= (UML_Create_Link_Object_Action_Collections.Bag with null record);
Empty_Sequence_Of_UML_Create_Link_Object_Action : constant Sequence_Of_UML_Create_Link_Object_Action
:= (UML_Create_Link_Object_Action_Collections.Sequence with null record);
end AMF.UML.Create_Link_Object_Actions.Collections;
|
AdaCore/training_material | Ada | 831 | ads | with SPARK.Big_Integers; use SPARK.Big_Integers;
with Nat_Multisets; use Nat_Multisets;
with Sort_Types; use Sort_Types;
package Perm with SPARK_Mode, Ghost is
use Nat_Multisets;
function Occurrences (Values : Nat_Array; Lst : Integer) return Multiset is
(if Lst < Values'First then Empty_Multiset
else Add (Occurrences (Values, Lst - 1), Values (Lst)))
with
Subprogram_Variant => (Decreases => Lst),
Pre => Lst <= Values'Last;
function Occurrences (Values : Nat_Array) return Multiset is
(Occurrences (Values, Values'Last));
function Occ (Values : Nat_Array; N : Natural) return Big_Natural is
(Nb_Occurence (Occurrences (Values), N));
function Is_Perm (Left, Right : Nat_Array) return Boolean is
(Occurrences (Left) = Occurrences (Right));
end Perm;
|
reznikmm/matreshka | Ada | 3,474 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.SAX.Output_Destinations.Strings;
package XML.SAX.String_Output_Destinations
renames XML.SAX.Output_Destinations.Strings;
|
persan/AdaYaml | Ada | 189 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package Yaml.Transformation_Tests is
end Yaml.Transformation_Tests;
|
gitter-badger/libAnne | Ada | 56 | ads | package Generics.Containers is
end Generics.Containers;
|
Fabien-Chouteau/GESTE | Ada | 4,896 | adb | with GESTE;
with GESTE.Tile_Bank;
with GESTE.Sprite;
with GESTE_Config; use GESTE_Config;
with GESTE.Maths_Types; use GESTE.Maths_Types;
with GESTE.Physics;
with Game_Assets;
with Game_Assets.Tileset;
package body Player is
type Player_Type (Bank : not null GESTE.Tile_Bank.Const_Ref;
Init_Frame : GESTE_Config.Tile_Index)
is limited new GESTE.Physics.Object with record
Sprite : aliased GESTE.Sprite.Instance (Bank, Init_Frame);
end record;
Tile_Bank : aliased GESTE.Tile_Bank.Instance
(Game_Assets.Tileset.Tiles'Access,
GESTE.No_Collisions,
Game_Assets.Palette'Access);
P : aliased Player_Type (Tile_Bank'Access, 79);
Max_Jump_Frame : constant := 7;
Jumping : Boolean := False;
Do_Jump : Boolean := False;
Jump_Cnt : Natural := 0;
Going_Left : Boolean := False;
Going_Right : Boolean := False;
type Collision_Points is (BL, BR, Left, Right, TL, TR);
Collides : array (Collision_Points) of Boolean;
Offset : constant array (Collision_Points) of GESTE.Pix_Point
:= (BL => (-4, 7),
BR => (4, 7),
Left => (-6, 5),
Right => (6, 5),
TL => (-4, -7),
TR => (4, -7));
Grounded : Boolean := False;
procedure Update_Collisions;
-----------------------
-- Update_Collisions --
-----------------------
procedure Update_Collisions is
X : constant Integer := Integer (P.Position.X);
Y : constant Integer := Integer (P.Position.Y);
begin
for Pt in Collision_Points loop
Collides (Pt) := GESTE.Collides ((X + Offset (Pt).X,
Y + Offset (Pt).Y));
end loop;
end Update_Collisions;
----------
-- Move --
----------
procedure Move (Pt : GESTE.Pix_Point) is
begin
P.Set_Position (GESTE.Maths_Types.Point'(Value (Pt.X), Value (Pt.Y)));
end Move;
--------------
-- Position --
--------------
function Position return GESTE.Pix_Point
is ((Integer (P.Position.X), Integer (P.Position.Y)));
------------
-- Update --
------------
procedure Update is
Old : constant Point := P.Position;
begin
if Going_Right then
P.Sprite.Flip_Vertical (False);
P.Sprite.Set_Tile (Tile_Index (79 + (Integer (Old.X) / 2) mod 3));
elsif Going_Left then
P.Sprite.Flip_Vertical (True);
P.Sprite.Set_Tile (Tile_Index (79 + (Integer (Old.X) / 2) mod 3));
end if;
if Grounded then
if Going_Right then
P.Apply_Force ((14_000.0, 0.0));
elsif Going_Left then
P.Apply_Force ((-14_000.0, 0.0));
else
-- Friction
P.Apply_Force (
(Value (Value (-800.0) * P.Speed.X),
0.0));
end if;
else
if Going_Right then
P.Apply_Force ((7_000.0, 0.0));
elsif Going_Left then
P.Apply_Force ((-7_000.0, 0.0));
end if;
P.Apply_Gravity (Value (-500.0));
end if;
if Do_Jump then
P.Apply_Force ((0.0, -20_0000.0));
Jumping := True;
end if;
P.Step (Value (1.0 / 60.0));
Update_Collisions;
if Collides (BL)
or else
Collides (BR)
or else
Collides (TL)
or else
Collides (TR)
then
P.Set_Position ((P.Position.X, Old.Y));
P.Set_Speed ((P.Speed.X, Value (0.0)));
Jump_Cnt := 0;
end if;
if Collides (TL) or else Collides (TR) then
Jump_Cnt := Max_Jump_Frame + 1;
end if;
Grounded := Collides (BL) or else Collides (BR);
Jumping := Jumping and not Grounded;
if (P.Speed.X > Value (0.0)
and then (Collides (Right) or else Collides (TR)))
or else
(P.Speed.X < Value (0.0)
and then (Collides (Left) or else Collides (TL)))
then
P.Set_Position ((Old.X, P.Position.Y));
P.Set_Speed ((Value (0.0), P.Speed.Y));
end if;
P.Sprite.Move ((Integer (P.Position.X) - 8,
Integer (P.Position.Y) - 8));
Do_Jump := False;
Going_Left := False;
Going_Right := False;
end Update;
----------
-- Jump --
----------
procedure Jump is
begin
if Grounded or else (Jumping and then Jump_Cnt < Max_Jump_Frame) then
Do_Jump := True;
Jump_Cnt := Jump_Cnt + 1;
end if;
end Jump;
---------------
-- Move_Left --
---------------
procedure Move_Left is
begin
Going_Left := True;
end Move_Left;
----------------
-- Move_Right --
----------------
procedure Move_Right is
begin
Going_Right := True;
end Move_Right;
begin
P.Set_Mass (Value (90.0));
GESTE.Add (P.Sprite'Access, 3);
end Player;
|
python36/0xfa | Ada | 2,809 | ads | with interfaces;
with ada.unchecked_conversion;
with ada.numerics.generic_elementary_functions;
with ada.text_io;
with ada.strings.fixed;
package numbers is
function uint32_to_integer is
new ada.unchecked_conversion(source => interfaces.unsigned_32, target => integer);
subtype byte is interfaces.unsigned_8;
subtype word is interfaces.unsigned_16;
function integer_to_word is
new ada.unchecked_conversion(source => integer, target => word);
use type byte;
use type word;
function words_add (a, b : word) return word;
function words_sub (a, b : word) return word;
function words_mul (a, b : word) return word;
function words_div (a, b : word) return word;
function words_pow (a, b : word) return word;
function words_mod (a, b : word) return word;
function words_or (a, b : word) return word;
function words_and (a, b : word) return word;
function words_xor (a, b : word) return word;
function words_sl (a, b : word) return word;
function words_sr (a, b : word) return word;
function sl (value : byte; amount : natural) return byte renames interfaces.shift_left;
function sr (value : byte; amount : natural) return byte renames interfaces.shift_right;
function sl (value : word; amount : natural) return word renames interfaces.shift_left;
function sr (value : word; amount : natural) return word renames interfaces.shift_right;
procedure inc (p_i : in out integer);
procedure dec (p_i : in out integer);
procedure inc (p_i : in out word);
procedure dec (p_i : in out word);
procedure inc (p_i : in out byte);
procedure dec (p_i : in out byte);
procedure incd (p_i : in out byte);
procedure incd (p_i : in out word);
function incd (p_i : word) return word;
procedure decd (p_i : in out word);
function swpb (w : word) return word;
procedure swpb (w : in out word);
function word_to_integer (w : word) return integer;
function validate_word (str : string) return boolean;
function value (str : string) return word;
procedure void (w : word);
function to_positive (b : boolean; v : positive := 1) return positive;
function to_natural (b : boolean; v : natural := 1) return natural;
function to_word (b : boolean; v : word := 1) return word;
function image (w : word; base : positive; fix_size : boolean := true) return string;
function hex (w : word; fix_size : boolean := true) return string;
function bin (w : word; fix_size : boolean := true) return string;
function odd (w : word) return boolean;
function even (w : word) return boolean;
private
package natural_io is new ada.text_io.integer_io(natural);
package word_func is new ada.numerics.generic_elementary_functions(long_float);
function get_max_image_length (base : positive; val : word := word'last) return positive;
end numbers; |
reznikmm/matreshka | Ada | 4,600 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Position_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Position_Attribute_Node is
begin
return Self : Style_Position_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Position_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Position_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Position_Attribute,
Style_Position_Attribute_Node'Tag);
end Matreshka.ODF_Style.Position_Attributes;
|
reznikmm/matreshka | Ada | 3,684 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Office_Dde_Source_Elements is
pragma Preelaborate;
type ODF_Office_Dde_Source is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Office_Dde_Source_Access is
access all ODF_Office_Dde_Source'Class
with Storage_Size => 0;
end ODF.DOM.Office_Dde_Source_Elements;
|
reznikmm/gela | Ada | 831 | ads | package Gela.Int.Tuples is
pragma Preelaborate;
type Tuple (<>) is new Interpretation with private;
function Create
(Value : Gela.Interpretations.Interpretation_Set_Index_Array)
return Tuple;
function Value
(Self : Tuple) return Gela.Interpretations.Interpretation_Set_Index_Array;
type Chosen_Tuple is new Interpretation with null record;
private
type Tuple (Length : Natural; Size : Positive) is
new Interpretation (Length) with
record
Value : Gela.Interpretations.Interpretation_Set_Index_Array (1 .. Size);
end record;
overriding procedure Visit
(Self : Tuple;
Visiter : access Gela.Int.Visiters.Visiter'Class);
overriding procedure Visit
(Self : Chosen_Tuple;
Visiter : access Gela.Int.Visiters.Visiter'Class);
end Gela.Int.Tuples;
|
tum-ei-rcs/StratoX | Ada | 994 | ads | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Module: Software Configuration
--
-- Authors: Martin Becker ([email protected])
with STM32.Timers;
with STm32.Device;
-- @summary
-- Target-specific types for the hardware timers in Pixracer V1.
package HIL.Devices.Timers with SPARK_Mode is
subtype HIL_Timer is STM32.Timers.Timer;
subtype HIL_Timer_Channel is STM32.Timers.Timer_Channel;
-- the buzzer is routed to Timer 2 channel 1 (STM32.Device.PA15)
Timer_Buzzer_Port : STM32.Timers.Timer renames STM32.Device.Timer_2; -- Buuzer port
Timerchannel_Buzzer_Port : STM32.Timers.Timer_Channel renames STM32.Timers.Channel_1;
-- alternatively, we can use FMU AUX5 at the Servo pins (Timer 4 channel 2):
Timer_Buzzer_Aux : STM32.Timers.Timer renames STM32.Device.Timer_4;
Timerchannel_Buzzer_Aux : STM32.Timers.Timer_Channel renames STM32.Timers.Channel_2;
end HIL.Devices.Timers;
|
thierr26/ada-keystore | Ada | 1,772 | ads | -----------------------------------------------------------------------
-- keystore-passwords-keys -- Key provider
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Keystore.Passwords.Keys is
use type Ada.Streams.Stream_Element_Offset;
DEFAULT_KEY_LENGTH : constant := 32 + 16 + 32;
type Key_Provider is limited interface;
type Key_Provider_Access is access all Key_Provider'Class;
-- Get the Key, IV and signature.
procedure Get_Keys (From : in Key_Provider;
Key : out Secret_Key;
IV : out Secret_Key;
Sign : out Secret_Key) is abstract with
Post'Class => Key.Length = 32 and IV.Length = 16 and Sign.Length = 32;
-- Create a key, iv, sign provider from the string.
function Create (Password : in String;
Length : in Key_Length := DEFAULT_KEY_LENGTH)
return Key_Provider_Access;
function Create (Password : in Ada.Streams.Stream_Element_Array)
return Key_Provider_Access;
end Keystore.Passwords.Keys;
|
stcarrez/ada-asf | Ada | 12,018 | adb | -----------------------------------------------------------------------
-- components-widgets-likes -- Social Likes Components
-- Copyright (C) 2013, 2014, 2015, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Locales;
with Util.Beans.Objects;
with Util.Strings.Tokenizers;
-- GNAT bug, the with clause is necessary to call Get_Global on the application.
pragma Warnings (Off, "*is not referenced");
with ASF.Applications.Main;
pragma Warnings (On, "*is not referenced");
with ASF.Requests;
with ASF.Contexts.Writer;
package body ASF.Components.Widgets.Likes is
FB_LAYOUT_ATTR : aliased constant String := "data-layout";
FB_SHOW_FACES_ATTR : aliased constant String := "data-show-faces";
FB_WIDTH_ATTR : aliased constant String := "data-width";
FB_ACTION_ATTR : aliased constant String := "data-action";
FB_FONT_ATTR : aliased constant String := "data-font";
FB_COlORSCHEME_ATTR : aliased constant String := "data-colorscheme";
FB_REF_ATTR : aliased constant String := "data-ref";
FB_KIDS_ATTR : aliased constant String := "data-kid_directed_site";
FB_SEND_ATTR : aliased constant String := "data-send";
TW_VIA_ATTR : aliased constant String := "data-via";
TW_COUNT_ATTR : aliased constant String := "data-count";
TW_SIZE_ATTR : aliased constant String := "data-size";
TW_COUNTURL_ATTR : aliased constant String := "data-counturl";
TW_TEXT_ATTR : aliased constant String := "data-text";
TW_RELATED_ATTR : aliased constant String := "data-related";
TW_LANG_ATTR : aliased constant String := "data-lang";
TW_HASHTAGS_ATTR : aliased constant String := "data-hashtags";
FACEBOOK_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set;
FACEBOOK_SCRIPT_ATTRIBUTE : constant String := "asf.widgets.facebook.script";
TWITTER_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set;
TWITTER_SCRIPT_ATTRIBUTE : constant String := "asf.widgets.twitter.script";
type Like_Generator_Binding is record
Name : Util.Strings.Name_Access;
Generator : Like_Generator_Access;
end record;
type Like_Generator_Array is array (1 .. MAX_LIKE_GENERATOR) of Like_Generator_Binding;
FB_NAME : aliased constant String := "facebook";
FB_GENERATOR : aliased Facebook_Like_Generator;
TWITTER_NAME : aliased constant String := "twitter";
TWITTER_GENERATOR : aliased Twitter_Like_Generator;
Generators : Like_Generator_Array := (1 => (FB_NAME'Access, FB_GENERATOR'Access),
2 => (TWITTER_NAME'Access, TWITTER_GENERATOR'Access),
others => (null, null));
-- ------------------------------
-- Render the facebook like button according to the component attributes.
-- ------------------------------
overriding
procedure Render_Like (Generator : in Facebook_Like_Generator;
UI : in UILike'Class;
Href : in String;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
pragma Unreferenced (Generator);
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
Request : constant ASF.Requests.Request_Access := Context.Get_Request;
begin
if not Context.Is_Ajax_Request and then
Util.Beans.Objects.Is_Null (Request.Get_Attribute (FACEBOOK_SCRIPT_ATTRIBUTE))
then
Request.Set_Attribute (FACEBOOK_SCRIPT_ATTRIBUTE, Util.Beans.Objects.To_Object (True));
Writer.Queue_Script ("(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0];"
& "if (d.getElementById(id)) return;"
& "js = d.createElement(s); js.id = id;js.async=true;"
& "js.src = ""//connect.facebook.net/");
Writer.Queue_Script (Util.Locales.To_String (Context.Get_Locale));
Writer.Queue_Script ("/all.js#xfbml=1&;appId=");
declare
App_Id : constant String
:= Context.Get_Application.Get_Config (P_Facebook_App_Id.P);
begin
if App_Id'Length = 0 then
UI.Log_Error ("The facebook client application id is empty");
UI.Log_Error ("Please, configure the '{0}' property "
& "in the application", P_Facebook_App_Id.PARAM_NAME);
else
Writer.Queue_Script (App_Id);
end if;
end;
Writer.Queue_Script (""";fjs.parentNode.insertBefore(js, fjs);"
& "}(document, 'script', 'facebook-jssdk'));");
Writer.Start_Element ("div");
Writer.Write_Attribute ("id", "fb-root");
Writer.End_Element ("div");
end if;
Writer.Start_Element ("div");
Writer.Write_Attribute ("class", "fb-like");
Writer.Write_Attribute ("data-href", Href);
UI.Render_Attributes (Context, FACEBOOK_ATTRIBUTE_NAMES, Writer);
Writer.End_Element ("div");
end Render_Like;
-- ------------------------------
-- Tweeter like generator
-- ------------------------------
overriding
procedure Render_Like (Generator : in Twitter_Like_Generator;
UI : in UILike'Class;
Href : in String;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
pragma Unreferenced (Generator);
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
Request : constant ASF.Requests.Request_Access := Context.Get_Request;
Lang : constant String := Util.Locales.Get_ISO3_Language (Context.Get_Locale);
begin
if not Context.Is_Ajax_Request and then
Util.Beans.Objects.Is_Null (Request.Get_Attribute (TWITTER_SCRIPT_ATTRIBUTE))
then
Request.Set_Attribute (TWITTER_SCRIPT_ATTRIBUTE, Util.Beans.Objects.To_Object (True));
Writer.Queue_Script ("!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],"
& "p=/^http:/.test(d.location)?'http':'https';"
& "if(!d.getElementById(id)){js=d.createElement(s);js.id=id;"
& "js.src=p+'://platform.twitter.com/widgets.js';"
& "fjs.parentNode.insertBefore(js,fjs);}}"
& "(document, 'script', 'twitter-wjs');");
end if;
Writer.Start_Element ("a");
Writer.Write_Attribute ("href", "https://twitter.com/share");
Writer.Write_Attribute ("class", "twitter-share-button");
Writer.Write_Attribute ("data-url", Href);
Writer.Write_Attribute ("data-lang", Lang);
UI.Render_Attributes (Context, TWITTER_ATTRIBUTE_NAMES, Writer);
Writer.Write_Text ("Tweet");
Writer.End_Element ("a");
end Render_Like;
-- ------------------------------
-- Get the link to submit in the like action.
-- ------------------------------
function Get_Link (UI : in UILike;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is
Href : constant String := UI.Get_Attribute ("href", Context, "");
begin
if Href'Length > 0 then
return Href;
else
return Context.Get_Request.Get_Request_URI;
end if;
end Get_Link;
-- ------------------------------
-- Render an image with the source link created from an email address to the Gravatars service.
-- ------------------------------
overriding
procedure Encode_Begin (UI : in UILike;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
if UI.Is_Rendered (Context) then
declare
Writer : constant Contexts.Writer.Response_Writer_Access
:= Context.Get_Response_Writer;
Kind : constant String := UI.Get_Attribute ("type", Context, "");
Href : constant String := UILike'Class (UI).Get_Link (Context);
Style : constant String := UI.Get_Attribute ("style", Context, "");
Class : constant String := UI.Get_Attribute ("styleClass", Context, "");
procedure Render (Name : in String; Done : out Boolean);
procedure Render (Name : in String;
Done : out Boolean) is
use type Util.Strings.Name_Access;
begin
Done := False;
for I in Generators'Range loop
exit when Generators (I).Name = null;
if Generators (I).Name.all = Name then
Writer.Start_Element ("div");
if Style'Length > 0 then
Writer.Write_Attribute ("style", Style);
end if;
if Class'Length > 0 then
Writer.Write_Attribute ("class", Class);
end if;
Generators (I).Generator.Render_Like (UI, Href, Context);
Writer.End_Element ("div");
return;
end if;
end loop;
UI.Log_Error ("Like type {0} is not recognized", Name);
end Render;
begin
if Kind'Length = 0 then
UI.Log_Error ("The like type is empty.");
else
Util.Strings.Tokenizers.Iterate_Tokens (Content => Kind, Pattern => ",",
Process => Render'Access);
end if;
end;
end if;
end Encode_Begin;
-- ------------------------------
-- Register the like generator under the given name.
-- ------------------------------
procedure Register_Like (Name : in Util.Strings.Name_Access;
Generator : in Like_Generator_Access) is
use type Util.Strings.Name_Access;
begin
for I in Generators'Range loop
if Generators (I).Name = null then
Generators (I).Name := Name;
Generators (I).Generator := Generator;
return;
end if;
end loop;
end Register_Like;
begin
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_LAYOUT_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_SHOW_FACES_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_WIDTH_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_ACTION_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_FONT_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_COlORSCHEME_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_REF_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_KIDS_ATTR'Access);
FACEBOOK_ATTRIBUTE_NAMES.Insert (FB_SEND_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_SIZE_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_COUNT_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_VIA_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_COUNTURL_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_TEXT_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_RELATED_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_LANG_ATTR'Access);
TWITTER_ATTRIBUTE_NAMES.Insert (TW_HASHTAGS_ATTR'Access);
end ASF.Components.Widgets.Likes;
|
tum-ei-rcs/StratoX | Ada | 540 | ads | -- Project: MART - Modular Airborne Real-Time Testbed
-- System: Emergency Recovery System
-- Authors: Markus Neumair (Original C-Code)
-- Emanuel Regnath ([email protected]) (Ada Port)
--
-- Module Description:
-- @summary Top-level driver for the Barometer MS5611-01BA03
package MS5611 with SPARK_Mode is
-- define return values
type Sample_Status_Type is
(BARO_NO_NEW_VALUE,
BARO_NEW_TEMPERATURE,
BARO_NEW_PRESSURE,
BARO_READ_TEMPERATURE_ERROR,
BARO_READ_PRESSURE_ERROR);
end MS5611;
|
stcarrez/etherscope | Ada | 1,836 | adb | -----------------------------------------------------------------------
-- etherscope-receiver -- Ethernet Packet Receiver
-- Copyright (C) 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Real_Time;
with Ada.Synchronous_Task_Control;
with Net.Buffers;
with Net.Interfaces;
with EtherScope.Analyzer.Base;
package body EtherScope.Receiver is
Ready : Ada.Synchronous_Task_Control.Suspension_Object;
-- ------------------------------
-- Start the receiver loop.
-- ------------------------------
procedure Start is
begin
Ada.Synchronous_Task_Control.Set_True (Ready);
end Start;
-- ------------------------------
-- The task that waits for packets.
-- ------------------------------
task body Controller is
use type Ada.Real_Time.Time;
Packet : Net.Buffers.Buffer_Type;
begin
-- Wait until the Ethernet driver is ready.
Ada.Synchronous_Task_Control.Suspend_Until_True (Ready);
Net.Buffers.Allocate (Packet);
loop
Ifnet.Receive (Packet);
EtherScope.Analyzer.Base.Analyze (Packet);
end loop;
end Controller;
end EtherScope.Receiver;
|
RREE/ada-util | Ada | 8,351 | ads | -----------------------------------------------------------------------
-- util-http -- HTTP Utility Library
-- Copyright (C) 2012, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
-- = HTTP =
-- The `Util.Http` package provides a set of APIs that allows applications to use
-- the HTTP protocol. It defines a common interface on top of CURL and AWS so that
-- it is possible to use one of these two libraries in a transparent manner.
--
-- @include util-http-clients.ads
package Util.Http is
-- Standard codes returned in HTTP responses.
SC_CONTINUE : constant Natural := 100;
SC_SWITCHING_PROTOCOLS : constant Natural := 101;
SC_OK : constant Natural := 200;
SC_CREATED : constant Natural := 201;
SC_ACCEPTED : constant Natural := 202;
SC_NON_AUTHORITATIVE_INFORMATION : constant Natural := 203;
SC_NO_CONTENT : constant Natural := 204;
SC_RESET_CONTENT : constant Natural := 205;
SC_PARTIAL_CONTENT : constant Natural := 206;
SC_MULTIPLE_CHOICES : constant Natural := 300;
SC_MOVED_PERMANENTLY : constant Natural := 301;
SC_MOVED_TEMPORARILY : constant Natural := 302;
SC_FOUND : constant Natural := 302;
SC_SEE_OTHER : constant Natural := 303;
SC_NOT_MODIFIED : constant Natural := 304;
SC_USE_PROXY : constant Natural := 305;
SC_TEMPORARY_REDIRECT : constant Natural := 307;
SC_BAD_REQUEST : constant Natural := 400;
SC_UNAUTHORIZED : constant Natural := 401;
SC_PAYMENT_REQUIRED : constant Natural := 402;
SC_FORBIDDEN : constant Natural := 403;
SC_NOT_FOUND : constant Natural := 404;
SC_METHOD_NOT_ALLOWED : constant Natural := 405;
SC_NOT_ACCEPTABLE : constant Natural := 406;
SC_PROXY_AUTHENTICATION_REQUIRED : constant Natural := 407;
SC_REQUEST_TIMEOUT : constant Natural := 408;
SC_CONFLICT : constant Natural := 409;
SC_GONE : constant Natural := 410;
SC_LENGTH_REQUIRED : constant Natural := 411;
SC_PRECONDITION_FAILED : constant Natural := 412;
SC_REQUEST_ENTITY_TOO_LARGE : constant Natural := 413;
SC_REQUEST_URI_TOO_LONG : constant Natural := 414;
SC_UNSUPPORTED_MEDIA_TYPE : constant Natural := 415;
SC_REQUESTED_RANGE_NOT_SATISFIABLE : constant Natural := 416;
SC_EXPECTATION_FAILED : constant Natural := 417;
SC_INTERNAL_SERVER_ERROR : constant Natural := 500;
SC_NOT_IMPLEMENTED : constant Natural := 501;
SC_BAD_GATEWAY : constant Natural := 502;
SC_SERVICE_UNAVAILABLE : constant Natural := 503;
SC_GATEWAY_TIMEOUT : constant Natural := 504;
SC_HTTP_VERSION_NOT_SUPPORTED : constant Natural := 505;
-- ------------------------------
-- Abstract Message
-- ------------------------------
-- The <b>Abstract_Message</b> interface describe an HTTP message representing either
-- a request or a response.
type Abstract_Message is limited interface;
-- Returns a boolean indicating whether the named message header has already
-- been set.
function Contains_Header (Message : in Abstract_Message;
Name : in String) return Boolean is abstract;
-- Returns the value of the specified message header as a String. If the message
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any message header.
function Get_Header (Message : in Abstract_Message;
Name : in String) return String is abstract;
-- Sets a message header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
procedure Set_Header (Message : in out Abstract_Message;
Name : in String;
Value : in String) is abstract;
-- Adds a request header with the given name and value.
-- This method allows request headers to have multiple values.
procedure Add_Header (Message : in out Abstract_Message;
Name : in String;
Value : in String) is abstract;
-- Iterate over the message headers and executes the <b>Process</b> procedure.
procedure Iterate_Headers (Message : in Abstract_Message;
Process : not null access
procedure (Name : in String;
Value : in String)) is abstract;
-- Sets a header with the given name and date-value.
-- The date is specified in terms of milliseconds since the epoch.
-- If the header had already been set, the new value overwrites the previous one.
-- The containsHeader method can be used to test for the presence of a header
-- before setting its value.
procedure Set_Date_Header (Request : in out Abstract_Message'Class;
Name : in String;
Date : in Ada.Calendar.Time);
-- Adds a header with the given name and date-value. The date is specified
-- in terms of milliseconds since the epoch. This method allows response headers
-- to have multiple values.
procedure Add_Date_Header (Request : in out Abstract_Message'Class;
Name : in String;
Date : in Ada.Calendar.Time);
-- Sets a header with the given name and integer value.
-- If the header had already been set, the new value overwrites the previous one.
-- The containsHeader method can be used to test for the presence of a header
-- before setting its value.
procedure Set_Int_Header (Request : in out Abstract_Message'Class;
Name : in String;
Value : in Integer);
-- Adds a header with the given name and integer value. This method
-- allows headers to have multiple values.
procedure Add_Int_Header (Request : in out Abstract_Message'Class;
Name : in String;
Value : in Integer);
-- ------------------------------
-- Abstract Request
-- ------------------------------
type Abstract_Request is limited interface and Abstract_Message;
type Abstract_Request_Access is access all Abstract_Request'Class;
-- ------------------------------
-- Abstract Response
-- ------------------------------
type Abstract_Response is limited interface and Abstract_Message;
type Abstract_Response_Access is access all Abstract_Response'Class;
-- Get the response status code.
function Get_Status (Response : in Abstract_Response) return Natural is abstract;
-- Get the response body as a string.
function Get_Body (Response : in Abstract_Response) return String is abstract;
end Util.Http;
|
zhmu/ananas | Ada | 2,890 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B C H E C K --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, 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- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package Bcheck is
-- This package contains the routines to perform binder consistency checks
procedure Check_Duplicated_Subunits;
-- Check that no subunit names duplicate names of other packages in
-- the partition (check required by RM 10.2(19)).
procedure Check_Versions;
-- Check correct library and standard versions used
procedure Check_Consistency;
-- This procedure performs checks that the ALI files are consistent
-- with the corresponding source files and with one another. At the
-- time this is called, the Source table has been completely built and
-- contains either the time stamp from the actual source file if the
-- Check_Source_Files mode is set, or the latest stamp found in any of
-- the ALI files in the program.
procedure Check_Configuration_Consistency;
-- This procedure performs a similar check that configuration pragma
-- set items that are required to be consistent are in fact consistent
end Bcheck;
|
aherd2985/Amass | Ada | 2,187 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "ReconDev"
type = "api"
function start()
setratelimit(5)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
local resp
local u = buildurl(domain, c.key)
-- Check if the response data is in the graph database
if (cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(domain, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request(ctx, {
url=u,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
log(ctx, err .. ": " .. resp)
return
end
if (cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(domain, resp)
end
end
local data = json.decode(resp)
if (data == nil or #data == 0) then
return
end
for i, set in pairs(data) do
local domains = set["rawDomains"]
if domains ~= nil and #domains > 0 then
for j, name in pairs(domains) do
sendnames(ctx, name)
end
end
local addrs = set["rawIp"]
if addr ~= nil then
newaddr(ctx, domain, addr)
end
end
end
function buildurl(domain, key)
return "https://recon.dev/api/search?key=" .. key .. "&domain=" .. domain
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
local found = {}
for i, v in pairs(names) do
if found[v] == nil then
newname(ctx, v)
found[v] = true
end
end
end
|
BrickBot/Bound-T-H8-300 | Ada | 2,623 | ads | -- Storage.Data.Opt (decl)
--
-- Command-line options for the Storage.Data package.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.3 $
-- $Date: 2015/10/24 19:36:52 $
--
-- $Log: storage-data-opt.ads,v $
-- Revision 1.3 2015/10/24 19:36:52 niklas
-- Moved to free licence.
--
-- Revision 1.2 2011-08-31 04:23:34 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.1 2007/08/25 18:29:59 niklas
-- First version.
--
with Options.Bool;
package Storage.Data.Opt is
pragma Elaborate_Body;
--
-- To register the options.
Trace_Space_Ops_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the storage and retrieval of data-states
-- in spaces of such states.
--
Trace_Space_Ops : Boolean renames Trace_Space_Ops_Opt.Value;
end Storage.Data.Opt;
|
sungyeon/drake | Ada | 14,168 | adb | with Ada.Exceptions.Finally;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Ada.Unchecked_Reallocation;
with System.Growth;
package body Ada.Environment_Encoding.Generic_Strings is
pragma Check_Policy (Validate => Ignore);
use type Streams.Stream_Element_Offset;
pragma Compile_Time_Error (
String_Type'Component_Size /= Character_Type'Size,
"String_Type is not packed");
pragma Compile_Time_Error (
Character_Type'Size rem Streams.Stream_Element'Size /= 0,
"String_Type could not be treated as Stream_Element_Array");
function Current_Id return Encoding_Id;
function Current_Id return Encoding_Id is
begin
if Character_Type'Size = 8 then
return UTF_8;
elsif Character_Type'Size = 16 then
return UTF_16;
elsif Character_Type'Size = 32 then
return UTF_32;
else
raise Program_Error; -- bad instance
end if;
end Current_Id;
type String_Type_Access is access String_Type;
procedure Free is
new Unchecked_Deallocation (
String_Type,
String_Type_Access);
procedure Reallocate is
new Unchecked_Reallocation (
Positive,
Character_Type,
String_Type,
String_Type_Access);
type Stream_Element_Array_Access is access Streams.Stream_Element_Array;
procedure Free is
new Unchecked_Deallocation (
Streams.Stream_Element_Array,
Stream_Element_Array_Access);
procedure Reallocate is
new Unchecked_Reallocation (
Streams.Stream_Element_Offset,
Streams.Stream_Element,
Streams.Stream_Element_Array,
Stream_Element_Array_Access);
Minimal_Size : constant := 8;
-- implementation of decoder
function From (Id : Encoding_Id) return Decoder is
-- [gcc-7] strange error if extended return is placed outside of
-- the package Controlled, and Disable_Controlled => True
type T1 is access function (From, To : Encoding_Id) return Converter;
type T2 is access function (From, To : Encoding_Id) return Decoder;
function Cast is new Unchecked_Conversion (T1, T2);
begin
return Cast (Controlled.Open'Access) (From => Id, To => Current_Id);
end From;
procedure Decode (
Object : Decoder;
Item : Streams.Stream_Element_Array;
Last : out Streams.Stream_Element_Offset;
Out_Item : out String_Type;
Out_Last : out Natural;
Finish : Boolean;
Status : out Subsequence_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Out_Item_As_SEA :
Streams.Stream_Element_Array (1 .. Out_Item'Length * CS_In_SE);
for Out_Item_As_SEA'Address use Out_Item'Address;
Out_Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (
Object,
Item,
Last,
Out_Item_As_SEA,
Out_Item_SEA_Last,
Finish,
Status);
pragma Check (Validate, Out_Item_SEA_Last rem CS_In_SE = 0);
Out_Last := Out_Item'First + Integer (Out_Item_SEA_Last / CS_In_SE - 1);
end Decode;
procedure Decode (
Object : Decoder;
Item : Streams.Stream_Element_Array;
Last : out Streams.Stream_Element_Offset;
Out_Item : out String_Type;
Out_Last : out Natural;
Status : out Continuing_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Out_Item_As_SEA :
Streams.Stream_Element_Array (1 .. Out_Item'Length * CS_In_SE);
for Out_Item_As_SEA'Address use Out_Item'Address;
Out_Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (Object, Item, Last, Out_Item_As_SEA, Out_Item_SEA_Last, Status);
pragma Check (Validate, Out_Item_SEA_Last rem CS_In_SE = 0);
Out_Last := Out_Item'First + Integer (Out_Item_SEA_Last / CS_In_SE - 1);
end Decode;
procedure Decode (
Object : Decoder;
Out_Item : out String_Type;
Out_Last : out Natural;
Finish : True_Only;
Status : out Finishing_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Out_Item_As_SEA :
Streams.Stream_Element_Array (1 .. Out_Item'Length * CS_In_SE);
for Out_Item_As_SEA'Address use Out_Item'Address;
Out_Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (Object, Out_Item_As_SEA, Out_Item_SEA_Last, Finish, Status);
pragma Check (Validate, Out_Item_SEA_Last rem CS_In_SE = 0);
Out_Last := Out_Item'First + Integer (Out_Item_SEA_Last / CS_In_SE - 1);
end Decode;
procedure Decode (
Object : Decoder;
Item : Streams.Stream_Element_Array;
Last : out Streams.Stream_Element_Offset;
Out_Item : out String_Type;
Out_Last : out Natural;
Finish : True_Only;
Status : out Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Out_Item_As_SEA :
Streams.Stream_Element_Array (1 .. Out_Item'Length * CS_In_SE);
for Out_Item_As_SEA'Address use Out_Item'Address;
Out_Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (
Object,
Item,
Last,
Out_Item_As_SEA,
Out_Item_SEA_Last,
Finish,
Status);
pragma Check (Validate, Out_Item_SEA_Last rem CS_In_SE = 0);
Out_Last := Out_Item'First + Integer (Out_Item_SEA_Last / CS_In_SE - 1);
end Decode;
procedure Decode (
Object : Decoder;
Item : Streams.Stream_Element_Array;
Last : out Streams.Stream_Element_Offset;
Out_Item : out String_Type;
Out_Last : out Natural;
Finish : True_Only;
Status : out Substituting_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Out_Item_As_SEA :
Streams.Stream_Element_Array (1 .. Out_Item'Length * CS_In_SE);
for Out_Item_As_SEA'Address use Out_Item'Address;
Out_Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (
Object,
Item,
Last,
Out_Item_As_SEA,
Out_Item_SEA_Last,
Finish,
Status);
pragma Check (Validate, Out_Item_SEA_Last rem CS_In_SE = 0);
Out_Last := Out_Item'First + Integer (Out_Item_SEA_Last / CS_In_SE - 1);
end Decode;
function Decode (
Object : Decoder;
Item : Streams.Stream_Element_Array)
return String_Type
is
package Holder is
new Exceptions.Finally.Scoped_Holder (String_Type_Access, Free);
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
MS_In_SE : constant Streams.Stream_Element_Positive_Count :=
Min_Size_In_From_Stream_Elements (Object);
I : Streams.Stream_Element_Offset := Item'First;
Out_Item : aliased String_Type_Access;
Out_Last : Natural;
begin
Holder.Assign (Out_Item);
Out_Item := new String_Type (
1 ..
Natural (
Streams.Stream_Element_Count'Max (
2 * ((Item'Length + MS_In_SE - 1) / MS_In_SE),
Minimal_Size / CS_In_SE)));
Out_Last := 0;
loop
declare
Last : Streams.Stream_Element_Offset;
Status : Substituting_Status_Type;
begin
Decode (
Object,
Item (I .. Item'Last),
Last,
Out_Item.all (Out_Last + 1 .. Out_Item'Last),
Out_Last,
Finish => True,
Status => Status);
case Status is
when Finished =>
exit;
when Success =>
null;
when Overflow =>
declare
function Grow is new System.Growth.Fast_Grow (Natural);
begin
Reallocate (Out_Item, 1, Grow (Out_Item'Last));
end;
end case;
I := Last + 1;
end;
end loop;
return Out_Item (Out_Item'First .. Out_Last);
end Decode;
-- implementation of encoder
function To (Id : Encoding_Id) return Encoder is
-- [gcc-7] strange error if extended return is placed outside of
-- the package Controlled, and Disable_Controlled => True
type T1 is access function (From, To : Encoding_Id) return Converter;
type T2 is access function (From, To : Encoding_Id) return Encoder;
function Cast is new Unchecked_Conversion (T1, T2);
begin
return Cast (Controlled.Open'Access) (From => Current_Id, To => Id);
end To;
procedure Encode (
Object : Encoder;
Item : String_Type;
Last : out Natural;
Out_Item : out Streams.Stream_Element_Array;
Out_Last : out Streams.Stream_Element_Offset;
Finish : Boolean;
Status : out Subsequence_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Item_As_SEA : Streams.Stream_Element_Array (1 .. Item'Length * CS_In_SE);
for Item_As_SEA'Address use Item'Address;
Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (
Object,
Item_As_SEA,
Item_SEA_Last,
Out_Item,
Out_Last,
Finish,
Status);
pragma Check (Validate, Item_SEA_Last rem CS_In_SE = 0);
Last := Item'First + Integer (Item_SEA_Last / CS_In_SE - 1);
end Encode;
procedure Encode (
Object : Encoder;
Item : String_Type;
Last : out Natural;
Out_Item : out Streams.Stream_Element_Array;
Out_Last : out Streams.Stream_Element_Offset;
Status : out Continuing_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Item_As_SEA : Streams.Stream_Element_Array (1 .. Item'Length * CS_In_SE);
for Item_As_SEA'Address use Item'Address;
Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (Object, Item_As_SEA, Item_SEA_Last, Out_Item, Out_Last, Status);
pragma Check (Validate, Item_SEA_Last rem CS_In_SE = 0);
Last := Item'First + Integer (Item_SEA_Last / CS_In_SE - 1);
end Encode;
procedure Encode (
Object : Encoder;
Item : String_Type;
Last : out Natural;
Out_Item : out Streams.Stream_Element_Array;
Out_Last : out Streams.Stream_Element_Offset;
Finish : True_Only;
Status : out Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Item_As_SEA : Streams.Stream_Element_Array (1 .. Item'Length * CS_In_SE);
for Item_As_SEA'Address use Item'Address;
Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (
Object,
Item_As_SEA,
Item_SEA_Last,
Out_Item,
Out_Last,
Finish,
Status);
pragma Check (Validate, Item_SEA_Last rem CS_In_SE = 0);
Last := Item'First + Integer (Item_SEA_Last / CS_In_SE - 1);
end Encode;
procedure Encode (
Object : Encoder;
Item : String_Type;
Last : out Natural;
Out_Item : out Streams.Stream_Element_Array;
Out_Last : out Streams.Stream_Element_Offset;
Finish : True_Only;
Status : out Substituting_Status_Type)
is
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
Item_As_SEA : Streams.Stream_Element_Array (1 .. Item'Length * CS_In_SE);
for Item_As_SEA'Address use Item'Address;
Item_SEA_Last : Streams.Stream_Element_Offset;
begin
Convert (
Object,
Item_As_SEA,
Item_SEA_Last,
Out_Item,
Out_Last,
Finish,
Status);
pragma Check (Validate, Item_SEA_Last rem CS_In_SE = 0);
Last := Item'First + Integer (Item_SEA_Last / CS_In_SE - 1);
end Encode;
function Encode (
Object : Encoder;
Item : String_Type)
return Streams.Stream_Element_Array
is
package Holder is
new Exceptions.Finally.Scoped_Holder (
Stream_Element_Array_Access,
Free);
CS_In_SE : constant Streams.Stream_Element_Count :=
Character_Type'Size / Streams.Stream_Element'Size;
I : Positive := Item'First;
Out_Item : aliased Stream_Element_Array_Access;
Out_Last : Streams.Stream_Element_Offset;
begin
Holder.Assign (Out_Item);
Out_Item := new Streams.Stream_Element_Array (
0 ..
Streams.Stream_Element_Offset'Max (
2 * Item'Length * CS_In_SE,
Minimal_Size)
- 1);
Out_Last := -1;
loop
declare
Last : Natural;
Status : Substituting_Status_Type;
begin
Encode (
Object,
Item (I .. Item'Last),
Last,
Out_Item.all (Out_Last + 1 .. Out_Item'Last),
Out_Last,
Finish => True,
Status => Status);
case Status is
when Finished =>
exit;
when Success =>
null;
when Overflow =>
declare
function Grow is
new System.Growth.Fast_Grow (
Streams.Stream_Element_Count);
begin
Reallocate (Out_Item, 1, Grow (Out_Item'Last));
end;
end case;
I := Last + 1;
end;
end loop;
return Out_Item (Out_Item'First .. Out_Last);
end Encode;
end Ada.Environment_Encoding.Generic_Strings;
|
jrcarter/Ada_GUI | Ada | 44,672 | adb | -- An Ada-oriented GUI library
-- Implementation derived from Gnoga
--
-- Copyright (C) 2023 by PragmAda Software Engineering
--
-- Released under the terms of the 3-Clause BSD License. See https://opensource.org/licenses/BSD-3-Clause
with Ada.Containers.Vectors;
with Ada.Exceptions;
with Ada.Numerics.Elementary_Functions;
with Ada.Real_Time;
with Ada.Strings.Fixed;
with Ada_GUI.Gnoga.Application;
with Ada_GUI.Gnoga.Gui.Element.Canvas.Context_2D;
with Ada_GUI.Gnoga.Gui.Element.Common;
with Ada_GUI.Gnoga.Gui.Element.Form;
with Ada_GUI.Gnoga.Gui.Element.Multimedia;
with Ada_GUI.Gnoga.Gui.View.Console;
with Ada_GUI.Gnoga.Gui.View.Grid;
with Ada_GUI.Gnoga.Gui.Window;
with Ada_GUI.Gnoga.Colors;
package body Ada_GUI is
type Form_Set is array (Positive range <>, Positive range <>) of Gnoga.Gui.Element.Form.Form_Type;
type Form_Ptr is access Form_Set; -- Extensive use of access due to nature of Gnoga
package Column_Maps is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Boolean);
package Row_Maps is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => Column_Maps.Vector, "=" => Column_Maps."=");
Window : Gnoga.Gui.Window.Window_Type;
View : Gnoga.Gui.View.Console.Console_View_Type;
Grid : Gnoga.Gui.View.Grid.Grid_View_Type;
Form : Form_Ptr;
Valid : Row_Maps.Vector; -- Valid (Row) (Column) is True if (Row, Column) is an Area
Setup : Boolean := False with Atomic;
function Set_Up return Boolean is (Setup);
function Converted (Alignment : Alignment_ID) return Gnoga.Gui.Element.Alignment_Type is
(case Alignment is
when Left => Gnoga.Gui.Element.Left,
when Center => Gnoga.Gui.Element.Center,
when Right => Gnoga.Gui.Element.Right);
procedure Set_Up (Grid : in Grid_Set := (1 => (1 => (others => <>) ) );
ID : in Positive := 8080;
Title : in String := "Ada-GUI Application";
Icon : in String := "favicon.ico")
is
G_Grid : Gnoga.Gui.View.Grid.Grid_Rows_Type (Grid'Range (1), Grid'Range (2) );
begin -- Set_Up
Fill_Grid : for Row in Grid'Range (1) loop
Valid.Append (New_Item => Column_Maps.Empty_Vector);
Grid_Cols : for Column in Grid'Range (2) loop
G_Grid (Row, Column) := (if Grid (Row, Column).Kind = Area then Gnoga.Gui.View.Grid.COL else Gnoga.Gui.View.Grid.SPN);
Valid (Row).Append (New_Item => Grid (Row, Column).Kind = Area);
end loop Grid_Cols;
end loop Fill_Grid;
Gnoga.Application.Initialize (Main_Window => Window, ID => ID, Title => Title, Icon => Icon);
View.Create (Parent => Window);
Ada_GUI.Grid.Create (Parent => View, Layout => G_Grid);
Form := new Form_Set (Grid'Range (1), Grid'Range (2) );
All_Rows : for I in Form'Range (1) loop
All_Columns : for J in Form'Range (2) loop
if Grid (I, J).Kind = Area then
Form (I, J).Create (Parent => Ada_GUI.Grid.Panel (I, J).all);
Form (I, J).Text_Alignment (Value => Converted (Grid (I, J).Alignment) );
end if;
end loop All_Columns;
end loop All_Rows;
Setup := True;
end Set_Up;
function Window_Height return Positive is (Window.Inner_Height);
function Window_Width return Positive is (Window.Inner_Width);
type Radio_Info is record
Button : Gnoga.Gui.Element.Form.Radio_Button_Type;
Label : Gnoga.Gui.Element.Form.Label_Type;
end record;
type Radio_List is array (Positive range <>) of Radio_Info;
type Radio_Ptr is access Radio_List;
type Widget_Info (Kind : Widget_Kind_ID := Button) is record
case Kind is
when Audio_Player =>
Audio : Gnoga.Gui.Element.Multimedia.Audio_Access;
when Background_Text =>
Background : Gnoga.Gui.Element.Common.Span_Access;
when Button =>
Switch : Gnoga.Gui.Element.Common.Button_Access;
when Check_Box =>
Check : Gnoga.Gui.Element.Form.Check_Box_Access;
Check_Label : Gnoga.Gui.Element.Form.Label_Access;
when Graphic_Area =>
Canvas : Gnoga.Gui.Element.Canvas.Canvas_Access;
Width : Positive;
Height : Positive;
when Password_Box =>
Password : Gnoga.Gui.Element.Form.Password_Access;
Password_Label : Gnoga.Gui.Element.Form.Label_Access;
when Progress_Bar =>
Progress : Gnoga.Gui.Element.Common.Progress_Bar_Access;
when Radio_Buttons =>
Radio : Radio_Ptr;
when Selection_List =>
Selector : Gnoga.Gui.Element.Form.Selection_Access;
Multi : Boolean;
when Text_Area =>
Area : Gnoga.Gui.Element.Form.Text_Area_Access;
when Text_Box =>
Box : Gnoga.Gui.Element.Form.Text_Access;
Box_Label : Gnoga.Gui.Element.Form.Label_Access;
end case;
end record;
package Widget_Lists is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Widget_Info);
Widget_List : Widget_Lists.Vector;
function Kind (ID : Widget_ID) return Widget_Kind_ID is (Widget_List.Element (ID.Value).Kind);
function Adjusted (Row : in Positive; Column : in Positive) return Positive;
-- If (Row, Column) is an Extension, reduces Column until (Row, Column) is an Area
procedure Break (Desired : in Boolean; Row : in Positive; Column : in Positive);
-- If Desired, make the next thing declared in Form (Row, Column) appear below existing things there
function Adjusted (Row : in Positive; Column : in Positive) return Positive is
begin -- Adjusted
Find : for C in reverse 1 .. Column loop
if Valid (Row) (C) then
return C;
end if;
end loop Find;
raise Program_Error;
end Adjusted;
procedure Break (Desired : in Boolean; Row : in Positive; Column : in Positive) is
-- Empty
begin -- Break
if Desired then
Form (Row, Column).New_Line;
end if;
end Break;
function New_Audio_Player (Row : Positive := 1;
Column : Positive := 1;
Break_Before : Boolean := False;
Source : String := "";
Controls : Boolean := True)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Audio_Player);
begin -- New_Audio_Player
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Audio := new Gnoga.Gui.Element.Multimedia.Audio_Type;
Widget.Audio.Create (Parent => Form (Row, Adjusted (Row, Column) ),
Source => Source,
Controls => Controls,
Preload => True,
ID => ID.Value'Image);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Audio_Player;
function New_Background_Text (Row : Positive := 1; Column : Positive := 1; Text : String := ""; Break_Before : Boolean := False)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Background_Text);
begin -- New_Background_Text
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Background := new Gnoga.Gui.Element.Common.Span_Type;
Widget.Background.Create (Parent => Form (Row, Adjusted (Row, Column) ), Content => Text, ID => ID.Value'Image);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Background_Text;
function New_Button (Row : Positive := 1; Column : Positive := 1; Text : String := ""; Break_Before : Boolean := False)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Button);
begin -- New_Button
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Switch := new Gnoga.Gui.Element.Common.Button_Type;
Widget.Switch.Create (Parent => Form (Row, Adjusted (Row, Column) ), Content => Text, ID => ID.Value'Image);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Button;
function New_Check_Box (Row : Positive := 1;
Column : Positive := 1;
Label : String := "";
Break_Before : Boolean := False;
Active : Boolean := False)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Check_Box);
begin -- New_Check_Box
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Check := new Gnoga.Gui.Element.Form.Check_Box_Type;
Widget.Check.Create (Form => Form (Row, Adjusted (Row, Column) ), ID => ID.Value'Image);
Widget.Check.Checked (Value => Active);
Widget.Check_Label := new Gnoga.Gui.Element.Form.Label_Type;
Widget.Check_Label.Create
(Form => Form (Row, Adjusted (Row, Column) ), Label_For => Widget.Check.all, Content => Label, Auto_Place => False);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Check_Box;
function New_Graphic_Area
(Row : Positive := 1; Column : Positive := 1; Width : Positive; Height : Positive; Break_Before : Boolean := False)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Graphic_Area);
begin -- New_Graphic_Area
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Canvas := new Gnoga.Gui.Element.Canvas.Canvas_Type;
Widget.Canvas.Create (Parent => Form (Row, Adjusted (Row, Column) ), Width => Width, Height => Height, ID => ID.Value'Image);
Widget.Width := Width;
Widget.Height := Height;
Widget_List.Append (New_Item => Widget);
return ID;
end New_Graphic_Area;
function New_Password_Box (Row : Positive := 1;
Column : Positive := 1;
Text : String := "";
Break_Before : Boolean := False;
Label : String := "";
Width : Positive := 20)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Password_Box);
begin -- New_Password_Box
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Password := new Gnoga.Gui.Element.Form.Password_Type;
Widget.Password.Create (Form => Form (Row, Adjusted (Row, Column) ), Size => Width, Value => Text, ID => ID.Value'Image);
Widget.Password_Label := new Gnoga.Gui.Element.Form.Label_Type;
Widget.Password_Label.Create
(Form => Form (Row, Adjusted (Row, Column) ), Label_For => Widget.Password.all, Content => Label);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Password_Box;
function New_Progress_Bar (Row : Positive := 1;
Column : Positive := 1;
Value : Natural := 0;
Maximum : Natural := 100;
Break_Before : Boolean := False)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Progress_Bar);
begin -- New_Progress_Bar
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Progress := new Gnoga.Gui.Element.Common.Progress_Bar_Type;
Widget.Progress.Create (Parent => Form (Row, Adjusted (Row, Column) ), Value => Value, Maximum => Maximum);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Progress_Bar;
use Ada.Strings.Unbounded;
Next_Button : Positive := 1;
function New_Radio_Buttons (Row : Positive := 1;
Column : Positive := 1;
Label : Text_List;
Break_Before : Boolean := False;
Orientation : Orientation_ID := Vertical)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Radio_Buttons);
Name : String := Next_Button'Image;
begin -- New_Radio_Buttons
Name (Name'First) := 'R';
Next_Button := Next_Button + 1;
Widget.Radio := new Radio_List (Label'Range);
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
All_Buttons : for I in Label'Range loop
Widget.Radio (I).Button.Create (Form => Form (Row, Adjusted (Row, Column) ),
Checked => I = Label'First,
Name => Name,
ID => I'Image & 'R' & ID.Value'Image);
Widget.Radio (I).Label.Create (Form => Form (Row, Adjusted (Row, Column) ),
Label_For => Widget.Radio (I).Button,
Content => To_String (Label (I) ),
Auto_Place => False);
if I < Label'Last and Orientation = Vertical then
Form (Row, Adjusted (Row, Column) ).New_Line;
end if;
end loop All_Buttons;
Widget_List.Append (New_Item => Widget);
return ID;
end New_Radio_Buttons;
function New_Selection_List (Row : Positive := 1;
Column : Positive := 1;
Text : Text_List := (1 .. 0 => <>);
Break_Before : Boolean := False;
Height : Positive := 1;
Multiple_Select : Boolean := False)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Selection_List);
begin -- New_Selection_List
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Selector := new Gnoga.Gui.Element.Form.Selection_Type;
Widget.Selector.Create (Form => Form (Row, Adjusted (Row, Column) ),
Multiple_Select => Multiple_Select,
Visible_Lines => Height,
ID => ID.Value'Image);
Widget.Multi := Multiple_Select;
Widget_List.Append (New_Item => Widget);
Add_Options : for I in Text'Range loop
Widget.Selector.Add_Option (Value => To_String (Text (I) ), Text => To_String (Text (I) ) );
end loop Add_Options;
return ID;
end New_Selection_List;
function New_Text_Area (Row : Positive := 1;
Column : Positive := 1;
Text : String := "";
Break_Before : Boolean := False;
Width : Positive := 20;
Height : Positive := 2)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Text_Area);
begin -- New_Text_Area
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Area := new Gnoga.Gui.Element.Form.Text_Area_Type;
Widget.Area.Create
(Form => Form (Row, Adjusted (Row, Column) ), Columns => Width, Rows => Height, Value => Text, ID => ID.Value'Image);
Widget_List.Append (New_Item => Widget);
return ID;
end New_Text_Area;
function New_Text_Box (Row : Positive := 1;
Column : Positive := 1;
Text : String := "";
Break_Before : Boolean := False;
Label : String := "";
Placeholder : String := "";
Width : Positive := 20)
return Widget_ID is
ID : constant Widget_ID := (Value => Widget_List.Last_Index + 1);
Widget : Widget_Info (Kind => Text_Box);
begin -- New_Text_Box
Break (Desired => Break_Before, Row => Row, Column => Adjusted (Row, Column) );
Widget.Box := new Gnoga.Gui.Element.Form.Text_Type;
Widget.Box.Create (Form => Form (Row, Adjusted (Row, Column) ), Size => Width, Value => Text, ID => ID.Value'Image);
Widget.Box_Label := new Gnoga.Gui.Element.Form.Label_Type;
Widget.Box_Label.Create (Form => Form (Row, Adjusted (Row, Column) ), Label_For => Widget.Box.all, Content => Label);
if Placeholder /= "" then
Widget.Box.Place_Holder (Value => Placeholder);
end if;
Widget_List.Append (New_Item => Widget);
return ID;
end New_Text_Box;
procedure Set_Title (Title : in String) is
-- Empty
begin -- Set_Title
Window.Document.Title (Value => Title);
end Set_Title;
procedure Show_Message_Box (Text : in String) is
-- Empty
begin -- Show_Message_Box
Window.Alert (Message => Text);
end Show_Message_Box;
protected Dialog_Control is -- Controls multiple calls to dialogs and calls to Next_Event while a call to a dialog is in progress
procedure Set_Ongoing (Value : in Boolean);
-- Makes Ongoing return Value
function Ongoing return Boolean;
-- Returns the last value passed to Set_Ongoing; False initially
entry Block;
-- Blocks the caller until not Ongoing
private -- Dialog_Control
In_Progress : Boolean := False;
end Dialog_Control;
function Next_Event (Timeout : Duration := Duration'Last) return Next_Result_Info is separate;
procedure Set_Hidden (ID : in Widget_ID; Hidden : in Boolean := True) is
Widget : Widget_Info renames Widget_List.Element (ID.Value);
begin -- Set_Hidden
case Widget.Kind is
when Audio_Player =>
Widget.Audio.Hidden (Value => Hidden);
when Background_Text =>
Widget.Background.Hidden (Value => Hidden);
when Button =>
Widget.Switch.Hidden (Value => Hidden);
when Check_Box =>
Widget.Check.Hidden (Value => Hidden);
Widget.Check_Label.Hidden (Value => Hidden);
when Graphic_Area =>
Widget.Canvas.Hidden (Value => Hidden);
when Password_Box =>
Widget.Password.Hidden (Value => Hidden);
Widget.Password_Label.Hidden (Value => Hidden);
when Progress_Bar =>
Widget.Progress.Hidden (Value => Hidden);
when Radio_Buttons =>
All_Buttons : for I in Widget.Radio'Range loop
Widget.Radio (I).Button.Hidden (Value => Hidden);
Widget.Radio (I).Label.Hidden (Value => Hidden);
end loop All_Buttons;
when Selection_List =>
Widget.Selector.Hidden (Value => Hidden);
when Text_Area =>
Widget.Area.Hidden (Value => Hidden);
when Text_Box =>
Widget.Box.Hidden (Value => Hidden);
Widget.Box_Label.Hidden (Value => Hidden);
end case;
end Set_Hidden;
procedure Set_Visibility (ID : in Widget_ID; Visible : in Boolean := True) is
Widget : Widget_Info renames Widget_List.Element (ID.Value);
begin -- Set_Visibility
case Widget.Kind is
when Audio_Player =>
Widget.Audio.Visible (Value => Visible);
when Background_Text =>
Widget.Background.Visible (Value => Visible);
when Button =>
Widget.Switch.Visible (Value => Visible);
when Check_Box =>
Widget.Check.Visible (Value => Visible);
Widget.Check_Label.Visible (Value => Visible);
when Graphic_Area =>
Widget.Canvas.Visible (Value => Visible);
when Password_Box =>
Widget.Password.Visible (Value => Visible);
Widget.Password_Label.Visible (Value => Visible);
when Progress_Bar =>
Widget.Progress.Visible (Value => Visible);
when Radio_Buttons =>
All_Buttons : for I in Widget.Radio'Range loop
Widget.Radio (I).Button.Visible (Value => Visible);
Widget.Radio (I).Label.Visible (Value => Visible);
end loop All_Buttons;
when Selection_List =>
Widget.Selector.Visible (Value => Visible);
when Text_Area =>
Widget.Area.Visible (Value => Visible);
when Text_Box =>
Widget.Box.Visible (Value => Visible);
Widget.Box_Label.Visible (Value => Visible);
end case;
end Set_Visibility;
procedure Log (Message : in String) renames Gnoga.Log;
package body Dialogs is separate;
protected body Dialog_Control is
procedure Set_Ongoing (Value : in Boolean) is
-- Empty
begin -- Set_Ongoing
In_Progress := Value;
end Set_Ongoing;
function Ongoing return Boolean is (In_Progress);
entry Block when not In_Progress is
-- Empty
begin -- Block
null;
end Block;
end Dialog_Control;
procedure Set_Source (ID : in Widget_ID; Source : in String) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Source
Widget.Audio.Media_Source (Source => Source);
end Set_Source;
function Source (ID : Widget_ID) return String is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Source
return Widget.Audio.Media_Source;
end Source;
function Ready (ID : Widget_ID) return Boolean is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Ready
return Widget.Audio.Ready_To_Play;
end Ready;
procedure Play (ID : in Widget_ID) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Play
Widget.Audio.Play;
end Play;
procedure Pause (ID : in Widget_ID) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Pause
Widget.Audio.Pause;
end Pause;
function Paused (ID : Widget_ID) return Boolean is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Paused
return Widget.Audio.Paused;
end Paused;
function Playback_Ended (ID : Widget_ID) return Boolean is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Playback_Ended
return Widget.Audio.Playback_Ended;
end Playback_Ended;
function Length (ID : Widget_ID) return Float is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Length
return Widget.Audio.Media_Duration;
end Length;
procedure Set_Position (ID : in Widget_ID; Position : in Float) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Position
Widget.Audio.Media_Position (Seconds => Position);
end Set_Position;
function Position (ID : Widget_ID) return Float is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Position
return Widget.Audio.Media_Position;
end Position;
procedure Set_Text (ID : in Widget_ID; Text : in String) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Text
case Widget.Kind is
when Background_Text =>
Widget.Background.Inner_HTML (Value => Text);
when Button =>
Widget.Switch.Inner_HTML (Value => Text);
when Password_Box =>
Widget.Password.Value (Value => Text);
when Text_Area =>
Widget.Area.Inner_HTML (Value => Text);
when Text_Box =>
Widget.Box.Value (Value => Text);
when others =>
raise Program_Error;
end case;
end Set_Text;
procedure Set_Text_Alignment (ID : in Widget_ID; Alignment : in Alignment_ID) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Text_Alignment
case Widget.Kind is
when Background_Text =>
Widget.Background.Text_Alignment (Value => Converted (Alignment) );
when Button =>
Widget.Switch.Text_Alignment (Value => Converted (Alignment) );
when Password_Box =>
Widget.Password.Text_Alignment (Value => Converted (Alignment) );
when Selection_List =>
Widget.Selector.Text_Alignment (Value => Converted (Alignment) );
when Text_Area =>
Widget.Area.Text_Alignment (Value => Converted (Alignment) );
when Text_Box =>
Widget.Box.Text_Alignment (Value => Converted (Alignment) );
when others =>
raise Program_Error;
end case;
end Set_Text_Alignment;
procedure Set_Text_Font_Kind (ID : in Widget_ID; Kind : in Font_Kind_ID) is
function Family return String is
(if Kind = Proportional then "sans-serif" else "monospace");
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Text_Font_Kind
case Widget.Kind is
when Background_Text =>
Widget.Background.Font (Family => Family);
when Button =>
Widget.Switch.Font (Family => Family);
when Password_Box =>
Widget.Password.Font (Family => Family);
when Selection_List =>
Widget.Selector.Font (Family => Family);
when Text_Area =>
Widget.Area.Font (Family => Family);
when Text_Box =>
Widget.Box.Font (Family => Family);
when others =>
raise Program_Error;
end case;
end Set_Text_Font_Kind;
procedure Set_Label (ID : in Widget_ID; Text : in String) is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Label
case Widget.Kind is
when Check_Box =>
Widget.Check_Label.Inner_HTML (Value => Text);
when Password_Box =>
Widget.Password_Label.Inner_HTML (Value => Text);
when Text_Box =>
Widget.Box_Label.Inner_HTML (Value => Text);
when others =>
raise Program_Error;
end case;
end Set_Label;
procedure Set_Read_Only (ID : in Widget_ID; Read_Only : in Boolean := True) is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Read_Only
case Widget.Kind is
when Text_Area =>
Widget.Area.Read_Only (Value => Read_Only);
when Text_Box =>
Widget.Box.Read_Only (Value => Read_Only);
when others =>
raise Program_Error;
end case;
end Set_Read_Only;
function Multiple_Select (ID : Widget_ID) return Boolean is (Widget_List.Element (ID.Value).Multi);
function Text (ID : Widget_ID) return String is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Text
case Widget.Kind is
when Background_Text =>
return Widget.Background.Text;
when Button =>
return Widget.Switch.Text;
when Password_Box =>
return Widget.Password.Value;
when Selection_List =>
return Widget.Selector.Value;
when Text_Area =>
return Widget.Area.Value;
when Text_Box =>
return Widget.Box.Value;
when others =>
raise Program_Error;
end case;
end Text;
procedure Set_Active (ID : in Widget_ID; Active : in Boolean) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Active
Widget.Check.Checked (Value => Active);
end Set_Active;
function Active (ID : Widget_ID) return Boolean is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Active
return Widget.Check.Checked;
end Active;
function AG_Color (Color : Gnoga.RGBA_Type) return Color_Info is
(Red => RGB_Value (Color.Red),
Green => RGB_Value (Color.Green),
Blue => RGB_Value (Color.Blue),
Alpha => Alpha_Value (Color.Alpha) );
function To_Color (Color : Color_ID) return Color_Info is
(AG_Color (Gnoga.Colors.To_RGBA (Gnoga.Colors.Color_Enumeration'Val (Color_ID'Pos (Color) ) ) ) );
function Gnoga_Color (Color : Color_Info) return Gnoga.RGBA_Type is
(Red => Gnoga.Color_Type (Color.Red),
Green => Gnoga.Color_Type (Color.Green),
Blue => Gnoga.Color_Type (Color.Blue),
Alpha => Gnoga.Alpha_Type (Color.Alpha) );
function To_ID (Color : Color_Info) return Color_ID is
(Color_ID'Val (Gnoga.Colors.Color_Enumeration'Pos (Gnoga.Colors.To_Color_Enumeration (Gnoga_Color (Color) ) ) ) );
function Gnoga_Pixel (Color : Color_Info) return Gnoga.Pixel_Type is
(Red => Gnoga.Color_Type (Color.Red),
Green => Gnoga.Color_Type (Color.Green),
Blue => Gnoga.Color_Type (Color.Blue),
Alpha => Gnoga.Color_Type (255.0 * Color.Alpha) );
procedure Set_Background_Color (Color : in Color_Info) is
-- Empty
begin -- Set_Background_Color
View.Background_Color (RGBA => Gnoga_Color (Color) );
All_Rows : for Row in Form'Range (1) loop
All_Columns : for Column in Form'Range (2) loop
if Valid (Row) (Column) then
Form (Row, Column).Background_Color (RGBA => Gnoga_Color (Color) );
end if;
end loop All_Columns;
end loop All_Rows;
end Set_Background_Color;
procedure Set_Background_Color (ID : Widget_ID; Color : in Color_Info := To_Color (Black) ) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Background_Color
case Widget.Kind is
when Audio_Player =>
Widget.Audio.Background_Color (RGBA => Gnoga_Color (Color) );
when Background_Text =>
Widget.Background.Background_Color (RGBA => Gnoga_Color (Color) );
when Button =>
Widget.Switch.Background_Color (RGBA => Gnoga_Color (Color) );
when Check_Box =>
Widget.Check.Background_Color (RGBA => Gnoga_Color (Color) );
Widget.Check_Label.Background_Color (RGBA => Gnoga_Color (Color) );
when Graphic_Area =>
Widget.Canvas.Background_Color (RGBA => Gnoga_Color (Color) );
when Password_Box =>
Widget.Password.Background_Color (RGBA => Gnoga_Color (Color) );
Widget.Password_Label.Background_Color (RGBA => Gnoga_Color (Color) );
when Progress_Bar =>
Widget.Progress.Background_Color (RGBA => Gnoga_Color (Color) );
when Radio_Buttons =>
All_Buttons : for I in Widget.Radio'Range loop
Widget.Radio (I).Button.Background_Color (RGBA => Gnoga_Color (Color) );
Widget.Radio (I).Label.Background_Color (RGBA => Gnoga_Color (Color) );
end loop All_Buttons;
when Selection_List =>
Widget.Selector.Background_Color (RGBA => Gnoga_Color (Color) );
when Text_Area =>
Widget.Area.Background_Color (RGBA => Gnoga_Color (Color) );
when Text_Box =>
Widget.Box.Background_Color (RGBA => Gnoga_Color (Color) );
Widget.Box_Label.Background_Color (RGBA => Gnoga_Color (Color) );
end case;
end Set_Background_Color;
procedure Set_Foreground_Color (ID : Widget_ID; Color : in Color_Info := To_Color (Black) ) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Foreground_Color
case Widget.Kind is
when Audio_Player =>
Widget.Audio.Color (RGBA => Gnoga_Color (Color) );
when Background_Text =>
Widget.Background.Color (RGBA => Gnoga_Color (Color) );
when Button =>
Widget.Switch.Color (RGBA => Gnoga_Color (Color) );
when Check_Box =>
Widget.Check.Color (RGBA => Gnoga_Color (Color) );
Widget.Check_Label.Color (RGBA => Gnoga_Color (Color) );
when Graphic_Area =>
Widget.Canvas.Color (RGBA => Gnoga_Color (Color) );
when Password_Box =>
Widget.Password.Color (RGBA => Gnoga_Color (Color) );
Widget.Password_Label.Color (RGBA => Gnoga_Color (Color) );
when Progress_Bar =>
Widget.Progress.Color (RGBA => Gnoga_Color (Color) );
when Radio_Buttons =>
All_Buttons : for I in Widget.Radio'Range loop
Widget.Radio (I).Button.Color (RGBA => Gnoga_Color (Color) );
Widget.Radio (I).Label.Color (RGBA => Gnoga_Color (Color) );
end loop All_Buttons;
when Selection_List =>
Widget.Selector.Color (RGBA => Gnoga_Color (Color) );
when Text_Area =>
Widget.Area.Color (RGBA => Gnoga_Color (Color) );
when Text_Box =>
Widget.Box.Color (RGBA => Gnoga_Color (Color) );
Widget.Box_Label.Color (RGBA => Gnoga_Color (Color) );
end case;
end Set_Foreground_Color;
procedure Set_Pixel (ID : in Widget_ID; X : in Integer; Y : in Integer; Color : in Color_Info := To_Color (Black) ) is
G_Color : constant Gnoga.Pixel_Type := Gnoga_Pixel (Color);
Widget : Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Set_Pixel
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
Context.Pixel (X => X, Y => Y, Color => G_Color);
end Set_Pixel;
function AG_Color (Color : Gnoga.Pixel_Type) return Color_Info is
(Red => RGB_Value (Color.Red),
Green => RGB_Value (Color.Green),
Blue => RGB_Value (Color.Blue),
Alpha => Float (Color.Alpha) / 255.0);
function Pixel (ID : Widget_ID; X : Integer; Y : Integer) return Color_Info is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
G_Color : Gnoga.Pixel_Type;
begin -- Pixel_Type
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
G_Color := Context.Pixel (X, Y);
return AG_Color (G_Color);
end Pixel;
procedure Draw_Line (ID : in Widget_ID;
From_X : in Integer;
From_Y : in Integer;
To_X : in Integer;
To_Y : in Integer;
Width : in Positive := 1;
Color : in Color_Info := To_Color (Black) )
is
G_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Color);
Widget : Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Draw_Line
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
Context.Stroke_Color (Value => G_Color);
Context.Line_Width (Value => Width);
Context.Begin_Path;
Context.Move_To (X => From_X, Y => From_Y);
Context.Line_To (X => To_X, Y => To_Y);
Context.Stroke;
end Draw_Line;
procedure Draw_Rectangle (ID : in Widget_ID;
From_X : in Integer;
From_Y : in Integer;
To_X : in Integer;
To_Y : in Integer;
Line_Color : in Optional_Color := (None => False, Color => To_Color (Black) );
Fill_Color : in Optional_Color := (None => True) )
is
Widget : Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Draw_Rectangle
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
Context.Line_Width (Value => 1);
Context.Begin_Path;
Context.Rectangle (Rectangle => (X => Integer'Min (From_X, To_X),
Y => Integer'Min (From_Y, To_Y),
Width => abs (From_X - To_X) + 1,
Height => abs (From_Y - To_Y) + 1) );
if not Fill_Color.None then
Convert_Fill : declare
F_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Fill_Color.Color);
begin -- Convert_Fill
Context.Fill_Color (Value => F_Color);
Context.Fill;
end Convert_Fill;
end if;
if not Line_Color.None then
Convert_Line : declare
L_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Line_Color.Color);
begin -- Convert_Line
Context.Stroke_Color (Value => L_Color);
Context.Stroke;
end Convert_Line;
end if;
end Draw_Rectangle;
procedure Draw_Arc (ID : in Widget_ID;
X : in Integer;
Y : in Integer;
Radius : in Positive;
Start : in Float;
Stop : in Float;
Counter_Clockwise : in Boolean := False;
Line_Color : in Optional_Color := (None => False, Color => To_Color (Black) );
Fill_Color : in Optional_Color := (None => True) )
is
Widget : Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Draw_Arc
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
Context.Line_Width (Value => 1);
Context.Begin_Path;
if not Fill_Color.None then
Context.Move_To (X => X, Y => Y);
Context.Line_To (X => X + Integer (Float (Radius) * Ada.Numerics.Elementary_Functions.Cos (Start) ),
Y => Y + Integer (Float (Radius) * Ada.Numerics.Elementary_Functions.Sin (Start) ) );
end if;
Context.Arc_Radians
(X => X, Y => Y, Radius => Radius, Starting_Angle => Start, Ending_Angle => Stop, Counter_Clockwise => Counter_Clockwise);
if not Fill_Color.None then
Convert_Fill : declare
F_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Fill_Color.Color);
begin -- Convert_Fill
Context.Close_Path;
Context.Fill_Color (Value => F_Color);
Context.Fill;
end Convert_Fill;
end if;
if not Line_Color.None then
Convert_Line : declare
L_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Line_Color.Color);
begin -- Convert_Line
Context.Stroke_Color (Value => L_Color);
Context.Stroke;
end Convert_Line;
end if;
end Draw_Arc;
procedure Draw_Text (ID : in Widget_ID;
X : in Integer;
Y : in Integer;
Text : in String;
Height : in Positive := 20;
Line_Color : in Optional_Color := (None => True);
Fill_Color : in Optional_Color := (None => False, Color => To_Color (Black) ) )
is
Widget : Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Draw_Text
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
Context.Font (Height => Height'Image & "px");
Context.Line_Width (Value => 1);
if not Fill_Color.None then
Convert_Fill : declare
F_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Fill_Color.Color);
begin -- Convert_Fill
Context.Fill_Color (Value => F_Color);
Context.Fill_Text (Text => Text, X => X, Y => Y);
end Convert_Fill;
end if;
if not Line_Color.None then
Convert_Line : declare
L_Color : constant Gnoga.RGBA_Type := Gnoga_Color (Line_Color.Color);
begin -- Convert_Line
Context.Stroke_Color (Value => L_Color);
Context.Stroke_Text (Text => Text, X => X, Y => Y);
end Convert_Line;
end if;
end Draw_Text;
procedure Replace_Pixels (ID : in Widget_ID; Image : in Widget_ID; X : in Integer; Y : in Integer) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Replace_Pixels
Context.Get_Drawing_Context_2D (Canvas => Widget.Canvas.all);
Context.Draw_Image (Image => Widget_List.Element (Image.Value).Canvas.all, X => X, Y => Y);
end Replace_Pixels;
function Maximum (ID : Widget_ID) return Natural is
(Widget_List.Element (ID.Value).Progress.Maximum);
function Value (ID : Widget_ID) return Natural is
(Widget_List.Element (ID.Value).Progress.Value);
procedure Set_Value (ID : in Widget_ID; Value : in Natural) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Value
Widget.Progress.Value (Value => Value);
end Set_Value;
procedure Set_Maximum (ID : in Widget_ID; Maximum : in Natural) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Maximum
Widget.Progress.Maximum (Value => Maximum);
end Set_Maximum;
function Num_Buttons (ID : Widget_ID) return Positive is
(Widget_List.Element (ID.Value).Radio'Length);
procedure Set_Active (ID : in Widget_ID; Index : in Positive; Active : in Boolean) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Active
Widget.Radio (Index).Button.Checked (Value => Active);
end Set_Active;
function Active (ID : Widget_ID; Index : Positive) return Boolean is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Active
return Widget.Radio (Index).Button.Checked;
end Active;
function Active (ID : Widget_ID) return Positive is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Active
Check : for I in Widget.Radio'Range loop
if Widget.Radio (I).Button.Checked then
return I;
end if;
end loop Check;
return Widget.Radio'Length + 1;
end Active;
procedure Set_Label (ID : in Widget_ID; Index : in Positive; Text : in String) is
Widget : constant Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Label
Widget.Radio (Index).Label.Inner_HTML (Value => Text);
end Set_Label;
function Length (ID : Widget_ID) return Natural is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Length
return Widget.Selector.Length;
end Length;
procedure Clear (ID : in Widget_ID) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Clear
Widget.Selector.Empty_Options;
end Clear;
procedure Set_Selected (ID : in Widget_ID; Index : in Positive; Selected : in Boolean := True) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Set_Selected
Widget.Selector.Selected (Index => Index, Value => Selected);
end Set_Selected;
function Selected (ID : Widget_ID) return Natural is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Selected
return Widget.Selector.Selected_Index;
end Selected;
function Selected (ID : Widget_ID; Index : Positive) return Boolean is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Selected
return Widget.Selector.Selected (Index);
end Selected;
function Text (ID : Widget_ID; Index : Positive) return String is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Text
return Widget.Selector.all.Value (Index);
end Text;
procedure Insert (ID : in Widget_ID; Text : in String; Before : in Positive := Integer'Last) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
Index : constant Natural := (if Before > Widget.Selector.Length then 0 else Before);
begin -- Insert
Widget.Selector.Add_Option (Value => Text, Text => Text, Index => Index);
end Insert;
procedure Delete (ID : in Widget_ID; Index : in Positive) is
Widget : Widget_Info := Widget_List.Element (ID.Value);
begin -- Delete
Widget.Selector.Remove_Option (Index => Index);
end Delete;
procedure End_GUI is
-- Empty
begin -- End_GUI
if not Setup then
Gnoga.Application.Initialize (Main_Window => Window);
end if;
Gnoga.Application.End_Application;
Setup := False;
end End_GUI;
package body Plotting is separate;
end Ada_Gui;
|
micahwelf/FLTK-Ada | Ada | 851 | ads |
package FLTK.Images.Bitmaps is
type Bitmap is new Image with private;
type Bitmap_Reference (Data : not null access Bitmap'Class) is limited null record
with Implicit_Dereference => Data;
function Copy
(This : in Bitmap;
Width, Height : in Natural)
return Bitmap'Class;
function Copy
(This : in Bitmap)
return Bitmap'Class;
procedure Draw
(This : in Bitmap;
X, Y : in Integer);
procedure Draw
(This : in Bitmap;
X, Y, W, H : in Integer;
CX, CY : in Integer := 0);
private
type Bitmap is new Image with null record;
overriding procedure Finalize
(This : in out Bitmap);
pragma Inline (Copy);
pragma Inline (Draw);
end FLTK.Images.Bitmaps;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.