content
stringlengths
23
1.05M
pragma Warnings (Off); with SDL_Framebuffer; use SDL_Framebuffer; procedure Compile is begin null; end Compile;
with Matriz, Ada.Text_IO, Ada.Integer_Text_IO; use Matriz, Ada.Text_IO, Ada.Integer_Text_IO; procedure escribir_matriz (M : in Matriz_de_Enteros) is begin for I in M'range(1) loop for J in M'range(2) loop Put(M(I,J),3); end loop; New_Line; end loop; end escribir_matriz;
----------------------------------------------------------------------- -- net-interfaces -- Network interface -- Copyright (C) 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Net.Buffers; -- === Network Interface === -- The <tt>Ifnet_Type</tt> represents the network interface driver that -- allows to receive or send packets. package Net.Interfaces is pragma Preelaborate; type Stats_Type is record Bytes : Uint64 := 0; Packets : Uint32 := 0; Dropped : Uint32 := 0; Ignored : Uint32 := 0; end record; type Ifnet_Type is abstract tagged limited record Mac : Ether_Addr := (0, 16#81#, 16#E1#, others => 0); Ip : Ip_Addr := (others => 0); Netmask : Ip_Addr := (255, 255, 255, 0); Gateway : Ip_Addr := (others => 0); Dns : Ip_Addr := (others => 0); Mtu : Ip_Length := 1500; Rx_Stats : Stats_Type; Tx_Stats : Stats_Type; end record; -- Initialize the network interface. procedure Initialize (Ifnet : in out Ifnet_Type) is abstract; -- Send a packet to the interface. procedure Send (Ifnet : in out Ifnet_Type; Buf : in out Net.Buffers.Buffer_Type) is abstract with Pre'Class => not Buf.Is_Null, Post'Class => Buf.Is_Null; -- Receive a packet from the interface. procedure Receive (Ifnet : in out Ifnet_Type; Buf : in out Net.Buffers.Buffer_Type) is abstract with Pre'Class => not Buf.Is_Null, Post'Class => not Buf.Is_Null; -- Check if the IP address is in the same subnet as the interface IP address. function Is_Local_Network (Ifnet : in Ifnet_Type; Ip : in Ip_Addr) return Boolean; end Net.Interfaces;
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY 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. pragma License (Modified_GPL); package body SAL.Gen_Unbounded_Definite_Vectors is function To_Peek_Type (Item : in Extended_Index) return Base_Peek_Type is begin return Base_Peek_Type'Base (Item - Index_Type'First) + Peek_Type'First; end To_Peek_Type; function To_Index_Type (Item : in Base_Peek_Type) return Extended_Index is begin return Extended_Index (Item - Peek_Type'First) + Index_Type'First; end To_Index_Type; procedure Grow (Elements : in out Array_Access; Index : in Base_Peek_Type) is -- Reallocate Elements so Elements (Index) is a valid element. Old_First : constant Peek_Type := Elements'First; Old_Last : constant Peek_Type := Elements'Last; New_First : Peek_Type := Old_First; New_Last : Peek_Type := Old_Last; New_Length : Peek_Type := Elements'Length; New_Array : Array_Access; begin loop exit when New_First <= Index; New_Length := New_Length * 2; New_First := Peek_Type'Max (Peek_Type'First, Old_Last - New_Length + 1); end loop; loop exit when New_Last >= Index; New_Length := New_Length * 2; New_Last := Peek_Type'Min (Peek_Type'Last, New_First + New_Length - 1); end loop; New_Array := new Array_Type (New_First .. New_Last); -- We'd like to use this: -- -- New_Array (New_First .. Old_First - 1) := (others => <>); -- -- but that can overflow the stack, since the aggregate is allocated -- on the stack. for I in New_First .. Old_First - 1 loop New_Array (I .. I) := (others => <>); end loop; New_Array (Old_First .. Old_Last) := Elements.all; for I in Old_Last + 1 .. New_Last loop New_Array (I .. I) := (others => <>); end loop; Free (Elements); Elements := New_Array; end Grow; ---------- -- public subprograms overriding procedure Finalize (Container : in out Vector) is begin Free (Container.Elements); Container.First := No_Index; Container.Last := No_Index; end Finalize; overriding procedure Adjust (Container : in out Vector) is begin if Container.Elements /= null then Container.Elements := new Array_Type'(Container.Elements.all); end if; end Adjust; function Length (Container : in Vector) return Ada.Containers.Count_Type is begin -- We assume the type ranges are sensible, so no exceptions occur -- here. if Container.Elements = null then return 0; else return Ada.Containers.Count_Type (To_Peek_Type (Container.Last) - Container.Elements'First + 1); end if; end Length; function Capacity (Container : in Vector) return Ada.Containers.Count_Type is begin if Container.Elements = null then return 0; else return Ada.Containers.Count_Type (Container.Elements'Length); end if; end Capacity; procedure Set_Capacity (Container : in out Vector; First : in Index_Type; Last : in Extended_Index) is First_Peek : constant Peek_Type := To_Peek_Type (First); Last_Peek : constant Peek_Type := To_Peek_Type (Last); begin if Container.Elements = null then Container.Elements := new Array_Type (First_Peek .. Last_Peek); else if First_Peek < Container.Elements'First then Grow (Container.Elements, First_Peek); end if; if Last_Peek < Container.Elements'Last then Grow (Container.Elements, Last_Peek); end if; end if; end Set_Capacity; function Element (Container : Vector; Index : Index_Type) return Element_Type is begin return Container.Elements (To_Peek_Type (Index)); end Element; procedure Replace_Element (Container : Vector; Index : Index_Type; New_Item : in Element_Type) is begin Container.Elements (To_Peek_Type (Index)) := New_Item; end Replace_Element; function First_Index (Container : Vector) return Extended_Index is begin if Container.First = No_Index then return No_Index + 1; else return Container.First; end if; end First_Index; function Last_Index (Container : Vector) return Extended_Index is begin return Container.Last; end Last_Index; procedure Append (Container : in out Vector; New_Item : in Element_Type) is begin if Container.First = No_Index then Container.First := Index_Type'First; Container.Last := Index_Type'First; else Container.Last := Container.Last + 1; end if; declare J : constant Base_Peek_Type := To_Peek_Type (Container.Last); begin if Container.Elements = null then Container.Elements := new Array_Type (J .. J); elsif J > Container.Elements'Last then Grow (Container.Elements, J); end if; Container.Elements (J) := New_Item; end; end Append; procedure Append (Container : in out Vector; New_Items : in Vector) is use all type Ada.Containers.Count_Type; Old_Last : Extended_Index := Container.Last; begin if New_Items.Length = 0 then return; end if; if Container.First = No_Index then Container.First := Index_Type'First; Old_Last := Container.First - 1; Container.Last := Container.First + Extended_Index (New_Items.Length) - 1; else Container.Last := Container.Last + Extended_Index (New_Items.Length); end if; declare I : constant Peek_Type := To_Peek_Type (Old_Last + 1); J : constant Peek_Type := To_Peek_Type (Container.Last); begin if Container.Elements = null then Container.Elements := new Array_Type (I .. J); elsif J > Container.Elements'Last then Grow (Container.Elements, J); end if; Container.Elements (I .. J) := New_Items.Elements (To_Peek_Type (New_Items.First) .. To_Peek_Type (New_Items.Last)); end; end Append; procedure Prepend (Container : in out Vector; New_Item : in Element_Type) is begin if Container.First = No_Index then Container.First := Index_Type'First; Container.Last := Index_Type'First; else Container.First := Container.First - 1; end if; declare J : constant Peek_Type := To_Peek_Type (Container.First); begin if Container.Elements = null then Container.Elements := new Array_Type (J .. J); elsif J < Container.Elements'First then Grow (Container.Elements, J); end if; Container.Elements (J) := New_Item; end; end Prepend; procedure Prepend (Target : in out Vector; Source : in Vector; Source_First : in Index_Type; Source_Last : in Index_Type) is Source_I : constant Peek_Type := To_Peek_Type (Source_First); Source_J : constant Peek_Type := To_Peek_Type (Source_Last); begin if Target.Elements = null then Target.Elements := new Array_Type'(Source.Elements (Source_I .. Source_J)); Target.First := Source_First; Target.Last := Source_Last; else declare New_First : constant Index_Type := Target.First - (Source_Last - Source_First + 1); I : constant Peek_Type := To_Peek_Type (New_First); J : constant Peek_Type := To_Peek_Type (Target.First - 1); begin if Target.Elements'First > I then Grow (Target.Elements, I); end if; Target.Elements (I .. J) := Source.Elements (Source_I .. Source_J); Target.First := New_First; end; end if; end Prepend; procedure Insert (Container : in out Vector; Element : in Element_Type; Before : in Index_Type) is use all type Ada.Containers.Count_Type; begin if Container.Length = 0 then Container.Append (Element); else Container.Last := Container.Last + 1; declare J : constant Peek_Type := To_Peek_Type (Before); K : constant Base_Peek_Type := To_Peek_Type (Container.Last); begin if K > Container.Elements'Last then Grow (Container.Elements, K); end if; Container.Elements (J + 1 .. K) := Container.Elements (J .. K - 1); Container.Elements (J) := Element; end; end if; end Insert; procedure Merge (Target : in out Vector; Source : in out Vector) is use all type Ada.Containers.Count_Type; begin if Source.Length = 0 then Source.Clear; elsif Target.Length = 0 then Target := Source; Source.Clear; else declare New_First : constant Index_Type := Extended_Index'Min (Target.First, Source.First); New_Last : constant Index_Type := Extended_Index'Max (Target.Last, Source.Last); New_I : constant Peek_Type := To_Peek_Type (New_First); New_J : constant Base_Peek_Type := To_Peek_Type (New_Last); begin if New_I < Target.Elements'First then Grow (Target.Elements, New_I); end if; if New_J > Target.Elements'Last then Grow (Target.Elements, New_J); end if; Target.Elements (To_Peek_Type (Source.First) .. To_Peek_Type (Source.Last)) := Source.Elements (To_Peek_Type (Source.First) .. To_Peek_Type (Source.Last)); Target.First := New_First; Target.Last := New_Last; Source.Clear; end; end if; end Merge; function To_Vector (Item : in Element_Type; Count : in Ada.Containers.Count_Type := 1) return Vector is begin return Result : Vector do for I in 1 .. Count loop Result.Append (Item); end loop; end return; end To_Vector; function "+" (Element : in Element_Type) return Vector is begin return Result : Vector do Result.Append (Element); end return; end "+"; function "&" (Left, Right : in Element_Type) return Vector is begin return Result : Vector do Result.Append (Left); Result.Append (Right); end return; end "&"; function "&" (Left : in Vector; Right : in Element_Type) return Vector is begin return Result : Vector := Left do Result.Append (Right); end return; end "&"; procedure Set_First (Container : in out Vector; First : in Index_Type) is J : constant Peek_Type := To_Peek_Type (First); begin Container.First := First; if Container.Last = No_Index then Container.Last := First - 1; end if; if Container.Last >= First then if Container.Elements = null then Container.Elements := new Array_Type'(J .. To_Peek_Type (Container.Last) => Default_Element); elsif Container.Elements'First > J then Grow (Container.Elements, J); end if; end if; end Set_First; procedure Set_Last (Container : in out Vector; Last : in Extended_Index) is J : constant Base_Peek_Type := To_Peek_Type (Last); begin Container.Last := Last; if Container.First = No_Index then Container.First := Last + 1; end if; if Last >= Container.First then if Container.Elements = null then Container.Elements := new Array_Type'(To_Peek_Type (Container.First) .. J => Default_Element); elsif Container.Elements'Last < J then Grow (Container.Elements, J); end if; end if; end Set_Last; procedure Set_First_Last (Container : in out Vector; First : in Index_Type; Last : in Extended_Index) is begin Set_First (Container, First); Set_Last (Container, Last); end Set_First_Last; procedure Delete (Container : in out Vector; Index : in Index_Type) is J : constant Peek_Type := To_Peek_Type (Index); begin Container.Elements (J .. J) := (J => <>); if Index = Container.Last then Container.Last := Container.Last - 1; end if; end Delete; function Contains (Container : in Vector; Element : in Element_Type) return Boolean is use all type Ada.Containers.Count_Type; begin if Container.Length = 0 then return False; else for It of Container.Elements.all loop if It = Element then return True; end if; end loop; return False; end if; end Contains; function Has_Element (Position : Cursor) return Boolean is begin return Position.Index /= Invalid_Peek_Index; end Has_Element; function Element (Position : Cursor) return Element_Type is begin return Position.Container.Elements (Position.Index); end Element; function First (Container : aliased in Vector) return Cursor is begin if Container.First = No_Index then return No_Element; else return (Container'Access, To_Peek_Type (Container.First)); end if; end First; function Next (Position : in Cursor) return Cursor is begin if Position = No_Element then return No_Element; elsif Position.Index < To_Peek_Type (Position.Container.Last) then return (Position.Container, Position.Index + 1); else return No_Element; end if; end Next; procedure Next (Position : in out Cursor) is begin if Position = No_Element then null; elsif Position.Index < To_Peek_Type (Position.Container.Last) then Position.Index := Position.Index + 1; else Position := No_Element; end if; end Next; function Prev (Position : in Cursor) return Cursor is begin if Position = No_Element then return No_Element; elsif Position.Index > To_Peek_Type (Position.Container.First) then return (Position.Container, Position.Index - 1); else return No_Element; end if; end Prev; procedure Prev (Position : in out Cursor) is begin if Position = No_Element then null; elsif Position.Index > To_Peek_Type (Position.Container.First) then Position.Index := Position.Index - 1; else Position := No_Element; end if; end Prev; function To_Cursor (Container : aliased in Vector; Index : in Extended_Index) return Cursor is begin if Index not in Container.First .. Container.Last then return No_Element; else return (Container'Access, To_Peek_Type (Index)); end if; end To_Cursor; function To_Index (Position : in Cursor) return Extended_Index is begin if Position = No_Element then return No_Index; else return To_Index_Type (Position.Index); end if; end To_Index; function Constant_Ref (Container : aliased Vector; Index : in Index_Type) return Constant_Reference_Type is J : constant Peek_Type := To_Peek_Type (Index); begin return (Element => Container.Elements (J)'Access, Dummy => 1); end Constant_Ref; function Variable_Ref (Container : aliased in Vector; Index : in Index_Type) return Variable_Reference_Type is J : constant Peek_Type := To_Peek_Type (Index); begin return (Element => Container.Elements (J)'Access, Dummy => 1); end Variable_Ref; overriding function First (Object : Iterator) return Cursor is begin if Object.Container.Elements = null then return (null, Invalid_Peek_Index); else return (Object.Container, To_Peek_Type (Object.Container.First)); end if; end First; overriding function Last (Object : Iterator) return Cursor is begin if Object.Container.Elements = null then return (null, Invalid_Peek_Index); else return (Object.Container, To_Peek_Type (Object.Container.Last)); end if; end Last; overriding function Next (Object : in Iterator; Position : in Cursor) return Cursor is begin if Position.Index = To_Peek_Type (Object.Container.Last) then return (null, Invalid_Peek_Index); else return (Object.Container, Position.Index + 1); end if; end Next; overriding function Previous (Object : in Iterator; Position : in Cursor) return Cursor is begin if Position.Index = To_Peek_Type (Index_Type'First) then return (null, Invalid_Peek_Index); else return (Object.Container, Position.Index - 1); end if; end Previous; function Iterate (Container : aliased in Vector) return Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Container => Container'Unrestricted_Access); end Iterate; function Constant_Ref (Container : aliased Vector; Position : in Cursor) return Constant_Reference_Type is begin return (Element => Container.Elements (Position.Index)'Access, Dummy => 1); end Constant_Ref; function Variable_Ref (Container : aliased in Vector; Position : in Cursor) return Variable_Reference_Type is begin return (Element => Container.Elements (Position.Index)'Access, Dummy => 1); end Variable_Ref; end SAL.Gen_Unbounded_Definite_Vectors;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Lire_Entier is Base_MAX : constant Integer := 10 + 26; -- 10 chiffres ('0'..'9') + 26 lettres ('A'..'Z') -- Est-ce que la base est valide ? function Est_Base_Valide(Base : in Integer) return Boolean is begin return 2 <= Base and Base <= Base_MAX; --return True; end Est_Base_Valide; -- Transformer indice en nombre entierdans base10 function Indice_En_Base10(Indice: Character) return Integer is begin if Indice >= '0' and Indice <= '9' then return Character'Pos(Indice) - Character'Pos('0'); else return 10 + Character'Pos(Indice) - Character'Pos('A'); end if; end Indice_En_Base10; function Nombre_En_Indice(Nombre: Integer) return Character is begin if Nombre < 10 then return Character'Val(Nombre + Character'Pos('0')); else return Character'Val(Nombre - 10 + Character'Pos('A')); end if; end Nombre_En_Indice; -- Lire un entier au clavier dans la base considérée. procedure Lire ( Nombre: out Integer ; -- l'entier lu au clavier Base: in Integer := 10 -- la base à utiliser ) with Pre => Est_Base_Valide (Base) is NbrEnBase: String(1 .. 10); Iteration: Integer; begin Get_Line(NbrEnBase, Iteration); Nombre := 0; for char of NbrEnBase loop Iteration := Iteration - 1; Nombre := Nombre + Indice_En_Base10(char) * Base**Iteration; exit when Iteration = 0; end loop; end Lire; -- Écrire un entier dans une base donnée. procedure Ecrire ( Nombre: in Integer ; -- l'entier à écrire Base : in Integer -- la base à utliser ) with Pre => Est_Base_Valide (Base) and Nombre >= 0 is begin if Nombre < Base then Put(Nombre_En_Indice(Nombre)); return; end if; Ecrire(Nombre/Base, Base); Put(Nombre_En_Indice(Nombre mod Base)); end Ecrire; Base_Lecture: Integer; -- la base de l'entier lu Base_Ecriture: Integer; -- la base de l'entier écrit Un_Entier: Integer; -- un entier lu au clavier begin -- Demander la base de lecture Put ("Base de l'entier lu : "); Get (Base_Lecture); Skip_Line; -- Demander un entier Put ("Un entier (base "); Put (Base_Lecture, 1); Put (") : "); if Est_Base_Valide(Base_Lecture) then Lire (Un_Entier, Base_Lecture); else Skip_Line; Un_Entier := 0; end if; -- Afficher l'entier lu en base 10 Put ("L'entier lu est (base 10) : "); Put (Un_Entier, 1); New_Line; -- Demander la base d'écriture Put ("Base pour écrire l'entier : "); Get (Base_Ecriture); Skip_Line; -- Afficher l'entier lu dans la base d'écriture if Est_Base_Valide(Base_Lecture) then Put ("L'entier en base "); Put (Base_Ecriture, 1); Put (" est "); Ecrire (Un_Entier, Base_Ecriture); New_Line; end if; -- Remarque : on aurait pu utiliser les sous-programme Lire pour lire -- les bases et Ecrire pour les écrire en base 10. Nous utilisons les -- Get et Put d'Ada pour faciliter le test du programme. end Lire_Entier;
-- Auto_Counters_Suite.Unique_Ptrs_Tests -- Unit tests for Auto_Counters Unique_Ptrs package -- Copyright (c) 2016, James Humphry - see LICENSE file for details with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; package Auto_Counters_Suite.Unique_Ptrs_Tests is type Unique_Ptrs_Test is new Test_Cases.Test_Case with null record; procedure Register_Tests (T: in out Unique_Ptrs_Test); function Name (T : Unique_Ptrs_Test) return Test_String; procedure Set_Up (T : in out Unique_Ptrs_Test); procedure Check_Unique_Ptrs (T : in out Test_Cases.Test_Case'Class); procedure Check_Unique_Const_Ptrs (T : in out Test_Cases.Test_Case'Class); end Auto_Counters_Suite.Unique_Ptrs_Tests;
package body Iterateur_Mots is function Initialiser( Chaine : String; Separateur : Character) return Iterateur_Mot is begin return (Chaine => To_Unbounded_String(Chaine), Curseur => 1, Separateur => Separateur); end; function Fin(Iterateur : Iterateur_Mot) return Boolean is begin return Iterateur.Curseur > Length(Iterateur.Chaine); end; -- Obtient le texte entre le séparateur courant et le suivant -- Sans avancer le curseur -- Requiert Curseur = 1 ou Chaine (Curseur) = Separateur function Lire_Mot_Suivant(Iterateur : Iterateur_Mot) return String is Car_Lus : Natural; begin return Lire_Mot_Suivant_Interne(Iterateur, Car_Lus); end; -- Avance jusqu'au prochain séparateur et récupère le contenu -- Requiert Curseur = 1 ou Chaine (Curseur) = Separateur function Avancer_Mot_Suivant(Iterateur : in out Iterateur_Mot) return String is Caracteres_Lus : Natural := 0; Contenu : constant String := Lire_Mot_Suivant_Interne (Iterateur, Caracteres_Lus); begin Iterateur.Curseur := Caracteres_Lus; return Contenu; end; function Lire_Mot_Suivant_Interne(Iterateur : Iterateur_Mot; Caracteres_Lus : out Natural) return String is Contenu_Deb, Contenu_Fin : Positive := 1; begin if Iterateur.Curseur > Length(Iterateur.Chaine) then return ""; end if; Caracteres_Lus := Iterateur.Curseur + 1; -- On vérifie que le car. courant est bien un séparateur -- On traite la chaine de séparateur en séparateur -- Cas particulier: quand Curseur = début, on ignore ce test if Iterateur.Curseur /= 1 and then Element(Iterateur.Chaine, Iterateur.Curseur) /= Iterateur.Separateur then raise Erreur_Syntaxe with "Carac. inattendu (courant /= séparateur): L(" & Positive'Image(Iterateur.Curseur) & ") = " & Element(Iterateur.Chaine, Iterateur.Curseur) & " /= " & Iterateur.Separateur; end if; -- On avance jusqu'à trouver le prochain séparateur -- ou jusqu'à la fin de la chaine while Caracteres_Lus <= Length(Iterateur.Chaine) and then Element(Iterateur.Chaine, Caracteres_Lus) /= Iterateur.Separateur loop Caracteres_Lus := Caracteres_Lus + 1; end loop; Contenu_Deb := Iterateur.Curseur; Contenu_Fin := Caracteres_Lus; -- Si on n'est pas à la fin de la chaîne -- alors la fin du contenu est -- 1 car. avant le séparateur suivant if Caracteres_Lus /= Length(Iterateur.Chaine) then Contenu_Fin := Contenu_Fin - 1; end if; -- Si on n'est pas au début de la chaîne -- alors le début du contenu est -- 1 car. après le séparateur précedent if Iterateur.Curseur /= 1 then Contenu_Deb := Contenu_Deb + 1; end if; if Contenu_Fin > Length(Iterateur.Chaine) then return ""; end if; return Slice(Iterateur.Chaine, Contenu_Deb, Contenu_Fin); end; end;
with Ada.Strings.Fixed; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A026 is use Ada.Strings.Fixed; use Ada.Integer_Text_IO; Base_Number, Temp_Sub_Str_001, Temp_Sub_Str_002, Temp_Sub_Str_02 : String (1 .. 2000); Temp_Sub_Str_01 : String (1 .. 10); Base_Sub_Number : String (1 .. 8); I_Max : Integer := 0; N : Integer := 80; J, Carry_Val, Find_Length, Quotient : Integer; begin for I in 11 .. 999 loop if (I mod 2) = 0 then goto Continue_I; end if; if (I mod 5) = 0 then goto Continue_I; end if; if (I mod 7) = 0 then goto Continue_I; end if; Base_Number := 2000 * "0"; Base_Number (1) := '1'; J := 1; Carry_Val := 0; while J <= 2000 loop Base_Sub_Number := 8 * " "; Move (Source => Trim (Integer'Image (Carry_Val), Ada.Strings.Both), Target => Base_Sub_Number (1 .. 3), Justify => Ada.Strings.Right, Pad => '0'); Base_Sub_Number (4 .. 8) := Base_Number (J .. J + 4); Quotient := Integer'Value (Base_Sub_Number); Carry_Val := Quotient mod I; Quotient := Integer (Float'Floor (Float (Quotient) / Float (I))); Move (Source => Trim (Integer'Image (Quotient), Ada.Strings.Both), Target => Base_Sub_Number (1 .. 5), Justify => Ada.Strings.Right, Pad => '0'); Base_Number (J .. J + 4) := Base_Sub_Number (1 .. 5); J := J + 5; end loop; J := 1; while Base_Number (J) = '0' loop J := J + 1; end loop; Find_Length := N; while J <= (2001 - Find_Length) loop Temp_Sub_Str_001 := 2000 * " "; Temp_Sub_Str_002 := 2000 * " "; Temp_Sub_Str_001 (1 .. Find_Length) := Base_Number (J .. J + Find_Length - 1); Temp_Sub_Str_002 (1 .. 2001 - Find_Length - J) := Base_Number (J + Find_Length .. 2000); if Index (Temp_Sub_Str_002, Temp_Sub_Str_001 (1 .. Find_Length)) /= 0 then Temp_Sub_Str_02 := 2000 * " "; Temp_Sub_Str_01 := Temp_Sub_Str_001 (1 .. 10); Temp_Sub_Str_02 (1 .. Find_Length - 10) := Temp_Sub_Str_001 (11 .. Find_Length); if Index (Temp_Sub_Str_02, Temp_Sub_Str_01) = 0 then N := Find_Length; Find_Length := Find_Length + 1; if Temp_Sub_Str_002 (Index (Temp_Sub_Str_002, Temp_Sub_Str_001 (1 .. N)) .. 2001 - N - J) = Temp_Sub_Str_002 (1 .. 2001 - N - J) then I_Max := I; exit; else goto Continue_J; end if; end if; end if; J := J + 1; <<Continue_J>> end loop; <<Continue_I>> end loop; Put (I_Max, Width => 0); end A026;
-- { dg-do compile } package Access1 is type R; type S is access R; type R is new S; end Access1;
----------------------------------------------------------------------- -- awa-storages -- Storage module -- Copyright (C) 2012, 2015, 2016, 2018, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 ADO; -- = Storages Module = -- The `storages` module provides a set of storage services allowing -- an application to store data files, documents, images in a persistent area. -- The persistent store can be on a file system, in the database or provided -- by a remote service such as Amazon Simple Storage Service. -- -- @include awa-storages-modules.ads -- -- == Creating a storage == -- A data in the storage is represented by a `Storage_Ref` instance. -- The data itself can be physically stored in a file system (`FILE` mode), -- in the database (`DATABASE` mode) or on a remote server (`URL` mode). -- To put a file in the storage space, first create the storage object -- instance: -- -- Data : AWA.Storages.Models.Storage_Ref; -- -- Then setup the storage mode that you want. The storage service uses -- this information to save the data in a file, in the database or in -- a remote service (in the future). -- To save a file in the store, we can use the `Save` operation of the -- storage service. -- It will read the file and put in in the corresponding persistent store -- (the database in this example). -- -- Service.Save (Into => Data, Path => Path_To_The_File, -- Storage => AWA.Storages.Models.DATABASE); -- -- Upon successful completion, the storage instance `Data` will be allocated -- a unique identifier that can be retrieved by `Get_Id` or `Get_Key`. -- -- == Getting the data == -- Several operations are defined to retrieve the data. Each of them has been -- designed to optimize the retrieval and -- -- * The data can be retrieved in a local file. -- This mode is useful if an external program must be launched and be able -- to read the file. If the storage mode of the data is `FILE`, the path -- of the file on the storage file system is used. For other storage modes, -- the file is saved in a temporary file. In that case the `Store_Local` -- database table is used to track such locally saved data. -- -- * The data can be returned as a stream. -- When the application has to read the data, opening a read stream -- connection is the most efficient mechanism. -- -- == Local file == -- To access the data by using a local file, we must define a local storage -- reference: -- -- Data : AWA.Storages.Models.Store_Local_Ref; -- -- and use the `Load` operation with the storage identifier. When loading -- locally we also indicate whether the file will be read or written. A file -- that is in `READ` mode can be shared by several tasks or processes. -- A file that is in `WRITE` mode will have a specific copy for the caller. -- An optional expiration parameter indicate when the local file representation -- can expire. -- -- Service.Load (From => Id, Into => Data, Mode => READ, Expire => ONE_DAY); -- -- Once the load operation succeeded, the data is stored on the file system and -- the local path is obtained by using the `Get_Path` operation: -- -- Path : constant String := Data.Get_Path; -- -- @include awa-storages-services.ads -- -- == Ada Beans == -- @include-bean storages.xml -- @include-bean storage-list.xml -- @include-bean folder-queries.xml -- @include-bean storage-queries.xml -- -- @include awa-storages-servlets.ads -- -- == Queries == -- @include-query storage-list.xml -- @include-query folder-queries.xml -- @include-query storage-queries.xml -- @include-query storage-info.xml -- -- == Data model == -- [images/awa_storages_model.png] -- package AWA.Storages is type Storage_Type is (DATABASE, FILE, URL, CACHE, TMP); type Storage_File (Storage : Storage_Type) is tagged limited private; -- Get the path to get access to the file. function Get_Path (File : in Storage_File) return String; -- Set the file path for the FILE, URL, CACHE or TMP storage. procedure Set (File : in out Storage_File; Path : in String); -- Set the file database storage identifier. procedure Set (File : in out Storage_File; Workspace : in ADO.Identifier; Store : in ADO.Identifier); private type Storage_File (Storage : Storage_Type) is limited new Ada.Finalization.Limited_Controlled with record case Storage is when DATABASE => Workspace : ADO.Identifier; Store : ADO.Identifier; when FILE | URL | CACHE | TMP => Path : Ada.Strings.Unbounded.Unbounded_String; end case; end record; overriding procedure Finalize (File : in out Storage_File); end AWA.Storages;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Yaml.Dom.Node; package body Yaml.Dom.Sequence_Data is use type Count_Type; use type Ada.Containers.Hash_Type; type Iterator is new Iterators.Forward_Iterator with record Container : not null access constant Instance; end record; function First (Object : Iterator) return Cursor is ((Container => Object.Container, Index => 1)); function Next (Object : Iterator; Position : Cursor) return Cursor is ((Container => Object.Container, Index => Natural'Min (Position.Index, Object.Container.Data.Last_Index) + 1)); function "=" (Left, Right : Instance) return Boolean is begin if Left.Data.Length /= Right.Data.Length then return False; else for Index in 1 .. Left.Data.Length loop if Left.Data (Positive (Index)) /= Right.Data (Positive (Index)) then return False; end if; end loop; return True; end if; end "="; function Capacity (Container : Instance) return Count_Type is (Container.Data.Capacity); procedure Reserve_Capacity (Container : in out Instance; Capacity : in Count_Type) is begin Container.Data.Reserve_Capacity (Capacity); end Reserve_Capacity; function Length (Object : Instance) return Count_Type is (Object.Data.Length); function Is_Empty (Container : Instance) return Boolean is (Container.Data.Is_Empty); procedure Clear (Container : in out Instance) is begin Container.Data.Clear; end Clear; function To_Cursor (Container : Instance; Index : Natural) return Cursor is ((Container => Container'Unrestricted_Access, Index => Index)); function To_Index (Position : Cursor) return Natural is (Position.Index); function Has_Element (Position : Cursor) return Boolean is (Position.Container /= null and then Position.Index > 0 and then Position.Index <= Position.Container.Data.Last_Index); function Element (Object : Instance; Index : Positive) return Node_Reference is begin Increase_Refcount (Object.Document); return ((Ada.Finalization.Controlled with Data => Object.Data.Element (Index), Document => Object.Document)); end Element; function Element (Object : Instance; Position : Cursor) return Node_Reference is (Object.Element (Positive (Position.Index))); procedure Iterate (Object : Instance; Process : not null access procedure (Item : not null access Node.Instance)) is begin for Item of Object.Data loop Process.all (Item); end loop; end Iterate; function Iterate (Object : Instance) return Iterators.Forward_Iterator'Class is (Iterator'(Container => Object'Unrestricted_Access)); procedure Replace_Element (Container : in out Instance; Index : in Positive; New_Item : in Node_Reference) is begin Container.Data.Replace_Element (Index, New_Item.Data); end Replace_Element; procedure Replace_Element (Container : in out Instance; Position : in Cursor; New_Item : in Node_Reference) is begin Container.Data.Replace_Element (Position.Index, New_Item.Data); end Replace_Element; procedure Insert (Container : in out Instance; Before : in Positive; New_Item : in Node_Reference) is begin Container.Data.Insert (Before, New_Item.Data); end Insert; procedure Insert (Container : in out Instance; Before : in Cursor; New_Item : in Node_Reference) is begin Container.Data.Insert (Before.Index, New_Item.Data); end Insert; procedure Insert (Container : in out Instance; Before : in Cursor; New_Item : in Node_Reference; Position : out Cursor) is Raw_Cursor : Node_Vectors.Cursor; begin Container.Data.Insert (Container.Data.To_Cursor (Before.Index), New_Item.Data, Raw_Cursor); Position := (Container => Container'Unrestricted_Access, Index => Node_Vectors.To_Index (Raw_Cursor)); end Insert; procedure Prepend (Container : in out Instance; New_Item : in Node_Reference) is begin Container.Data.Prepend (New_Item.Data); end Prepend; procedure Append (Container : in out Instance; New_Item : in Node_Reference) is begin Container.Data.Append (New_Item.Data); end Append; procedure Delete (Container : in out Instance; Index : in Positive; Count : in Count_Type := 1) is begin Container.Data.Delete (Index, Count); end Delete; procedure Delete (Container : in out Instance; Position : in out Cursor; Count : in Count_Type := 1) is begin Container.Data.Delete (Position.Index, Count); end Delete; procedure Delete_First (Container : in out Instance; Count : in Count_Type := 1) is begin Container.Data.Delete_First (Count); end Delete_First; procedure Delete_Last (Container : in out Instance; Count : in Count_Type := 1) is begin Container.Data.Delete_Last (Count); end Delete_Last; procedure Reverse_Elements (Container : in out Instance) is begin Container.Data.Reverse_Elements; end Reverse_Elements; procedure Swap (Container : in out Instance; I, J : in Positive) is begin Container.Data.Swap (I, J); end Swap; procedure Swap (Container : in out Instance; I, J : in Cursor) is begin Container.Data.Swap (I.Index, J.Index); end Swap; function First_Index (Container : Instance) return Positive is (Container.Data.First_Index); function First (Container : Instance) return Cursor is ((Container => Container'Unrestricted_Access, Index => Container.Data.First_Index)); function First_Element (Container : Instance) return Node_Reference is (Container.Element (Container.Data.First_Index)); function Last_Index (Container : Instance) return Natural is (Container.Data.Last_Index); function Last (Container : Instance) return Cursor is ((Container => Container'Unrestricted_Access, Index => Container.Data.Last_Index)); function Last_Element (Container : Instance) return Node_Reference is (Container.Element (Container.Data.Last_Index)); function Next (Position : Cursor) return Cursor is ((Container => Position.Container, Index => Natural'Min (Position.Index, Position.Container.Data.Last_Index) + 1)); procedure Next (Position : in out Cursor) is begin Position.Index := Natural'Min (Position.Index, Position.Container.Data.Last_Index) + 1; end Next; function Previous (Position : Cursor) return Cursor is ((Container => Position.Container, Index => Position.Index - 1)); procedure Previous (Position : in out Cursor) is begin Position.Index := Position.Index - 1; end Previous; package body Friend_Interface is function For_Document (Document : not null access Document_Instance) return Instance is (Document => Document, Data => <>); procedure Raw_Append (Container : in out Instance; New_Item : not null access Node.Instance) is begin Container.Data.Append (New_Item); end Raw_Append; end Friend_Interface; end Yaml.Dom.Sequence_Data;
with Ada.Numerics.Discrete_Random; package body Random with SPARK_Mode => Off is pragma Compile_Time_Warning (True, "This PRNG is not cryptographically secure."); package PRNG is new Ada.Numerics.Discrete_Random (Interfaces.Unsigned_8); Gen : PRNG.Generator; function Random_Byte return Interfaces.Unsigned_8 is begin return PRNG.Random (Gen); end Random_Byte; procedure Random_Bytes (R : out SPARKNaCl.Byte_Seq) is begin for I in R'Range loop pragma Loop_Optimize (No_Unroll); R (I) := Random_Byte; end loop; end Random_Bytes; begin PRNG.Reset (Gen); -- time dependent end Random;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . C O N T T . U T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2011, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore. -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ -- This package defines for each ASIS Context the corresponding Unit Table, -- which contains all the information needed for the black-box ASIS queries -- about Compilation Units. This table also provides the mechanism for -- searching for a unit by its Ada name, this mechanism is some slight -- modification of the GNAT Namet package. with Asis; use Asis; with Asis.Extensions; use Asis.Extensions; package A4G.Contt.UT is -- Context_Table.Unit_Tables --------------------- -- ASIS Unit Table -- --------------------- -- ASIS Unit Table is the main part of the implementation of ASIS Context -- and ASIS Compilation Unit abstractions. The table is organized in the -- following way: -- - the internal representation of an ASIS Compilation Unit is the -- value of the corresponding Unit Record which is kept in Unit Table -- and indicated by Unit Id; -- - each ASIS Context has its own Unit Table, so most the routines -- dealing with Unit Table contain the Id of an Enclosing Context -- as a Parameter; -- - each ASIS Compilation Units keeps the Id of its enclosing -- Context as a part of its value; -- - The fully expanded Ada name, together for the spec/body sign, -- uniquely identifies a given unit inside its enclosing -- Context/Context; so the triple - expanded Ada name, spec/body -- sign and some identification of the Unit's enclosing Context/Context -- uniquely identifies a given unit among all the Unit processed -- by ASIS; -- - The normalized Ada name, is obtained from the fully expanded -- Ada Unit name by folding all the upper case letters in the -- corresponding lower case letters, appending the spec/body sign -- (which has the form "%s" for a spec and "%b" for a body); -- The entries in the table are accessed using a Unit_Id that ranges -- from First_Unit_Id to Last_Unit_Id. The fields of each entry and -- the corresponding interfaces may be subdivided into four groups. -- The first group, called as Unit Name Table, provides the modified -- version of the functionality of the GNAT Namet package, it is used -- for storing the names of the Units in two forms - in the normalized -- and in the form corresponding to the (defining) occurrence of a -- given name in a source text. Each unit can be effectively searched -- by its normalized name. -- The second group contains the black-box attributes of a Unit. -- The third group contains the information about relations (semantic -- dependencies) between the given unit and the other units in the -- enclosing Context/Context Note, that Ada Unit name, -- included in the first group, logically should also be considered -- as a black-box Unit attribute. -- And the fourth group contains the fields needed for organization of the -- tree swapping during the multiple Units processing. --------------------- -- Unit Name Table -- --------------------- -- Each Unit entry contain the following fields: -- "Normalized" Ada name "Normalized" Ada names of the ASIS Compilation -- Units are their names with upper case letters -- folded to lower case (by applying the -- Ada.Character.Handling.To_Lower functions; -- this lover-case-folding has no relation to GNAT -- conventions described in Namet!), appended by -- suffix %s or %b for spec or bodies/subunits, as -- defined in Uname (spec), and prepended by -- the string image of the Id value of the unit's -- enclosing Context. Each of the names of this -- kind may have only one entry in Unit Name Table. -- -- Ada name Ada names of the ASIS Compilation Units are -- stored keeping the casing from the source text. -- These entries are used to implement the ASIS -- query (-ies?) returning the Ada name of the -- Unit. Ada names may be included more than one -- time in Unit Name Table as the parts of the -- different table entries, as the name of a spec -- and the name of a corresponding body. -- -- Source File Name The name of the Ada source file used to compile -- the given compilation unit (on its own or as a -- supporter of some other unit). -- -- Reference File Name The name of the source file which represents -- the unit source from the user's viewpoint. It is -- the same as the Source File name unless the -- Source_Reference pragma presents for the given -- unit. type Column is (Norm_Ada_Name, Ada_Name, Source_File_Name, Ref_File_Name); -- This enumeration type defines literals used to make the difference -- between different forms of names stored in the Unit Table -- Really every name is kept as the reference into the Char table, -- together with the length of its name. -- The normalized names are hashed, so that a given normalized name appears -- only once in the table. -- Opposite to the GNAT name table, this name table does not handle the -- one-character values in a special way (there is no need for it, because -- storing an one-character name does not seem to be a usual thing -- for this table.) -- ASIS "normalized" Unit names follow the convention which is -- very similar to the GNAT convention defined in Uname (spec), the -- only difference is that ASIS folds all the upper case -- letters to the corresponding lower case letters without any encoding. -- ASIS packages implementing the ASIS Context model for GNAT contain -- "ASIS-related counterparts" of some facilities provided by three -- GNAT packages - Namet, Uname and Fname. -- We keep storing the two values, one of type Int and one of type Byte, -- with each names table entry and subprograms are provided for setting -- and retrieving these associated values. But for now these values are -- of no use in ASIS - we simply are keeping this mechanism from the -- GNAT name table - just in case. -- Unit Name Table may be considered as having the external view -- of the two-column table - for each row indicated by Unit_Id the -- first column contains the Ada name of the corresponding Unit and -- the second column contains Unit's "normalized" name. -- In fact we do not use any encoding-decoding in Unit Name Table. ASIS -- supports only a standard mode of GNAT (that is, it relies on the fact -- that all the identifiers contain only Row 00 characters). ASIS also -- assumes that all the names of the source files are the values of -- the Ada predefined String type. -- All the Unit Tables shares the same Name Buffer, see the specification -- of the parent package for its definition. --------------------------------- -- Unit Name Table Subprograms -- --------------------------------- procedure Get_Name_String (Id : Unit_Id; Col : Column); -- Get_Name_String is used to retrieve the one of the three strings -- associated with an entry in the names table. The Col parameter -- indicates which of the names should be retrieved (Ada name, normalized -- Ada name or source file name) by indicating the "column" in the table -- The resulting string is stored in Name_Buffer and Name_Len is set. function Length_Of_Name (Id : Unit_Id; Col : Column) return Nat; -- ??? pragma Inline (Length_Of_Name); -- Returns length of given name in characters, the result is equivalent to -- calling Get_Name_String and reading Name_Len, except that a call to -- Length_Of_Name does not affect the contents of Name_Len and Name_Buffer. function Name_Find (C : Context_Id) return Unit_Id; -- Name_Find is called with a string stored in Name_Buffer whose length -- is in Name_Len (i.e. the characters of the name are in subscript -- positions 1 to Name_Len in Name_Buffer). It searches the names -- table to see if the string has already been stored. If so the Id of -- the existing entry is returned. Otherwise (opposite to the GNAT name -- table, in which a new entry is created it this situation with its -- Name_Table_Info field set to zero) the Id value corresponding to the -- ASIS Nil_Compilation_Unit, that is Nil_Unit, is returned. -- -- Only normalized Ada names are hashed, so this function is intended to -- be applied to the normalized names only (in is not an error to apply -- it to other forms of names stored in the table, but the result will -- always be Nil_Unit. function Allocate_Unit_Entry (C : Context_Id) return Unit_Id; -- Allocates the new entry in the Unit Name Table for the "normalized" -- Ada Unit name stored in the Name_Buffer (Name_Len should be set -- in a proper way). This routine should be called only if the -- immediately preceding call to an operation working with Unit Name -- Table is the call to Name_Find which has yielded Nil_Unit as a -- result. Note, that this function sets only the "normalized" unit name, -- it does not set the Ada name or the source file name. It also -- increases by one the counter of allocated bodies or specs, depending -- on the suffix in the normalized unit name. function Allocate_Nonexistent_Unit_Entry (C : Context_Id) return Unit_Id; -- Differs from the previous function in the following aspects: -- - 'n' is added to the name suffix to mark that this entry -- corresponds to the nonexistent unit; -- - The body/spec counters are not increased -- - all the attributes of the allocated nonexistent unit are set by -- this procedure. -- -- Allocates the new entry in the Unit Name Table for the "normalized" -- Ada Unit name stored in the Name_Buffer (Name_Len should be set -- in a proper way). This routine should be called only if the -- immediately preceding call to an operation working with Unit Name -- Table is the call to Name_Find which has yielded Nil_Unit as a -- result. Note, that this function sets only the "normalized" unit name, -- it does not set the Ada name or the source file name. function Set_Unit (C : Context_Id; U : Unit_Number_Type) return Unit_Id; -- Creates the Unit table entry for the unit U and sets the normalized -- unit name (which is supposed to be stored in A_Name_Buffer when this -- procedure is called) and the time stamp for the unit. It also adds -- the (Id of the) currently accessed tree to the (empty) list -- of (consistent) trees for this unit. All the other unit attributes -- are set to nil values. The ID of the created entry is returned as a -- result procedure Set_Ada_Name (Id : Unit_Id); pragma Inline (Set_Ada_Name); -- Sets the string stored in Name_Buffer whose length is Name_Len as the -- value of the Ada name of the ASIS Unit indicated by Id value procedure Set_Norm_Ada_Name (Id : Unit_Id); pragma Inline (Set_Norm_Ada_Name); -- Sets the string stored in Name_Buffer whose length is Name_Len as the -- value of the "normalized" Ada name of the ASIS Unit indicated by Id -- value procedure Set_Ref_File_As_Source_File (U : Unit_Id); -- For a given unit in a given context, sets the reference file name equal -- to the source file name (by copying the corresponding references to -- the ASIS Chars table procedure Set_Source_File_Name (Id : Unit_Id; Ref : Boolean := False); pragma Inline (Set_Source_File_Name); -- Sets the string stored in the A_Name_Buffer whose length is A_Name_Len -- as the value of the source or reference (depending on the actual set -- for the Ref parameter) file name of the ASIS Unit indicated by Id value procedure Set_Norm_Ada_Name_String; -- Sets the Normalized Ada Unit name as the value of Name_Buffer. -- This normalized version of the Ada Unit name is -- obtained by folding to lover cases of the GNAT unit name -- which should be previously get as the content of -- Namet.Name_Buffer (that means that every call to this procedure -- should be preceded by the appropriate call to -- Namet.Get_Unqualified_Decoded_Name_String (or -- Namet.Get_Decoded_Name_String if the caller is sure, that the name is -- not qualified) procedure Set_Norm_Ada_Name_String_With_Check (Unit : Unit_Number_Type; Success : out Boolean); -- This is the modified version of Set_Norm_Ada_Name_String: after setting -- the ASIS name buffer it checks if Unit should be considered as -- Compilation_Unit by ASIS. The need for this check caused by artificial -- compilation units created by the compiler for library-level generic -- instantiations. If the check is successful, Success is set True, -- otherwise it is set False. -- -- In case of a tree created for library-level instantiation of a generic -- package (only package ???) GNAT sets the suffix of the name of the -- corresponding unit in its unit table as '%b', but ASIS has to see -- this unit as a spec, therefore in this case this procedure resets the -- suffix of the unit name to '%s' procedure Set_Ref_File_Name_String (U : Unit_Id); -- Is supposed to be called when GNAT Namet.Name_Buffer contains a full -- reference file name. It sets the Reference File name as the value of -- A_Name_Buffer. This name is composed from the reference file name -- obtained from the tree and from the source file name (in which the -- directory information is already adjusted , if needed, by the -- corresponding call to Set_S_File_Name_String) to contain the directory -- information needed to access this file from the current directory. ------------------------------- -- Black-Box Unit Attributes -- ------------------------------- -- Each Unit entry contains the following fields, representing the Unit -- black-box attributes, which are for the direct interest for the ASIS -- queries from the Asis_Compilation_Unit package, the primary idea of -- implementing the Context/Compilation_Unit stuff in ASIS-for-GNAT is -- to compute each of these attribute only once, when the new tree is -- inputted by ASIS for the first time, and then store them in Unit -- Table, so then ASIS queries will be able to get the required -- answer without any new tree processing: -- Top : Node_Id; -- The top node of the unit subtree in the currently accessed full tree. -- From one side, this node should be reset every time the full tree -- is changed. From the other side, the corresponding actions may be -- considered as too time-consumed. This problem is postponed now as -- OPEN PROBLEM, it is not important till we are working under the -- limitation "only one tree can be accessed at a time" -- Enclosing_Context : Context_Id; -- The reference to the Context table which indicates the Enclosing -- Context for a Unit -- Kind : Unit_Kinds; -- The kind of a Compilation Unit, as defined by Asis.Unit_Kinds -- package -- Class : Unit_Classes; -- The class of a Compilation Unit, as defined by Asis.Unit_Kinds -- package -- Origin : Unit_Origins; -- The origin of a Compilation Unit, as defined by Asis.Unit_Kinds -- package -- Main_Unit : Boolean; -- The boolean flag indicating if a Compilation Unit may be treated -- as the main unit for a partition (See RM 10.2(7)) -- GNAT-specific!!?? -- Is_Body_Required : Boolean; -- The boolean flag indicating if a Compilation Unit requires a body -- as a completion ----------------------------------------------------------- -- Black-Box Unit Attributes Access and Update Routines -- ----------------------------------------------------------- function Top (U : Unit_Id) return Node_Id; -- this function is not trivial, it can have tree swapping as its -- "side effect" function Kind (C : Context_Id; U : Unit_Id) return Unit_Kinds; function Class (C : Context_Id; U : Unit_Id) return Unit_Classes; function Origin (C : Context_Id; U : Unit_Id) return Unit_Origins; function Is_Main_Unit (C : Context_Id; U : Unit_Id) return Boolean; function Is_Body_Required (C : Context_Id; U : Unit_Id) return Boolean; -- This function does not reset Context, a Caller is responsible for this function Time_Stamp (C : Context_Id; U : Unit_Id) return Time_Stamp_Type; function Is_Consistent (C : Context_Id; U : Unit_Id) return Boolean; function Source_Status (C : Context_Id; U : Unit_Id) return Source_File_Statuses; function Main_Tree (C : Context_Id; U : Unit_Id) return Tree_Id; function Has_Limited_View_Only (C : Context_Id; U : Unit_Id) return Boolean; -- Checks if U has only limited view in C -------- procedure Set_Top (C : Context_Id; U : Unit_Id; N : Node_Id); procedure Set_Kind (C : Context_Id; U : Unit_Id; K : Unit_Kinds); procedure Set_Class (C : Context_Id; U : Unit_Id; Cl : Unit_Classes); procedure Set_Origin (C : Context_Id; U : Unit_Id; O : Unit_Origins); procedure Set_Is_Main_Unit (C : Context_Id; U : Unit_Id; M : Boolean); procedure Set_Is_Body_Required (C : Context_Id; U : Unit_Id; B : Boolean); procedure Set_Time_Stamp (C : Context_Id; U : Unit_Id; T : Time_Stamp_Type); procedure Set_Is_Consistent (C : Context_Id; U : Unit_Id; B : Boolean); procedure Set_Source_Status (C : Context_Id; U : Unit_Id; S : Source_File_Statuses); ------------------------------------------------- --------------------------- -- Semantic Dependencies -- --------------------------- ---------------------------------------------------- -- Subprograms for Semantic Dependencies Handling -- ---------------------------------------------------- function Not_Root return Boolean; -- Checks if U is not a root library unit (by checking if -- its name contains a dot). This function itself does not set the -- normalized name of U in A_Name_Buffer, it is supposed to be called -- when a proper name is already set. function Subunits (C : Context_Id; U : Unit_Id) return Unit_Id_List; -- Returns the full list of Ids of subunits for U (if any). The full list -- contains nonexistent units for missed subunits -- -- Note, that this function does not reset Context, it should be done in -- the caller! function Get_Subunit (Parent_Body : Asis.Compilation_Unit; Stub_Node : Node_Id) return Asis.Compilation_Unit; -- This function is intended to be used only when all the Unit attributes -- are already computed. It gets the Parent_Body, whose tree should -- contain Stub_Node as a node representing some body stub, and it -- returns the Compilation Unit containing the proper body for this stub. -- It returns a Nil_Compilation_Unit, if the Compilation Unit containing -- the proper body does not exist in the enclosing Context or if it is -- inconsistent with Parent_Body. function Children (U : Unit_Id) return Unit_Id_List; -- returns the list of Ids of children for U (if any) -- -- Note, that this function does not reset Context, it should be done in -- the caller! function GNAT_Compilation_Dependencies (U : Unit_Id) return Unit_Id_List; -- Returns the full list of GNAT compilation dependencies for U -- This list is empty if and only if U is not a main unit of some -- compilation which creates some tree for C. procedure Form_Parent_Name; -- supposing A_Name_Buffer containing a normalized unit name, this -- function forms the normalized name of its parent by stripping out -- the suffix in the Ada part of the name (that is, the part of the -- name between the rightmost '.' and '%") and changing the -- "normalized" suffix to "%s". A_Name_Len is set in accordance with -- this. If the Ada part of the name contains no suffix (that is, if -- it corresponds to a root library unit), A_Name_Len is set equal -- to 0. function Get_Parent_Unit (C : Context_Id; U : Unit_Id) return Unit_Id; -- returns the Id of the parent unit declaration for U. If U is -- First_Unit_Id, returns Nil_Unit. -- -- Note, that this function does not reset Context, it should be done in -- the caller! function Get_Body (C : Context_Id; U : Unit_Id) return Unit_Id; -- returns the Id of the library_unit_body for the unit U. -- Nil_Unit is not a valid argument for this function. -- -- Note, that this function does not reset Context, it should be done in -- the caller! function Get_Declaration (C : Context_Id; U : Unit_Id) return Unit_Id; -- returns the Id of the library_unit_declaration for the unit U. -- Nil_Unit is not a valid argument for this function. -- -- Note, that this function does not reset Context, it should be done in -- the caller! function Get_Subunit_Parent_Body (C : Context_Id; U : Unit_Id) return Unit_Id; -- returns the Id of the library_unit_body or subunit being the parent -- body for subunit U (a caller is responsible for calling this function -- for subunits). function Get_Nonexistent_Unit (C : Context_Id) return Unit_Id; -- Is supposed to be called just after an attempt to get a unit which is -- supposed to be a needed declaration or a needed body (that is, -- A_Name_Buffer contains a normalized unit name ending with "%s" or "%b" -- respectively). Tries to find the unit of A_Nonexistent_Declaration -- or A_Nonexistent_Body kind with this name, if this attempt fails, -- allocates the new unit entry for the corresponding nonexistent unit. -- Returns the Id of found or allocated unit. function Get_Same_Unit (Arg_C : Context_Id; Arg_U : Unit_Id; Targ_C : Context_Id) return Unit_Id; -- Tries to find in Targ_C just the same unit as Arg_U is in Arg_C. -- Just the same means, that Arg_U and the result of this function -- should have just the same time stamps. If Arg_C = Targ_C, Arg_U -- is returned. If there is no "just the same" unit in Targ_C, -- Nil_Unit is returned. -- -- If No (Arg_U), then the currently accessed Context is not reset (but -- this function is not supposed to be called for Arg_U equal to -- Nil_Unit_Id, although it is not an error). Otherwise Context is reset -- to Targ_C -------------------------------------- -- General-Purpose Unit Subprograms -- -------------------------------------- procedure Finalize (C : Context_Id); -- Currently this routine is only used to generate debugging output -- for the Unit Table of a given Context. function Present (Unit : Unit_Id) return Boolean; -- Tests given Unit Id for equality with Nil_Unit. This allows -- notations like "if Present (Current_Supporter)" as opposed to -- "if Current_Supporter /= Nil_Unit function No (Unit : Unit_Id) return Boolean; -- Tests given Unit Id for equality with Nil_Unit. This allows -- notations like "if No (Current_Supporter)" as opposed to -- "if Current_Supporter = Nil_Unit function Last_Unit return Unit_Id; -- Returns the Unit_Id of the last unit which has been allocated in the -- Unit Name Table. Used to define that the Unit_Id value returned by -- Name_Find corresponds to the ASIS Compilation Unit which is not -- known to ASIS. function Lib_Unit_Decls (C : Context_Id) return Natural; -- returns the number of library_unit_declaratios allocated in the -- Context Unit table function Comp_Unit_Bodies (C : Context_Id) return Natural; -- returns the number of library_unit_bodies and subunits allocated -- in the Context Unit table function Next_Decl (D : Unit_Id) return Unit_Id; -- Returns the Unit_Id of the next unit (starting from, but not including -- D), which is a library_unit_declaration. Returns Nil_Unit, if there -- is no such a unit in C. -- -- Note, that this function does not reset Context, it should be done in -- the caller! function First_Body return Unit_Id; -- Returns the Unit_Id of the first unit which is a -- compilation_unit_body or a subunit. Returns Nil_Unit, if there is -- no such a unit in a current Context. -- -- Note, that this function does not reset Context, it should be done in -- the caller! function Next_Body (B : Unit_Id) return Unit_Id; -- Returns the Unit_Id of the next unit (starting from, but not including -- B) which is a compilation_unit_body or a subunit. Returns Nil_Unit, -- if there is no such a unit in C. -- -- Note, that this function does not reset Context, it should be done in -- the caller! procedure Output_Unit (C : Context_Id; Unit : Unit_Id); -- Produces the debug output of the Unit Table entry corresponding -- to Unit -- DO WE NEED THIS PROCEDURE IN THE SPECIFICATION???? procedure Print_Units (C : Context_Id); -- Produces the debug output from the Unit table for the Context C. function Enclosing_Unit (Cont : Context_Id; Node : Node_Id) return Asis.Compilation_Unit; -- This function is intended to be used to define the enclosing -- unit for an Element obtained as a result of some ASIS semantic query. -- It finds the N_Compilation_Unit node for the subtree enclosing -- the Node given as its argument, and then defines the corresponding -- Unit Id, which is supposed to be the Id of Enclosing Unit for an -- Element built up on the base of Node. It does not change the tree -- being currently accessed. All these computations are supposed -- to be performed for a Context Cont. -- Node should not be a result of Atree.Original_Node, because -- it is used as an argument for Atree.Parent function -- -- Note, that this function does no consistency check, that is, the -- currently accessed tree may be not from the list of consistent trees -- for the resulted Unit. --------------- -- NEW STUFF -- --------------- procedure Register_Units (Set_First_New_Unit : Boolean := False); -- When a new tree file is read in during Opening a Context, this procedure -- goes through all the units represented by this tree and checks if these -- units are already known to ASIS. If some unit is unknown, this -- procedure "register" it - it creates the corresponding entry in the -- unit table, and it sets the normalized unit name. It does not set any -- other field of unit record except Kind. It sets Kind as Not_A_Unit -- to indicate, that this unit is only registered, but not processed. -- -- We need this (pre-)registration to be made before starting unit -- processing performed by Process_Unit_New, because we need all the units -- presenting in the tree to be presented also in the Context unit table -- when storing the dependency information. -- -- Note, that all the consistency checks are made by Process_Unit_New, -- even though we can make them here. The reason is to separate this -- (pre-)registration (which is an auxiliary technical action) from -- unit-by-unit processing to facilitate the maintainability of the code. -- -- If Set_First_New_Unit is set ON, stores in A4G.Contt.First_New_Unit -- the first new unit being registered. If Set_First_New_Unit is set OFF -- or if no new units has been registered, First_New_Unit is set to -- Nil_Unit -- -- ??? The current implementation uses Set_Unit, which also sets time -- ??? stamp for a unit being registered. It looks like we do not need -- ??? this, so we can get rid of this. function Already_Processed (C : Context_Id; U : Unit_Id) return Boolean; -- Checks if U has already been processed when scanning previous trees -- during opening C procedure Check_Source_Consistency (C : Context_Id; U_Id : Unit_Id); -- Is called when a Unit is being investigated as encountered for the first -- time during opening the Context C. It checks the existence of the source -- file for this unit, and if the source file exists, it checks that the -- units as represented by the tree is consistent with the source (if this -- is required by the options associated with the Context). -- This procedure should be called after extracting the source file name -- from the tree and putting this into the Context unit table. procedure Check_Consistency (C : Context_Id; U_Id : Unit_Id; U_Num : Unit_Number_Type); -- Is called when a unit is encountered again when opening C. Checks if in -- the currently accessed tree this unit has the same time stamp as it had -- in all the previously processed trees. In case if this check fails, it -- raises ASIS_Failed and forms the diagnosis on behalf of -- Asis.Ada_Environments.Open. (This procedure does not check the source -- file for the unit - this should be done by Check_Source_Consistency -- when the unit was processed for the first time) function TS_From_OS_Time (T : OS_Time) return Time_Stamp_Type; -- Converts OS_Time into Time_Stamp_Type. Is this the right place for -- this function??? procedure Reset_Cache; -- Resents to the empty state the cache data structure used to speed up the -- Top function. Should be called as a part of closing a Context. end A4G.Contt.UT;
with Ada.Unchecked_Deallocation; package BBqueue.Buffers.FFI is type BufferPtr is access BBqueue.Buffers.Buffer -- can't be "not null" bc. of deallocation with Convention => C; function Create (Size : Buffer_Size) return BufferPtr with Convention => C, Export => True, External_Name => "bbqueue_buffers_create"; procedure Drop (Ptr : in out BufferPtr) with Convention => C, Export => True, External_name => "bbqueue_buffers_drop"; procedure Free is new Ada.Unchecked_Deallocation ( Buffer, BufferPtr); end BBqueue.Buffers.FFI;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2013, Vadim Godunko <vgodunko@gmail.com> -- -- 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 package provides subprograms to extract julian day number and time -- inside day from X/Open representation and to construct X/Open -- representation from julian day number and time inside day. -- -- Subprograms in this package handles leap seconds also. -- -- Note: for convenience, julian day starts at midnight, not noon. ------------------------------------------------------------------------------ package Matreshka.Internals.Calendars.Times is pragma Preelaborate; subtype Hour_Number is Integer range 0 .. 23; subtype Minute_Number is Integer range 0 .. 59; subtype Second_Number is Integer range 0 .. 60; subtype Nano_Second_100_Number is Integer range 0 .. 9_999_999; function Create (Zone : not null Time_Zone_Access; Julian_Day : Julian_Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Nano_100 : Nano_Second_100_Number) return Absolute_Time; -- Creates absolute time from giving components. function Julian_Day (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Julian_Day_Number; -- Returns julian day number of the specified X/Open time. function Hour (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Hour_Number; function Hour (Time : Relative_Time) return Hour_Number; -- Returns the hour part (0 to 23) of the time. function Minute (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Minute_Number; function Minute (Time : Relative_Time) return Minute_Number; -- Returns the minute part (0 to 59) of the time. function Second (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Second_Number; function Second (Time : Relative_Time; Leap : Relative_Time) return Second_Number; -- Returns the second part (0 to 60) of the time. function Nanosecond_100 (Time : Relative_Time; Leap : Relative_Time) return Nano_Second_100_Number; function Nanosecond_100 (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Nano_Second_100_Number; -- Returns the second fraction part (0 to 9_999_999) of the time. procedure Split (Zone : not null Time_Zone_Access; Stamp : Absolute_Time; Julian_Day : out Julian_Day_Number; Time : out Relative_Time; Leap : out Relative_Time); -- Splits stamp onto julian day number, relative time and leap second -- fraction. procedure Split (Zone : not null Time_Zone_Access; Stamp : Absolute_Time; Julian_Day : out Julian_Day_Number; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Nanosecond_100 : out Nano_Second_100_Number); -- Splits stamp onto julian day number and splitted time inside day. Leap -- second is returned as Second equal to 60. It is not necessary last -- second of the day due to timezone correction. end Matreshka.Internals.Calendars.Times;
with Histogram; with PixelArray; with ImageRegions; with ImageThresholds; package HistogramGenerator is pragma Assertion_Policy (Pre => Check, Post => Check, Type_Invariant => Check); function verticalProjection(image: PixelArray.ImagePlane; r: ImageRegions.Rect) return Histogram.Data with Post => verticalProjection'Result.size = r.height; function horizontalProjection(image: PixelArray.ImagePlane; r: ImageRegions.Rect) return Histogram.Data with Post => horizontalProjection'Result.size = r.width; end HistogramGenerator;
with IO_EXCEPTIONS; generic type ELEMENT_TYPE is private; package SEQUENTIAL_IO is type FILE_TYPE is limited private; type FILE_MODE is (IN_FILE, OUT_FILE); -- File management procedure CREATE(FILE : in out FILE_TYPE; MODE : in FILE_MODE := OUT_FILE; NAME : in STRING := ""; FORM : in STRING := ""); procedure OPEN (FILE : in out FILE_TYPE; MODE : in FILE_MODE; NAME : in STRING; FORM : in STRING := ""); procedure CLOSE (FILE : in out FILE_TYPE); procedure DELETE(FILE : in out FILE_TYPE); procedure RESET (FILE : in out FILE_TYPE; MODE : in FILE_MODE); procedure RESET (FILE : in out FILE_TYPE); function MODE (FILE : in FILE_TYPE) return FILE_MODE; function NAME (FILE : in FILE_TYPE) return STRING; function FORM (FILE : in FILE_TYPE) return STRING; function IS_OPEN(FILE : in FILE_TYPE) return BOOLEAN; -- Input and output operations procedure READ (FILE : in FILE_TYPE; ITEM : out ELEMENT_TYPE); procedure WRITE (FILE : in FILE_TYPE; ITEM : in ELEMENT_TYPE); function END_OF_FILE(FILE : in FILE_TYPE) return BOOLEAN; -- Exceptions STATUS_ERROR : exception renames IO_EXCEPTIONS.STATUS_ERROR; MODE_ERROR : exception renames IO_EXCEPTIONS.MODE_ERROR; NAME_ERROR : exception renames IO_EXCEPTIONS.NAME_ERROR; USE_ERROR : exception renames IO_EXCEPTIONS.USE_ERROR; DEVICE_ERROR : exception renames IO_EXCEPTIONS.DEVICE_ERROR; END_ERROR : exception renames IO_EXCEPTIONS.END_ERROR; DATA_ERROR : exception renames IO_EXCEPTIONS.DATA_ERROR; private type FILE_TYPE is new integer; -- implementation-dependent end SEQUENTIAL_IO;
--------------------------------------------------------------------------------- -- Copyright 2004-2005 © Luke A. Guest -- -- This code is to be used for tutorial purposes only. -- You may not redistribute this code in any form without my express permission. --------------------------------------------------------------------------------- with Vector3; package Line_Segment is type Object is record StartPoint, EndPoint : Vector3.Object; end record; function Create(StartPoint, EndPoint : Vector3.Object) return Object; end Line_Segment;
-- { dg-do compile } with text_io; with System; procedure addr3 is Type T_SAME_TYPE is new System.Address; Type T_OTHER_TYPE is new System.Address; I : constant integer := 0; procedure dum ( i : INTEGER ) is begin text_io.put_line ("Integer op"); null; end; procedure dum ( i : system.ADDRESS ) is begin null; end; procedure dum ( i : T_SAME_TYPE ) is begin null; end; procedure dum ( i : T_OTHER_TYPE ) is begin null; end; begin dum( I ); dum( 1 ); end;
-- SipHash.Entropy -- A child package that attempts to set the key from an entropy source on the -- system. -- This implementation is for systems where no entropy is available. -- Copyright (c) 2015, James Humphry - see LICENSE file for details package body SipHash.Entropy with SPARK_Mode => Off is function System_Entropy_Source return Boolean is (False); procedure Set_Key_From_System_Entropy is begin raise Entropy_Unavailable with "System entropy not available on this system"; end Set_Key_From_System_Entropy; procedure Set_Key_From_System_Entropy (Success : out Boolean) is begin Success := False; end Set_Key_From_System_Entropy; end SipHash.Entropy;
----------------------------------------------------------------------- -- ADO Mysql Database -- MySQL Database connections -- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 System; with ADO.Drivers.Connections.Sqlite; package ADO.Statements.Sqlite is type Handle is null record; -- ------------------------------ -- Delete statement -- ------------------------------ type Sqlite_Delete_Statement is new Delete_Statement with private; type Sqlite_Delete_Statement_Access is access all Sqlite_Delete_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Sqlite_Delete_Statement; Result : out Natural); -- Create the delete statement function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access; -- ------------------------------ -- Update statement -- ------------------------------ type Sqlite_Update_Statement is new Update_Statement with private; type Sqlite_Update_Statement_Access is access all Sqlite_Update_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Sqlite_Update_Statement); -- Execute the query overriding procedure Execute (Stmt : in out Sqlite_Update_Statement; Result : out Integer); -- Create an update statement function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access; -- ------------------------------ -- Insert statement -- ------------------------------ type Sqlite_Insert_Statement is new Insert_Statement with private; type Sqlite_Insert_Statement_Access is access all Sqlite_Insert_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Sqlite_Insert_Statement; Result : out Integer); -- Create an insert statement. function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access; -- ------------------------------ -- Query statement for SQLite -- ------------------------------ type Sqlite_Query_Statement is new Query_Statement with private; type Sqlite_Query_Statement_Access is access all Sqlite_Query_Statement'Class; -- Execute the query overriding procedure Execute (Query : in out Sqlite_Query_Statement); -- Get the number of rows returned by the query overriding function Get_Row_Count (Query : in Sqlite_Query_Statement) return Natural; -- Returns True if there is more data (row) to fetch overriding function Has_Elements (Query : in Sqlite_Query_Statement) return Boolean; -- Fetch the next row overriding procedure Next (Query : in out Sqlite_Query_Statement); -- Returns true if the column <b>Column</b> is null. overriding function Is_Null (Query : in Sqlite_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. overriding function Get_Int64 (Query : Sqlite_Query_Statement; Column : Natural) return Int64; -- 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. overriding function Get_Unbounded_String (Query : Sqlite_Query_Statement; Column : Natural) return Unbounded_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. overriding function Get_String (Query : Sqlite_Query_Statement; Column : Natural) return String; -- Get the column value at position <b>Column</b> and -- return it as a <b>Blob</b> reference. overriding function Get_Blob (Query : in Sqlite_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 : Sqlite_Query_Statement; Column : Natural) return Ada.Calendar.Time; -- Get the column type -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Column_Type (Query : Sqlite_Query_Statement; Column : Natural) return ADO.Schemas.Column_Type; -- Get the column name. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Column_Name (Query : in Sqlite_Query_Statement; Column : in Natural) return String; -- Get the number of columns in the result. overriding function Get_Column_Count (Query : in Sqlite_Query_Statement) return Natural; -- Deletes the query statement. overriding procedure Finalize (Query : in out Sqlite_Query_Statement); -- Create the query statement. function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access; -- Create the query statement. function Create_Statement (Database : in ADO.Drivers.Connections.Sqlite.Sqlite_Access; Query : in String) return Query_Statement_Access; private type State is (HAS_ROW, HAS_MORE, DONE, ERROR); type Sqlite_Query_Statement is new Query_Statement with record This_Query : aliased ADO.SQL.Query; Connection : ADO.Drivers.Connections.Sqlite.Sqlite_Access; Stmt : ADO.Drivers.Connections.Sqlite.Sqlite_Access := System.Null_Address; Counter : Natural := 1; Status : State := DONE; Max_Column : Natural; end record; type Sqlite_Delete_Statement is new Delete_Statement with record Connection : ADO.Drivers.Connections.Sqlite.Sqlite_Access; Table : ADO.Schemas.Class_Mapping_Access; Delete_Query : aliased ADO.SQL.Query; end record; type Sqlite_Update_Statement is new Update_Statement with record Connection : ADO.Drivers.Connections.Sqlite.Sqlite_Access; This_Query : aliased ADO.SQL.Update_Query; Table : ADO.Schemas.Class_Mapping_Access; end record; type Sqlite_Insert_Statement is new Insert_Statement with record Connection : ADO.Drivers.Connections.Sqlite.Sqlite_Access; This_Query : aliased ADO.SQL.Update_Query; Table : ADO.Schemas.Class_Mapping_Access; end record; end ADO.Statements.Sqlite;
with STM32.F429Z; use STM32.F429Z; use STM32.F429Z.Modules.GPIO; use STM32.F429Z.Modules.USART; use STM32.F429Z.Modules.RCC; with Ada.Real_Time; use Ada.Real_Time; procedure UART_429Disco is UART_Port: GPIO_Registers renames GPIOA; UART_TX_Bit: constant Port_Bit_Number := 9; UART_RX_Bit: constant Port_Bit_Number := 10; APB2_Frequency : constant := 90_000_000; -- Set by board support Baud_Rate : constant := 115_200; Ratio : constant := (APB2_Frequency + Baud_Rate / 2) / Baud_Rate; --Ratio : constant := 128; Period: constant Time_Span := Milliseconds(10); Now: Time := Clock; begin -- clock test --RCC.CFGR.HPRE := AHB_Prescaler_1; --RCC.CFGR.PPRE2 := APB_Prescaler_2; RCC.AHB1ENR.GPIOC := True; RCC.CFGR.MCO2PRE := MCO_Prescaler_5; RCC.CFGR.MCO2 := Clock_Output_2_SYSCLK; GPIOC.OTYPER(9) := Push_Pull_Type; GPIOC.OSPEEDR(9) := Very_High_Speed; GPIOC.AFR(9) := Alternate_Functions.SYS; GPIOC.MODER(9) := Alternate_Mode; RCC.AHB1ENR.GPIOA := True; RCC.APB2ENR.USART1 := True; RCC.APB2RSTR.USART1 := True; RCC.APB2RSTR.USART1 := False; -- UART_Port.OTYPER(UART_TX_Bit) := Push_Pull_Type; UART_Port.OSPEEDR(UART_TX_Bit) := Very_High_Speed; UART_Port.PUPDR(UART_TX_Bit) := Pull_Down; UART_Port.AFR(UART_TX_Bit) := Alternate_Functions.USART1; UART_Port.MODER(UART_TX_Bit) := Alternate_Mode; UART_Port.OTYPER(UART_RX_Bit) := Push_Pull_Type; UART_Port.OSPEEDR(UART_RX_Bit) := Very_High_Speed; UART_Port.PUPDR(UART_RX_Bit) := No_Pull; UART_Port.AFR(UART_RX_Bit) := Alternate_Functions.USART1; UART_Port.MODER(UART_RX_Bit) := Alternate_Mode; -- UART initialisation (close to ST's HAL) USART1.CR1.UE := False; declare CR1: Control_Register_1 := USART1.CR1; begin CR1.M := Word_8_Bits; CR1.PCE := False; CR1.PS := Even_Parity; CR1.TE := True; CR1.RE := True; CR1.OVER8 := False; USART1.CR1 := CR1; end; declare CR3: Control_Register_3 := USART1.CR3; begin CR3.CTSE := False; CR3.RTSE := False; USART1.CR3 := CR3; end; declare BRR: STM32.F429Z.Modules.USART.Baud_Rate_Register := USART1.BRR; begin --USART1.BRR := (DIV_Mantissa: Ratio / 16, DIV_Fraction: Ratio mod 16, others => 0); BRR.DIV_Mantissa := Ratio / 16; BRR.DIV_Fraction := Ratio mod 16; USART1.BRR := BRR; end; declare CR2: Control_Register_2 := USART1.CR2; begin CR2.LINEN := False; CR2.CLKEN := False; CR2.STOP := Stop_1_Bit; USART1.CR2 := CR2; end; declare CR3: Control_Register_3 := USART1.CR3; begin CR3.SCEN := False; CR3.HDSEL := False; CR3.IREN := False; USART1.CR3 := CR3; end; --USART1.GTPR.PSC := 1; USART1.CR1.UE := True; loop USART1.DR := 16#40#; --Character'Pos('!'); Now := Now + Period; delay until Now; end loop; end UART_429Disco;
-- -- Copyright 2021 (C) Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with Ada.Characters.Wide_Wide_Latin_1; with Ada.Exceptions; with Notcurses.Context; with Notcurses.Direct; with Notcurses.Plane; with Notcurses.Progress_Bar; with Notcurses.Channel; with Notcurses.Visual; with Notcurses; package body Tests is procedure Test_Version is begin Ada.Text_IO.Put_Line (Notcurses.Version); end Test_Version; procedure Test_Hello_World is Plane : constant Notcurses.Notcurses_Plane := Notcurses.Plane.Standard_Plane; Context : constant Notcurses.Notcurses_Context := Notcurses.Plane.Context (Plane); begin Notcurses.Plane.Put (Plane, "Hello, world!"); Notcurses.Context.Render (Context); delay 1.0; Notcurses.Plane.Erase (Plane); end Test_Hello_World; procedure Test_Colors is use Notcurses; use Notcurses.Plane; Plane : constant Notcurses_Plane := Standard_Plane; begin Set_Background_RGB (Plane, 0, 0, 255); Set_Foreground_RGB (Plane, 255, 0, 0); Put (Plane, "Red on blue", Y => 0); Set_Background_RGB (Plane, 0, 255, 0); Set_Foreground_RGB (Plane, 255, 255, 255); Put (Plane, "White on green", Y => 1, X => 0); Set_Background_RGB (Plane, 0, 0, 0); Set_Foreground_RGB (Plane, 255, 0, 255); Put (Plane, "Purple on black", Y => 2, X => 0); Notcurses.Context.Render (Notcurses.Plane.Context (Plane)); delay 1.0; Notcurses.Plane.Erase (Plane); end Test_Colors; procedure Test_Palette is use Notcurses; use Notcurses.Plane; use Notcurses.Channel; Plane : constant Notcurses_Plane := Standard_Plane; Context : constant Notcurses_Context := Notcurses.Plane.Context (Plane); Dims : constant Coordinate := Dimensions (Plane); Palette_Size : constant Natural := Notcurses.Context.Palette_Size (Context); Point : Coordinate := (0, 0); Channel : Notcurses_Channel := (Use_Palette => True, Palette => 0, Alpha => Opaque, Not_Default => True); begin for I in 0 .. Palette_Size loop Channel.Palette := Palette_Index (I); Set_Background (Plane, Channel); Put (Plane, " ", Y => Point.Y, X => Point.X); Point.X := Point.X + 1; if Point.X = Dims.X then Point.Y := Point.Y + 1; Point.X := 0; end if; if Point.Y >= Dims.Y then Point.Y := 0; end if; end loop; Notcurses.Context.Render (Context); delay 1.0; Notcurses.Plane.Erase (Plane); end Test_Palette; procedure Test_Dimensions is use Notcurses; use Notcurses.Plane; use Notcurses.Channel; Plane : constant Notcurses_Plane := Standard_Plane; Red : Color_Type := 16#80#; Green : Color_Type := 16#80#; Blue : Color_Type := 16#80#; Dims : constant Coordinate := Dimensions (Plane); begin for Y in 0 .. Dims.Y - 1 loop for X in 0 .. Dims.X - 1 loop Set_Foreground_RGB (Plane, Red, Green, Blue); Set_Background_RGB (Plane, Blue, Red, Green); Put (Plane, "X", Y, X); Blue := Blue + 2; if Blue = Color_Type'Last then Green := Green + 2; if Green = Color_Type'Last then Red := (Red + 2); end if; end if; end loop; end loop; Notcurses.Context.Render (Notcurses.Plane.Context (Plane)); delay 1.0; Notcurses.Plane.Erase (Plane); end Test_Dimensions; procedure Test_Input is use Notcurses; use Notcurses.Plane; use Notcurses.Context; Plane : constant Notcurses_Plane := Standard_Plane; Context : constant Notcurses_Context := Notcurses.Plane.Context (Plane); Dims : constant Coordinate := Dimensions (Plane); Input : Notcurses_Input; begin Set_Background_RGB (Plane, R => 0, G => 0, B => 0); Enable_Cursor (Context, X => 0, Y => 1); Enable_Mouse (Context); loop Set_Foreground_RGB (Plane, R => 0, G => 255, B => 0); Put (Plane, "Press any key for information, ESC to exit", X => 0, Y => 0); Render (Context); Input := Notcurses.Context.Get (Context); Set_Foreground_RGB (Plane, R => 255, G => 255, B => 255); Erase_Region (Plane, Start => (X => 2, Y => 2), Size => (X => Dims.X - 2, Y => Dims.Y - 2)); Put (Plane, "Id:", X => 2, Y => 2); Put (Plane, Input.Id'Wide_Wide_Image, X => 12, Y => 2); Put (Plane, "XY:", X => 2, Y => 3); Put (Plane, Input.X'Wide_Wide_Image & "," & Input.Y'Wide_Wide_Image, X => 11, Y => 3); Put (Plane, "Seqnum:", X => 2, Y => 4); Put (Plane, Input.Seqnum'Wide_Wide_Image, X => 11, Y => 4); -- TODO: the modifiers never seem to be TRUE and sometimes have incorrect values -- if Input.Alt then -- Put (Plane, "ALT", X => 2, Y => 5); -- end if; -- if Input.Shift then -- Put (Plane, "SHIFT", X => 6, Y => 5); -- end if; -- if Input.Ctrl then -- Put (Plane, "CTRL", X => 12, Y => 5); -- end if; Render (Context); exit when Input.Id = Ada.Characters.Wide_Wide_Latin_1.ESC; end loop; end Test_Input; procedure Test_Plane_Split is use Notcurses; use Notcurses.Plane; Left : Notcurses_Plane := Create_Sub_Plane (Plane => Standard_Plane, Position => (0, 0), Size => Dimensions (Standard_Plane)); Right : Notcurses_Plane := Create_Sub_Plane (Plane => Standard_Plane, Position => (X => Dimensions (Standard_Plane).X / 2, Y => 0), Size => (X => Dimensions (Standard_Plane).X / 2, Y => Dimensions (Standard_Plane).Y)); begin Set_Foreground_RGB (Left, 0, 255, 0); Put (Left, "Left"); Set_Foreground_RGB (Right, 255, 0, 0); Put_Aligned (Right, "Right", Align => Notcurses.Plane.Right); Notcurses.Context.Render (Notcurses.Plane.Context (Standard_Plane)); delay 1.0; Destroy (Left); Destroy (Right); Erase (Standard_Plane); end Test_Plane_Split; procedure Test_Progress_Bar is use Notcurses.Progress_Bar; use Notcurses.Plane; use Notcurses; Context : constant Notcurses_Context := Notcurses.Plane.Context (Standard_Plane); Plane : constant Notcurses_Plane := Create_Sub_Plane (Plane => Standard_Plane, Position => (0, 0), Size => (X => Dimensions (Standard_Plane).X, Y => 1)); Bar : Notcurses_Progress_Bar := Create (Plane); begin for I in 1 .. 100 loop Set_Progress (Bar, Progress_Value (Float (I) / 100.0)); delay 0.01; Notcurses.Context.Render (Context); end loop; Destroy (Bar); Erase (Standard_Plane); end Test_Progress_Bar; procedure Test_Direct is use Notcurses.Direct; Plane : Notcurses_Direct; Dims : Notcurses.Coordinate; begin Initialize (Plane); Set_Cursor_Enabled (Plane, False); Dims := Dimensions (Plane); Put (Plane, "Terminal size: (" & Dims.X'Wide_Wide_Image & "," & Dims.Y'Wide_Wide_Image & ")"); New_Line (Plane); Put (Plane, "Red", Foreground => (R => 255, others => <>)); New_Line (Plane); Put (Plane, "Green", Foreground => (G => 255, others => <>)); New_Line (Plane); Put (Plane, "Blue", Foreground => (B => 255, others => <>), Background => (R => 255, G => 255, B => 255, others => <>)); New_Line (Plane); Stop (Plane); exception when E : others => Stop (Plane); Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); end Test_Direct; procedure Test_Visual_File is use Notcurses; use Notcurses.Plane; use Notcurses.Visual; C : constant Notcurses_Context := Notcurses.Plane.Context (Standard_Plane); O : constant Visual_Options := (Scaling => Scale, Plane => Standard_Plane, others => <>); V : constant Notcurses_Visual := From_File ("tests/acidburn.gif"); P : Notcurses_Plane; begin loop Notcurses.Visual.Render (Context => C, Options => O, Visual => V, Plane => P); Notcurses.Context.Render (C); exit when Decode (V) /= Ok; delay 0.1; end loop; Destroy (V); Erase (Standard_Plane); end Test_Visual_File; procedure Test_Visual_Bitmap is use Notcurses; use Notcurses.Plane; use Notcurses.Visual; C : constant Notcurses_Context := Notcurses.Plane.Context (Standard_Plane); O : constant Visual_Options := (Scaling => None, Plane => Standard_Plane, others => <>); Bitmap : RGBA_Bitmap (1 .. 32, 1 .. 128); Pixel : RGBA := (0, 0, 0, 255); Colors : constant array (Natural range <>) of RGBA := ((16#00#, 16#00#, 16#FF#, 16#FF#), (16#00#, 16#FF#, 16#00#, 16#FF#), (16#00#, 16#FF#, 16#FF#, 16#FF#), (16#FF#, 16#00#, 16#00#, 16#FF#), (16#FF#, 16#00#, 16#FF#, 16#FF#), (16#FF#, 16#FF#, 16#00#, 16#FF#), (16#FF#, 16#FF#, 16#FF#, 16#FF#)); I : Natural := Colors'First; V : Notcurses_Visual; P : Notcurses_Plane := Standard_Plane; begin Notcurses.Plane.Set_Foreground_RGB (P, 255, 255, 255); Notcurses.Plane.Set_Background_RGB (P, 0, 0, 0); Notcurses.Plane.Fill (P, ' '); for Y in Bitmap'Range (1) loop for X in Bitmap'Range (2) loop I := (I + 1) mod (Colors'Last + 1); Pixel := Colors (I); Bitmap (Y, X) := Pixel; end loop; end loop; V := From_Bitmap (Bitmap); Render (Context => C, Visual => V, Options => O, Plane => P); Notcurses.Context.Render (C); delay 1.0; Destroy (V); end Test_Visual_Bitmap; procedure Test_Visual_Pixel is use Notcurses; use Notcurses.Visual; Plane : Notcurses_Plane := Notcurses.Plane.Standard_Plane; Context : constant Notcurses_Context := Notcurses.Plane.Context (Plane); begin -- Plane must contain only spaces or block characters before calling From_Plane Notcurses.Plane.Fill (Plane, ' '); Notcurses.Context.Render (Context); declare Visual : constant Notcurses_Visual := From_Plane (Plane => Plane, Blit => Media_Default_Blitter (Context, Scale => None)); Options : constant Visual_Options := (Plane => Plane, Scaling => None, others => <>); Size : constant Coordinate := Dimensions (Context, Visual, Options); Radius : constant Natural := (Integer'Min (Size.X, Size.Y) - 1) / 2; Origin : constant Coordinate := (Y => Radius, X => Radius); Color : constant RGBA := (255, 0, 0, 255); -- http://rosettacode.org/wiki/Bitmap/Midpoint_circle_algorithm#Ada F : Integer := 1 - Radius; ddF_X : Integer := 0; ddF_Y : Integer := (-2) * Radius; X : Integer := 0; Y : Integer := Radius; begin Set (Visual, (Origin.X, Origin.Y + Radius), Color); Set (Visual, (Origin.X, Origin.Y - Radius), Color); Set (Visual, (Origin.X + Radius, Origin.Y), Color); Set (Visual, (Origin.X - Radius, Origin.Y), Color); while X < Y loop if F >= 0 then Y := Y - 1; ddF_Y := ddF_Y + 2; F := F + ddF_Y; end if; X := X + 1; ddF_X := ddF_X + 2; F := F + ddF_X + 1; Set (Visual, (Origin.X + X, Origin.Y + Y), Color); Set (Visual, (Origin.X - X, Origin.Y + Y), Color); Set (Visual, (Origin.X + X, Origin.Y - Y), Color); Set (Visual, (Origin.X - X, Origin.Y - Y), Color); Set (Visual, (Origin.X + Y, Origin.Y + X), Color); Set (Visual, (Origin.X - Y, Origin.Y + X), Color); Set (Visual, (Origin.X + Y, Origin.Y - X), Color); Set (Visual, (Origin.X - Y, Origin.Y - X), Color); end loop; Notcurses.Visual.Render (Context, Visual, Options, Plane); Notcurses.Context.Render (Context); end; delay 1.0; Notcurses.Plane.Erase (Plane); end Test_Visual_Pixel; end Tests;
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ implementation of builtin field types -- -- |___/_|\_\_|_|____| by: Timm Felden -- -- -- pragma Ada_2012; with Ada.Containers; with Ada.Containers.Doubly_Linked_Lists; with Ada.Containers.Hashed_Maps; with Ada.Containers.Hashed_Sets; with Ada.Containers.Vectors; with Skill.Types; with Skill.Hashes; use Skill.Hashes; with Skill.Types.Pools; with Skill.Containers.Arrays; with Skill.Containers.Sets; with Skill.Containers.Maps; package body Skill.Field_Types.Builtin is use type Skill.Types.v64; use type Skill.Types.Uv64; use type Skill.Containers.Boxed_Array; use type Skill.Types.Boxed_List; use type Skill.Containers.Boxed_Set; use type Skill.Types.Boxed_Map; function Offset_Single_V64 (Input : Types.v64) return Types.v64 is function Cast is new Ada.Unchecked_Conversion (Skill.Types.v64, Skill.Types.Uv64); V : constant Skill.Types.Uv64 := Cast (Input); begin if 0 = (V and 16#FFFFFFFFFFFFFF80#) then return 1; elsif 0 = (V and 16#FFFFFFFFFFFFC000#) then return 2; elsif 0 = (V and 16#FFFFFFFFFFE00000#) then return 3; elsif 0 = (V and 16#FFFFFFFFF0000000#) then return 4; elsif 0 = (V and 16#FFFFFFF800000000#) then return 5; elsif 0 = (V and 16#FFFFFC0000000000#) then return 6; elsif 0 = (V and 16#FFFE000000000000#) then return 7; elsif 0 = (V and 16#FF00000000000000#) then return 8; else return 9; end if; end Offset_Single_V64; procedure Insert (This : in out Skill.Containers.Boxed_Array; E : in Types.Box) is begin This.Append (E); end Insert; package body Annotation_Type_P is use type Types.Annotation; procedure Fix_Types (This : access Field_Type_T) is procedure Add (P : Types.Pools.Pool) is begin This.Types_By_Name.Include (P.Skill_Name, P); end Add; begin This.Types.Foreach (Add'Access); end Fix_Types; overriding function Read_Box (This : access Field_Type_T; Input : Streams.Reader.Stream) return Types.Box is T : Types.v64 := Input.V64; Idx : Types.v64 := Input.V64; begin if 0 = T then return Boxed (null); else declare Data : Types.Annotation_Array := This.Types.Element (Integer (T - 1)).Base.Data; begin return Boxed (Data (Integer (Idx))); end; end if; end Read_Box; overriding function Offset_Box (This : access Field_Type_T; Target : Types.Box) return Types.v64 is type T is access all String; function Cast is new Ada.Unchecked_Conversion (T, Types.String_Access); Ref : Types.Annotation := Unboxed (Target); begin if null = Ref then return 2; else return Offset_Single_V64 (Types.v64 (1 + This.Types_By_Name.Element (Ref.Dynamic.Skill_Name).Pool_Offset)) + Offset_Single_V64 (Types.v64 (Ref.Skill_ID)); end if; end Offset_Box; overriding procedure Write_Box (This : access Field_Type_T; Output : Streams.Writer.Sub_Stream; Target : Types.Box) is type T is access all String; function Cast is new Ada.Unchecked_Conversion (T, Types.String_Access); Ref : Types.Annotation := Unboxed (Target); begin if null = Ref then Output.I16 (0); else Output.V64 (Types.v64 (1 + This.Types_By_Name.Element (Ref.Dynamic.Skill_Name).Pool_Offset)); Output.V64 (Types.v64 (Ref.Skill_ID)); end if; end Write_Box; end Annotation_Type_P; package Arrays_P is new Skill.Containers.Arrays (Types.Box); package body Const_Arrays_P is pragma Warnings (Off); function Boxed (This : access Containers.Boxed_Array_T'Class) return Types.Box is type X is access all Containers.Boxed_Array_T'Class; function Cast is new Ada.Unchecked_Conversion (X, Types.Box); begin return Cast (X (This)); end Boxed; function Read_Box (This : access Field_Type_T; Input : Streams.Reader.Stream) return Types.Box is Count : Types.v64 := This.Length; Result : Containers.Boxed_Array := Containers.Boxed_Array (Arrays_P.Make); begin for I in 1 .. Count loop Insert (Result, This.Base.Read_Box (Input)); end loop; return Boxed (Result); end Read_Box; function Offset_Box (This : access Field_Type_T; Target : Types.Box) return Types.v64 is Result : Types.v64 := 0; Count : Natural := Natural (This.Length); begin for I in 1 .. Count loop Result := Result + This.Base.Offset_Box (Unboxed (Target).Get (I - 1)); end loop; return Result; end Offset_Box; procedure Write_Box (This : access Field_Type_T; Output : Streams.Writer.Sub_Stream; Target : Types.Box) is Length : Natural := Natural (This.Length); begin for I in 1 .. Length loop This.Base.Write_Box (Output, Unboxed (Target).Get (I - 1)); end loop; end Write_Box; end Const_Arrays_P; package body Var_Arrays_P is function Read_Box (This : access Field_Type_T; Input : Streams.Reader.Stream) return Types.Box is Count : Types.v64 := Input.V64; Result : Containers.Boxed_Array := Containers.Boxed_Array (Arrays_P.Make); begin for I in 1 .. Count loop Insert (Result, This.Base.Read_Box (Input)); end loop; return Boxed (Result); end Read_Box; function Offset_Box (This : access Field_Type_T; Target : Types.Box) return Types.v64 is Result : Types.v64; Arr : Containers.Boxed_Array := Unboxed (Target); Count : Natural := Natural (Arr.Length); begin if null = Arr then return 1; end if; Result := Offset_Single_V64 (Types.v64 (Count)); for I in 1 .. Count loop Result := Result + This.Base.Offset_Box (Arr.Get (I - 1)); end loop; return Result; end Offset_Box; procedure Write_Box (This : access Field_Type_T; Output : Streams.Writer.Sub_Stream; Target : Types.Box) is Arr : Containers.Boxed_Array := Unboxed (Target); Length : Natural := Natural (Arr.Length); begin if null = Arr then Output.I8 (0); return; end if; Output.V64 (Types.v64 (Length)); for I in 1 .. Length loop This.Base.Write_Box (Output, Arr.Get (I - 1)); end loop; end Write_Box; end Var_Arrays_P; package body List_Type_P is function Read_Box (This : access Field_Type_T; Input : Streams.Reader.Stream) return Types.Box is Count : Types.v64 := Input.V64; Result : Containers.Boxed_Array := Containers.Boxed_Array (Arrays_P.Make); begin for I in 1 .. Count loop Insert (Result, This.Base.Read_Box (Input)); end loop; return Boxed (Result); end Read_Box; function Offset_Box (This : access Field_Type_T; Target : Types.Box) return Types.v64 is Result : Types.v64; Arr : Containers.Boxed_Array := Unboxed (Target); Count : Natural := Natural (Arr.Length); begin if null = Arr then return 1; end if; Result := Offset_Single_V64 (Types.v64 (Count)); for I in 1 .. Count loop Result := Result + This.Base.Offset_Box (Arr.Get (I - 1)); end loop; return Result; end Offset_Box; procedure Write_Box (This : access Field_Type_T; Output : Streams.Writer.Sub_Stream; Target : Types.Box) is Arr : Containers.Boxed_Array := Unboxed (Target); Length : Natural := Natural (Arr.Length); begin if null = Arr then Output.I8 (0); return; end if; Output.V64 (Types.v64 (Length)); for I in 1 .. Length loop This.Base.Write_Box (Output, Arr.Get (I - 1)); end loop; end Write_Box; end List_Type_P; package Sets_P is new Skill.Containers.Sets (Types.Box, Types.Hash, "="); package body Set_Type_P is function Read_Box (This : access Field_Type_T; Input : Streams.Reader.Stream) return Types.Box is Count : Types.v64 := Input.V64; Result : Containers.Boxed_Set := Containers.Boxed_Set (Sets_P.Make); begin for I in 1 .. Count loop Result.Add (This.Base.Read_Box (Input)); end loop; return Boxed (Result); end Read_Box; function Offset_Box (This : access Field_Type_T; Target : Types.Box) return Types.v64 is Result : Types.v64; Set : Containers.Boxed_Set := Unboxed (Target); Count : Natural := Natural (Set.Length); Iter : Containers.Set_Iterator; begin if null = Set then return 1; end if; Result := Offset_Single_V64 (Types.v64 (Count)); Iter := Set.Iterator; while Iter.Has_Next loop Result := Result + This.Base.Offset_Box (Iter.Next); end loop; Iter.Free; return Result; end Offset_Box; procedure Write_Box (This : access Field_Type_T; Output : Streams.Writer.Sub_Stream; Target : Types.Box) is Set : Containers.Boxed_Set := Unboxed (Target); Length : Natural := Natural (Set.Length); Iter : Containers.Set_Iterator; begin if null = Set then Output.I8 (0); return; end if; Output.V64 (Types.v64 (Length)); Iter := Set.Iterator; while Iter.Has_Next loop This.Base.Write_Box (Output, Iter.Next); end loop; Iter.Free; end Write_Box; end Set_Type_P; package Maps_P is new Skill.Containers.Maps(Types.Box, Types.Box, Types.Hash, "=", "="); package body Map_Type_P is function Read_Box (This : access Field_Type_T; Input : Streams.Reader.Stream) return Types.Box is Count : Types.v64 := Input.V64; Result : Types.Boxed_Map := Types.Boxed_Map (Maps_P.Make); K, V : Types.Box; begin for I in 1 .. Count loop K := This.Key.Read_Box (Input); V := This.Value.Read_Box (Input); Result.Update (K, V); end loop; return Boxed (Result); end Read_Box; function Offset_Box (This : access Field_Type_T; Target : Types.Box) return Types.v64 is Map : Containers.Boxed_Map := Unboxed (Target); Iter : Containers.Map_Iterator; Result : Types.v64; Count : Natural := Natural (Map.Length); begin if null = Map or 0 = Count then return 1; end if; Result := Offset_Single_V64 (Types.v64 (Count)); Iter := Map.Iterator; while Iter.Has_Next loop Result := Result + This.Key.Offset_Box (Iter.Key) + This.Value.Offset_Box (Iter.Value); Iter.Advance; end loop; Iter.Free; return Result; end Offset_Box; procedure Write_Box (This : access Field_Type_T; Output : Streams.Writer.Sub_Stream; Target : Types.Box) is Map : Types.Boxed_Map := Unboxed (Target); Iter : Containers.Map_Iterator; Length : Natural := Natural (Map.Length); begin if null = Map or 0 = Length then Output.I8 (0); return; end if; Output.V64 (Types.v64 (Length)); Iter := Map.Iterator; while Iter.Has_Next loop This.Key.Write_Box (Output, Iter.Key); This.Value.Write_Box (Output, Iter.Value); Iter.Advance; end loop; Iter.Free; end Write_Box; end Map_Type_P; end Skill.Field_Types.Builtin;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. with Apsepp.Generic_Array_Operations, Apsepp.Tags; package Apsepp.Test_Node_Class.Testing is type Flattened_Routine_State is record Routine_I : Test_Routine_Count; Assert_C : Test_Assert_Count; Assert_O : Test_Outcome; T : Tag; end record; function "<" (Left, Right : Flattened_Routine_State) return Boolean is (Tags."<" (Left.T, Right.T)); type Routine_State_Array is array (Positive range <>) of Flattened_Routine_State; package Flattened_Routine_State_Array_Operations is new Generic_Array_Operations (Index_Type => Positive, Element_type => Flattened_Routine_State, Array_Type => Routine_State_Array, "<" => "<"); use Flattened_Routine_State_Array_Operations; function To_Array return Routine_State_Array with Post => To_Array'Result'First = 1 and then Monotonic_Incr (To_Array'Result(2 .. To_Array'Result'Last)); private function To_Flattened_Routine_State (T_R_S : Tag_Routine_State) return Flattened_Routine_State is (T => T_R_S.T, Routine_I => T_R_S.S.Routine_Index, Assert_C => Prot_Test_Assert_Count.Val (T_R_S.S.Assert_Count), Assert_O => T_R_S.S.Assert_Outcome); end Apsepp.Test_Node_Class.Testing;
with afrl.impact.AngledAreaSearchTask; with afrl.impact.ImpactLineSearchTask; with afrl.impact.ImpactPointSearchTask; package afrl.cmasi.lmcpTask.SPARK_Boundary with SPARK_Mode is pragma Annotate (GNATprove, Terminating, SPARK_Boundary); -- This package introduces a private type hiding an access to a -- LmcpTask. type Task_Kind is (AngledAreaSearchTask, ImpactLineSearchTask, ImpactPointSearchTask, Other_Task); type Task_Kind_And_Id (Kind : Task_Kind := Other_Task) is record case Kind is when AngledAreaSearchTask => SearchAreaID : Int64; when ImpactLineSearchTask => LineID : Int64; when ImpactPointSearchTask => SearchLocationID : Int64; when Other_Task => null; end case; end record; function Get_Kind_And_Id (X : LmcpTask_Any) return Task_Kind_And_Id with Global => null, SPARK_Mode => Off; private pragma SPARK_Mode (Off); function Get_Kind_And_Id (X : LmcpTask_Any) return Task_Kind_And_Id is (if X.getLmcpTypeName = afrl.impact.AngledAreaSearchTask.Subscription then (Kind => AngledAreaSearchTask, SearchAreaID => afrl.impact.AngledAreaSearchTask.AngledAreaSearchTask (X.all).GetSearchAreaID) elsif X.getLmcpTypeName = afrl.impact.ImpactLineSearchTask.Subscription then (Kind => ImpactLineSearchTask, LineID => afrl.impact.ImpactLineSearchTask.ImpactLineSearchTask (X.all).getLineID) elsif X.getLmcpTypeName = afrl.impact.ImpactPointSearchTask.Subscription then (Kind => ImpactPointSearchTask, SearchLocationId => afrl.impact.ImpactPointSearchTask.ImpactPointSearchTask (X.all).getSearchLocationID) else (Kind => Other_task)); end afrl.cmasi.lmcpTask.SPARK_Boundary;
pragma License (Unrestricted); generic type T (<>) is abstract tagged limited private; type Parameters (<>) is limited private; with function Constructor (Params : not null access Parameters) return T is abstract; function Ada.Tags.Generic_Dispatching_Constructor ( The_Tag : Tag; Params : not null access Parameters) return T'Class with Import, Convention => Intrinsic; pragma Preelaborate (Ada.Tags.Generic_Dispatching_Constructor);
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with League.Strings; with XML.SAX.Attributes; with XML.SAX.Content_Handlers; with XML.Templates.Streams; with Tests.Commands; package Tests.Parser_Data.XML_Reader is type Reader (Data : access Provider) is limited new XML.SAX.Content_Handlers.SAX_Content_Handler with private; function Get_Commands (Self : Reader) return Tests.Commands.Command_Vectors.Vector; private type Reader (Data : access Provider) is limited new XML.SAX.Content_Handlers.SAX_Content_Handler with record Collect_Text : Boolean := False; Collect_XML : Boolean := False; Index : Positive; Text : League.Strings.Universal_String; List : League.String_Vectors.Universal_String_Vector; Commands : Tests.Commands.Command_Vectors.Vector; Vector : XML.Templates.Streams.XML_Stream_Element_Vectors.Vector; end record; overriding procedure Characters (Self : in out Reader; Text : League.Strings.Universal_String; Success : in out Boolean); overriding procedure End_Element (Self : in out Reader; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean); overriding function Error_String (Self : Reader) return League.Strings.Universal_String; overriding procedure Start_Element (Self : in out Reader; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Attributes : XML.SAX.Attributes.SAX_Attributes; Success : in out Boolean); end Tests.Parser_Data.XML_Reader;
pragma License (Unrestricted); -- implementation unit required by compiler with System.Synchronous_Objects; package System.Tasking.Protected_Objects is -- required by compiler subtype Protected_Entry_Index is Entry_Index range Null_Entry .. Max_Entry; subtype Positive_Protected_Entry_Index is Protected_Entry_Index range 1 .. Max_Entry; -- not req type Barrier_Function_Pointer is access function ( O : Address; E : Protected_Entry_Index) return Boolean; type Entry_Action_Pointer is access procedure ( O : Address; P : Address; E : Protected_Entry_Index); -- required by compiler type Entry_Body is record Barrier : Barrier_Function_Pointer; Action : Entry_Action_Pointer; end record; pragma Suppress_Initialization (Entry_Body); -- required for protected object by compiler type Protection is limited record Lock : Synchronous_Objects.RW_Lock; end record; pragma Suppress_Initialization (Protection); procedure Initialize_Protection ( Object : not null access Protection; Ceiling_Priority : Integer); procedure Finalize_Protection (Object : in out Protection); -- required for protected procedure by compiler procedure Lock (Object : not null access Protection); -- required for protected function by compiler procedure Lock_Read_Only (Object : not null access Protection); -- required for protected procedure/function by compiler procedure Unlock (Object : not null access Protection); -- required by compiler (s-taprob.ads) function Get_Ceiling (Object : not null access Protection) return Any_Priority; -- unimplemented subprograms required by compiler -- Set_Ceiling -- protected type be expanded below: -- -- protected type protected1__rwT is -- ... subprograms ... -- end protected1__rwT; -- type protected1__rwTV is limited record -- _object : aliased system__tasking__protected_objects__protection; -- end record; -- procedure protected1__rw__procN (_object : in out protected1__rwTV); -- procedure protected1__rw__procP (_object : in out protected1__rwTV); -- freeze protected1__rwTV [ -- procedure protected1__rwTVIP (_init : in out protected1__rwTV) is -- begin -- $system__tasking__protected_objects__initialize_protection ( -- _init._object'unchecked_access, -- system__tasking__unspecified_priority, objectL => 0); -- return; -- end protected1__rwTVIP; -- ] -- -- procedure protected1___finalizer is -- A24b : constant boolean := $ada__exceptions__triggered_by_abort; -- E25b : ada__exceptions__exception_occurrence; -- R26b : boolean := false; -- begin -- system__soft_links__abort_defer.all; -- if ... initialization is completed ... then -- B27b : begin -- ... finalize components ... -- exception -- when others => -- null; -- end B27b; -- $system__tasking__protected_objects__finalize_protection ( -- protected1__rwTV!(rw)._object); -- end if; -- if R26b and then not A24b then -- $ada__exceptions__raise_from_controlled_operation (E25b); -- end if; -- system__soft_links__abort_undefer.all; -- return; -- end protected1___finalizer; -- -- procedure protected1__rw__procP (_object : in out protected1__rwTV) is -- procedure protected1__rw__procP___finalizer is -- begin -- $system__tasking__protected_objects__unlock (_object._object' -- unchecked_access, objectL => 0); -- system__soft_links__abort_undefer.all; -- return; -- end protected1__rw__procP___finalizer; -- begin -- system__soft_links__abort_defer.all; -- $system__tasking__protected_objects__lock (_object._object' -- unchecked_access, objectL => 0); -- B12b : begin -- protected1__rw__procN (_object); -- at end -- protected1__rw__procP___finalizer; -- end B12b; -- return; -- end protected1__rw__procP; -- suffix N is body of protected subprogram -- suffix P is locking wrapper end System.Tasking.Protected_Objects;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ U N S T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2014-2016, 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. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for unnesting subprograms with Table; with Types; use Types; package Exp_Unst is -- ----------------- -- -- The Problem -- -- ----------------- -- Normally, nested subprograms in the source result in corresponding -- nested subprograms in the resulting tree. We then expect the back end -- to handle such nested subprograms, including all cases of uplevel -- references. For example, the GCC back end can do this relatively easily -- since GNU C (as an extension) allows nested functions with uplevel -- references, and implements an appropriate static chain approach to -- dealing with such uplevel references. -- However, we also want to be able to interface with back ends that do -- not easily handle such uplevel references. One example is the back end -- that translates the tree into standard C source code. In the future, -- other back ends might need the same capability (e.g. a back end that -- generated LLVM intermediate code). -- We could imagine simply handling such references in the appropriate -- back end. For example the back end that generates C could recognize -- nested subprograms and rig up some way of translating them, e.g. by -- making a static-link source level visible. -- Rather than take that approach, we prefer to do a semantics-preserving -- transformation on the GNAT tree, that eliminates the problem before we -- hand the tree over to the back end. There are two reasons for preferring -- this approach: -- First: the work needs only to be done once for all affected back ends -- and we can remain within the semantics of the tree. The front end is -- full of tree transformations, so we have all the infrastructure for -- doing transformations of this type. -- Second: given that the transformation will be semantics-preserving, -- we can still used the standard GCC back end to build code from it. -- This means we can easily run our full test suite to verify that the -- transformations are indeed semantics preserving. It is a lot more -- work to thoroughly test the output of specialized back ends. -- Looking at the problem, we have three situations to deal with. Note -- that in these examples, we use all lower case, since that is the way -- the internal tree is cased. -- First, cases where there are no uplevel references, for example -- procedure case1 is -- function max (m, n : Integer) return integer is -- begin -- return integer'max (m, n); -- end max; -- ... -- end case1; -- Second, cases where there are explicit uplevel references. -- procedure case2 (b : integer) is -- procedure Inner (bb : integer); -- -- procedure inner2 is -- begin -- inner(5); -- end; -- -- x : integer := 77; -- y : constant integer := 15 * 16; -- rv : integer := 10; -- -- procedure inner (bb : integer) is -- begin -- x := rv + y + bb + b; -- end; -- -- begin -- inner2; -- end case2; -- In this second example, B, X, RV are uplevel referenced. Y is not -- considered as an uplevel reference since it is a static constant -- where references are replaced by the value at compile time. -- Third, cases where there are implicit uplevel references via types -- whose bounds depend on locally declared constants or variables: -- function case3 (x, y : integer) return boolean is -- subtype dynam is integer range x .. y + 3; -- subtype static is integer range 42 .. 73; -- xx : dynam := y; -- -- type darr is array (dynam) of Integer; -- type darec is record -- A : darr; -- B : integer; -- end record; -- darecv : darec; -- -- function inner (b : integer) return boolean is -- begin -- return b in dynam and then darecv.b in static; -- end inner; -- -- begin -- return inner (42) and then inner (xx * 3 - y * 2); -- end case3; -- -- In this third example, the membership test implicitly references the -- the bounds of Dynam, which both involve uplevel references. -- ------------------ -- -- The Solution -- -- ------------------ -- Looking at the three cases above, the first case poses no problem at -- all. Indeed the subprogram could have been declared at the outer level -- (perhaps changing the name). But this style is quite common as a way -- of limiting the scope of a local procedure called only within the outer -- procedure. We could move it to the outer level (with a name change if -- needed), but we don't bother. We leave it nested, and the back end just -- translates it as though it were not nested. -- In general we leave nested procedures nested, rather than trying to move -- them to the outer level (the back end may do that, e.g. as part of the -- translation to C, but we don't do it in the tree itself). This saves a -- LOT of trouble in terms of visibility and semantics. -- But of course we have to deal with the uplevel references. The idea is -- to rewrite these nested subprograms so that they no longer have any such -- uplevel references, so by the time they reach the back end, they all are -- case 1 (no uplevel references) and thus easily handled. -- To deal with explicit uplevel references (case 2 above), we proceed with -- the following steps: -- All entities marked as being uplevel referenced are marked as aliased -- since they will be accessed indirectly via an activation record as -- described below. -- An activation record is created containing system address values -- for each uplevel referenced entity in a given scope. In the example -- given before, we would have: -- type AREC1T is record -- b : Address; -- x : Address; -- rv : Address; -- end record; -- type AREC1PT is access all AREC1T; -- AREC1 : aliased AREC1T; -- AREC1P : constant AREC1PT := AREC1'Access; -- The fields of AREC1 are set at the point the corresponding entity -- is declared (immediately for parameters). -- Note: the 1 in all these names is a unique index number. Different -- scopes requiring different ARECnT declarations will have different -- values of n to ensure uniqueness. -- Note: normally the field names in the activation record match the -- name of the entity. An exception is when the entity is declared in -- a declare block, in which case we append the entity number, to avoid -- clashes between the same name declared in different declare blocks. -- For all subprograms nested immediately within the corresponding scope, -- a parameter AREC1F is passed, and all calls to these routines have -- AREC1P added as an additional formal. -- Now within the nested procedures, any reference to an uplevel entity -- xxx is replaced by typ'Deref(AREC1.xxx) where typ is the type of the -- reference. -- Note: the reason that we use Address as the component type in the -- declaration of AREC1T is that we may create this type before we see -- the declaration of this type. -- The following shows example 2 above after this translation: -- procedure case2x (b : aliased Integer) is -- type AREC1T is record -- b : Address; -- x : Address; -- rv : Address; -- end record; -- -- type AREC1PT is access all AREC1T; -- -- AREC1 : aliased AREC1T; -- AREC1P : constant AREC1PT := AREC1'Access; -- -- AREC1.b := b'Address; -- -- procedure inner (bb : integer; AREC1F : AREC1PT); -- -- procedure inner2 (AREC1F : AREC1PT) is -- begin -- inner(5, AREC1F); -- end; -- -- x : aliased integer := 77; -- AREC1.x := X'Address; -- -- y : constant Integer := 15 * 16; -- -- rv : aliased Integer; -- AREC1.rv := rv'Address; -- -- procedure inner (bb : integer; AREC1F : AREC1PT) is -- begin -- Integer'Deref(AREC1F.x) := -- Integer'Deref(AREC1F.rv) + y + b + Integer_Deref(AREC1F.b); -- end; -- -- begin -- inner2 (AREC1P); -- end case2x; -- And now the inner procedures INNER2 and INNER have no uplevel references -- so they have been reduced to case 1, which is the case easily handled by -- the back end. Note that the generated code is not strictly legal Ada -- because of the assignments to AREC1 in the declarative sequence, but the -- GNAT tree always allows such mixing of declarations and statements, so -- the back end must be prepared to handle this in any case. -- Case 3 where we have uplevel references to types is a bit more complex. -- That would especially be the case if we did a full transformation that -- completely eliminated such uplevel references as we did for case 2. But -- instead of trying to do that, we rewrite the subprogram so that the code -- generator can easily detect and deal with these uplevel type references. -- First we distinguish two cases -- Static types are one of the two following cases: -- Discrete types whose bounds are known at compile time. This is not -- quite the same as what is tested by Is_OK_Static_Subtype, in that -- it allows compile time known values that are not static expressions. -- Composite types, whose components are (recursively) static types. -- Dynamic types are one of the two following cases: -- Discrete types with at least one bound not known at compile time. -- Composite types with at least one component that is (recursively) -- a dynamic type. -- Uplevel references to static types are not a problem, the front end -- or the code generator fetches the bounds as required, and since they -- are compile time known values, this value can just be extracted and -- no actual uplevel reference is required. -- Uplevel references to dynamic types are a potential problem, since -- such references may involve an implicit access to a dynamic bound, -- and this reference is an implicit uplevel access. -- To fully unnest such references would be messy, since we would have -- to create local copies of the dynamic types involved, so that the -- front end or code generator could generate an explicit uplevel -- reference to the bound involved. Rather than do that, we set things -- up so that this situation can be easily detected and dealt with when -- there is an implicit reference to the bounds. -- What we do is to always generate a local constant for any dynamic -- bound in a dynamic subtype xx with name xx_FIRST or xx_LAST. The one -- case where we can skip this is where the bound is e.g. in the third -- example above, subtype dynam is expanded as -- dynam_LAST : constant Integer := y + 3; -- subtype dynam is integer range x .. dynam_LAST; -- Now if type dynam is uplevel referenced (as it is this case), then -- the bounds x and dynam_LAST are marked as uplevel references -- so that appropriate entries are made in the activation record. Any -- explicit reference to such a bound in the front end generated code -- will be handled by the normal uplevel reference mechanism which we -- described above for case 2. For implicit references by a back end -- that needs to unnest things, any such implicit reference to one of -- these bounds can be replaced by an appropriate reference to the entry -- in the activation record for xx_FIRST or xx_LAST. Thus the back end -- can eliminate the problematical uplevel reference without the need to -- do the heavy tree modification to do that at the code expansion level -- Looking at case 3 again, here is the normal -gnatG expanded code -- function case3 (x : integer; y : integer) return boolean is -- dynam_LAST : constant integer := y {+} 3; -- subtype dynam is integer range x .. dynam_LAST; -- subtype static is integer range 42 .. 73; -- -- [constraint_error when -- not (y in x .. dynam_LAST) -- "range check failed"] -- -- xx : dynam := y; -- -- type darr is array (x .. dynam_LAST) of integer; -- type darec is record -- a : darr; -- b : integer; -- end record; -- [type TdarrB is array (x .. dynam_LAST range <>) of integer] -- freeze TdarrB [] -- darecv : darec; -- -- function inner (b : integer) return boolean is -- begin -- return b in x .. dynam_LAST and then darecv.b in 42 .. 73; -- end inner; -- begin -- return inner (42) and then inner (xx {*} 3 {-} y {*} 2); -- end case3; -- Note: the actual expanded code has fully qualified names so for -- example function inner is actually function case3__inner. For now -- we ignore that detail to clarify the examples. -- Here we see that some of the bounds references are expanded by the -- front end, so that we get explicit references to y or dynamLast. These -- cases are handled by the normal uplevel reference mechanism described -- above for case 2. This is the case for the constraint check for the -- initialization of xx, and the range check in function inner. -- But the reference darecv.b in the return statement of function -- inner has an implicit reference to the bounds of dynam, since to -- compute the location of b in the record, we need the length of a. -- Here is the full translation of the third example: -- function case3x (x, y : integer) return boolean is -- type AREC1T is record -- x : Address; -- dynam_LAST : Address; -- end record; -- -- type AREC1PT is access all AREC1T; -- -- AREC1 : aliased AREC1T; -- AREC1P : constant AREC1PT := AREC1'Access; -- -- AREC1.x := x'Address; -- -- dynam_LAST : constant integer := y {+} 3; -- AREC1.dynam_LAST := dynam_LAST'Address; -- subtype dynam is integer range x .. dynam_LAST; -- xx : dynam := y; -- -- [constraint_error when -- not (y in x .. dynam_LAST) -- "range check failed"] -- -- subtype static is integer range 42 .. 73; -- -- type darr is array (x .. dynam_LAST) of Integer; -- type darec is record -- A : darr; -- B : integer; -- end record; -- darecv : darec; -- -- function inner (b : integer; AREC1F : AREC1PT) return boolean is -- begin -- return b in x .. Integer'Deref(AREC1F.dynam_LAST) -- and then darecv.b in 42 .. 73; -- end inner; -- -- begin -- return inner (42, AREC1P) and then inner (xx * 3, AREC1P); -- end case3x; -- And now the back end when it processes darecv.b will access the bounds -- of darecv.a by referencing the d and dynam_LAST fields of AREC1P. ----------------------------- -- Multiple Nesting Levels -- ----------------------------- -- In our examples so far, we have only nested to a single level, but the -- scheme generalizes to multiple levels of nesting and in this section we -- discuss how this generalization works. -- Consider this example with two nesting levels -- To deal with elimination of uplevel references, we follow the same basic -- approach described above for case 2, except that we need an activation -- record at each nested level. Basically the rule is that any procedure -- that has nested procedures needs an activation record. When we do this, -- the inner activation records have a pointer (uplink) to the immediately -- enclosing activation record, the normal arrangement of static links. The -- following shows the full translation of this fourth case. -- function case4x (x : integer) return integer is -- type AREC1T is record -- v1 : Address; -- end record; -- -- type AREC1PT is access all AREC1T; -- -- AREC1 : aliased AREC1T; -- AREC1P : constant AREC1PT := AREC1'Access; -- -- v1 : integer := x; -- AREC1.v1 := v1'Address; -- -- function inner1 (y : integer; AREC1F : AREC1PT) return integer is -- type AREC2T is record -- AREC1U : AREC1PT; -- v2 : Address; -- end record; -- -- type AREC2PT is access all AREC2T; -- -- AREC2 : aliased AREC2T; -- AREC2P : constant AREC2PT := AREC2'Access; -- -- AREC2.AREC1U := AREC1F; -- -- v2 : integer := Integer'Deref (AREC1F.v1) {+} 1; -- AREC2.v2 := v2'Address; -- -- function inner2 -- (z : integer; AREC2F : AREC2PT) return integer -- is -- begin -- return integer(z {+} -- Integer'Deref (AREC2F.AREC1U.v1) {+} -- Integer'Deref (AREC2F.v2).all); -- end inner2; -- begin -- return integer(y {+} -- inner2 (Integer'Deref (AREC1F.v1), AREC2P)); -- end inner1; -- begin -- return inner1 (x, AREC1P); -- end case4x; -- As can be seen in this example, the index numbers following AREC in the -- generated names avoid confusion between AREC names at different levels. ------------------------- -- Name Disambiguation -- ------------------------- -- As described above, the translation scheme would raise issues when the -- code generator did the actual unnesting if identically named nested -- subprograms exist. Similarly overloading would cause a naming issue. -- In fact, the expanded code includes qualified names which eliminate this -- problem. We omitted the qualification from the exapnded examples above -- for simplicity. But to see this in action, consider this example: -- function Mnames return Boolean is -- procedure Inner is -- procedure Inner is -- begin -- null; -- end; -- begin -- Inner; -- end; -- function F (A : Boolean) return Boolean is -- begin -- return not A; -- end; -- function F (A : Integer) return Boolean is -- begin -- return A > 42; -- end; -- begin -- Inner; -- return F (42) or F (True); -- end; -- The expanded code actually looks like: -- function mnames return boolean is -- procedure mnames__inner is -- procedure mnames__inner__inner is -- begin -- null; -- return; -- end mnames__inner__inner; -- begin -- mnames__inner__inner; -- return; -- end mnames__inner; -- function mnames__f (a : boolean) return boolean is -- begin -- return not a; -- end mnames__f; -- function mnames__f__2 (a : integer) return boolean is -- begin -- return a > 42; -- end mnames__f__2; -- begin -- mnames__inner; -- return mnames__f__2 (42) or mnames__f (true); -- end mnames; -- As can be seen from studying this example, the qualification deals both -- with the issue of clashing names (mnames__inner, mnames__inner__inner), -- and with overloading (mnames__f, mnames__f__2). -- In addition, the declarations of ARECnT and ARECnPT get moved to the -- outer level when we actually generate C code, so we suffix these names -- with the corresponding entity name to make sure they are unique. --------------------------- -- Terminology for Calls -- --------------------------- -- The level of a subprogram in the nest being analyzed is defined to be -- the level of nesting, so the outer level subprogram (the one passed to -- Unnest_Subprogram) is 1, subprograms immediately nested within this -- outer level subprogram have a level of 2, etc. -- Calls within the nest being analyzed are of three types: -- Downward call: this is a call from a subprogram to a subprogram that -- is immediately nested with in the caller, and thus has a level that -- is one greater than the caller. It is a fundamental property of the -- nesting structure and visibility that it is not possible to make a -- call from level N to level M, where M is greater than N + 1. -- Parallel call: this is a call from a nested subprogram to another -- nested subprogram that is at the same level. -- Upward call: this is a call from a subprogram to a subprogram that -- encloses the caller. The level of the callee is less than the level -- of the caller, and there is no limit on the difference, e.g. for an -- uplevel call, a subprogram at level 5 can call one at level 2 or even -- the outer level subprogram at level 1. ----------- -- Subps -- ----------- -- Table to record subprograms within the nest being currently analyzed. -- Entries in this table are made for each subprogram expanded, and do not -- get cleared as we complete the expansion, since we want the table info -- around in Cprint for the actual unnesting operation. Subps_First in this -- unit records the starting entry in the table for the entries for Subp -- and this is also recorded in the Subps_Index field of the outer level -- subprogram in the nest. The last subps index for the nest can be found -- in the Subp_Entry Last field of this first entry. subtype SI_Type is Nat; -- Index type for the table Subps_First : SI_Type; -- Record starting index for entries in the current nest (this is the table -- index of the entry for Subp itself, and is recorded in the Subps_Index -- field of the entity for this subprogram). type Subp_Entry is record Ent : Entity_Id; -- Entity of the subprogram Bod : Node_Id; -- Subprogram_Body node for this subprogram Lev : Nat; -- Subprogram level (1 = outer subprogram (Subp argument), 2 = nested -- immediately within this outer subprogram etc.) Reachable : Boolean; -- This flag is set True if there is a call path from the outer level -- subprogram to this subprogram. If Reachable is False, it means that -- the subprogram is declared but not actually referenced. We remove -- such subprograms from the tree, which simplifies our task, because -- we don't have to worry about e.g. uplevel references from such an -- unreferenced subpogram, which might require (useless) activation -- records to be created. This is computed by setting the outer level -- subprogram (Subp itself) as reachable, and then doing a transitive -- closure following all calls. Uplevel_Ref : Nat; -- The outermost level which defines entities which this subprogram -- references either directly or indirectly via a call. This cannot -- be greater than Lev. If it is equal to Lev, then it means that the -- subprogram does not make any uplevel references and that thus it -- does not need an activation record pointer passed. If it is less than -- Lev, then an activation record pointer is needed, since there is at -- least one uplevel reference. This is computed by initially setting -- Uplevel_Ref to Lev for all subprograms. Then on the initial tree -- traversal, decreasing Uplevel_Ref for an explicit uplevel reference, -- and finally by doing a transitive closure that follows calls (if A -- calls B and B has an uplevel reference to level X, then A references -- level X indirectly). Declares_AREC : Boolean; -- This is set True for a subprogram which include the declarations -- for a local activation record to be passed on downward calls. It -- is set True for the target level of an uplevel reference, and for -- all intervening nested subprograms. For example, if a subprogram X -- at level 5 makes an uplevel reference to an entity declared in a -- level 2 subprogram, then the subprograms at levels 4,3,2 enclosing -- the level 5 subprogram will have this flag set True. Uents : Elist_Id; -- This is a list of entities declared in this subprogram which are -- uplevel referenced. It contains both objects (which will be put in -- the corresponding AREC activation record), and types. The types are -- not put in the AREC activation record, but referenced bounds (i.e. -- generated _FIRST and _LAST entites, and formal parameters) will be -- in the list in their own right. Last : SI_Type; -- This field is set only in the entry for the outer level subprogram -- in a nest, and records the last index in the Subp table for all the -- entries for subprograms in this nest. ARECnF : Entity_Id; -- This entity is defined for all subprograms which need an extra formal -- that contains a pointer to the activation record needed for uplevel -- references. ARECnF must be defined for any subprogram which has a -- direct or indirect uplevel reference (i.e. Reference_Level < Lev). ARECn : Entity_Id; ARECnT : Entity_Id; ARECnPT : Entity_Id; ARECnP : Entity_Id; -- These AREC entities are defined only for subprograms for which we -- generate an activation record declaration, i.e. for subprograms for -- which the Declares_AREC flag is set True. ARECnU : Entity_Id; -- This AREC entity is the uplink component. It is other than Empty only -- for nested subprograms that declare an activation record as indicated -- by Declares_AREC being Ture, and which have uplevel references (Lev -- greater than Uplevel_Ref). It is the additional component in the -- activation record that references the ARECnF pointer (which points -- the activation record one level higher, thus forming the chain). end record; package Subps is new Table.Table ( Table_Component_Type => Subp_Entry, Table_Index_Type => SI_Type, Table_Low_Bound => 1, Table_Initial => 1000, Table_Increment => 200, Table_Name => "Unnest_Subps"); -- Records the subprograms in the nest whose outer subprogram is Subp ----------------- -- Subprograms -- ----------------- function Get_Level (Subp : Entity_Id; Sub : Entity_Id) return Nat; -- Sub is either Subp itself, or a subprogram nested within Subp. This -- function returns the level of nesting (Subp = 1, subprograms that -- are immediately nested within Subp = 2, etc.). function Subp_Index (Sub : Entity_Id) return SI_Type; -- Given the entity for a subprogram, return corresponding Subp's index procedure Unnest_Subprograms (N : Node_Id); -- Called to unnest subprograms. If we are in unnest subprogram mode, this -- is the call that traverses the tree N and locates all the library level -- subprograms with nested subprograms to process them. end Exp_Unst;
private with STM32_SVD.COMP; package STM32.COMP is type Comparator is limited private; procedure Enable (This : in out Comparator) with Post => Enabled (This); procedure Disable (This : in out Comparator) with Post => not Enabled (This); function Enabled (This : Comparator) return Boolean; type I_Input_Port is (One_Quarter_Vrefint, One_Half_Vrefint, Three_Quarter_Vrefint, Vrefint, DAC_CH1, DAC_CH2, Option_7, Option_8); -- These bits allows to select the source connected to the inverting input -- of the comparator. The first 6 options are common, the last 2 options -- change for each comparator: -- Option COMP1 COMP2 -- 7 PB1 PE10 -- 8 PC4 PE7 -- See RM0433 rev 7 chapter 24.3.2 pg 1094 Table 233: COMP input/output -- internal signals and Table 234: COMP input/output pins. procedure Set_I_Input_Port (This : in out Comparator; Input : I_Input_Port) with Post => Get_I_Input_Port (This) = Input; -- Select the source connected to the inverting input of the comparator. -- See RM0433 rev 7 chapter 24.3.2 pg 1094 Table 233: COMP input/output -- internal signals and Table 234: COMP input/output pins. function Get_I_Input_Port (This : Comparator) return I_Input_Port; -- Return the source connected to the inverting input of the comparator. type NI_Input_Port is (Option_1, Option_2); -- These bits allows to select the source connected to the non-inverting -- input of the comparator: -- Option COMP1 COMP2 -- 1 PB0 PE9 -- 2 PB2 PE11 -- See RM0433 rev 7 chapter 24.3.2 pg 1094 Table 233: COMP input/output -- internal signals and Table 234: COMP input/output pins. procedure Set_NI_Input_Port (This : in out Comparator; Input : NI_Input_Port) with Post => Get_NI_Input_Port (This) = Input; -- Select the source connected to the non-inverting input of the comparator. -- See RM0433 rev 7 chapter 24.3.2 pg 1094 Table 233: COMP input/output -- internal signals and Table 234: COMP input/output pins. function Get_NI_Input_Port (This : Comparator) return NI_Input_Port; -- Return the source connected to the non-inverting input of the comparator. type Output_Polarity is (Not_Inverted, Inverted); -- This bit is used to invert the comparator output. procedure Set_Output_Polarity (This : in out Comparator; Output : Output_Polarity) with Post => Get_Output_Polarity (This) = Output; -- Used to invert the comparator output. function Get_Output_Polarity (This : Comparator) return Output_Polarity; -- Return the comparator output polarity. type Comparator_Hysteresis is (No_Hysteresis, Low_Hysteresis, Medium_Hysteresis, High_Hysteresis); -- These bits select the hysteresis of the comparator. procedure Set_Comparator_Hysteresis (This : in out Comparator; Value : Comparator_Hysteresis) with Post => Get_Comparator_Hysteresis (This) = Value; -- Select the comparator hysteresis value. function Get_Comparator_Hysteresis (This : Comparator) return Comparator_Hysteresis; -- Return the comparator hysteresis value. type Output_Blanking is (No_Blanking, TIM1_OC5, TIM2_OC3, TIM3_OC3, TIM3_OC4, TIM8_OC5, TIM15_OC1) with Size => 4; -- These bits select which Timer output controls the comparator output -- blanking. -- See RM0433 rev 7 chapter 24.3.2 pg 1094 Table 233: COMP input/output -- internal signals procedure Set_Output_Blanking (This : in out Comparator; Output : Output_Blanking) with Post => Get_Output_Blanking (This) = Output; -- Select which Timer output controls the comparator output blanking. function Get_Output_Blanking (This : Comparator) return Output_Blanking; -- Return which Timer output controls the comparator output blanking. procedure Set_Vrefint_Scaler_Resistor (This : in out Comparator; Enabled : Boolean) with Post => Get_Vrefint_Scaler_Resistor (This) = Enabled; -- Enables the operation of resistor bridge in the VREFINT scaler. To -- disable the resistor bridge, BRGEN bits of all COMP_CxCSR registers must -- be set to Disable state. When the resistor bridge is disabled, the 1/4 -- VREFINT, 1/2 VREFINT, and 3/4 VREFINT inputs of the input selector -- receive VREFINT voltage. function Get_Vrefint_Scaler_Resistor (This : Comparator) return Boolean; -- Return True if VREFINT resistor bridge is enabled. procedure Set_Vrefint_Scaler (This : in out Comparator; Enabled : Boolean) with Post => Get_Vrefint_Scaler (This) = Enabled; -- Enables the operation of VREFINT scaler at the inverting input of all -- comparator. To disable the VREFINT scaler, SCALEN bits of all COMP_CxCSR -- registers must be set to Disable state. When the VREFINT scaler is -- disabled, the 1/4 VREFINT, 1/2 VREFINT, 3/4 VREFINT and VREFINT inputs -- of the multiplexer should not be selected. function Get_Vrefint_Scaler (This : Comparator) return Boolean; -- Return True if VREFINT scaler is enabled. type Comparator_Output is (Low, High); function Get_Comparator_Output (This : Comparator) return Comparator_Output; -- Read the comparator output before the polarity selector and blanking: -- Low = non-inverting input is below inverting input, -- High = (non-inverting input is above inverting input type AF_Port_Source is (PA6, PA8, PB12, PE6, PE15, PG2, PG3, PG4, PI1, PI4, PK2) with Size => 4; procedure Set_AF_Port_Source (This : Comparator; Port : AF_Port_Source); type COMP_Power_Mode is (High_Speed, Medium_Speed_1, Medium_Speed_2, Very_Low_Speed); procedure Set_Power_Mode (This : in out Comparator; Mode : COMP_Power_Mode); type Init_Parameters is record Input_Minus : I_Input_Port; Input_Plus : NI_Input_Port; Output_Pol : Output_Polarity; Hysteresis : Comparator_Hysteresis; Blanking_Source : Output_Blanking; Power_Mode : COMP_Power_Mode; end record; procedure Configure_Comparator (This : in out Comparator; Param : Init_Parameters); type COMP_Status_Flag is (Comparator_Output_Value, Interrupt_Indicated); function Status (This : Comparator; Flag : COMP_Status_Flag) return Boolean; procedure Enable_Interrupt (This : in out Comparator) with Inline, Post => Interrupt_Enabled (This); procedure Disable_Interrupt (This : in out Comparator) with Inline, Post => not Interrupt_Enabled (This); function Interrupt_Enabled (This : Comparator) return Boolean with Inline; procedure Clear_Interrupt_Pending (This : in out Comparator) with Inline; procedure Set_Lock_Comparator (This : in out Comparator) with Post => Get_Lock_Comparator (This) = True; -- Allows to have COMPx_CFGR and COMP_OR registers as read-only. It can -- only be cleared by a system reset. function Get_Lock_Comparator (This : Comparator) return Boolean; -- Return the comparator lock bit state. private ----------------- -- Peripherals -- ----------------- -- representation for the whole Comparator type ----------------- type Comparator is record CFGR : STM32_SVD.COMP.CFGR1_Register; end record with Volatile, Size => 1 * 32; for Comparator use record CFGR at 16#00# range 0 .. 31; end record; end STM32.COMP;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- A D A . I N T E R R U P T S . N A M E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2012-2017, 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Xilinx Ultrascale+ MPSoC version of this package pragma Restrictions (No_Elaboration_Code); package Ada.Interrupts.Names is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; -- Software Generated Interrupts (SGI) SGI_0 : constant Interrupt_ID := 0; -- Reserved by the runtime SGI_1 : constant Interrupt_ID := 1; SGI_2 : constant Interrupt_ID := 2; SGI_3 : constant Interrupt_ID := 3; SGI_4 : constant Interrupt_ID := 4; SGI_5 : constant Interrupt_ID := 5; SGI_6 : constant Interrupt_ID := 6; SGI_7 : constant Interrupt_ID := 7; SGI_8 : constant Interrupt_ID := 8; SGI_9 : constant Interrupt_ID := 9; SGI_10 : constant Interrupt_ID := 10; SGI_11 : constant Interrupt_ID := 11; SGI_12 : constant Interrupt_ID := 12; SGI_13 : constant Interrupt_ID := 13; SGI_14 : constant Interrupt_ID := 14; SGI_15 : constant Interrupt_ID := 15; -- Private Peripheral Interrupts (PPI) Virtual_Maintenance_Interrupt : constant Interrupt_ID := 25; Hypervisor_Timer_Interrupt : constant Interrupt_ID := 26; Virtual_Timer_Interrupt : constant Interrupt_ID := 27; Legacy_FIQ_Interrupt : constant Interrupt_ID := 28; Secure_Physical_Timer_Interrupt : constant Interrupt_ID := 29; Non_Secure_Physical_Time_Interrupt : constant Interrupt_ID := 30; Legacy_IRQ_Interrupt : constant Interrupt_ID := 31; -- System Interrupts RPU0_AMP_Interrupt : constant Interrupt_ID := 40; RPU1_AMP_Interrupt : constant Interrupt_ID := 41; OCM_Interrupt : constant Interrupt_ID := 42; LPD_APB_Interrupt : constant Interrupt_ID := 43; RPU0_ECC_Interrupt : constant Interrupt_ID := 44; RPU1_ECC_Interrupt : constant Interrupt_ID := 45; NAND_Interrupt : constant Interrupt_ID := 46; QSPI_Interrupt : constant Interrupt_ID := 47; GPIO_Interrupt : constant Interrupt_ID := 48; I2C0_Interrupt : constant Interrupt_ID := 49; I2C1_Interrupt : constant Interrupt_ID := 50; SPI0_Interrupt : constant Interrupt_ID := 51; SPI1_Interrupt : constant Interrupt_ID := 52; UART0_Interrupt : constant Interrupt_ID := 53; UART1_Interrupt : constant Interrupt_ID := 54; CAN0_Interrupt : constant Interrupt_ID := 55; CAN1_Interrupt : constant Interrupt_ID := 56; LPD_APM_Interrupt : constant Interrupt_ID := 57; RTC_Alarm_Interrupt : constant Interrupt_ID := 58; RTC_Seconds_Interrupt : constant Interrupt_ID := 59; ClkMon_Interrupt : constant Interrupt_ID := 60; IPI_Ch7_Interrupt : constant Interrupt_ID := 61; IPI_Ch8_Interrupt : constant Interrupt_ID := 62; IPI_Ch9_Interrupt : constant Interrupt_ID := 63; IPI_Ch10_Interrupt : constant Interrupt_ID := 64; IPI_Ch2_Interrupt : constant Interrupt_ID := 65; IPI_Ch1_Interrupt : constant Interrupt_ID := 66; IPI_Ch0_Interrupt : constant Interrupt_ID := 67; TTC0_0_Interrupt : constant Interrupt_ID := 68; TTC0_1_Interrupt : constant Interrupt_ID := 69; TTC0_2_Interrupt : constant Interrupt_ID := 70; TTC1_0_Interrupt : constant Interrupt_ID := 71; TTC1_1_Interrupt : constant Interrupt_ID := 72; TTC1_2_Interrupt : constant Interrupt_ID := 73; TTC2_0_Interrupt : constant Interrupt_ID := 74; TTC2_1_Interrupt : constant Interrupt_ID := 75; TTC2_2_Interrupt : constant Interrupt_ID := 76; TTC3_0_Interrupt : constant Interrupt_ID := 77; TTC3_1_Interrupt : constant Interrupt_ID := 78; TTC3_2_Interrupt : constant Interrupt_ID := 79; SDIO0_Interrupt : constant Interrupt_ID := 80; SDIO1_Interrupt : constant Interrupt_ID := 81; SDIO0_Wakeup_Interrupt : constant Interrupt_ID := 82; SDIO1_Wakeup_Interrupt : constant Interrupt_ID := 83; LPD_SWDT_Interrupt : constant Interrupt_ID := 84; CSU_SWDT_Interrupt : constant Interrupt_ID := 85; LPD_ATB_Interrupt : constant Interrupt_ID := 86; AIB_Interrupt : constant Interrupt_ID := 87; SysMon_Interrupt : constant Interrupt_ID := 88; GEM0_Interrupt : constant Interrupt_ID := 89; GEM0_Wakeup_Interrupt : constant Interrupt_ID := 90; GEM1_Interrupt : constant Interrupt_ID := 91; GEM1_Wakeup_Interrupt : constant Interrupt_ID := 92; GEM2_Interrupt : constant Interrupt_ID := 93; GEM2_Wakeup_Interrupt : constant Interrupt_ID := 94; GEM3_Interrupt : constant Interrupt_ID := 95; GEM3_Wakeup_Interrupt : constant Interrupt_ID := 96; USB0_Endpoint0_Interrupt : constant Interrupt_ID := 97; USB0_Endpoint1_Interrupt : constant Interrupt_ID := 98; USB0_Endpoint2_Interrupt : constant Interrupt_ID := 99; USB0_Endpoint3_Interrupt : constant Interrupt_ID := 100; USB0_OTG_Interrupt : constant Interrupt_ID := 101; USB1_Endpoint0_Interrupt : constant Interrupt_ID := 102; USB1_Endpoint1_Interrupt : constant Interrupt_ID := 103; USB1_Endpoint2_Interrupt : constant Interrupt_ID := 104; USB1_Endpoint3_Interrupt : constant Interrupt_ID := 105; USB1_OTG_Interrupt : constant Interrupt_ID := 106; USB0_Wakeup_Interrupt : constant Interrupt_ID := 107; USB1_Wakeup_Interrupt : constant Interrupt_ID := 108; LPD_DMA_Ch0_Interrupt : constant Interrupt_ID := 109; LPD_DMA_Ch1_Interrupt : constant Interrupt_ID := 110; LPD_DMA_Ch2_Interrupt : constant Interrupt_ID := 111; LPD_DMA_Ch3_Interrupt : constant Interrupt_ID := 112; LPD_DMA_Ch4_Interrupt : constant Interrupt_ID := 113; LPD_DMA_Ch5_Interrupt : constant Interrupt_ID := 114; LPD_DMA_Ch6_Interrupt : constant Interrupt_ID := 115; LPD_DMA_Ch7_Interrupt : constant Interrupt_ID := 116; CSU_Interrupt : constant Interrupt_ID := 117; CSU_DMA_Interrupt : constant Interrupt_ID := 118; eFuse_Interrupt : constant Interrupt_ID := 119; XPPU_Interrupt : constant Interrupt_ID := 120; PL_PS_0_Interrupt : constant Interrupt_ID := 121; PL_PS_1_Interrupt : constant Interrupt_ID := 122; PL_PS_2_Interrupt : constant Interrupt_ID := 123; PL_PS_3_Interrupt : constant Interrupt_ID := 124; PL_PS_4_Interrupt : constant Interrupt_ID := 125; PL_PS_5_Interrupt : constant Interrupt_ID := 126; PL_PS_6_Interrupt : constant Interrupt_ID := 127; PL_PS_7_Interrupt : constant Interrupt_ID := 128; -- 7 reserved interrupts from 129 to 135 PL_PS_8_Interrupt : constant Interrupt_ID := 136; PL_PS_9_Interrupt : constant Interrupt_ID := 137; PL_PS_10_Interrupt : constant Interrupt_ID := 138; PL_PS_11_Interrupt : constant Interrupt_ID := 139; PL_PS_12_Interrupt : constant Interrupt_ID := 140; PL_PS_13_Interrupt : constant Interrupt_ID := 141; PL_PS_14_Interrupt : constant Interrupt_ID := 142; PL_PS_15_Interrupt : constant Interrupt_ID := 143; DDR_Interrupt : constant Interrupt_ID := 144; FPD_SWDT_Interrupt : constant Interrupt_ID := 145; PCIe_MSI0_Interrupt : constant Interrupt_ID := 146; PCIe_MSI1_Interrupt : constant Interrupt_ID := 147; PCIe_INTx_Interrupt : constant Interrupt_ID := 148; PCIe_DMA_Interrupt : constant Interrupt_ID := 149; PCIe_MSC_Interrupt : constant Interrupt_ID := 150; DisplayPort_Interrupt : constant Interrupt_ID := 151; FPD_APB_Interrupt : constant Interrupt_ID := 152; FPD_DTB_Interrupt : constant Interrupt_ID := 153; DPDMA_Interrupt : constant Interrupt_ID := 154; FPD_ATM_Interrupt : constant Interrupt_ID := 155; FPD_DMA_Ch0_Interrupt : constant Interrupt_ID := 156; FPD_DMA_Ch1_Interrupt : constant Interrupt_ID := 157; FPD_DMA_Ch2_Interrupt : constant Interrupt_ID := 158; FPD_DMA_Ch3_Interrupt : constant Interrupt_ID := 159; FPD_DMA_Ch4_Interrupt : constant Interrupt_ID := 160; FPD_DMA_Ch5_Interrupt : constant Interrupt_ID := 161; FPD_DMA_Ch6_Interrupt : constant Interrupt_ID := 162; FPD_DMA_Ch7_Interrupt : constant Interrupt_ID := 163; GPU_Interrupt : constant Interrupt_ID := 164; SATA_Interrupt : constant Interrupt_ID := 165; FPD_XMPU_Interrupt : constant Interrupt_ID := 166; APU_VCPUMNT_0_Interrupt : constant Interrupt_ID := 167; APU_VCPUMNT_1_Interrupt : constant Interrupt_ID := 168; APU_VCPUMNT_2_Interrupt : constant Interrupt_ID := 169; APU_VCPUMNT_3_Interrupt : constant Interrupt_ID := 170; CPU_CTI_0_Interrupt : constant Interrupt_ID := 171; CPU_CTI_1_Interrupt : constant Interrupt_ID := 172; CPU_CTI_2_Interrupt : constant Interrupt_ID := 173; CPU_CTI_3_Interrupt : constant Interrupt_ID := 174; PMU_Comm_0_Interrupt : constant Interrupt_ID := 175; PMU_Comm_1_Interrupt : constant Interrupt_ID := 176; PMU_Comm_2_Interrupt : constant Interrupt_ID := 177; PMU_Comm_3_Interrupt : constant Interrupt_ID := 178; APU_Comm_0_Interrupt : constant Interrupt_ID := 179; APU_Comm_1_Interrupt : constant Interrupt_ID := 180; APU_Comm_2_Interrupt : constant Interrupt_ID := 181; APU_Comm_3_Interrupt : constant Interrupt_ID := 182; L2_Cache_Interrupt : constant Interrupt_ID := 183; APU_ExtError_Interrupt : constant Interrupt_ID := 184; APU_RegError_Interrupt : constant Interrupt_ID := 185; CCI_Interrupt : constant Interrupt_ID := 186; SMMU_Interrupt : constant Interrupt_ID := 187; end Ada.Interrupts.Names;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <denkpadje@gmail.com> -- -- 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. private with Ada.Finalization; private with Orka.Atomics; package Orka.Jobs is pragma Preelaborate; type Job is limited interface; type Job_Ptr is not null access all Job'Class; type Execution_Context is limited interface; procedure Enqueue (Object : Execution_Context; Element : Job_Ptr) is abstract; procedure Execute (Object : Job; Context : Execution_Context'Class) is abstract; -- Execute the job. The job can insert extra jobs between itself and its -- Dependent by calling the Enqueue procedure function Dependent (Object : Job) return Job_Ptr is abstract; -- Return a pointer to the job (if there is any) that depends on this job function Decrement_Dependencies (Object : in out Job) return Boolean is abstract; -- Decrement the number of dependencies (jobs) that still need to be -- executed. Return True if all have been executed, False if there is -- at least one job that still needs to run. -- -- When this function returns True, this job can and should be scheduled. function Has_Dependencies (Object : Job) return Boolean is abstract; type Dependency_Array is array (Positive range <>) of Job_Ptr; procedure Set_Dependency (Object : access Job; Dependency : Job_Ptr) is abstract; -- Set a job as the dependency of the given job. Object becomes the -- dependent (successor) job of Dependency -- -- J2.Set_Dependency (J1) creates the link J1 --> J2 procedure Set_Dependencies (Object : access Job; Dependencies : Dependency_Array) is abstract; -- Set some jobs as dependencies of the given job. Object becomes -- the dependent (successor) job of each job in Dependencies -- -- J4.Set_Dependencies ((J1, J2, J3)) gives: -- -- J1 -- -- \ -- J2 ---> J4 -- / -- J3 -- procedure Chain (Jobs : Dependency_Array); -- Create a chain of jobs such that each job is a dependency of the -- next job -- -- Chain ((J1, J2, J3)) will result in: -- -- J1 --> J2 --> J3 -- -- where J1 is the first job that will be executed and J3 the last job. ----------------------------------------------------------------------------- Null_Job : constant Job_Ptr; function Get_Null_Job return Job_Ptr is (Null_Job); -- A function that is used when a non-static constant (Null_Job) is -- needed in a preelaborated unit procedure Free (Pointer : in out Job_Ptr) with Pre => Pointer /= Null_Job; function Create_Empty_Job return Job_Ptr; ----------------------------------------------------------------------------- type Parallel_Job is interface and Job; type Parallel_Job_Ptr is not null access all Parallel_Job'Class; procedure Set_Range (Object : in out Parallel_Job; From, To : Positive) is abstract; procedure Execute (Object : Parallel_Job; Context : Execution_Context'Class; From, To : Positive) is abstract; -- Any job which inherits Abstract_Parallel_Job needs to override this -- procedure instead of the regular Execute procedure type Parallel_Job_Cloner is not null access function (Job : Parallel_Job_Ptr; Length : Positive) return Dependency_Array; function Parallelize (Job : Parallel_Job_Ptr; Clone : Parallel_Job_Cloner; Length, Slice : Positive) return Job_Ptr; -- Parallelize a job by returning a new job that will enqueue multiple -- instances of the given job with different ranges -- -- Length is the total number of elements and Slice is the maximum range -- of a slice. For example, Length => 24 and Slice => 6 will spawn 4 jobs -- with the ranges 1..6, 7..12, 13..18, and 19..24. ----------------------------------------------------------------------------- type Abstract_Job is abstract new Job with private; type Abstract_Parallel_Job is abstract new Abstract_Job and Parallel_Job with private; overriding procedure Execute (Object : Abstract_Parallel_Job; Context : Execution_Context'Class); overriding procedure Set_Range (Object : in out Abstract_Parallel_Job; From, To : Positive); ----------------------------------------------------------------------------- type GPU_Job is interface and Job; private type No_Job is new Job with null record; overriding procedure Execute (Object : No_Job; Context : Execution_Context'Class); overriding function Dependent (Object : No_Job) return Job_Ptr is (Null_Job); overriding function Decrement_Dependencies (Object : in out No_Job) return Boolean is (False); overriding function Has_Dependencies (Object : No_Job) return Boolean is (False); overriding procedure Set_Dependency (Object : access No_Job; Dependency : Job_Ptr) is null; overriding procedure Set_Dependencies (Object : access No_Job; Dependencies : Dependency_Array) is null; Null_Job : constant Job_Ptr := new No_Job; ----------------------------------------------------------------------------- subtype Zero_Counter is Atomics.Counter (Initial_Value => 0); type Zero_Counter_Access is access Zero_Counter; type Counter_Controlled is new Ada.Finalization.Controlled with record Counter : Zero_Counter_Access := new Zero_Counter; end record; overriding procedure Adjust (Object : in out Counter_Controlled); overriding procedure Finalize (Object : in out Counter_Controlled); type Abstract_Job is abstract new Job with record Dependent : Job_Ptr := Null_Job; Dependencies : Counter_Controlled; end record; overriding function Dependent (Object : Abstract_Job) return Job_Ptr is (Object.Dependent); overriding function Decrement_Dependencies (Object : in out Abstract_Job) return Boolean; overriding function Has_Dependencies (Object : Abstract_Job) return Boolean; overriding procedure Set_Dependency (Object : access Abstract_Job; Dependency : Job_Ptr); overriding procedure Set_Dependencies (Object : access Abstract_Job; Dependencies : Dependency_Array); ----------------------------------------------------------------------------- type Empty_Job is new Abstract_Job with null record; overriding procedure Execute (Object : Empty_Job; Context : Execution_Context'Class) is null; function Create_Empty_Job return Job_Ptr is (new Empty_Job); ----------------------------------------------------------------------------- type Parallel_For_Job is new Abstract_Job with record Length, Slice : Positive; Job : Parallel_Job_Ptr; Clone : Parallel_Job_Cloner; end record with Dynamic_Predicate => not Parallel_For_Job.Job.Has_Dependencies; overriding procedure Execute (Object : Parallel_For_Job; Context : Execution_Context'Class); type Abstract_Parallel_Job is abstract new Abstract_Job and Parallel_Job with record From, To : Positive; end record; end Orka.Jobs;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <contact@flyx.org> -- -- 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; private with GL.Low_Level; package GL.Context is pragma Preelaborate; procedure Flush; type String_List is array (Positive range <>) of Ada.Strings.Unbounded.Unbounded_String; type Reset_Status is (No_Error, Guilty, Innocent, Unknown); function Status return Reset_Status; -- Return the reset status of the context -- -- If the context has been created with the Robust context flag -- enabled, then any OpenGL function may raise a Context_Lost_Error -- when a reset has occurred. -- -- If a context has been lost, it must be recreated, including any -- OpenGL objects. This function will return a status not equal to -- No_Error while the context is still resetting and No_Error when -- the reset has been completed. type Context_Flags is record Forward_Compatible : Boolean := False; Debug : Boolean := False; Robust_Access : Boolean := False; No_Error : Boolean := False; end record; function Flags return Context_Flags; type Context_Reset_Notification is (Lose_Context_On_Reset, No_Reset_Notification); function Reset_Notification return Context_Reset_Notification; type Context_Release_Behavior is (None, Flush); function Release_Behavior return Context_Release_Behavior; function Major_Version return Natural; function Minor_Version return Natural; -- These two require OpenGL 3 function Version_String return String; -- Legacy (deprecated in OpenGL 3) function Vendor return String; function Renderer return String; function Extensions return String_List; function Has_Extension (Extensions : String_List; Name : String) return Boolean; -- Uses OpenGL 3 interface function Primary_Shading_Language_Version return String; function Supported_Shading_Language_Versions return String_List; function Supports_Shading_Language_Version (Versions : String_List; Name : String) return Boolean; -- Available since OpenGL 4.3 private for Reset_Status use (No_Error => 0, Guilty => 16#8253#, Innocent => 16#8254#, Unknown => 16#8255#); for Reset_Status'Size use Low_Level.Enum'Size; for Context_Flags use record Forward_Compatible at 0 range 0 .. 0; Debug at 0 range 1 .. 1; Robust_Access at 0 range 2 .. 2; No_Error at 0 range 3 .. 3; end record; for Context_Flags'Size use Low_Level.Bitfield'Size; for Context_Reset_Notification use (Lose_Context_On_Reset => 16#8252#, No_Reset_Notification => 16#8261#); for Context_Reset_Notification'Size use Low_Level.Enum'Size; for Context_Release_Behavior use (None => 0, Flush => 16#82FC#); for Context_Release_Behavior'Size use Low_Level.Enum'Size; end GL.Context;
with Interfaces; use Interfaces; with Interfaces.EFM32.CMU; use Interfaces.EFM32.CMU; with Interfaces.EFM32.GPIO; use Interfaces.EFM32.GPIO; package Leds is type Bit is mod 2**1 with Size => 1; type Color is (Blue, Green, Cyan, Red, Magenta, Yellow, White, Black); type Pin_Type is (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15); type Led_No is (LED0, LED1); type Port_Type is (PA, PB, PC, PD, PE, PF); procedure Led_Init; procedure Led_Set (LED : Led_No; Led_Color : Color); procedure Blink(LED: Led_No; Led_Color : Color); procedure GPIO_Tgl_Pin(Port : Port_Type; Pin : Pin_Type); procedure GPIO_Set_Pin(Port : Port_Type; Pin : Pin_Type); procedure GPIO_Clr_Pin(Port : Port_Type; Pin : Pin_Type); end Leds;
-- Gonzalo Martin Rodriguez -- Ivan Fernandez Samaniego with Priorities; use Priorities; with devices; use devices; with Ada.Interrupts.Names; with System; use System; package State is task Display is pragma Priority (Display_Priority); end Display; task Risks is pragma Priority (Risk_Priority); end Risks; task Sporadic_Task is pragma Priority (Sporadic_Priority); end Sporadic_Task; protected Operation_Mode is pragma Priority (Risk_Priority); procedure Write_Mode (Value: in integer); procedure Read_Mode (Value: out integer); private Mode: integer := 1; end Operation_Mode; protected Interruption_Handler is pragma Priority (System.Interrupt_Priority'First + 10); procedure Validate_Entry; pragma Attach_Handler (Validate_Entry, Ada.Interrupts.Names.External_Interrupt_2); entry Change_Mode; private Enter: Boolean := False; end Interruption_Handler; end State;
-- Copyright 2017 Steven Stewart-Gallus -- -- 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 Linted.Mod_Atomics; package Linted.Sched with Spark_Mode is pragma Preelaborate; type Contention_T is mod 2**32 with Default_Value => 0; package Contention_Atomics is new Mod_Atomics (Contention_T); subtype Contention is Contention_Atomics.Atomic; type Backoff_State is mod 2**32 with Default_Value => 0; procedure Backoff (State : in out Backoff_State) with Inline_Always, Global => null, Depends => (State => State); procedure Success (C : in out Contention) with Inline_Always, Global => null, Depends => (C => C); procedure Backoff (C : in out Contention) with Inline_Always, Global => (null), Depends => (C => C); procedure Backoff (C : in out Contention; Highly_Contended : out Boolean) with Inline_Always, Global => (null), Depends => ((Highly_Contended, C) => C); procedure Pause; pragma Import (Intrinsic, Pause, "__builtin_ia32_pause"); end Linted.Sched;
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- package Ada.Numerics is pragma Pure (Numerics); Argument_Error : exception; Pi : constant := 3.14159_26535_89793_23846_26433_83279_50288_41971_69399_37511; π : constant := Pi; e : constant := 2.71828_18284_59045_23536_02874_71352_66249_77572_47093_69996; end Ada.Numerics;
with XML; private with Ada.Finalization; package Serialization.XML is pragma Preelaborate; type Reference_Type ( Serializer : not null access Serialization.Serializer) is limited private; function Reading (Reader : not null access Standard.XML.Reader; Tag : String) return Reference_Type; function Writing (Writer : not null access Standard.XML.Writer; Tag : String) return Reference_Type; private type Serializer_Access is access Serializer; type XML_Reader; type XML_Reader_Access is access XML_Reader; type XML_Writer; type XML_Writer_Access is access XML_Writer; type Reference_Type ( Serializer : not null access Serializer) is limited new Ada.Finalization.Limited_Controlled with record Serializer_Body : Serializer_Access; Reader_Body : XML_Reader_Access; Writer_Body : XML_Writer_Access; end record; overriding procedure Finalize (Object : in out Reference_Type); -- reading type XML_Reader is limited new Serialization.Reader with record Reader : not null access Standard.XML.Reader; Next_Kind : Stream_Element_Kind; Next_Name : Ada.Strings.Unbounded.String_Access; Next_Value : Ada.Strings.Unbounded.String_Access; Next_Next_Name : Ada.Strings.Unbounded.String_Access; Level : Natural; end record; overriding function Next_Kind (Object : not null access XML_Reader) return Stream_Element_Kind; overriding function Next_Name (Object : not null access XML_Reader) return not null access constant String; overriding function Next_Value (Object : not null access XML_Reader) return not null access constant String; overriding procedure Advance ( Object : not null access XML_Reader; Position : in State); -- writing type XML_Writer is limited new Serialization.Writer with record Writer : not null access Standard.XML.Writer; Level : Natural; end record; overriding procedure Put ( Object : not null access XML_Writer; Name : in String; Item : in String); overriding procedure Enter_Mapping ( Object : not null access XML_Writer; Name : in String); overriding procedure Leave_Mapping (Object : not null access XML_Writer); overriding procedure Enter_Sequence ( Object : not null access XML_Writer; Name : in String); overriding procedure Leave_Sequence (Object : not null access XML_Writer); end Serialization.XML;
pragma License (Unrestricted); generic type Table_Component_Type is private; type Table_Index_Type is range <>; Table_Low_Bound : Table_Index_Type; Table_Initial : Positive; Table_Increment : Natural; pragma Unreferenced (Table_Increment); package GNAT.Dynamic_Tables is package Implementation is subtype Index_Type is Table_Index_Type range Table_Low_Bound .. Table_Index_Type'Last; end Implementation; type Table_Type is array (Implementation.Index_Type range <>) of Table_Component_Type; type Table_Ptr is access Table_Type; type Instance is record Table : aliased Table_Ptr := null; Last_Index : Implementation.Index_Type'Base := Table_Low_Bound - 1; end record; procedure Init (T : in out Instance); function Last (T : Instance) return Table_Index_Type; procedure Free (T : in out Instance); First : constant Table_Index_Type := Table_Low_Bound; procedure Set_Last (T : in out Instance; New_Val : Table_Index_Type); procedure Append (T : in out Instance; New_Val : Table_Component_Type); end GNAT.Dynamic_Tables;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt package AdaBase.Interfaces.Logger is type iLogger is interface; procedure reaction (listener : iLogger) is null; end AdaBase.Interfaces.Logger;
function Is_Perfect(N : Positive) return Boolean is Sum : Natural := 0; begin for I in 1..N - 1 loop if N mod I = 0 then Sum := Sum + I; end if; end loop; return Sum = N; end Is_Perfect;
with STM32_SVD; use STM32_SVD; with STM32_SVD.GPIO; with STM32_SVD.USB; use STM32_SVD.USB; with STM32_SVD.RCC; with Ada.Interrupts.Names; with Ada.Text_IO; package body STM32GD.USB.Peripheral is procedure Init is begin STM32_SVD.RCC.RCC_Periph.APB1ENR.USBEN := 1; STM32_SVD.RCC.RCC_Periph.APB1RSTR.USBRST := 1; STM32_SVD.RCC.RCC_Periph.APB1RSTR.USBRST:= 0; USB_Periph.CNTR.FRES := 1; USB_Periph.CNTR := ( CTRM => 1, WKUPM => 1, RESETM => 1, SUSPM => 1, Reserved_5_7 => 0, Reserved_16_31 => 0, others => 0 ); end Init; procedure Handle_Reset is BTable_Offset : Integer := 0; begin Ada.Text_IO.Put_Line ("Reset"); USB_Periph.DADDR.ADD := 0; USB_Periph.DADDR.EF := 1; BTable_Offset := EP0_Reset_Callback (BTable_Offset); BTable_Offset := EP1_Reset_Callback (BTable_Offset); BTable_Offset := EP2_Reset_Callback (BTable_Offset); BTable_Offset := EP3_Reset_Callback (BTable_Offset); BTable_Offset := EP4_Reset_Callback (BTable_Offset); BTable_Offset := EP5_Reset_Callback (BTable_Offset); BTable_Offset := EP6_Reset_Callback (BTable_Offset); BTable_Offset := EP7_Reset_Callback (BTable_Offset); end Handle_Reset; protected body Handler is procedure IRQ_Handler is begin if USB_Periph.ISTR.CTR = 1 then USB_Periph.ISTR.CTR := 0; Ada.Text_IO.Put_Line ("Control"); case USB_Periph.ISTR.EP_ID is when 0 => EP0_Handler_Callback (USB_Periph.ISTR.DIR = 1); when others => EP0_Handler_Callback (USB_Periph.ISTR.DIR = 1); end case; elsif USB_Periph.ISTR.RESET = 1 then USB_Periph.ISTR.RESET := 0; Handle_Reset; elsif USB_Periph.ISTR.WKUP = 1 then USB_Periph.ISTR.WKUP := 0; USB_Periph.CNTR := ( CTRM => 1, WKUPM => 1, RESETM => 1, SUSPM => 1, Reserved_5_7 => 0, Reserved_16_31 => 0, others => 0 ); Ada.Text_IO.Put_Line ("Wakeup"); elsif USB_Periph.ISTR.SUSP = 1 then USB_Periph.ISTR.SUSP := 0; USB_Periph.CNTR.LPMODE := 1; USB_Periph.CNTR.FSUSP := 1; Ada.Text_IO.Put_Line ("Suspend"); end if; end IRQ_Handler; end Handler; end STM32GD.USB.Peripheral;
with Interfaces; generic Resistor_Value : Unsigned_32 := 10_000; NTC_Is_Upper : Boolean := True; Beta : Positive := 3976; V_In_Max : Unsigned_32 := 2 ** 10 - 1; package Drivers.NTC is pragma Preelaborate; function Value (V : Positive) return Unsigned_32; function Temperature (V : Positive) return Integer; end Drivers.NTC;
pragma License (Unrestricted); -- runtime unit package System.Formatting.Address is pragma Pure; subtype Address_String is String (1 .. (Standard'Address_Size + 3) / 4); procedure Image ( Value : System.Address; Item : out Address_String; Set : Type_Set := Upper_Case); procedure Value ( Item : Address_String; Result : out System.Address; Error : out Boolean); end System.Formatting.Address;
-- -- Comment for <code>Main</code> procedure. -- @author Andrea Lucarelli -- with Ada.Text_Io; -- With package Text_Io use Ada.Text_Io; -- Use components procedure Main is Count : Integer; -- Declaration of count begin Count := 10; -- Set to 10 while Count > 0 loop -- loop while greater than 0 if Count = 3 then -- If 3 print Ignition Put("Ignition"); New_Line; end if; Put( Integer'Image( Count ) ); -- Print current count New_Line; Count := Count - 1; -- Decrement by 1 count delay 1.0; -- Wait 1 second end loop; Put("Blast off"); New_Line; -- Print Blast off end Main;
package body Plunderer is task body PlundererTask is targetIndex: Natural; target: pNodeObj; n: Natural := nodes'Length; exitTask: Boolean := False; begin loop select accept Stop do exitTask := True; end Stop; else SleepForSomeTime(maxSleep, intervals); -- pick a node targetIndex := RAD.Next(n); target := nodes(targetIndex); -- setup a trap target.all.nodeTask.all.SetupTrap; end select; if exitTask then exit; end if; end loop; end PlundererTask; end Plunderer;
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package body WebIDL.Lexers is procedure Initialize (Self : in out Lexer'Class; Text : League.String_Vectors.Universal_String_Vector) is begin Self.Handler.Initialize; Self.Source.Set_String_Vector (Text); Self.Scanner.Set_Source (Self.Source'Unchecked_Access); Self.Scanner.Set_Handler (Self.Handler'Unchecked_Access); end Initialize; ---------------- -- Next_Token -- ---------------- overriding procedure Next_Token (Self : in out Lexer; Value : out WebIDL.Tokens.Token) is begin Self.Scanner.Get_Token (Value); end Next_Token; end WebIDL.Lexers;
package Linker_Section is Data1 : constant String := "12345678901234567"; pragma Linker_Section (Entity => Data1, Section => ".eeprom"); type EEPROM_String is new String; pragma Linker_Section (Entity => EEPROM_String, Section => ".eeprom"); Data2 : constant EEPROM_String := "12345678901234567"; package Inner is end; pragma Linker_Section (Entity => Inner, -- { dg-error "objects" } Section => ".eeprom"); end Linker_Section;
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32H743x.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package STM32_SVD.AXI is pragma Preelaborate; --------------- -- Registers -- --------------- subtype AXI_PERIPH_ID_4_JEP106CON_Field is HAL.UInt4; subtype AXI_PERIPH_ID_4_KCOUNT4_Field is HAL.UInt4; -- AXI interconnect - peripheral ID4 register type AXI_PERIPH_ID_4_Register is record -- Read-only. JEP106 continuation code JEP106CON : AXI_PERIPH_ID_4_JEP106CON_Field; -- Read-only. Register file size KCOUNT4 : AXI_PERIPH_ID_4_KCOUNT4_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_PERIPH_ID_4_Register use record JEP106CON at 0 range 0 .. 3; KCOUNT4 at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_PERIPH_ID_0_PARTNUM_Field is HAL.UInt8; -- AXI interconnect - peripheral ID0 register type AXI_PERIPH_ID_0_Register is record -- Read-only. Peripheral part number bits 0 to 7 PARTNUM : AXI_PERIPH_ID_0_PARTNUM_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_PERIPH_ID_0_Register use record PARTNUM at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_PERIPH_ID_1_PARTNUM_Field is HAL.UInt4; subtype AXI_PERIPH_ID_1_JEP106I_Field is HAL.UInt4; -- AXI interconnect - peripheral ID1 register type AXI_PERIPH_ID_1_Register is record -- Read-only. Peripheral part number bits 8 to 11 PARTNUM : AXI_PERIPH_ID_1_PARTNUM_Field; -- Read-only. JEP106 identity bits 0 to 3 JEP106I : AXI_PERIPH_ID_1_JEP106I_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_PERIPH_ID_1_Register use record PARTNUM at 0 range 0 .. 3; JEP106I at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_PERIPH_ID_2_JEP106ID_Field is HAL.UInt3; subtype AXI_PERIPH_ID_2_REVISION_Field is HAL.UInt4; -- AXI interconnect - peripheral ID2 register type AXI_PERIPH_ID_2_Register is record -- Read-only. JEP106 Identity bits 4 to 6 JEP106ID : AXI_PERIPH_ID_2_JEP106ID_Field; -- Read-only. JEP106 code flag JEDEC : Boolean; -- Read-only. Peripheral revision number REVISION : AXI_PERIPH_ID_2_REVISION_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_PERIPH_ID_2_Register use record JEP106ID at 0 range 0 .. 2; JEDEC at 0 range 3 .. 3; REVISION at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_PERIPH_ID_3_CUST_MOD_NUM_Field is HAL.UInt4; subtype AXI_PERIPH_ID_3_REV_AND_Field is HAL.UInt4; -- AXI interconnect - peripheral ID3 register type AXI_PERIPH_ID_3_Register is record -- Read-only. Customer modification CUST_MOD_NUM : AXI_PERIPH_ID_3_CUST_MOD_NUM_Field; -- Read-only. Customer version REV_AND : AXI_PERIPH_ID_3_REV_AND_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_PERIPH_ID_3_Register use record CUST_MOD_NUM at 0 range 0 .. 3; REV_AND at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_COMP_ID_0_PREAMBLE_Field is HAL.UInt8; -- AXI interconnect - component ID0 register type AXI_COMP_ID_0_Register is record -- Read-only. Preamble bits 0 to 7 PREAMBLE : AXI_COMP_ID_0_PREAMBLE_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_COMP_ID_0_Register use record PREAMBLE at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_COMP_ID_1_PREAMBLE_Field is HAL.UInt4; subtype AXI_COMP_ID_1_CLASS_Field is HAL.UInt4; -- AXI interconnect - component ID1 register type AXI_COMP_ID_1_Register is record -- Read-only. Preamble bits 8 to 11 PREAMBLE : AXI_COMP_ID_1_PREAMBLE_Field; -- Read-only. Component class CLASS : AXI_COMP_ID_1_CLASS_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_COMP_ID_1_Register use record PREAMBLE at 0 range 0 .. 3; CLASS at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_COMP_ID_2_PREAMBLE_Field is HAL.UInt8; -- AXI interconnect - component ID2 register type AXI_COMP_ID_2_Register is record -- Read-only. Preamble bits 12 to 19 PREAMBLE : AXI_COMP_ID_2_PREAMBLE_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_COMP_ID_2_Register use record PREAMBLE at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype AXI_COMP_ID_3_PREAMBLE_Field is HAL.UInt8; -- AXI interconnect - component ID3 register type AXI_COMP_ID_3_Register is record -- Read-only. Preamble bits 20 to 27 PREAMBLE : AXI_COMP_ID_3_PREAMBLE_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_COMP_ID_3_Register use record PREAMBLE at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG1_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG1_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix functionality 2 register type AXI_TARG1_FN_MOD2_Register is record -- Disable packing of beats to match the output data width BYPASS_MERGE : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG1_FN_MOD2_Register use record BYPASS_MERGE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - TARG x long burst functionality modification type AXI_TARG1_FN_MOD_LB_Register is record -- Controls burst breaking of long bursts FN_MOD_LB : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG1_FN_MOD_LB_Register use record FN_MOD_LB at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - TARG x long burst functionality modification type AXI_TARG1_FN_MOD_Register is record -- Override AMIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override AMIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG1_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG2_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG2_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix functionality 2 register type AXI_TARG2_FN_MOD2_Register is record -- Disable packing of beats to match the output data width BYPASS_MERGE : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG2_FN_MOD2_Register use record BYPASS_MERGE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - TARG x long burst functionality modification type AXI_TARG2_FN_MOD_LB_Register is record -- Controls burst breaking of long bursts FN_MOD_LB : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG2_FN_MOD_LB_Register use record FN_MOD_LB at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - TARG x long burst functionality modification type AXI_TARG2_FN_MOD_Register is record -- Override AMIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override AMIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG2_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG3_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG3_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG4_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG4_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG5_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG5_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG6_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG6_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix issuing functionality register type AXI_TARG7_FN_MOD_ISS_BM_Register is record -- READ_ISS_OVERRIDE READ_ISS_OVERRIDE : Boolean := False; -- Switch matrix write issuing override for target WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG7_FN_MOD_ISS_BM_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - TARG x bus matrix functionality 2 register type AXI_TARG7_FN_MOD2_Register is record -- Disable packing of beats to match the output data width BYPASS_MERGE : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG7_FN_MOD2_Register use record BYPASS_MERGE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - TARG x long burst functionality modification type AXI_TARG7_FN_MOD_Register is record -- Override AMIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override AMIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_TARG7_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - INI x functionality modification 2 register type AXI_INI1_FN_MOD2_Register is record -- Disables alteration of transactions by the up-sizer unless required -- by the protocol BYPASS_MERGE : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI1_FN_MOD2_Register use record BYPASS_MERGE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - INI x AHB functionality modification register type AXI_INI1_FN_MOD_AHB_Register is record -- Converts all AHB-Lite write transactions to a series of single beat -- AXI RD_INC_OVERRIDE : Boolean := False; -- Converts all AHB-Lite read transactions to a series of single beat -- AXI WR_INC_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI1_FN_MOD_AHB_Register use record RD_INC_OVERRIDE at 0 range 0 .. 0; WR_INC_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype AXI_INI1_READ_QOS_AR_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x read QoS register type AXI_INI1_READ_QOS_Register is record -- Read channel QoS setting AR_QOS : AXI_INI1_READ_QOS_AR_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI1_READ_QOS_Register use record AR_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype AXI_INI1_WRITE_QOS_AW_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x write QoS register type AXI_INI1_WRITE_QOS_Register is record -- Write channel QoS setting AW_QOS : AXI_INI1_WRITE_QOS_AW_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI1_WRITE_QOS_Register use record AW_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- AXI interconnect - INI x issuing functionality modification register type AXI_INI1_FN_MOD_Register is record -- Override ASIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override ASIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI1_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype AXI_INI2_READ_QOS_AR_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x read QoS register type AXI_INI2_READ_QOS_Register is record -- Read channel QoS setting AR_QOS : AXI_INI2_READ_QOS_AR_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI2_READ_QOS_Register use record AR_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype AXI_INI2_WRITE_QOS_AW_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x write QoS register type AXI_INI2_WRITE_QOS_Register is record -- Write channel QoS setting AW_QOS : AXI_INI2_WRITE_QOS_AW_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI2_WRITE_QOS_Register use record AW_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- AXI interconnect - INI x issuing functionality modification register type AXI_INI2_FN_MOD_Register is record -- Override ASIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override ASIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI2_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- AXI interconnect - INI x functionality modification 2 register type AXI_INI3_FN_MOD2_Register is record -- Disables alteration of transactions by the up-sizer unless required -- by the protocol BYPASS_MERGE : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#2#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI3_FN_MOD2_Register use record BYPASS_MERGE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- AXI interconnect - INI x AHB functionality modification register type AXI_INI3_FN_MOD_AHB_Register is record -- Converts all AHB-Lite write transactions to a series of single beat -- AXI RD_INC_OVERRIDE : Boolean := False; -- Converts all AHB-Lite read transactions to a series of single beat -- AXI WR_INC_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI3_FN_MOD_AHB_Register use record RD_INC_OVERRIDE at 0 range 0 .. 0; WR_INC_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype AXI_INI3_READ_QOS_AR_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x read QoS register type AXI_INI3_READ_QOS_Register is record -- Read channel QoS setting AR_QOS : AXI_INI3_READ_QOS_AR_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI3_READ_QOS_Register use record AR_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype AXI_INI3_WRITE_QOS_AW_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x write QoS register type AXI_INI3_WRITE_QOS_Register is record -- Write channel QoS setting AW_QOS : AXI_INI3_WRITE_QOS_AW_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI3_WRITE_QOS_Register use record AW_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- AXI interconnect - INI x issuing functionality modification register type AXI_INI3_FN_MOD_Register is record -- Override ASIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override ASIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI3_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype AXI_INI4_READ_QOS_AR_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x read QoS register type AXI_INI4_READ_QOS_Register is record -- Read channel QoS setting AR_QOS : AXI_INI4_READ_QOS_AR_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI4_READ_QOS_Register use record AR_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype AXI_INI4_WRITE_QOS_AW_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x write QoS register type AXI_INI4_WRITE_QOS_Register is record -- Write channel QoS setting AW_QOS : AXI_INI4_WRITE_QOS_AW_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI4_WRITE_QOS_Register use record AW_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- AXI interconnect - INI x issuing functionality modification register type AXI_INI4_FN_MOD_Register is record -- Override ASIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override ASIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI4_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype AXI_INI5_READ_QOS_AR_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x read QoS register type AXI_INI5_READ_QOS_Register is record -- Read channel QoS setting AR_QOS : AXI_INI5_READ_QOS_AR_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI5_READ_QOS_Register use record AR_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype AXI_INI5_WRITE_QOS_AW_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x write QoS register type AXI_INI5_WRITE_QOS_Register is record -- Write channel QoS setting AW_QOS : AXI_INI5_WRITE_QOS_AW_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI5_WRITE_QOS_Register use record AW_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- AXI interconnect - INI x issuing functionality modification register type AXI_INI5_FN_MOD_Register is record -- Override ASIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override ASIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI5_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype AXI_INI6_READ_QOS_AR_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x read QoS register type AXI_INI6_READ_QOS_Register is record -- Read channel QoS setting AR_QOS : AXI_INI6_READ_QOS_AR_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI6_READ_QOS_Register use record AR_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype AXI_INI6_WRITE_QOS_AW_QOS_Field is HAL.UInt4; -- AXI interconnect - INI x write QoS register type AXI_INI6_WRITE_QOS_Register is record -- Write channel QoS setting AW_QOS : AXI_INI6_WRITE_QOS_AW_QOS_Field := 16#4#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI6_WRITE_QOS_Register use record AW_QOS at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- AXI interconnect - INI x issuing functionality modification register type AXI_INI6_FN_MOD_Register is record -- Override ASIB read issuing capability READ_ISS_OVERRIDE : Boolean := False; -- Override ASIB write issuing capability WRITE_ISS_OVERRIDE : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for AXI_INI6_FN_MOD_Register use record READ_ISS_OVERRIDE at 0 range 0 .. 0; WRITE_ISS_OVERRIDE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- AXI interconnect registers type AXI_Peripheral is record -- AXI interconnect - peripheral ID4 register AXI_PERIPH_ID_4 : aliased AXI_PERIPH_ID_4_Register; -- AXI interconnect - peripheral ID0 register AXI_PERIPH_ID_0 : aliased AXI_PERIPH_ID_0_Register; -- AXI interconnect - peripheral ID1 register AXI_PERIPH_ID_1 : aliased AXI_PERIPH_ID_1_Register; -- AXI interconnect - peripheral ID2 register AXI_PERIPH_ID_2 : aliased AXI_PERIPH_ID_2_Register; -- AXI interconnect - peripheral ID3 register AXI_PERIPH_ID_3 : aliased AXI_PERIPH_ID_3_Register; -- AXI interconnect - component ID0 register AXI_COMP_ID_0 : aliased AXI_COMP_ID_0_Register; -- AXI interconnect - component ID1 register AXI_COMP_ID_1 : aliased AXI_COMP_ID_1_Register; -- AXI interconnect - component ID2 register AXI_COMP_ID_2 : aliased AXI_COMP_ID_2_Register; -- AXI interconnect - component ID3 register AXI_COMP_ID_3 : aliased AXI_COMP_ID_3_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG1_FN_MOD_ISS_BM : aliased AXI_TARG1_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix functionality 2 register AXI_TARG1_FN_MOD2 : aliased AXI_TARG1_FN_MOD2_Register; -- AXI interconnect - TARG x long burst functionality modification AXI_TARG1_FN_MOD_LB : aliased AXI_TARG1_FN_MOD_LB_Register; -- AXI interconnect - TARG x long burst functionality modification AXI_TARG1_FN_MOD : aliased AXI_TARG1_FN_MOD_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG2_FN_MOD_ISS_BM : aliased AXI_TARG2_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix functionality 2 register AXI_TARG2_FN_MOD2 : aliased AXI_TARG2_FN_MOD2_Register; -- AXI interconnect - TARG x long burst functionality modification AXI_TARG2_FN_MOD_LB : aliased AXI_TARG2_FN_MOD_LB_Register; -- AXI interconnect - TARG x long burst functionality modification AXI_TARG2_FN_MOD : aliased AXI_TARG2_FN_MOD_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG3_FN_MOD_ISS_BM : aliased AXI_TARG3_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG4_FN_MOD_ISS_BM : aliased AXI_TARG4_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG5_FN_MOD_ISS_BM : aliased AXI_TARG5_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG6_FN_MOD_ISS_BM : aliased AXI_TARG6_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix issuing functionality register AXI_TARG7_FN_MOD_ISS_BM : aliased AXI_TARG7_FN_MOD_ISS_BM_Register; -- AXI interconnect - TARG x bus matrix functionality 2 register AXI_TARG7_FN_MOD2 : aliased AXI_TARG7_FN_MOD2_Register; -- AXI interconnect - TARG x long burst functionality modification AXI_TARG7_FN_MOD : aliased AXI_TARG7_FN_MOD_Register; -- AXI interconnect - INI x functionality modification 2 register AXI_INI1_FN_MOD2 : aliased AXI_INI1_FN_MOD2_Register; -- AXI interconnect - INI x AHB functionality modification register AXI_INI1_FN_MOD_AHB : aliased AXI_INI1_FN_MOD_AHB_Register; -- AXI interconnect - INI x read QoS register AXI_INI1_READ_QOS : aliased AXI_INI1_READ_QOS_Register; -- AXI interconnect - INI x write QoS register AXI_INI1_WRITE_QOS : aliased AXI_INI1_WRITE_QOS_Register; -- AXI interconnect - INI x issuing functionality modification register AXI_INI1_FN_MOD : aliased AXI_INI1_FN_MOD_Register; -- AXI interconnect - INI x read QoS register AXI_INI2_READ_QOS : aliased AXI_INI2_READ_QOS_Register; -- AXI interconnect - INI x write QoS register AXI_INI2_WRITE_QOS : aliased AXI_INI2_WRITE_QOS_Register; -- AXI interconnect - INI x issuing functionality modification register AXI_INI2_FN_MOD : aliased AXI_INI2_FN_MOD_Register; -- AXI interconnect - INI x functionality modification 2 register AXI_INI3_FN_MOD2 : aliased AXI_INI3_FN_MOD2_Register; -- AXI interconnect - INI x AHB functionality modification register AXI_INI3_FN_MOD_AHB : aliased AXI_INI3_FN_MOD_AHB_Register; -- AXI interconnect - INI x read QoS register AXI_INI3_READ_QOS : aliased AXI_INI3_READ_QOS_Register; -- AXI interconnect - INI x write QoS register AXI_INI3_WRITE_QOS : aliased AXI_INI3_WRITE_QOS_Register; -- AXI interconnect - INI x issuing functionality modification register AXI_INI3_FN_MOD : aliased AXI_INI3_FN_MOD_Register; -- AXI interconnect - INI x read QoS register AXI_INI4_READ_QOS : aliased AXI_INI4_READ_QOS_Register; -- AXI interconnect - INI x write QoS register AXI_INI4_WRITE_QOS : aliased AXI_INI4_WRITE_QOS_Register; -- AXI interconnect - INI x issuing functionality modification register AXI_INI4_FN_MOD : aliased AXI_INI4_FN_MOD_Register; -- AXI interconnect - INI x read QoS register AXI_INI5_READ_QOS : aliased AXI_INI5_READ_QOS_Register; -- AXI interconnect - INI x write QoS register AXI_INI5_WRITE_QOS : aliased AXI_INI5_WRITE_QOS_Register; -- AXI interconnect - INI x issuing functionality modification register AXI_INI5_FN_MOD : aliased AXI_INI5_FN_MOD_Register; -- AXI interconnect - INI x read QoS register AXI_INI6_READ_QOS : aliased AXI_INI6_READ_QOS_Register; -- AXI interconnect - INI x write QoS register AXI_INI6_WRITE_QOS : aliased AXI_INI6_WRITE_QOS_Register; -- AXI interconnect - INI x issuing functionality modification register AXI_INI6_FN_MOD : aliased AXI_INI6_FN_MOD_Register; end record with Volatile; for AXI_Peripheral use record AXI_PERIPH_ID_4 at 16#1FD0# range 0 .. 31; AXI_PERIPH_ID_0 at 16#1FE0# range 0 .. 31; AXI_PERIPH_ID_1 at 16#1FE4# range 0 .. 31; AXI_PERIPH_ID_2 at 16#1FE8# range 0 .. 31; AXI_PERIPH_ID_3 at 16#1FEC# range 0 .. 31; AXI_COMP_ID_0 at 16#1FF0# range 0 .. 31; AXI_COMP_ID_1 at 16#1FF4# range 0 .. 31; AXI_COMP_ID_2 at 16#1FF8# range 0 .. 31; AXI_COMP_ID_3 at 16#1FFC# range 0 .. 31; AXI_TARG1_FN_MOD_ISS_BM at 16#2008# range 0 .. 31; AXI_TARG1_FN_MOD2 at 16#2024# range 0 .. 31; AXI_TARG1_FN_MOD_LB at 16#202C# range 0 .. 31; AXI_TARG1_FN_MOD at 16#2108# range 0 .. 31; AXI_TARG2_FN_MOD_ISS_BM at 16#3008# range 0 .. 31; AXI_TARG2_FN_MOD2 at 16#3024# range 0 .. 31; AXI_TARG2_FN_MOD_LB at 16#302C# range 0 .. 31; AXI_TARG2_FN_MOD at 16#3108# range 0 .. 31; AXI_TARG3_FN_MOD_ISS_BM at 16#4008# range 0 .. 31; AXI_TARG4_FN_MOD_ISS_BM at 16#5008# range 0 .. 31; AXI_TARG5_FN_MOD_ISS_BM at 16#6008# range 0 .. 31; AXI_TARG6_FN_MOD_ISS_BM at 16#7008# range 0 .. 31; AXI_TARG7_FN_MOD_ISS_BM at 16#800C# range 0 .. 31; AXI_TARG7_FN_MOD2 at 16#8024# range 0 .. 31; AXI_TARG7_FN_MOD at 16#8108# range 0 .. 31; AXI_INI1_FN_MOD2 at 16#42024# range 0 .. 31; AXI_INI1_FN_MOD_AHB at 16#42028# range 0 .. 31; AXI_INI1_READ_QOS at 16#42100# range 0 .. 31; AXI_INI1_WRITE_QOS at 16#42104# range 0 .. 31; AXI_INI1_FN_MOD at 16#42108# range 0 .. 31; AXI_INI2_READ_QOS at 16#43100# range 0 .. 31; AXI_INI2_WRITE_QOS at 16#43104# range 0 .. 31; AXI_INI2_FN_MOD at 16#43108# range 0 .. 31; AXI_INI3_FN_MOD2 at 16#44024# range 0 .. 31; AXI_INI3_FN_MOD_AHB at 16#44028# range 0 .. 31; AXI_INI3_READ_QOS at 16#44100# range 0 .. 31; AXI_INI3_WRITE_QOS at 16#44104# range 0 .. 31; AXI_INI3_FN_MOD at 16#44108# range 0 .. 31; AXI_INI4_READ_QOS at 16#45100# range 0 .. 31; AXI_INI4_WRITE_QOS at 16#45104# range 0 .. 31; AXI_INI4_FN_MOD at 16#45108# range 0 .. 31; AXI_INI5_READ_QOS at 16#46100# range 0 .. 31; AXI_INI5_WRITE_QOS at 16#46104# range 0 .. 31; AXI_INI5_FN_MOD at 16#46108# range 0 .. 31; AXI_INI6_READ_QOS at 16#47100# range 0 .. 31; AXI_INI6_WRITE_QOS at 16#47104# range 0 .. 31; AXI_INI6_FN_MOD at 16#47108# range 0 .. 31; end record; -- AXI interconnect registers AXI_Periph : aliased AXI_Peripheral with Import, Address => AXI_Base; end STM32_SVD.AXI;
----------------------------------------------------------------------- -- hestia-time -- Date and time information -- Copyright (C) 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Interfaces; with Hestia.Config; package body Hestia.Time is Secs_In_Day : constant := 24 * 3600; Secs_In_Four_Years : constant := (3 * 365 + 366) * Secs_In_Day; Secs_In_Non_Leap_Year : constant := 365 * Secs_In_Day; type Day_Count_Array is array (Month_Name) of Day_Number; type Day_Array is array (Boolean) of Day_Count_Array; Day_Table : constant Day_Array := (False => (January => 31, February => 28, March => 31, April => 30, May => 31, June => 30, July => 31, August => 31, September => 30, October => 31, November => 30, December => 31), True => (January => 31, February => 29, March => 31, April => 30, May => 31, June => 30, July => 31, August => 31, September => 30, October => 31, November => 30, December => 31)); function Is_Leap (Year : in Year_Number) return Boolean; function Is_Leap (Year : in Year_Number) return Boolean is begin return Year mod 400 = 0 or (Year mod 4 = 0 and not (Year mod 100 = 0)); end Is_Leap; function "-" (Left, Right : in Day_Name) return Integer is begin return Day_Name'Pos (Left) - Day_Name'Pos (Right); end "-"; -- ------------------------------ -- Convert the NTP time reference to a date. -- ------------------------------ function Convert (Time : in Net.NTP.NTP_Reference) return Date_Time is use type Interfaces.Unsigned_32; T : Net.NTP.NTP_Timestamp; S : Net.Uint32; Result : Date_Time; Four_Year_Segs : Natural; Rem_Years : Natural; Year_Day : Natural; Is_Leap_Year : Boolean; begin T := Net.NTP.Get_Time (Time); S := T.Seconds; -- Apply the timezone correction. S := S + 60 * Hestia.Config.TIME_ZONE_CORRECTION; -- Compute year. Four_Year_Segs := Natural (S / Secs_In_Four_Years); if Four_Year_Segs > 0 then S := S - Net.Uint32 (Four_Year_Segs) * Net.Uint32 (Secs_In_Four_Years); end if; Rem_Years := Natural (S / Secs_In_Non_Leap_Year); if Rem_Years > 3 then Rem_Years := 3; end if; S := S - Net.Uint32 (Rem_Years * Secs_In_Non_Leap_Year); Result.Year := Natural (4 * Four_Year_Segs + Rem_Years) + 1970; -- Compute year day. Year_Day := 1 + Natural (S / Secs_In_Day); Result.Year_Day := Year_Day; -- Compute month and day of month. Is_Leap_Year := Is_Leap (Result.Year); Result.Month := January; while Year_Day > Day_Table (Is_Leap_Year) (Result.Month) loop Year_Day := Year_Day - Day_Table (Is_Leap_Year) (Result.Month); Result.Month := Month_Name'Succ (Result.Month); end loop; Result.Day := Year_Day; -- Compute hours, minutes and remaining seconds. S := S mod 86400; Result.Hour := Hour_Number (S / 3600); S := S mod 3600; Result.Minute := Minute_Number (S / 60); Result.Second := Second_Number (S mod 60); Result.Sub_Seconds := T.Sub_Seconds; Result.Week_Day := Monday; return Result; end Convert; end Hestia.Time;
with Ada.Calendar.Naked; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System.Form_Parameters; with System.Storage_Elements; package body Ada.Directories is use type System.Native_Directories.File_Kind; use type System.Native_Directories.Searching.Handle_Type; use type System.Storage_Elements.Storage_Offset; subtype Directory_Entry_Information_Type is System.Native_Directories.Directory_Entry_Information_Type; procedure Free is new Unchecked_Deallocation (String, String_Access); function Pack_For_Copy_File (Form : String) return Boolean; function Pack_For_Copy_File (Form : String) return Boolean is Keyword_First : Positive; Keyword_Last : Natural; Item_First : Positive; Item_Last : Natural; Last : Natural; Overwrite : Boolean := True; -- default begin Last := Form'First - 1; while Last < Form'Last loop System.Form_Parameters.Get ( Form (Last + 1 .. Form'Last), Keyword_First, Keyword_Last, Item_First, Item_Last, Last); declare Keyword : String renames Form (Keyword_First .. Keyword_Last); Item : String renames Form (Item_First .. Item_Last); begin if Keyword = "overwrite" then if Item'Length > 0 and then Item (Item'First) = 'f' then Overwrite := False; -- false elsif Item'Length > 0 and then Item (Item'First) = 't' then Overwrite := True; -- true end if; elsif Keyword = "mode" then -- compatibility with GNAT runtime if Item'Length > 0 and then Item (Item'First) = 'c' then Overwrite := False; -- copy elsif Item'Length > 0 and then Item (Item'First) = 'o' then Overwrite := True; -- overwrite end if; end if; end; end loop; return Overwrite; end Pack_For_Copy_File; procedure Finalize (Object : in out Non_Controlled_Directory_Entry_Type); procedure Finalize (Object : in out Non_Controlled_Directory_Entry_Type) is begin if Object.Status = Detached then Free (Object.Path); System.Native_Directories.Searching.Free (Object.Directory_Entry); end if; end Finalize; procedure Assign ( Target : out Non_Controlled_Directory_Entry_Type; Source : Non_Controlled_Directory_Entry_Type); procedure Assign ( Target : out Non_Controlled_Directory_Entry_Type; Source : Non_Controlled_Directory_Entry_Type) is begin Target.Additional.Filled := False; Target.Status := Detached; Target.Path := new String'(Source.Path.all); Target.Directory_Entry := System.Native_Directories.Searching.New_Directory_Entry ( Source.Directory_Entry); end Assign; procedure End_Search ( Search : aliased in out Non_Controlled_Search_Type; Raise_On_Error : Boolean); procedure End_Search ( Search : aliased in out Non_Controlled_Search_Type; Raise_On_Error : Boolean) is begin Free (Search.Path); System.Native_Directories.Searching.End_Search ( Search.Search, Raise_On_Error => Raise_On_Error); end End_Search; procedure Get_Next_Entry ( Search : aliased in out Non_Controlled_Search_Type; Directory_Entry : in out Non_Controlled_Directory_Entry_Type); procedure Get_Next_Entry ( Search : aliased in out Non_Controlled_Search_Type; Directory_Entry : in out Non_Controlled_Directory_Entry_Type) is Has_Next : Boolean; begin System.Native_Directories.Searching.Get_Next_Entry ( Search.Search, Directory_Entry.Directory_Entry, Has_Next); if Has_Next then Directory_Entry.Additional.Filled := False; else Directory_Entry.Status := Empty; end if; end Get_Next_Entry; function Current (Object : Directory_Iterator) return Cursor; function Current (Object : Directory_Iterator) return Cursor is Listing : constant not null Directory_Listing_Access := Object.Listing; begin if not Is_Assigned ( Controlled_Searches.Next_Directory_Entry (Listing.Search).all) then -- call End_Search at this time, for propagating the exceptions. declare NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Listing.Search).all; begin End_Search (NC_Search, Raise_On_Error => True); end; return 0; -- No_Element else return Cursor (Listing.Count); end if; end Current; -- directory and file operations procedure Create_Directory ( New_Directory : String; Form : String) is pragma Unreferenced (Form); begin System.Native_Directories.Create_Directory (New_Directory); end Create_Directory; procedure Create_Directory ( New_Directory : String) is begin System.Native_Directories.Create_Directory (New_Directory); end Create_Directory; procedure Create_Path ( New_Directory : String; Form : String) is pragma Unreferenced (Form); begin Create_Path (New_Directory); end Create_Path; procedure Create_Path ( New_Directory : String) is I : Positive := New_Directory'Last + 1; begin while I > New_Directory'First loop declare P : Positive := I - 1; begin Hierarchical_File_Names.Exclude_Trailing_Path_Delimiter ( New_Directory, Last => P); exit when Exists (New_Directory (New_Directory'First .. P)); declare S_First : Positive; S_Last : Natural; begin Hierarchical_File_Names.Simple_Name ( New_Directory (New_Directory'First .. P), First => S_First, Last => S_Last); I := S_First; end; end; end loop; while I <= New_Directory'Last loop declare R_First : Positive; R_Last : Natural; begin Hierarchical_File_Names.Relative_Name ( New_Directory (I .. New_Directory'Last), First => R_First, Last => R_Last); declare P : Natural := R_First - 1; begin Hierarchical_File_Names.Exclude_Trailing_Path_Delimiter ( New_Directory, Last => P); Create_Directory (New_Directory (New_Directory'First .. P)); end; I := R_First; end; end loop; end Create_Path; procedure Delete_Tree (Directory : String) is Search : aliased Search_Type; begin Start_Search (Search, Directory, "*", (others => True)); while More_Entries (Search) loop declare Directory_Entry : Directory_Entry_Type renames Look_Next_Entry (Search).Element.all; Name : constant String := Full_Name (Directory_Entry); begin case Kind (Directory_Entry) is when Ordinary_File | Special_File => Delete_File (Name); when Directories.Directory => Delete_Tree (Name); -- recursive end case; end; Skip_Next_Entry (Search); end loop; End_Search (Search); Delete_Directory (Directory); end Delete_Tree; procedure Copy_File ( Source_Name : String; Target_Name : String; Form : String) is begin System.Native_Directories.Copy_File ( Source_Name, Target_Name, Overwrite => Pack_For_Copy_File (Form)); end Copy_File; function Compose ( Containing_Directory : String := ""; Name : String; Extension : String := ""; Path_Delimiter : Hierarchical_File_Names.Path_Delimiter_Type := Hierarchical_File_Names.Default_Path_Delimiter) return String is pragma Check (Pre, Check => Containing_Directory'Length = 0 or else Hierarchical_File_Names.Is_Simple_Name (Name) or else raise Name_Error); -- RM A.16(82/3) begin return Hierarchical_File_Names.Compose ( Containing_Directory, Name, Extension, Path_Delimiter => Path_Delimiter); end Compose; -- file and directory queries function Kind (Name : String) return File_Kind is Information : aliased Directory_Entry_Information_Type; begin System.Native_Directories.Get_Information (Name, Information); return File_Kind'Enum_Val ( System.Native_Directories.File_Kind'Enum_Rep ( System.Native_Directories.Kind (Information))); end Kind; function Size (Name : String) return File_Size is Information : aliased Directory_Entry_Information_Type; begin System.Native_Directories.Get_Information (Name, Information); if System.Native_Directories.Kind (Information) /= System.Native_Directories.Ordinary_File then raise Constraint_Error; -- implementation-defined else return System.Native_Directories.Size (Information); end if; end Size; function Modification_Time (Name : String) return Calendar.Time is Information : aliased Directory_Entry_Information_Type; begin System.Native_Directories.Get_Information (Name, Information); return Calendar.Naked.To_Time ( System.Native_Directories.Modification_Time (Information)); end Modification_Time; procedure Set_Modification_Time (Name : String; Time : Calendar.Time) is begin System.Native_Directories.Set_Modification_Time ( Name, Calendar.Naked.To_Native_Time (Time)); end Set_Modification_Time; -- directory searching function Is_Assigned (Directory_Entry : Directory_Entry_Type) return Boolean is NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return NC_Directory_Entry.Status /= Empty; end Is_Assigned; package body Controlled_Entries is function Reference (Object : Directories.Directory_Entry_Type) return not null access Non_Controlled_Directory_Entry_Type is begin return Directory_Entry_Type (Object).Data'Unrestricted_Access; end Reference; overriding procedure Finalize (Object : in out Directory_Entry_Type) is begin Finalize (Object.Data); end Finalize; end Controlled_Entries; function Is_Open (Search : Search_Type) return Boolean is NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; begin return NC_Search.Search.Handle /= System.Native_Directories.Searching.Null_Handle; end Is_Open; procedure Start_Search ( Search : in out Search_Type; Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True)) is pragma Check (Pre, Check => not Is_Open (Search) or else raise Status_Error); function Cast is new Unchecked_Conversion ( Filter_Type, System.Native_Directories.Searching.Filter_Type); NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; Has_Next : Boolean; begin NC_Search.Path := new String'(Full_Name (Directory)); declare NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Controlled_Searches.Next_Directory_Entry (Search).all).all; begin System.Native_Directories.Searching.Start_Search ( NC_Search.Search, Directory, Pattern, Cast (Filter), NC_Next_Directory_Entry.Directory_Entry, Has_Next); if Has_Next then NC_Next_Directory_Entry.Path := NC_Search.Path; NC_Next_Directory_Entry.Additional.Filled := False; NC_Next_Directory_Entry.Status := Attached; else NC_Next_Directory_Entry.Status := Empty; end if; end; end Start_Search; function Start_Search ( Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True)) return Search_Type is begin return Result : Search_Type do Start_Search (Result, Directory, Pattern, Filter); end return; end Start_Search; procedure End_Search (Search : in out Search_Type) is pragma Check (Pre, Is_Open (Search) or else raise Status_Error); NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; begin End_Search (NC_Search, Raise_On_Error => True); end End_Search; function More_Entries ( Search : Search_Type) return Boolean is pragma Check (Dynamic_Predicate, Check => Is_Open (Search) or else raise Status_Error); begin return Is_Assigned ( Controlled_Searches.Next_Directory_Entry (Search).all); end More_Entries; procedure Get_Next_Entry ( Search : in out Search_Type; Directory_Entry : out Directory_Entry_Type) is pragma Unmodified (Directory_Entry); -- modified via Reference pragma Check (Pre, Check => More_Entries (Search) -- checking the predicate or else raise Use_Error); -- RM A.16(110/3) NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Controlled_Searches.Next_Directory_Entry (Search).all).all; NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin Finalize (NC_Directory_Entry); -- copy to the detached entry Assign (Target => NC_Directory_Entry, Source => NC_Next_Directory_Entry); -- search next Get_Next_Entry (NC_Search, NC_Next_Directory_Entry); end Get_Next_Entry; function Get_Next_Entry ( Search : aliased in out Search_Type) return Directory_Entry_Type is begin return Result : Directory_Entry_Type do Get_Next_Entry (Search, Result); end return; end Get_Next_Entry; function Look_Next_Entry ( Search : aliased Search_Type) return Constant_Reference_Type is pragma Check (Dynamic_Predicate, Check => Is_Open (Search) or else raise Status_Error); begin return (Element => Controlled_Searches.Next_Directory_Entry (Search)); end Look_Next_Entry; procedure Skip_Next_Entry ( Search : in out Search_Type) is pragma Check (Dynamic_Predicate, Check => Is_Open (Search) or else raise Status_Error); NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Controlled_Searches.Next_Directory_Entry (Search).all).all; begin Get_Next_Entry (NC_Search, NC_Next_Directory_Entry); end Skip_Next_Entry; procedure Search ( Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True); Process : not null access procedure ( Directory_Entry : Directory_Entry_Type)) is Search : aliased Search_Type; begin Start_Search (Search, Directory, Pattern, Filter); while More_Entries (Search) loop Process (Look_Next_Entry (Search).Element.all); Skip_Next_Entry (Search); end loop; End_Search (Search); end Search; package body Controlled_Searches is function Reference (Object : Directories.Search_Type) return not null access Non_Controlled_Search_Type is begin return Search_Type (Object).Data'Unrestricted_Access; end Reference; function Next_Directory_Entry (Object : Directories.Search_Type) return not null access Directory_Entry_Type is begin return Search_Type (Object).Next_Directory_Entry'Unrestricted_Access; end Next_Directory_Entry; overriding procedure Finalize (Search : in out Search_Type) is begin if Search.Data.Search.Handle /= System.Native_Directories.Searching.Null_Handle then End_Search (Search.Data, Raise_On_Error => False); end if; end Finalize; end Controlled_Searches; -- directory iteration function Is_Open (Listing : Directory_Listing) return Boolean is begin return Is_Open (Listing.Search); end Is_Open; function Entries ( Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True)) return Directory_Listing is begin return Result : Directory_Listing do Result.Count := 1; Start_Search (Result.Search, Directory, Pattern, Filter); end return; end Entries; function Has_Entry (Position : Cursor) return Boolean is begin return Position > 0; end Has_Entry; function Iterate ( Listing : Directory_Listing'Class) return Directory_Iterators.Forward_Iterator'Class is pragma Check (Dynamic_Predicate, Check => Is_Open (Directory_Listing (Listing)) or else raise Status_Error); begin return Directory_Iterator'(Listing => Listing'Unrestricted_Access); end Iterate; function Current_Entry ( Entries : Directory_Listing'Class; Position : Cursor) return Directory_Entry_Type is begin return Result : Directory_Entry_Type do pragma Unmodified (Result); -- modified via Reference declare Source_Reference : constant Constant_Reference_Type := Constant_Reference (Directory_Listing (Entries), Position); -- checking the predicate and Position in Constant_Reference NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Source_Reference.Element.all) .all; NC_Result : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Result).all; begin Assign (Target => NC_Result, Source => NC_Next_Directory_Entry); end; end return; end Current_Entry; function Constant_Reference ( Container : aliased Directory_Listing; Position : Cursor) return Constant_Reference_Type is pragma Check (Dynamic_Predicate, Check => Is_Open (Container) or else raise Status_Error); pragma Check (Pre, Check => Integer (Position) = Container.Count or else raise Status_Error); begin return Look_Next_Entry (Container.Search); end Constant_Reference; overriding function First (Object : Directory_Iterator) return Cursor is pragma Check (Pre, Object.Listing.Count = 1 or else raise Status_Error); begin return Current (Object); end First; overriding function Next (Object : Directory_Iterator; Position : Cursor) return Cursor is pragma Check (Pre, Check => Integer (Position) = Object.Listing.Count or else raise Status_Error); Listing : constant not null Directory_Listing_Access := Object.Listing; begin -- increment Listing.Count := Listing.Count + 1; -- search next Skip_Next_Entry (Listing.Search); return Current (Object); end Next; -- operations on directory entries procedure Get_Entry ( Name : String; Directory_Entry : out Directory_Entry_Type) is pragma Unmodified (Directory_Entry); -- modified via Reference NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; Directory_First : Positive; Directory_Last : Natural; Simple_Name_First : Positive; Simple_Name_Last : Natural; begin -- decompose the name Hierarchical_File_Names.Containing_Directory (Name, First => Directory_First, Last => Directory_Last); Hierarchical_File_Names.Simple_Name (Name, First => Simple_Name_First, Last => Simple_Name_Last); -- make a detached entry Finalize (NC_Directory_Entry); NC_Directory_Entry.Path := new String'(Full_Name (Name (Directory_First .. Directory_Last))); NC_Directory_Entry.Directory_Entry := null; NC_Directory_Entry.Additional.Filled := False; NC_Directory_Entry.Status := Detached; System.Native_Directories.Searching.Get_Entry ( NC_Directory_Entry.Path.all, Name (Simple_Name_First .. Simple_Name_Last), NC_Directory_Entry.Directory_Entry, NC_Directory_Entry.Additional); end Get_Entry; function Get_Entry ( Name : String) return Directory_Entry_Type is begin return Result : Directory_Entry_Type do Get_Entry (Name, Result); end return; end Get_Entry; function Simple_Name ( Directory_Entry : Directory_Entry_Type) return String is pragma Check (Dynamic_Predicate, Check => Is_Assigned (Directory_Entry) or else raise Status_Error); NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return System.Native_Directories.Searching.Simple_Name ( NC_Directory_Entry.Directory_Entry); end Simple_Name; function Full_Name ( Directory_Entry : Directory_Entry_Type) return String is Name : constant String := Simple_Name (Directory_Entry); -- checking the predicate NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return Hierarchical_File_Names.Compose ( NC_Directory_Entry.Path.all, Name); end Full_Name; function Kind ( Directory_Entry : Directory_Entry_Type) return File_Kind is pragma Check (Dynamic_Predicate, Check => Is_Assigned (Directory_Entry) or else raise Status_Error); NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return File_Kind'Enum_Val ( System.Native_Directories.File_Kind'Enum_Rep ( System.Native_Directories.Searching.Kind ( NC_Directory_Entry.Directory_Entry))); end Kind; function Size ( Directory_Entry : Directory_Entry_Type) return File_Size is begin if Kind (Directory_Entry) /= Ordinary_File then -- checking the predicate raise Constraint_Error; -- implementation-defined else declare NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return System.Native_Directories.Searching.Size ( NC_Directory_Entry.Path.all, NC_Directory_Entry.Directory_Entry, NC_Directory_Entry.Additional); end; end if; end Size; function Modification_Time ( Directory_Entry : Directory_Entry_Type) return Calendar.Time is pragma Check (Dynamic_Predicate, Check => Is_Assigned (Directory_Entry) or else raise Status_Error); NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return Calendar.Naked.To_Time ( System.Native_Directories.Searching.Modification_Time ( NC_Directory_Entry.Path.all, NC_Directory_Entry.Directory_Entry, NC_Directory_Entry.Additional)); end Modification_Time; end Ada.Directories;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- SQL Database Access -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2014, Vadim Godunko <vgodunko@gmail.com> -- -- 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 package is low level bindings to Firebird library. ------------------------------------------------------------------------------ with System; with Interfaces.C; package Matreshka.Internals.SQL_Drivers.Firebird is ----------- -- Types -- ----------- type Isc_Database_Handle is new System.Address; type Isc_Database_Handle_Access is access constant Isc_Database_Handle; pragma Convention (C, Isc_Database_Handle_Access); Null_Isc_Database_Handle : constant Isc_Database_Handle := Isc_Database_Handle (System.Null_Address); type Isc_Transaction_Handle is new System.Address; type Isc_Transaction_Handle_Access is access constant Isc_Transaction_Handle; pragma Convention (C, Isc_Transaction_Handle_Access); Null_Isc_Transaction_Handle : constant Isc_Transaction_Handle := Isc_Transaction_Handle (System.Null_Address); type Isc_Stmt_Handle is new System.Address; Null_Isc_Stmt_Handle : constant Isc_Stmt_Handle := Isc_Stmt_Handle (System.Null_Address); subtype Isc_Address is System.Address; Zero : constant Isc_Address := System.Null_Address; subtype Isc_Short is Interfaces.C.short; type Isc_Short_Access is access all Isc_Short; pragma Convention (C, Isc_Short_Access); subtype Isc_Ushort is Interfaces.Unsigned_16; subtype Isc_Long is Interfaces.C.long; type Isc_Result_Code is new Isc_Long; type Isc_Results is array (1 .. 20) of aliased Isc_Result_Code; pragma Convention (C, Isc_Results); type Isc_Result_Codes is array (Positive range <>) of Isc_Result_Code; type Isc_Results_Access is access constant Isc_Result_Code; pragma Convention (C, Isc_Results_Access); subtype Isc_String is Interfaces.C.char_array; type Isc_String_Access is access all Isc_String; type Isc_Teb is record Db_Handle : access Isc_Database_Handle := null; Tpb_Length : Isc_Long := 0; Tpb : access Isc_String := null; end record; pragma Convention (C, Isc_Teb); type Isc_Tebs is array (Integer range <>) of Isc_Teb; pragma Convention (C, Isc_Tebs); subtype Isc_Db_Dialect is Interfaces.Unsigned_16 range 1 .. 3; Isc_Sqlda_Current_Version : constant := 1; Current_Metanames_Length : constant := 32; type Isc_Field_Index is new Isc_Short range 0 .. Isc_Short'Last; subtype Isc_Valid_Field_Index is Isc_Field_Index range 1 .. Isc_Field_Index'Last; -- for allow XSQLVAR:sqltype bits manipulation subtype Isc_Num_Bits is Natural range 0 .. 15; type Isc_Sqltype is array (Isc_Num_Bits) of Boolean; pragma Pack (Isc_Sqltype); for Isc_Sqltype'Size use 16; Isc_Sqlind_Flag : constant Isc_Num_Bits := 0; Isc_Type_Text : constant Isc_Sqltype := (False, False, True, False, False, False, True, True, True, others => False); -- 452; 111000100 Isc_Type_Varying : constant Isc_Sqltype := (False, False, False, False, False, False, True, True, True, others => False); -- 448; 111000000 Isc_Type_Short : constant Isc_Sqltype := (False, False, True, False, True, True, True, True, True, others => False); -- 500; 111110100 Isc_Type_Long : constant Isc_Sqltype := (False, False, False, False, True, True, True, True, True, others => False); -- 496; 111110000 Isc_Type_Float : constant Isc_Sqltype := (False, True, False, False, False, True, True, True, True, others => False); -- 482; 111100010 Isc_Type_Double : constant Isc_Sqltype := (False, False, False, False, False, True, True, True, True, others => False); -- 480; 111100000 Isc_Type_D_Float : constant Isc_Sqltype := (False, True, False, False, True, False, False, False, False, True, others => False); -- 530; 1000010010 Isc_Type_Timestamp : constant Isc_Sqltype := (False, True, True, True, True, True, True, True, True, others => False); -- 510; 111111110 Isc_Type_Blob : constant Isc_Sqltype := (False, False, False, True, False, False, False, False, False, True, others => False); -- 520; 1000001000 Isc_Type_Array : constant Isc_Sqltype := (False, False, True, True, True, False, False, False, False, True, others => False); -- 540; 1000011100 Isc_Type_Quad : constant Isc_Sqltype := (False, True, True, False, False, True, False, False, False, True, others => False); -- 550; 1000100110 Isc_Type_Time : constant Isc_Sqltype := (False, False, False, False, True, True, False, False, False, True, others => False); -- 560; 1000110000 Isc_Type_Date : constant Isc_Sqltype := (False, True, False, True, True, True, False, False, False, True, others => False); -- 570; 1000111010 Isc_Type_Int64 : constant Isc_Sqltype := (False, False, True, False, False, False, True, False, False, True, others => False); -- 580; 1001000100 Isc_Type_Boolean : constant Isc_Sqltype := (False, True, True, True, False, False, True, False, False, True, others => False); -- 590; 1001001110 Isc_Type_Empty : constant Isc_Sqltype := (others => False); -- 0; Isc_Type_Empty1 : constant Isc_Sqltype := (True, others => False); -- 1; Isc_Type_Min : constant Isc_Sqltype := (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True); -- -1; Empty_Metanames_String : constant Isc_String (1 .. Current_Metanames_Length) := (others => Interfaces.C.nul); type Isc_Sqlvar is record Sqltype : Isc_Sqltype := Isc_Type_Empty; -- datatype of field Sqlscale : Isc_Short := 0; -- scale factor Sqlsubtype : Isc_Short := 0; -- BLOBs & Text types only Sqllen : Isc_Short := 0; -- length of data area Sqldata : Isc_Address := Zero; -- address of data Sqlind : Isc_Short_Access := null; -- address of indicator variable Sqlname_Length : Isc_Short := 0; -- length of sqlname field -- name of field, name length + space for NULL Sqlname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; Relname_Length : Isc_Short := 0; -- length of relation name -- field's relation name + space for NULL Relname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; Ownname_Length : Isc_Short := 0; -- length of owner name -- relation's owner name + space for NULL Ownname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; Aliasname_Length : Isc_Short := 0; -- length of alias name -- relation's alias name + space for NULL Aliasname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; end record; pragma Convention (C, Isc_Sqlvar); type Isc_Sqlvars is array (Isc_Valid_Field_Index) of aliased Isc_Sqlvar; pragma Convention (C, Isc_Sqlvars); pragma Suppress (Index_Check, Isc_Sqlvars); type Isc_Sqlda is record -- version of this XSQLDA Version : Isc_Short := Isc_Sqlda_Current_Version; -- XSQLDA name field Sqldaid : Isc_String (1 .. 8) := (others => Interfaces.C.nul); Sqldabc : Isc_Long := 0; -- length in bytes of SQLDA Sqln : Isc_Field_Index := 1; -- number of fields allocated Sqld : Isc_Field_Index := 0; -- used number of fields Sqlvar : Isc_Sqlvars; -- first field of 1..n array of fields end record; pragma Convention (C, Isc_Sqlda); -- Constants -- Buffer_Length : constant := 512; Huge_Buffer_Length : constant := Buffer_Length * 20; Isc_True : constant := 1; -- Database parameter block stuff -- subtype Isc_Dpb_Code is Interfaces.C.char; Isc_Dpb_Version1 : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (1); Isc_Dpb_Cdd_Pathname : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (1); Isc_Dpb_Allocation : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (2); Isc_Dpb_Journal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (3); Isc_Dpb_Page_Size : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (4); Isc_Dpb_Num_Buffers : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (5); Isc_Dpb_Buffer_Length : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (6); Isc_Dpb_Debug : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (7); Isc_Dpb_Garbage_Collect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (8); Isc_Dpb_Verify : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (9); Isc_Dpb_Sweep : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (10); Isc_Dpb_Enable_Journal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (11); Isc_Dpb_Disable_Journal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (12); Isc_Dpb_Dbkey_Scope : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (13); Isc_Dpb_Number_Of_Users : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (14); Isc_Dpb_Trace : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (15); Isc_Dpb_No_Garbage_Collect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (16); Isc_Dpb_Damaged : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (17); Isc_Dpb_License : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (18); Isc_Dpb_Sys_User_Name : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (19); Isc_Dpb_Encrypt_Key : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (20); Isc_Dpb_Activate_Shadow : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (21); Isc_Dpb_Sweep_Interval : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (22); Isc_Dpb_Delete_Shadow : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (23); Isc_Dpb_Force_Write : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (24); Isc_Dpb_Begin_Log : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (25); Isc_Dpb_Quit_Log : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (26); Isc_Dpb_No_Reserve : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (27); Isc_Dpb_User_Name : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (28); Isc_Dpb_Password : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (29); Isc_Dpb_Password_Enc : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (30); Isc_Dpb_Sys_User_Name_Enc : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (31); Isc_Dpb_Interp : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (32); Isc_Dpb_Online_Dump : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (33); Isc_Dpb_Old_File_Size : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (34); Isc_Dpb_Old_Num_Files : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (35); Isc_Dpb_Old_File : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (36); Isc_Dpb_Old_Start_Page : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (37); Isc_Dpb_Old_Start_Seqno : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (38); Isc_Dpb_Old_Start_File : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (39); Isc_Dpb_Drop_Walfile : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (40); Isc_Dpb_Old_Dump_Id : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (41); Isc_Dpb_Wal_Backup_Dir : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (42); Isc_Dpb_Wal_Chkptlen : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (43); Isc_Dpb_Wal_Numbufs : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (44); Isc_Dpb_Wal_Bufsize : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (45); Isc_Dpb_Wal_Grp_Cmt_Wait : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (46); Isc_Dpb_Lc_Messages : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (47); Isc_Dpb_Lc_Ctype : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (48); Isc_Dpb_Cache_Manager : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (49); Isc_Dpb_Shutdown : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (50); Isc_Dpb_Online : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (51); Isc_Dpb_Shutdown_Delay : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (52); Isc_Dpb_Reserved : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (53); Isc_Dpb_Overwrite : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (54); Isc_Dpb_Sec_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (55); Isc_Dpb_Disable_Wal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (56); Isc_Dpb_Connect_Timeout : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (57); Isc_Dpb_Dummy_Packet_Interval : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (58); Isc_Dpb_Gbak_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (59); Isc_Dpb_Sql_Role_Name : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (60); Isc_Dpb_Set_Page_Buffers : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (61); Isc_Dpb_Working_Directory : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (62); Isc_Dpb_Sql_Dialect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (63); Isc_Dpb_Set_Db_Readonly : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (64); Isc_Dpb_Set_Db_Sql_Dialect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (65); Isc_Dpb_Gfix_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (66); Isc_Dpb_Gstat_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (67); Isc_Dpb_Set_Db_Charset : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (68); -- Isc_DPB_Verify specific flags -- subtype Isc_Dpb_Vcode is Interfaces.C.char; Isc_Dpb_Pages : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (1); Isc_Dpb_Records : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (2); Isc_Dpb_Indices : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (4); Isc_Dpb_Transactions : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (8); Isc_Dpb_No_Update : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (16); Isc_Dpb_Repair : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (32); Isc_DPB_Ignore : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (64); -- Transaction parameter block stuff -- subtype Isc_Tpb_Code is Interfaces.C.char; Isc_Tpb_Version1 : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (1); Isc_Tpb_Version3 : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (3); Isc_Tpb_Consistency : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (1); Isc_Tpb_Concurrency : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (2); Isc_Tpb_Shared : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (3); Isc_Tpb_Protected : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (4); Isc_Tpb_Exclusive : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (5); Isc_Tpb_Wait : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (6); Isc_Tpb_Nowait : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (7); Isc_Tpb_Read : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (8); Isc_Tpb_Write : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (9); Isc_Tpb_Lock_Read : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (10); Isc_Tpb_Lock_Write : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (11); Isc_Tpb_Verb_Time : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (12); Isc_Tpb_Commit_Time : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (13); Isc_Tpb_Ignore_Limbo : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (14); Isc_Tpb_Read_Committed : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (15); Isc_Tpb_Autocommit : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (16); Isc_Tpb_Rec_Version : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (17); Isc_Tpb_No_Rec_Version : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (18); Isc_Tpb_Restart_Requests : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (19); Isc_Tpb_No_Auto_Undo : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (20); Isc_Tpb_No_Savepoint : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (21); -- IB 7.5 Isc_Tpb_Last_Code : constant Isc_Tpb_Code := Isc_Tpb_No_Savepoint; type Isc_Stmt_Free_Code is new Isc_Short; pragma Convention (C, Isc_Stmt_Free_Code); Isc_Sql_Close : constant Isc_Stmt_Free_Code := 1; Isc_Sql_Drop : constant Isc_Stmt_Free_Code := 2; type Isc_Character_Set is (UNKNOWN, NONE, OCTETS, ASCII, UNICODE_FSS, SJIS_0208, EUCJ_0208, DOS737, DOS437, DOS850, DOS865, DOS860, DOS863, DOS775, DOS858, DOS862, DOS864, NEXT, ISO8859_1, ISO8859_2, ISO8859_3, ISO8859_4, ISO8859_5, ISO8859_6, ISO8859_7, ISO8859_8, ISO8859_9, ISO8859_13, KSC_5601, DOS852, DOS857, DOS861, DOS866, DOS869, CYRL, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254, BIG_5, GB_2312, WIN1255, WIN1256, WIN1257, UFT8); Isc_Charsets_Count : constant Isc_Short := 60; type Isc_Character_Sets is array (0 .. Isc_Charsets_Count) of Isc_Character_Set; Character_Set : constant Isc_Character_Sets := (NONE, OCTETS, ASCII, UNICODE_FSS, UFT8, SJIS_0208, EUCJ_0208, UNKNOWN, UNKNOWN, DOS737, DOS437, DOS850, DOS865, DOS860, DOS863, DOS775, DOS858, DOS862, DOS864, NEXT, UNKNOWN, ISO8859_1, ISO8859_2, ISO8859_3, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, ISO8859_4, ISO8859_5, ISO8859_6, ISO8859_7, ISO8859_8, ISO8859_9, ISO8859_13, UNKNOWN, UNKNOWN, UNKNOWN, KSC_5601, DOS852, DOS857, DOS861, DOS866, DOS869, CYRL, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254, BIG_5, GB_2312, WIN1255, WIN1256, WIN1257); -- Error codes -- Isc_Dsql_Cursor_Err : constant Isc_Result_Code := 335544572; Isc_Bad_Stmt_Handle : constant Isc_Result_Code := 335544485; Isc_Dsql_Cursor_Close_Err : constant Isc_Result_Code := 335544577; -- Info -- subtype Isc_Info_Request is Interfaces.C.char; Isc_Info_Sql_Stmt_Type : constant Isc_Info_Request := Isc_Info_Request'Val (21); Frb_Info_Att_Charset : constant Isc_Info_Request := Isc_Info_Request'Val (101); -- methods -- function Isc_Attach_Database (Status : access Isc_Results; Db_Name_Length : Isc_Short; Db_Name : Isc_String; Db_Handle : access Isc_Database_Handle; Parms_Length : Isc_Short; Parms : Isc_String) return Isc_Result_Code; function Isc_Detach_Database (Status : access Isc_Results; Handle : access Isc_Database_Handle) return Isc_Result_Code; function Isc_Sqlcode (Status : Isc_Results) return Isc_Long; procedure Isc_Sql_Interprete (Sqlcode : Isc_Short; Buffer : access Isc_String; Buffer_Length : Isc_Short); function Isc_Interprete (Buffer : access Isc_String; Status : access Isc_Results_Access) return Isc_Result_Code; function Isc_Commit_Retaining (Status : access Isc_Results; Handle : access Isc_Transaction_Handle) return Isc_Result_Code; function Isc_Start_Multiple (Status : access Isc_Results; Handle : access Isc_Transaction_Handle; Tebs_Count : Isc_Short; Teb : access Isc_Tebs) return Isc_Result_Code; function Isc_Rollback_Transaction (Status : access Isc_Results; Handle : access Isc_Transaction_Handle) return Isc_Result_Code; function Isc_Dsql_Fetch (Status : access Isc_Results; Handle : access Isc_Stmt_Handle; Version : Isc_Db_Dialect; Sqlda : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Free_Statement (Status : access Isc_Results; Handle : access Isc_Stmt_Handle; Code : Isc_Stmt_Free_Code) return Isc_Result_Code; function Isc_Dsql_Alloc_Statement2 (Status : access Isc_Results; Db : Isc_Database_Handle_Access; Stmt : access Isc_Stmt_Handle) return Isc_Result_Code; function Isc_Dsql_Prepare (Status : access Isc_Results; Tr : Isc_Transaction_Handle_Access; Stmt : access Isc_Stmt_Handle; Length : Isc_Ushort; Statement : Isc_String; Dialect : Isc_Ushort; Xsqlda : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Sql_Info (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Items_Length : Isc_Short; Items : Isc_String; Buffer_Length : Isc_Short; Buffer : access Isc_String) return Isc_Result_Code; function Isc_Vax_Integer (Buffer : Isc_String; Length : Isc_Short) return Isc_Long; function Isc_Dsql_Set_Cursor_Name (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Name : Isc_String; Itype : Isc_Ushort) return Isc_Result_Code; function Isc_Dsql_Describe_Bind (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Params : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Describe (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Rec : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Execute_Immediate (Status : access Isc_Results; Db : Isc_Database_Handle_Access; Tr : Isc_Transaction_Handle_Access; Length : Isc_Short; Statement : Isc_String; Version : Isc_Ushort; Params : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Execute (Status : access Isc_Results; Tr : Isc_Transaction_Handle_Access; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Params : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Execute2 (Status : access Isc_Results; Tr : Isc_Transaction_Handle_Access; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Params : access Isc_Sqlda; Fields : access Isc_Sqlda) return Isc_Result_Code; function Isc_Database_Info (Status : access Isc_Results; Handle : access Isc_Database_Handle; Length : Isc_Short; Items : Isc_String; Buf_Length : Isc_Short; Buf : access Isc_String) return Isc_Result_Code; ----------- -- Utils -- ----------- function Get_Error (Status : access Isc_Results) return League.Strings.Universal_String; function Check_For_Error (Status : access Isc_Results; Codes : Isc_Result_Codes) return Boolean; function To_Isc_String (Item : League.Strings.Universal_String) return Isc_String; function Is_Datetime_Type (Sql_Type : Isc_Sqltype) return Boolean; function Is_Numeric_Type (Sql_Type : Isc_Sqltype) return Boolean; ------------------------- -- Time & Date Support -- ------------------------- type Isc_Date is new Isc_Long; type Isc_Time is new Interfaces.Unsigned_32; type Isc_Timestamp is record Timestamp_Date : Isc_Date; Timestamp_Time : Isc_Time; end record; pragma Convention (C, Isc_Timestamp); Isc_Time_Seconds_Precision_Scale : constant := 4; MSecs_Per_Sec : constant := 10**Isc_Time_Seconds_Precision_Scale; -- C_Time -- type C_Time is record Tm_Sec : Interfaces.C.int := 0; Tm_Min : Interfaces.C.int := 0; Tm_Hour : Interfaces.C.int := 0; Tm_Mday : Interfaces.C.int := 0; Tm_Mon : Interfaces.C.int := 0; Tm_Year : Interfaces.C.int := 0; Tm_Wday : Interfaces.C.int := 0; Tm_Yday : Interfaces.C.int := 0; Tm_Isdst : Interfaces.C.int := 0; Tm_Gmtoff : Interfaces.C.int := 0; Tm_Zone : System.Address := System.Null_Address; end record; pragma Convention (C, C_Time); procedure Isc_Encode_Sql_Time (C_Date : access C_Time; Ib_Date : access Isc_Time); procedure Isc_Encode_Sql_Date (C_Date : access C_Time; Ib_Date : access Isc_Date); procedure Isc_Encode_Timestamp (C_Date : access C_Time; Ib_Date : access Isc_Timestamp); procedure Isc_Decode_Timestamp (Ib_Date : access Isc_Timestamp; C_Date : access C_Time); procedure Isc_Decode_Sql_Date (Ib_Date : access Isc_Date; C_Date : access C_Time); procedure Isc_Decode_Sql_Time (Ib_Date : access Isc_Time; C_Date : access C_Time); private pragma Import (Stdcall, Isc_Attach_Database, "isc_attach_database"); pragma Import (Stdcall, Isc_Detach_Database, "isc_detach_database"); pragma Import (Stdcall, Isc_Sqlcode, "isc_sqlcode"); pragma Import (Stdcall, Isc_Sql_Interprete, "isc_sql_interprete"); pragma Import (Stdcall, Isc_Interprete, "isc_interprete"); pragma Import (Stdcall, Isc_Commit_Retaining, "isc_commit_retaining"); pragma Import (Stdcall, Isc_Start_Multiple, "isc_start_multiple"); pragma Import (Stdcall, Isc_Dsql_Fetch, "isc_dsql_fetch"); pragma Import (Stdcall, Isc_Dsql_Free_Statement, "isc_dsql_free_statement"); pragma Import (Stdcall, Isc_Dsql_Prepare, "isc_dsql_prepare"); pragma Import (Stdcall, Isc_Dsql_Sql_Info, "isc_dsql_sql_info"); pragma Import (Stdcall, Isc_Vax_Integer, "isc_vax_integer"); pragma Import (Stdcall, Isc_Dsql_Describe_Bind, "isc_dsql_describe_bind"); pragma Import (Stdcall, Isc_Dsql_Describe, "isc_dsql_describe"); pragma Import (Stdcall, Isc_Dsql_Execute, "isc_dsql_execute"); pragma Import (Stdcall, Isc_Dsql_Execute2, "isc_dsql_execute2"); pragma Import (Stdcall, Isc_Encode_Sql_Time, "isc_encode_sql_time"); pragma Import (Stdcall, Isc_Encode_Timestamp, "isc_encode_timestamp"); pragma Import (Stdcall, Isc_Encode_Sql_Date, "isc_encode_sql_date"); pragma Import (Stdcall, Isc_Decode_Timestamp, "isc_decode_timestamp"); pragma Import (Stdcall, Isc_Decode_Sql_Date, "isc_decode_sql_date"); pragma Import (Stdcall, Isc_Decode_Sql_Time, "isc_decode_sql_time"); pragma Import (Stdcall, Isc_Database_Info, "isc_database_info"); pragma Import (Stdcall, Isc_Rollback_Transaction, "isc_rollback_transaction"); pragma Import (Stdcall, Isc_Dsql_Alloc_Statement2, "isc_dsql_alloc_statement2"); pragma Import (Stdcall, Isc_Dsql_Set_Cursor_Name, "isc_dsql_set_cursor_name"); pragma Import (Stdcall, Isc_Dsql_Execute_Immediate, "isc_dsql_execute_immediate"); end Matreshka.Internals.SQL_Drivers.Firebird;
with Ada.Integer_Text_IO, Ada.Text_IO; use Ada.Integer_Text_IO, Ada.Text_IO; package body data is function Sum_Vector(A,B: in Vector) return Vector is S: Vector; begin for i in 1..N loop S(i):=A(i)+B(i); end loop; return S; end Sum_Vector; function Matrix_Multiplication(A,B: in Matrix) return Matrix is M: Matrix; s: Integer; begin for k in 1..N loop for i in 1..N loop s:=0; for j in 1..N loop s:=A(k)(j)*B(j)(i); M(k)(i):=s; end loop; end loop; end loop; return M; end Matrix_Multiplication; function Vector_Matrix_Multiplication(A: in Vector; B: in Matrix) return Vector is P: Vector; s: Integer; begin for i in 1..N loop s:=0; for j in 1..N loop s:=S+A(i)*B(j)(i); end loop; P(i):=S; end loop; return P; end Vector_Matrix_Multiplication; procedure Vector_Sort(A: in out Vector) is E: Integer; begin for i in 1..N loop for j in 1..N loop if A(i)>A(j) then E:=A(j); A(j):=A(i); A(i):=E; end if; end loop; end loop; end Vector_Sort; function Matrix_Sub(A,B: in Matrix) return Matrix is S: Matrix; begin for i in 1..N loop for j in 1..N loop S(i)(j):=A(i)(j) - B(i)(j); end loop; end loop; return S; end Matrix_Sub; function Max_of_Matrix(A: in Matrix) return Integer is S: Integer; begin for i in 1..N loop for j in 1..N loop if A(i)(j)>S then S:= A(i)(j); end if; end loop; end loop; return S; end Max_of_Matrix; function Max_of_Vector(A: in Vector) return Integer is D: Integer; begin for i in 1..N loop if A(i)>D then D:= A(i); end if; end loop; return D; end Max_of_Vector; procedure Matrix_Fill_Ones (A: out Matrix) is begin for i in 1..N loop for j in 1..N loop A(i)(j):=1; end loop; end loop; end Matrix_Fill_Ones; procedure Vector_Fill_Ones (A: out Vector) is begin for i in 1..N loop A(i):=1; end loop; end Vector_Fill_Ones; procedure Vector_Input (A: out Vector) is begin for i in 1..N loop Get(A(i)); end loop; end Vector_Input; procedure Vector_Output (A: in Vector) is begin for i in 1..N loop Put(A(i)); end loop; New_Line; end Vector_Output; procedure Matrix_Input (A: out Matrix) is begin for i in 1..N loop for j in 1..N loop Get(A(i)(j)); end loop; end loop; end Matrix_Input; procedure Matrix_Output (A: in Matrix) is begin for i in 1..N loop for j in 1..N loop Put(A(i)(j)); end loop; New_Line; end loop; New_Line; end Matrix_Output; function Func1(A,B,C: in Vector; MA,ME: in Matrix) return Integer is Z_Sum, O_Sum, U_Mult: Vector; MK: Matrix; d: Integer; begin O_Sum:= Sum_Vector(A,B); Z_Sum:= Sum_Vector(O_Sum,C); MK:= Matrix_Multiplication(MA,ME); U_Mult:= Vector_Matrix_Multiplication(Z_Sum,MK); d:= Max_of_Vector(U_Mult); return d; end Func1; function Func2(MH,MK,ML: in Matrix) return Integer is MF: Matrix; MQ: Matrix; q: Integer; begin MF:= Matrix_Multiplication(MH,MK); MQ:= Matrix_Sub(MF, ML); q:= Max_of_Matrix(MQ); return q; end Func2; function Func3(P: out Vector; MR,MT: in Matrix) return Vector is O: Vector; MG: Matrix; begin Vector_Sort(P); MG:= Matrix_Multiplication(MR,MT); O:= Vector_Matrix_Multiplication(P,MG); return O; end Func3; end data;
with Unchecked_Deallocation; package body Ragged is SCCS_ID : constant String := "@(#) ragged.ada, Version 1.2"; -- The ragged array is implemented as a vector indexed by row -- of linked lists of (column,value) pairs in sorted order. type Cells is array( Row_Index range<> ) of Index; type Cells_Ptr is access Cells; pragma Controlled(Cells_Ptr); Vector : Cells_Ptr; procedure Make_Array(Lower, Upper: Row_Index) is begin Vector := new Cells(Lower..Upper); for I in Vector.all'range loop Vector(I) := null; end loop; end Make_Array; function New_Cell(Column : Col_Index; Next : Index) return Index is Temp : Index; begin Temp := new Cell; Temp.Hidden.Column := Column; Temp.Hidden.Next := Next; -- Will this work or do I need to null_value vector ? Null_Value(Temp.Value); return Temp; end New_Cell; function Lval(X: Row_Index; Y: Col_Index) return Index is Ptr, Last : Index; begin -- If a new cell is created its value field is uninitialized. -- Add to the beginning of the list ? if Vector(X) = null or else Vector(X).Hidden.Column > Y then Ptr := Vector(X); Vector(X) := New_Cell(Y,Ptr); return Vector(X); end if; -- Add in the middle of the list ? Ptr := Vector(X); while Ptr /= null loop if Ptr.Hidden.Column = Y then return Ptr; elsif Ptr.Hidden.Column > Y then Last.Hidden.Next := New_Cell(Y,Ptr); return Last.Hidden.Next; end if; Last := Ptr; Ptr := Ptr.Hidden.Next; end loop; -- Add at the end of the list Last.Hidden.Next := New_Cell(Y,null); return Last.Hidden.Next; end Lval; function Rval(X: Row_Index; Y: Col_Index) return Index is Ptr : Index; begin Ptr := Vector(X); while Ptr /= null and then Ptr.Hidden.Column < Y loop Ptr := Ptr.Hidden.Next; end loop; if Ptr = null or else Ptr.Hidden.Column > Y then raise Value_Range_Error; else -- ptr.hidden.column = y return Ptr; end if; end Rval; procedure Initialize(Iterator : out Index; Row : Row_Index) is begin Iterator := Vector(Row); end; procedure Next(Iterator : in out Index) is begin Iterator := Iterator.Hidden.Next; end; -- procedure free(i: index); -- pragma interface(c,free); procedure Free is new Unchecked_Deallocation(Cell, Index); procedure Free is new Unchecked_Deallocation(Cells, Cells_Ptr); procedure Free_Array is Traverse : Index; begin for I in Vector.all'range loop while Vector(I) /= null loop Traverse := Vector(I); Vector(I) := Vector(I).Hidden.Next; Null_Value(Traverse.Value); -- free value if its a ptr Free(Traverse); end loop; end loop; Free(Vector); end Free_Array; end Ragged;
procedure Hello is I : INTEGER; F,T : FLOAT; str : STRING; symb : CHARACTER; arr : ARRAY (1..9) of INTEGER; begin null; end Hello;
-- { dg-do compile } pragma Restrictions (No_Streams); with Ada.Containers.Ordered_Maps; package No_Streams is type Arr is new String (1..8); package My_Ordered_Map is new Ada.Containers.Ordered_Maps (Key_Type => Natural, Element_Type => Arr); end No_Streams;
-- $Id: Sort.mi,v 1.0 1992/08/07 14:42:01 grosch rel $ -- $Log: Sort.mi,v $ -- Ich, Doktor Josef Grosch, Informatiker, Aug. 1994 package body Sort is procedure QuickSort (Lwb, Upb: Integer) is i, j: Integer; k: Integer := Lwb; begin loop if k >= Upb then return; end if; i := k + 1; j := Upb; loop while (i < Upb) and IsLess (i, k) loop i := i + 1; end loop; while (k < j ) and IsLess (k, j) loop j := j - 1; end loop; if i < j then Swap (i, j); end if; if i >= j then exit; end if; end loop; Swap (k, j); QuickSort (k, j - 1); k := j + 1; -- QuickSort (j + 1, Upb); end loop; end QuickSort; end Sort;
-- Change log: -- RK 18 - Oct - 2006 : removed initialisation by dynamic allocation, -- to avoid memory leaks with GLU; package body GLOBE_3D.Software_Anti_Aliasing is use REF; type Jitter_matrix is array (Positive range <>, Positive range <>) of GL.Double; type p_Jitter_matrix is access all Jitter_matrix; -- Matrices for anti - aliasing (choice : matrix J at the end of Jitter) : J3 : aliased Jitter_matrix := ( ((0.5, 0.5), (1.35899e-05, 0.230369), (0.000189185, 0.766878))); J4 : aliased Jitter_matrix := ( (0.375, 0.23), (0.123, 0.77), (0.875, 0.27), (0.627, 0.73)); J11 : aliased Jitter_matrix := ( ((0.5, 0.5), (0.406537, 0.135858), (0.860325, 0.968558), (0.680141, 0.232877), (0.775694, 0.584871), (0.963354, 0.309056), (0.593493, 0.864072), (0.224334, 0.415055), (0.0366643, 0.690884), (0.139685, 0.0313988), (0.319861, 0.767097))); J16 : aliased Jitter_matrix := ( ((0.4375, 0.4375), (0.1875, 0.5625), (0.9375, 1.1875), (0.4375, -0.0625), (0.6875, 0.5625), (0.1875, 0.0625), (0.6875, 0.3125), (0.1875, 0.3125), (0.4375, 0.1875), (-0.0625, 0.4375), (0.6875, 0.8125), (0.4375, 0.6875), (0.6875, 0.0625), (0.9375, 0.9375), (1.1875, 0.8125), (0.9375, 0.6875))); J29 : aliased Jitter_matrix := ( ((0.5, 0.5), (0.498126, 0.141363), (0.217276, 0.651732), (0.439503, 0.954859), (0.734171, 0.836294), (0.912454, 0.79952), (0.406153, 0.671156), (0.0163892, 0.631994), (0.298064, 0.843476), (0.312025, 0.0990405), (0.98135, 0.965697), (0.841999, 0.272378), (0.559348, 0.32727), (0.809331, 0.638901), (0.632583, 0.994471), (0.00588314, 0.146344), (0.713365, 0.437896), (0.185173, 0.246584), (0.901735, 0.474544), (0.366423, 0.296698), (0.687032, 0.188184), (0.313256, 0.472999), (0.543195, 0.800044), (0.629329, 0.631599), (0.818263, 0.0439354), (0.163978, 0.00621497), (0.109533, 0.812811), (0.131325, 0.471624), (0.0196755, 0.331813))); J90 : aliased Jitter_matrix := ( ((0.5, 0.5), (0.784289, 0.417355), (0.608691, 0.678948), (0.546538, 0.976002), (0.972245, 0.270498), (0.765121, 0.189392), (0.513193, 0.743827), (0.123709, 0.874866), (0.991334, 0.745136), (0.56342, 0.0925047), (0.662226, 0.143317), (0.444563, 0.928535), (0.248017, 0.981655), (0.100115, 0.771923), (0.593937, 0.559383), (0.392095, 0.225932), (0.428776, 0.812094), (0.510615, 0.633584), (0.836431, 0.00343328), (0.494037, 0.391771), (0.617448, 0.792324), (0.688599, 0.48914), (0.530421, 0.859206), (0.0742278, 0.665344), (0.979388, 0.626835), (0.183806, 0.479216), (0.151222, 0.0803998), (0.476489, 0.157863), (0.792675, 0.653531), (0.0990416, 0.267284), (0.776667, 0.303894), (0.312904, 0.296018), (0.288777, 0.691008), (0.460097, 0.0436075), (0.594323, 0.440751), (0.876296, 0.472043), (0.0442623, 0.0693901), (0.355476, 0.00442787), (0.391763, 0.361327), (0.406994, 0.696053), (0.708393, 0.724992), (0.925807, 0.933103), (0.850618, 0.11774), (0.867486, 0.233677), (0.208805, 0.285484), (0.572129, 0.211505), (0.172931, 0.180455), (0.327574, 0.598031), (0.685187, 0.372379), (0.23375, 0.878555), (0.960657, 0.409561), (0.371005, 0.113866), (0.29471, 0.496941), (0.748611, 0.0735321), (0.878643, 0.34504), (0.210987, 0.778228), (0.692961, 0.606194), (0.82152, 0.8893), (0.0982095, 0.563104), (0.214514, 0.581197), (0.734262, 0.956545), (0.881377, 0.583548), (0.0560485, 0.174277), (0.0729515, 0.458003), (0.719604, 0.840564), (0.325388, 0.7883), (0.26136, 0.0848927), (0.393754, 0.467505), (0.425361, 0.577672), (0.648594, 0.0248658), (0.983843, 0.521048), (0.272936, 0.395127), (0.177695, 0.675733), (0.89175, 0.700901), (0.632301, 0.908259), (0.782859, 0.53611), (0.0141421, 0.855548), (0.0437116, 0.351866), (0.939604, 0.0450863), (0.0320883, 0.962943), (0.341155, 0.895317), (0.952087, 0.158387), (0.908415, 0.820054), (0.481435, 0.281195), (0.675525, 0.25699), (0.585273, 0.324454), (0.156488, 0.376783), (0.140434, 0.977416), (0.808155, 0.77305), (0.282973, 0.188937))); J : p_Jitter_matrix; function Anti_Alias_phases return Positive is begin if J = null then return 1; else return J'Length (1) + 2; end if; end Anti_Alias_phases; procedure Display_with_Anti_Aliasing (phase : Positive) is procedure Jitter is Dxy : array (J'Range (2)) of GL.Double; weight : constant GL.C_Float := 1.0 / GL.C_Float (J'Length (1)); procedure LoadDxDy (jt : Positive) is view : aliased GLU.Viewport_Rec; inv : array (1 .. 2) of GL.Double; begin -- GLU.Get (VIEWPORT, view'unrestricted_access); GLU.Get (view); inv (1) := 10.0 / GL.Double (view.Width); inv (2) := 10.0 / GL.Double (view.Height); for d in Dxy'Range loop Dxy (d) := (J.all (jt, d) - 0.25) * inv (d); end loop; end LoadDxDy; begin if phase = 1 then Clear (COLOR_BUFFER_BIT or ACCUM_BUFFER_BIT); elsif phase in 2 .. Anti_Alias_phases - 1 then Clear (COLOR_BUFFER_BIT); LoadDxDy (phase - 1); MatrixMode (MODELVIEW); PushMatrix; Translate (Dxy (1), Dxy (2), 0.0); Display; MatrixMode (MODELVIEW); PopMatrix; Accum (ACCUM, weight); elsif phase = Anti_Alias_phases then Accum (GL_RETURN, 1.0); -- ^ Transfers accumulation buffer values to the color buffer or -- buffers currently selected for writing. Flush; else raise Constraint_Error; end if; end Jitter; begin if J = null then Clear (COLOR_BUFFER_BIT); Display; Flush; else Jitter; end if; end Display_with_Anti_Aliasing; procedure Set_Quality (q : Quality) is begin case q is when Q1 => J := null; when Q3 => J := J3'Access; when Q4 => J := J4'Access; when Q11 => J := J11'Access; when Q16 => J := J16'Access; when Q29 => J := J29'Access; when Q90 => J := J90'Access; end case; end Set_Quality; begin Set_Quality (Q3); end GLOBE_3D.Software_Anti_Aliasing;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . O S _ P R I M I T I V E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1998-2005 Free Software Foundation, Inc. -- -- -- -- GNARL 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 2, or (at your option) any later ver- -- -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the OpenVMS/Alpha version of this file with System.Aux_DEC; package body System.OS_Primitives is -------------------------------------- -- Local functions and declarations -- -------------------------------------- function Get_GMToff return Integer; pragma Import (C, Get_GMToff, "get_gmtoff"); -- Get the offset from GMT for this timezone function VMS_Epoch_Offset return Long_Integer; pragma Inline (VMS_Epoch_Offset); -- The offset between the Unix Epoch and the VMS Epoch subtype Cond_Value_Type is System.Aux_DEC.Unsigned_Longword; -- Condition Value return type ---------------------- -- VMS_Epoch_Offset -- ---------------------- function VMS_Epoch_Offset return Long_Integer is begin return 10_000_000 * (3_506_716_800 + Long_Integer (Get_GMToff)); end VMS_Epoch_Offset; ---------------- -- Sys_Schdwk -- ---------------- -- -- Schedule Wakeup -- -- status = returned status -- pidadr = address of process id to be woken up -- prcnam = name of process to be woken up -- daytim = time to wake up -- reptim = repitition interval of wakeup calls -- procedure Sys_Schdwk ( Status : out Cond_Value_Type; Pidadr : in Address := Null_Address; Prcnam : in String := String'Null_Parameter; Daytim : in Long_Integer; Reptim : in Long_Integer := Long_Integer'Null_Parameter ); pragma Interface (External, Sys_Schdwk); -- VMS system call to schedule a wakeup event pragma Import_Valued_Procedure (Sys_Schdwk, "SYS$SCHDWK", (Cond_Value_Type, Address, String, Long_Integer, Long_Integer), (Value, Value, Descriptor (S), Reference, Reference) ); ---------------- -- Sys_Gettim -- ---------------- -- -- Get System Time -- -- status = returned status -- tim = current system time -- procedure Sys_Gettim ( Status : out Cond_Value_Type; Tim : out OS_Time ); -- VMS system call to get the current system time pragma Interface (External, Sys_Gettim); pragma Import_Valued_Procedure (Sys_Gettim, "SYS$GETTIM", (Cond_Value_Type, OS_Time), (Value, Reference) ); --------------- -- Sys_Hiber -- --------------- -- Hibernate (until woken up) -- status = returned status procedure Sys_Hiber (Status : out Cond_Value_Type); -- VMS system call to hibernate the current process pragma Interface (External, Sys_Hiber); pragma Import_Valued_Procedure (Sys_Hiber, "SYS$HIBER", (Cond_Value_Type), (Value) ); ----------- -- Clock -- ----------- function OS_Clock return OS_Time is Status : Cond_Value_Type; T : OS_Time; begin Sys_Gettim (Status, T); return (T); end OS_Clock; ----------- -- Clock -- ----------- function Clock return Duration is begin return To_Duration (OS_Clock, Absolute_Calendar); end Clock; --------------------- -- Monotonic_Clock -- --------------------- function Monotonic_Clock return Duration renames Clock; ----------------- -- Timed_Delay -- ----------------- procedure Timed_Delay (Time : Duration; Mode : Integer) is Sleep_Time : OS_Time; Status : Cond_Value_Type; begin Sleep_Time := To_OS_Time (Time, Mode); Sys_Schdwk (Status => Status, Daytim => Sleep_Time); Sys_Hiber (Status); end Timed_Delay; ----------------- -- To_Duration -- ----------------- function To_Duration (T : OS_Time; Mode : Integer) return Duration is pragma Warnings (Off, Mode); begin return Duration'Fixed_Value (T - VMS_Epoch_Offset) * 100; end To_Duration; ---------------- -- To_OS_Time -- ---------------- function To_OS_Time (D : Duration; Mode : Integer) return OS_Time is begin if Mode = Relative then return -(Long_Integer'Integer_Value (D) / 100); else return Long_Integer'Integer_Value (D) / 100 + VMS_Epoch_Offset; end if; end To_OS_Time; end System.OS_Primitives;
-- { dg-do run } with Tagged_Type_Pkg; use Tagged_Type_Pkg; with Ada.Text_IO; use Ada.Text_IO; procedure Aliased_Prefix_Accessibility is T_Obj : aliased TT; T_Obj_Acc : access TT'Class := T_Obj'Access; type Nested_TT is limited record TT_Comp : aliased TT; end record; NTT_Obj : Nested_TT; ATT_Obj : array (1 .. 2) of aliased TT; begin begin T_Obj_Acc := Pass_TT_Access (T_Obj'Access); Put_Line ("FAILED (1): call should have raised an exception"); exception when others => null; end; begin T_Obj_Acc := T_Obj.Pass_TT_Access; Put_Line ("FAILED (2): call should have raised an exception"); exception when others => null; end; begin T_Obj_Acc := Pass_TT_Access (NTT_Obj.TT_Comp'Access); Put_Line ("FAILED (3): call should have raised an exception"); exception when others => null; end; begin T_Obj_Acc := NTT_Obj.TT_Comp.Pass_TT_Access; Put_Line ("FAILED (4): call should have raised an exception"); exception when others => null; end; begin T_Obj_Acc := Pass_TT_Access (ATT_Obj (1)'Access); Put_Line ("FAILED (5): call should have raised an exception"); exception when others => null; end; begin T_Obj_Acc := ATT_Obj (2).Pass_TT_Access; Put_Line ("FAILED (6): call should have raised an exception"); exception when others => null; end; end Aliased_Prefix_Accessibility;
$NetBSD: patch-gnatlib-gnat_src-mlib-utl.adb,v 1.1 2013/07/09 10:16:02 marino Exp $ Use unique ada executable rather than generic gcc --- gnatlib/gnat_src/mlib-utl.adb.orig 2010-02-14 02:40:00.000000000 +0100 +++ gnatlib/gnat_src/mlib-utl.adb 2011-10-09 04:11:21.000000000 +0200 @@ -412,7 +412,7 @@ if Driver_Name = No_Name then if Gcc_Exec = null then if Gcc_Name = null then - Gcc_Name := Osint.Program_Name ("gcc", "gnatmake"); + Gcc_Name := Osint.Program_Name ("ada", "gnatmake"); end if; Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all);
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2009-2013, Vadim Godunko <vgodunko@gmail.com> -- -- 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.Text_IO; with Matreshka.Internals.Unicode.Ucd; with Put_File_Header; with Ucd_Data; with Utils; procedure Gen_Cases is use Matreshka.Internals.Unicode; use Matreshka.Internals.Unicode.Ucd; use Ucd_Data; use Utils; type String_Access is access constant String; CC_Final_Sigma_Image : aliased constant String := "Final_Sigma"; CC_After_Soft_Dotted_Image : aliased constant String := "After_Soft_Dotted"; CC_More_Above_Image : aliased constant String := "More_Above"; CC_Before_Dot_Image : aliased constant String := "Before_Dot"; CC_After_I_Image : aliased constant String := "After_I"; Casing_Context_Image : array (Casing_Context) of String_Access := (Final_Sigma => CC_Final_Sigma_Image'Access, After_Soft_Dotted => CC_After_Soft_Dotted_Image'Access, More_Above => CC_More_Above_Image'Access, Before_Dot => CC_Before_Dot_Image'Access, After_I => CC_After_I_Image'Access); B_False_Image : aliased constant String := "False"; B_True_Image : aliased constant String := "True"; Boolean_Image : array (Boolean) of String_Access := (False => B_False_Image'Access, True => B_True_Image'Access); type Group_Info is record Share : First_Stage_Index; Count : Natural; end record; Case_Info : array (Code_Point) of Case_Mapping := (others => ((0, 0, 0, 0), ((0, 0), (0, 0), (0, 0), (0, 0)), 0, 0)); Cont_Info : Casing_Context_Mapping_Sequence (Sequence_Index); Cont_Last : Sequence_Count := 0; Case_Seq : Code_Point_Sequence (Sequence_Index); Last_Seq : Sequence_Count := 0; Groups : array (First_Stage_Index) of Group_Info := (others => (0, 0)); Generated : array (First_Stage_Index) of Boolean := (others => False); procedure Append_Mapping (Mapping : Code_Point_Sequence; First : out Sequence_Index; Last : out Sequence_Count); procedure Put (Item : Case_Mapping); -- Output code for specified item. -------------------- -- Append_Mapping -- -------------------- procedure Append_Mapping (Mapping : Code_Point_Sequence; First : out Sequence_Index; Last : out Sequence_Count) is begin if Mapping'Length = 0 then First := 1; Last := 0; end if; for J in 1 .. Last_Seq - Mapping'Length + 1 loop if Case_Seq (J .. J + Mapping'Length - 1) = Mapping then First := J; Last := J + Mapping'Length - 1; return; end if; end loop; First := Last_Seq + 1; for J in Mapping'Range loop Last_Seq := Last_Seq + 1; Case_Seq (Last_Seq) := Mapping (J); end loop; Last := Last_Seq; end Append_Mapping; --------- -- Put -- --------- procedure Put (Item : Case_Mapping) is Column : Ada.Text_IO.Count := Ada.Text_IO.Col; begin Ada.Text_IO.Put ("((16#" & Code_Point_Image (Item.Simple (Lower)) & "#, 16#" & Code_Point_Image (Item.Simple (Upper)) & "#, 16#" & Code_Point_Image (Item.Simple (Title)) & "#, 16#" & Code_Point_Image (Item.Simple (Folding)) & "#),"); Ada.Text_IO.Set_Col (Column); Ada.Text_IO.Put (" ((" & Sequence_Count_Image (Item.Ranges (Lower).First) & ", " & Sequence_Count_Image (Item.Ranges (Lower).Last) & "), (" & Sequence_Count_Image (Item.Ranges (Upper).First) & ", " & Sequence_Count_Image (Item.Ranges (Upper).Last) & "), (" & Sequence_Count_Image (Item.Ranges (Title).First) & ", " & Sequence_Count_Image (Item.Ranges (Title).Last) & "), (" & Sequence_Count_Image (Item.Ranges (Folding).First) & ", " & Sequence_Count_Image (Item.Ranges (Folding).Last) & ")), " & Sequence_Count_Image (Item.Context_First) & ", " & Sequence_Count_Image (Item.Context_Last) & ")"); end Put; begin Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, " ... cases"); -- Construct casing information. for J in Code_Point loop if Core (J).B (Changes_When_Casemapped) or else Core (J).B (Changes_When_Casefolded) then -- Process data for default casing context. -- Uppercase mapping. if Cases (J).FUM.Default /= null then if Cases (J).FUM.Default'Length /= 1 or else Cases (J).FUM.Default (1) /= J then Append_Mapping (Cases (J).FUM.Default.all, Case_Info (J).Ranges (Upper).First, Case_Info (J).Ranges (Upper).Last); end if; else if Cases (J).SUM.Present then Append_Mapping (Code_Point_Sequence'(1 => Cases (J).SUM.C), Case_Info (J).Ranges (Upper).First, Case_Info (J).Ranges (Upper).Last); end if; end if; if Cases (J).SUM.Present then Case_Info (J).Simple (Upper) := Cases (J).SUM.C; else Case_Info (J).Simple (Upper) := 0; end if; -- Lowercase mapping. if Cases (J).FLM.Default /= null then if Cases (J).FLM.Default'Length /= 1 or else Cases (J).FLM.Default (1) /= J then Append_Mapping (Cases (J).FLM.Default.all, Case_Info (J).Ranges (Lower).First, Case_Info (J).Ranges (Lower).Last); end if; else if Cases (J).SLM.Present then Append_Mapping (Code_Point_Sequence'(1 => Cases (J).SLM.C), Case_Info (J).Ranges (Lower).First, Case_Info (J).Ranges (Lower).Last); end if; end if; if Cases (J).SLM.Present then Case_Info (J).Simple (Lower) := Cases (J).SLM.C; else Case_Info (J).Simple (Lower) := 0; end if; -- Titlecase mapping. if Cases (J).FTM.Default /= null then if Cases (J).FTM.Default'Length /= 1 or else Cases (J).FTM.Default (1) /= J then Append_Mapping (Cases (J).FTM.Default.all, Case_Info (J).Ranges (Title).First, Case_Info (J).Ranges (Title).Last); end if; else if Cases (J).STM.Present then Append_Mapping (Code_Point_Sequence'(1 => Cases (J).STM.C), Case_Info (J).Ranges (Title).First, Case_Info (J).Ranges (Title).Last); end if; end if; if Cases (J).STM.Present then Case_Info (J).Simple (Title) := Cases (J).STM.C; else Case_Info (J).Simple (Title) := 0; end if; -- Casefolding mapping. if Cases (J).FCF /= null then if Cases (J).FCF'Length /= 1 or else Cases (J).FCF (1) /= J then Append_Mapping (Cases (J).FCF.all, Case_Info (J).Ranges (Folding).First, Case_Info (J).Ranges (Folding).Last); end if; else if Cases (J).SCF.Present then Append_Mapping (Code_Point_Sequence'(1 => Cases (J).SCF.C), Case_Info (J).Ranges (Folding).First, Case_Info (J).Ranges (Folding).Last); end if; end if; if Cases (J).SCF.Present then Case_Info (J).Simple (Folding) := Cases (J).SCF.C; else Case_Info (J).Simple (Folding) := 0; end if; -- Process data for Final_Sigma casing context. declare R : Casing_Context_Mapping := (Final_Sigma, False, ((0, 0), (0, 0), (0, 0))); begin if Cases (J).FUM.Positive (Final_Sigma) /= null then Append_Mapping (Cases (J).FUM.Positive (Final_Sigma).all, R.Ranges (Upper).First, R.Ranges (Upper).Last); end if; if Cases (J).FLM.Positive (Final_Sigma) /= null then Append_Mapping (Cases (J).FLM.Positive (Final_Sigma).all, R.Ranges (Lower).First, R.Ranges (Lower).Last); end if; if Cases (J).FTM.Positive (Final_Sigma) /= null then Append_Mapping (Cases (J).FTM.Positive (Final_Sigma).all, R.Ranges (Title).First, R.Ranges (Title).Last); end if; if R /= (Final_Sigma, False, ((0, 0), (0, 0), (0, 0))) then Cont_Last := Cont_Last + 1; Cont_Info (Cont_Last) := R; Case_Info (J).Context_First := Cont_Last; Case_Info (J).Context_Last := Cont_Last; end if; end; end if; end loop; -- Pack groups: reuse groups with the same values. for J in Groups'Range loop for K in 0 .. J loop if Case_Info (Code_Unit_32 (K) * 256 .. Code_Unit_32 (K) * 256 + 255) = Case_Info (Code_Unit_32 (J) * 256 .. Code_Unit_32 (J) * 256 + 255) then Groups (J).Share := K; Groups (K).Count := Groups (K).Count + 1; exit; end if; end loop; end loop; -- Generate source code. Put_File_Header ("Localization, Internationalization, Globalization for Ada", 2009, 2013); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("pragma Restrictions (No_Elaboration_Code);"); Ada.Text_IO.Put_Line ("-- GNAT: enforce generation of preinitialized data section instead of"); Ada.Text_IO.Put_Line ("-- generation of elaboration code."); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("package Matreshka.Internals.Unicode.Ucd.Cases is"); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line (" pragma Preelaborate;"); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line (" Data : aliased constant Code_Point_Sequence"); for J in 1 .. Last_Seq loop if J = 1 then Ada.Text_IO.Put (" := ("); elsif (J - 1) mod 5 = 0 then Ada.Text_IO.Put_Line (","); Ada.Text_IO.Put (" "); else Ada.Text_IO.Put (", "); end if; Ada.Text_IO.Put (Code_Point_Ada_Image (Case_Seq (J))); end loop; Ada.Text_IO.Put_Line (");"); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line (" Context : aliased constant Casing_Context_Mapping_Sequence"); for J in 1 .. Cont_Last loop Ada.Text_IO.Put_Line (" := (1 => (" & Casing_Context_Image (Cont_Info (J).Context).all & ", " & Boolean_Image (Cont_Info (J).Negative).all & ", ((" & Sequence_Count_Image (Cont_Info (J).Ranges (Lower).First) & ", " & Sequence_Count_Image (Cont_Info (J).Ranges (Lower).Last) & "), (" & Sequence_Count_Image (Cont_Info (J).Ranges (Upper).First) & ", " & Sequence_Count_Image (Cont_Info (J).Ranges (Upper).Last) & "), (" & Sequence_Count_Image (Cont_Info (J).Ranges (Title).First) & ", " & Sequence_Count_Image (Cont_Info (J).Ranges (Title).Last) & "))));"); end loop; for J in Groups'Range loop if not Generated (Groups (J).Share) then declare Default : Case_Mapping; Current : Case_Mapping; First : Second_Stage_Index; Last : Second_Stage_Index; First_Code : Code_Point; Last_Code : Code_Point; begin -- Looking for most useful set of values, it will be used for -- others selector for generate more compact code. declare type Value_Count_Pair is record V : Case_Mapping; C : Natural; end record; Counts : array (Positive range 1 .. 256) of Value_Count_Pair := (others => <>); Last : Natural := 0; Maximum : Natural := 0; Index : Positive := 1; begin for K in Second_Stage_Index loop declare C : constant Code_Point := Code_Unit_32 (J) * 256 + Code_Unit_32 (K); R : Case_Mapping renames Case_Info (C); F : Boolean := False; begin -- Go throught known values and try to find the same -- value. for L in 1 .. Last loop if Counts (L).V = R then F := True; Counts (L).C := Counts (L).C + 1; if Maximum < Counts (L).C then Maximum := Counts (L).C; Default := Counts (L).V; end if; exit; end if; end loop; -- If value is not found, then add it to the end of list. if not F then Last := Last + 1; Counts (Last) := (R, 1); end if; end; end loop; end; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line (" Group_" & First_Stage_Image (Groups (J).Share) & " : aliased constant Case_Mapping_Second_Stage"); Ada.Text_IO.Put (" := ("); for K in Second_Stage_Index loop declare Code : constant Code_Point := Code_Unit_32 (J) * 256 + Code_Unit_32 (K); begin if K = Second_Stage_Index'First then Current := Case_Info (Code); First := K; Last := First; First_Code := Code; Last_Code := Code; elsif Case_Info (Code) = Current then Last := K; Last_Code := Code; else if Current /= Default then if First /= Last then Ada.Text_IO.Put_Line ("16#" & Second_Stage_Image (First) & "# .. 16#" & Second_Stage_Image (Last) & "# => -- " & Code_Point_Image (First_Code) & " .. " & Code_Point_Image (Last_Code)); Ada.Text_IO.Set_Col (11); Put (Current); Ada.Text_IO.Put (','); else Ada.Text_IO.Put_Line ("16#" & Second_Stage_Image (First) & "# => -- " & Code_Point_Image (First_Code)); Ada.Text_IO.Set_Col (11); Put (Current); Ada.Text_IO.Put (','); end if; Ada.Text_IO.New_Line; Ada.Text_IO.Set_Col (10); end if; Current := Case_Info (Code); First := K; Last := First; First_Code := Code; Last_Code := First_Code; end if; end; end loop; if Current /= Default then if First /= Last then Ada.Text_IO.Put_Line ("16#" & Second_Stage_Image (First) & "# .. 16#" & Second_Stage_Image (Last) & "# => -- " & Code_Point_Image (First_Code) & " .. " & Code_Point_Image (Last_Code)); Ada.Text_IO.Set_Col (11); Put (Current); Ada.Text_IO.Put (','); else Ada.Text_IO.Put_Line ("16#" & Second_Stage_Image (First) & "# => -- " & Code_Point_Image (First_Code)); Ada.Text_IO.Set_Col (11); Put (Current); Ada.Text_IO.Put (','); end if; Ada.Text_IO.New_Line; Ada.Text_IO.Set_Col (10); end if; Ada.Text_IO.Put_Line ("others =>"); Ada.Text_IO.Set_Col (11); Put (Default); Ada.Text_IO.Put_Line (");"); Generated (J) := True; end; end if; end loop; declare Default : First_Stage_Index := 0; Maximum : Natural := 0; N : Natural := 0; begin for J in Groups'Range loop if Maximum < Groups (J).Count then Maximum := Groups (J).Count; Default := J; end if; end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line (" Mapping : aliased constant Case_Mapping_First_Stage"); Ada.Text_IO.Put (" := ("); for J in Groups'Range loop if Groups (J).Share /= Default then Ada.Text_IO.Put ("16#" & First_Stage_Image (J) & "# => Group_" & First_Stage_Image (Groups (J).Share) & "'Access,"); case N mod 2 is when 0 => Ada.Text_IO.Set_Col (41); when 1 => Ada.Text_IO.New_Line; Ada.Text_IO.Set_Col (10); when others => raise Program_Error; end case; N := N + 1; end if; end loop; Ada.Text_IO.Put_Line ("others => Group_" & First_Stage_Image (Default) & "'Access);"); end; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("end Matreshka.Internals.Unicode.Ucd.Cases;"); end Gen_Cases;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . O S _ I N T E R F A C E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1991-1994, Florida State University -- -- Copyright (C) 1995-2005, AdaCore -- -- -- -- GNARL 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 2, or (at your option) any later ver- -- -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a DCE version of this package. -- Currently HP-UX and SNI use this file pragma Polling (Off); -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. -- This package encapsulates all direct interfaces to OS services -- that are needed by children of System. with Interfaces.C; use Interfaces.C; package body System.OS_Interface is ----------------- -- To_Duration -- ----------------- function To_Duration (TS : timespec) return Duration is begin return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9; end To_Duration; ----------------- -- To_Timespec -- ----------------- function To_Timespec (D : Duration) return timespec is S : time_t; F : Duration; begin S := time_t (Long_Long_Integer (D)); F := D - Duration (S); -- If F has negative value due to a round-up, adjust for positive F -- value. if F < 0.0 then S := S - 1; F := F + 1.0; end if; return timespec'(tv_sec => S, tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); end To_Timespec; function To_Duration (TV : struct_timeval) return Duration is begin return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6; end To_Duration; function To_Timeval (D : Duration) return struct_timeval is S : time_t; F : Duration; begin S := time_t (Long_Long_Integer (D)); F := D - Duration (S); -- If F has negative value due to a round-up, adjust for positive F -- value. if F < 0.0 then S := S - 1; F := F + 1.0; end if; return struct_timeval' (tv_sec => S, tv_usec => time_t (Long_Long_Integer (F * 10#1#E6))); end To_Timeval; ------------------------- -- POSIX.1c Section 3 -- ------------------------- function sigwait (set : access sigset_t; sig : access Signal) return int is Result : int; begin Result := sigwait (set); if Result = -1 then sig.all := 0; return errno; end if; sig.all := Signal (Result); return 0; end sigwait; -- DCE_THREADS does not have pthread_kill. Instead, we just ignore it. function pthread_kill (thread : pthread_t; sig : Signal) return int is pragma Unreferenced (thread, sig); begin return 0; end pthread_kill; -------------------------- -- POSIX.1c Section 11 -- -------------------------- -- For all following functions, DCE Threads has a non standard behavior. -- It sets errno but the standard Posix requires it to be returned. function pthread_mutexattr_init (attr : access pthread_mutexattr_t) return int is function pthread_mutexattr_create (attr : access pthread_mutexattr_t) return int; pragma Import (C, pthread_mutexattr_create, "pthread_mutexattr_create"); begin if pthread_mutexattr_create (attr) /= 0 then return errno; else return 0; end if; end pthread_mutexattr_init; function pthread_mutexattr_destroy (attr : access pthread_mutexattr_t) return int is function pthread_mutexattr_delete (attr : access pthread_mutexattr_t) return int; pragma Import (C, pthread_mutexattr_delete, "pthread_mutexattr_delete"); begin if pthread_mutexattr_delete (attr) /= 0 then return errno; else return 0; end if; end pthread_mutexattr_destroy; function pthread_mutex_init (mutex : access pthread_mutex_t; attr : access pthread_mutexattr_t) return int is function pthread_mutex_init_base (mutex : access pthread_mutex_t; attr : pthread_mutexattr_t) return int; pragma Import (C, pthread_mutex_init_base, "pthread_mutex_init"); begin if pthread_mutex_init_base (mutex, attr.all) /= 0 then return errno; else return 0; end if; end pthread_mutex_init; function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int is function pthread_mutex_destroy_base (mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_mutex_destroy_base, "pthread_mutex_destroy"); begin if pthread_mutex_destroy_base (mutex) /= 0 then return errno; else return 0; end if; end pthread_mutex_destroy; function pthread_mutex_lock (mutex : access pthread_mutex_t) return int is function pthread_mutex_lock_base (mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_mutex_lock_base, "pthread_mutex_lock"); begin if pthread_mutex_lock_base (mutex) /= 0 then return errno; else return 0; end if; end pthread_mutex_lock; function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int is function pthread_mutex_unlock_base (mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_mutex_unlock_base, "pthread_mutex_unlock"); begin if pthread_mutex_unlock_base (mutex) /= 0 then return errno; else return 0; end if; end pthread_mutex_unlock; function pthread_condattr_init (attr : access pthread_condattr_t) return int is function pthread_condattr_create (attr : access pthread_condattr_t) return int; pragma Import (C, pthread_condattr_create, "pthread_condattr_create"); begin if pthread_condattr_create (attr) /= 0 then return errno; else return 0; end if; end pthread_condattr_init; function pthread_condattr_destroy (attr : access pthread_condattr_t) return int is function pthread_condattr_delete (attr : access pthread_condattr_t) return int; pragma Import (C, pthread_condattr_delete, "pthread_condattr_delete"); begin if pthread_condattr_delete (attr) /= 0 then return errno; else return 0; end if; end pthread_condattr_destroy; function pthread_cond_init (cond : access pthread_cond_t; attr : access pthread_condattr_t) return int is function pthread_cond_init_base (cond : access pthread_cond_t; attr : pthread_condattr_t) return int; pragma Import (C, pthread_cond_init_base, "pthread_cond_init"); begin if pthread_cond_init_base (cond, attr.all) /= 0 then return errno; else return 0; end if; end pthread_cond_init; function pthread_cond_destroy (cond : access pthread_cond_t) return int is function pthread_cond_destroy_base (cond : access pthread_cond_t) return int; pragma Import (C, pthread_cond_destroy_base, "pthread_cond_destroy"); begin if pthread_cond_destroy_base (cond) /= 0 then return errno; else return 0; end if; end pthread_cond_destroy; function pthread_cond_signal (cond : access pthread_cond_t) return int is function pthread_cond_signal_base (cond : access pthread_cond_t) return int; pragma Import (C, pthread_cond_signal_base, "pthread_cond_signal"); begin if pthread_cond_signal_base (cond) /= 0 then return errno; else return 0; end if; end pthread_cond_signal; function pthread_cond_wait (cond : access pthread_cond_t; mutex : access pthread_mutex_t) return int is function pthread_cond_wait_base (cond : access pthread_cond_t; mutex : access pthread_mutex_t) return int; pragma Import (C, pthread_cond_wait_base, "pthread_cond_wait"); begin if pthread_cond_wait_base (cond, mutex) /= 0 then return errno; else return 0; end if; end pthread_cond_wait; function pthread_cond_timedwait (cond : access pthread_cond_t; mutex : access pthread_mutex_t; abstime : access timespec) return int is function pthread_cond_timedwait_base (cond : access pthread_cond_t; mutex : access pthread_mutex_t; abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait_base, "pthread_cond_timedwait"); begin if pthread_cond_timedwait_base (cond, mutex, abstime) /= 0 then if errno = EAGAIN then return ETIMEDOUT; else return errno; end if; else return 0; end if; end pthread_cond_timedwait; ---------------------------- -- POSIX.1c Section 13 -- ---------------------------- function pthread_setschedparam (thread : pthread_t; policy : int; param : access struct_sched_param) return int is function pthread_setscheduler (thread : pthread_t; policy : int; priority : int) return int; pragma Import (C, pthread_setscheduler, "pthread_setscheduler"); begin if pthread_setscheduler (thread, policy, param.sched_priority) = -1 then return errno; else return 0; end if; end pthread_setschedparam; function sched_yield return int is procedure pthread_yield; pragma Import (C, pthread_yield, "pthread_yield"); begin pthread_yield; return 0; end sched_yield; ----------------------------- -- P1003.1c - Section 16 -- ----------------------------- function pthread_attr_init (attributes : access pthread_attr_t) return int is function pthread_attr_create (attributes : access pthread_attr_t) return int; pragma Import (C, pthread_attr_create, "pthread_attr_create"); begin if pthread_attr_create (attributes) /= 0 then return errno; else return 0; end if; end pthread_attr_init; function pthread_attr_destroy (attributes : access pthread_attr_t) return int is function pthread_attr_delete (attributes : access pthread_attr_t) return int; pragma Import (C, pthread_attr_delete, "pthread_attr_delete"); begin if pthread_attr_delete (attributes) /= 0 then return errno; else return 0; end if; end pthread_attr_destroy; function pthread_attr_setstacksize (attr : access pthread_attr_t; stacksize : size_t) return int is function pthread_attr_setstacksize_base (attr : access pthread_attr_t; stacksize : size_t) return int; pragma Import (C, pthread_attr_setstacksize_base, "pthread_attr_setstacksize"); begin if pthread_attr_setstacksize_base (attr, stacksize) /= 0 then return errno; else return 0; end if; end pthread_attr_setstacksize; function pthread_create (thread : access pthread_t; attributes : access pthread_attr_t; start_routine : Thread_Body; arg : System.Address) return int is function pthread_create_base (thread : access pthread_t; attributes : pthread_attr_t; start_routine : Thread_Body; arg : System.Address) return int; pragma Import (C, pthread_create_base, "pthread_create"); begin if pthread_create_base (thread, attributes.all, start_routine, arg) /= 0 then return errno; else return 0; end if; end pthread_create; -------------------------- -- POSIX.1c Section 17 -- -------------------------- function pthread_setspecific (key : pthread_key_t; value : System.Address) return int is function pthread_setspecific_base (key : pthread_key_t; value : System.Address) return int; pragma Import (C, pthread_setspecific_base, "pthread_setspecific"); begin if pthread_setspecific_base (key, value) /= 0 then return errno; else return 0; end if; end pthread_setspecific; function pthread_getspecific (key : pthread_key_t) return System.Address is function pthread_getspecific_base (key : pthread_key_t; value : access System.Address) return int; pragma Import (C, pthread_getspecific_base, "pthread_getspecific"); Addr : aliased System.Address; begin if pthread_getspecific_base (key, Addr'Access) /= 0 then return System.Null_Address; else return Addr; end if; end pthread_getspecific; function pthread_key_create (key : access pthread_key_t; destructor : destructor_pointer) return int is function pthread_keycreate (key : access pthread_key_t; destructor : destructor_pointer) return int; pragma Import (C, pthread_keycreate, "pthread_keycreate"); begin if pthread_keycreate (key, destructor) /= 0 then return errno; else return 0; end if; end pthread_key_create; function Get_Stack_Base (thread : pthread_t) return Address is pragma Warnings (Off, thread); begin return Null_Address; end Get_Stack_Base; procedure pthread_init is begin null; end pthread_init; function intr_attach (sig : int; handler : isr_address) return long is function c_signal (sig : int; handler : isr_address) return long; pragma Import (C, c_signal, "signal"); begin return c_signal (sig, handler); end intr_attach; end System.OS_Interface;
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE miscellaneous aflex routines -- AUTHOR: John Self (UCI) -- DESCRIPTION -- NOTES contains functions used in various places throughout aflex. -- $Header: /dc/uc/self/tmp/gnat_aflex/orig/RCS/misc.adb,v 1.1 1995/02/19 01:38:51 self Exp self $ with misc_defs, tstring, text_io, misc, main_body; with int_io, calendar, external_file_manager; use misc, misc_defs, text_io, external_file_manager; package body misc is use TSTRING; -- action_out - write the actions from the temporary file to lex.yy.c procedure ACTION_OUT is BUF : VSTRING; begin while (not TEXT_IO.END_OF_FILE(TEMP_ACTION_FILE)) loop TSTRING.GET_LINE(TEMP_ACTION_FILE, BUF); if ((TSTRING.LEN(BUF) >= 2) and then ((CHAR(BUF, 1) = '%') and (CHAR(BUF, 2) = '%'))) then exit; else TSTRING.PUT_LINE(BUF); end if; end loop; end ACTION_OUT; -- bubble - bubble sort an integer array in increasing order -- -- description -- sorts the first n elements of array v and replaces them in -- increasing order. -- -- passed -- v - the array to be sorted -- n - the number of elements of 'v' to be sorted procedure BUBBLE(V : in INT_PTR; N : in INTEGER) is K : INTEGER; begin for I in reverse 2 .. N loop for J in 1 .. I - 1 loop if (V(J) > V(J + 1)) then -- compare K := V(J); -- exchange V(J) := V(J + 1); V(J + 1) := K; end if; end loop; end loop; end BUBBLE; -- clower - replace upper-case letter to lower-case function CLOWER(C : in INTEGER) return INTEGER is begin if (ISUPPER(CHARACTER'VAL(C))) then return TOLOWER(C); else return C; end if; end CLOWER; -- cshell - shell sort a character array in increasing order -- -- description -- does a shell sort of the first n elements of array v. -- -- passed -- v - array to be sorted -- n - number of elements of v to be sorted procedure CSHELL(V : in out CHAR_ARRAY; N : in INTEGER) is GAP, J, JG : INTEGER; K : CHARACTER; LOWER_BOUND : INTEGER := V'FIRST; begin GAP := N/2; while GAP > 0 loop for I in GAP .. N - 1 loop J := I - GAP; while (J >= 0) loop JG := J + GAP; if (V(J + LOWER_BOUND) <= V(JG + LOWER_BOUND)) then exit; end if; K := V(J + LOWER_BOUND); V(J + LOWER_BOUND) := V(JG + LOWER_BOUND); V(JG + LOWER_BOUND) := K; J := J - GAP; end loop; end loop; GAP := GAP/2; end loop; end CSHELL; -- dataend - finish up a block of data declarations procedure DATAEND is begin if (DATAPOS > 0) then DATAFLUSH; -- add terminator for initialization TEXT_IO.PUT_LINE(" ) ;"); TEXT_IO.NEW_LINE; DATALINE := 0; end if; end DATAEND; -- dataflush - flush generated data statements procedure DATAFLUSH(FILE : in FILE_TYPE) is begin TEXT_IO.NEW_LINE(FILE); DATALINE := DATALINE + 1; if (DATALINE >= NUMDATALINES) then -- put out a blank line so that the table is grouped into -- large blocks that enable the user to find elements easily TEXT_IO.NEW_LINE(FILE); DATALINE := 0; end if; -- reset the number of characters written on the current line DATAPOS := 0; end DATAFLUSH; procedure DATAFLUSH is begin DATAFLUSH(CURRENT_OUTPUT); end DATAFLUSH; -- aflex_gettime - return current time function AFLEX_GETTIME return VSTRING is use TSTRING, CALENDAR; CURRENT_TIME : TIME; CURRENT_YEAR : YEAR_NUMBER; CURRENT_MONTH : MONTH_NUMBER; CURRENT_DAY : DAY_NUMBER; CURRENT_SECONDS : DAY_DURATION; MONTH_STRING, HOUR_STRING, MINUTE_STRING, SECOND_STRING : VSTRING; HOUR, MINUTE, SECOND : INTEGER; SECONDS_PER_HOUR : constant DAY_DURATION := 3600.0; begin CURRENT_TIME := CLOCK; SPLIT(CURRENT_TIME, CURRENT_YEAR, CURRENT_MONTH, CURRENT_DAY, CURRENT_SECONDS); case CURRENT_MONTH is when 1 => MONTH_STRING := VSTR("Jan"); when 2 => MONTH_STRING := VSTR("Feb"); when 3 => MONTH_STRING := VSTR("Mar"); when 4 => MONTH_STRING := VSTR("Apr"); when 5 => MONTH_STRING := VSTR("May"); when 6 => MONTH_STRING := VSTR("Jun"); when 7 => MONTH_STRING := VSTR("Jul"); when 8 => MONTH_STRING := VSTR("Aug"); when 9 => MONTH_STRING := VSTR("Sep"); when 10 => MONTH_STRING := VSTR("Oct"); when 11 => MONTH_STRING := VSTR("Nov"); when 12 => MONTH_STRING := VSTR("Dec"); end case; HOUR := INTEGER(CURRENT_SECONDS)/INTEGER(SECONDS_PER_HOUR); MINUTE := INTEGER((CURRENT_SECONDS - (HOUR*SECONDS_PER_HOUR))/60); SECOND := INTEGER(CURRENT_SECONDS - HOUR*SECONDS_PER_HOUR - MINUTE*60.0); if (HOUR >= 10) then HOUR_STRING := VSTR(INTEGER'IMAGE(HOUR)); else HOUR_STRING := VSTR("0" & INTEGER'IMAGE(HOUR)); end if; if (MINUTE >= 10) then MINUTE_STRING := VSTR(INTEGER'IMAGE(MINUTE)(2 .. INTEGER'IMAGE(MINUTE)' LENGTH)); else MINUTE_STRING := VSTR("0" & INTEGER'IMAGE(MINUTE)(2 .. INTEGER'IMAGE( MINUTE)'LENGTH)); end if; if (SECOND >= 10) then SECOND_STRING := VSTR(INTEGER'IMAGE(SECOND)(2 .. INTEGER'IMAGE(SECOND)' LENGTH)); else SECOND_STRING := VSTR("0" & INTEGER'IMAGE(SECOND)(2 .. INTEGER'IMAGE( SECOND)'LENGTH)); end if; return MONTH_STRING & VSTR(INTEGER'IMAGE(CURRENT_DAY)) & HOUR_STRING & ":" & MINUTE_STRING & ":" & SECOND_STRING & INTEGER'IMAGE(CURRENT_YEAR); end AFLEX_GETTIME; -- aflexerror - report an error message and terminate -- overloaded function, one for vstring, one for string. procedure AFLEXERROR(MSG : in VSTRING) is use TEXT_IO; begin TSTRING.PUT(STANDARD_ERROR, "aflex: " & MSG); TEXT_IO.NEW_LINE(STANDARD_ERROR); MAIN_BODY.AFLEXEND(1); end AFLEXERROR; procedure AFLEXERROR(MSG : in STRING) is use TEXT_IO; begin TEXT_IO.PUT(STANDARD_ERROR, "aflex: " & MSG); TEXT_IO.NEW_LINE(STANDARD_ERROR); MAIN_BODY.AFLEXEND(1); end AFLEXERROR; -- aflexfatal - report a fatal error message and terminate -- overloaded function, one for vstring, one for string. procedure AFLEXFATAL(MSG : in VSTRING) is use TEXT_IO; begin TSTRING.PUT(STANDARD_ERROR, "aflex: fatal internal error " & MSG); TEXT_IO.NEW_LINE(STANDARD_ERROR); MAIN_BODY.AFLEXEND(1); end AFLEXFATAL; procedure AFLEXFATAL(MSG : in STRING) is use TEXT_IO; begin TEXT_IO.PUT(STANDARD_ERROR, "aflex: fatal internal error " & MSG); TEXT_IO.NEW_LINE(STANDARD_ERROR); MAIN_BODY.AFLEXEND(1); end AFLEXFATAL; -- basename - find the basename of a file function BASENAME return VSTRING is END_CHAR_POS : INTEGER := LEN(INFILENAME); START_CHAR_POS : INTEGER; begin if (END_CHAR_POS = 0) then -- if reading standard input give everything this name return VSTR("aflex_yy"); end if; -- find out where the end of the basename is while ((END_CHAR_POS >= 1) and then (CHAR(INFILENAME, END_CHAR_POS) /= '.')) loop END_CHAR_POS := END_CHAR_POS - 1; end loop; -- find out where the beginning of the basename is START_CHAR_POS := END_CHAR_POS; -- start at the end of the basename while ((START_CHAR_POS > 1) and then (CHAR(INFILENAME, START_CHAR_POS) /= '/')) loop START_CHAR_POS := START_CHAR_POS - 1; end loop; if (CHAR(INFILENAME, START_CHAR_POS) = '/') then START_CHAR_POS := START_CHAR_POS + 1; end if; if (END_CHAR_POS >= 1) then return SLICE(INFILENAME, START_CHAR_POS, END_CHAR_POS - 1); else return INFILENAME; end if; end BASENAME; -- line_directive_out - spit out a "# line" statement procedure LINE_DIRECTIVE_OUT(OUTPUT_FILE_NAME : in FILE_TYPE) is begin if (GEN_LINE_DIRS) then TEXT_IO.PUT(OUTPUT_FILE_NAME, "--# line "); INT_IO.PUT(OUTPUT_FILE_NAME, LINENUM, 1); TEXT_IO.PUT(OUTPUT_FILE_NAME, " """); TSTRING.PUT(OUTPUT_FILE_NAME, INFILENAME); TEXT_IO.PUT_LINE(OUTPUT_FILE_NAME, """"); end if; end LINE_DIRECTIVE_OUT; procedure LINE_DIRECTIVE_OUT is begin if (GEN_LINE_DIRS) then TEXT_IO.PUT("--# line "); INT_IO.PUT(LINENUM, 1); TEXT_IO.PUT(" """); TSTRING.PUT(INFILENAME); TEXT_IO.PUT_LINE(""""); end if; end LINE_DIRECTIVE_OUT; -- all_upper - returns true if a string is all upper-case function ALL_UPPER(STR : in VSTRING) return BOOLEAN is begin for I in 1 .. LEN(STR) loop if (not ((CHAR(STR, I) >= 'A') and (CHAR(STR, I) <= 'Z'))) then return FALSE; end if; end loop; return TRUE; end ALL_UPPER; -- all_lower - returns true if a string is all lower-case function ALL_LOWER(STR : in VSTRING) return BOOLEAN is begin for I in 1 .. LEN(STR) loop if (not ((CHAR(STR, I) >= 'a') and (CHAR(STR, I) <= 'z'))) then return FALSE; end if; end loop; return TRUE; end ALL_LOWER; -- mk2data - generate a data statement for a two-dimensional array -- -- generates a data statement initializing the current 2-D array to "value" procedure MK2DATA(FILE : in FILE_TYPE; VALUE : in INTEGER) is begin if (DATAPOS >= NUMDATAITEMS) then TEXT_IO.PUT(FILE, ','); DATAFLUSH(FILE); end if; if (DATAPOS = 0) then -- indent TEXT_IO.PUT(FILE, " "); else TEXT_IO.PUT(FILE, ','); end if; DATAPOS := DATAPOS + 1; INT_IO.PUT(FILE, VALUE, 5); end MK2DATA; procedure MK2DATA(VALUE : in INTEGER) is begin MK2DATA(CURRENT_OUTPUT, VALUE); end MK2DATA; -- -- generates a data statement initializing the current array element to -- "value" procedure MKDATA(VALUE : in INTEGER) is begin if (DATAPOS >= NUMDATAITEMS) then TEXT_IO.PUT(','); DATAFLUSH; end if; if (DATAPOS = 0) then -- indent TEXT_IO.PUT(" "); else TEXT_IO.PUT(','); end if; DATAPOS := DATAPOS + 1; INT_IO.PUT(VALUE, 5); end MKDATA; -- myctoi - return the integer represented by a string of digits function MYCTOI(NUM_ARRAY : in VSTRING) return INTEGER is TOTAL : INTEGER := 0; CNT : INTEGER := TSTRING.FIRST; begin while (CNT <= TSTRING.LEN(NUM_ARRAY)) loop TOTAL := TOTAL*10; TOTAL := TOTAL + CHARACTER'POS(CHAR(NUM_ARRAY, CNT)) - CHARACTER'POS('0') ; CNT := CNT + 1; end loop; return TOTAL; end MYCTOI; -- myesc - return character corresponding to escape sequence function MYESC(ARR : in VSTRING) return CHARACTER is use TEXT_IO; begin case (CHAR(ARR, TSTRING.FIRST + 1)) is when 'a' => return ASCII.BEL; when 'b' => return ASCII.BS; when 'f' => return ASCII.FF; when 'n' => return ASCII.LF; when 'r' => return ASCII.CR; when 't' => return ASCII.HT; when 'v' => return ASCII.VT; when '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => -- \<octal> declare C, ESC_CHAR : CHARACTER; SPTR : INTEGER := TSTRING.FIRST + 1; begin ESC_CHAR := OTOI(TSTRING.SLICE(ARR, TSTRING.FIRST + 1, TSTRING.LEN(ARR ))); if (ESC_CHAR = ASCII.NUL) then MISC.SYNERR("escape sequence for null not allowed"); return ASCII.SOH; end if; return ESC_CHAR; end; when others => return CHAR(ARR, TSTRING.FIRST + 1); end case; end MYESC; -- otoi - convert an octal digit string to an integer value function OTOI(STR : in VSTRING) return CHARACTER is TOTAL : INTEGER := 0; CNT : INTEGER := TSTRING.FIRST; begin while (CNT <= TSTRING.LEN(STR)) loop TOTAL := TOTAL*8; TOTAL := TOTAL + CHARACTER'POS(CHAR(STR, CNT)) - CHARACTER'POS('0'); CNT := CNT + 1; end loop; return CHARACTER'VAL(TOTAL); end OTOI; -- readable_form - return the the human-readable form of a character -- -- The returned string is in static storage. function READABLE_FORM(C : in CHARACTER) return VSTRING is begin if ((CHARACTER'POS(C) >= 0 and CHARACTER'POS(C) < 32) or (C = ASCII.DEL)) then case C is when ASCII.LF => return (VSTR("\n")); -- Newline when ASCII.HT => return (VSTR("\t")); -- Horizontal Tab when ASCII.FF => return (VSTR("\f")); -- Form Feed when ASCII.CR => return (VSTR("\r")); -- Carriage Return when ASCII.BS => return (VSTR("\b")); -- Backspace when others => return VSTR("\" & INTEGER'IMAGE(CHARACTER'POS(C))); end case; elsif (C = ' ') then return VSTR("' '"); else return VSTR(C); end if; end READABLE_FORM; -- transition_struct_out - output a yy_trans_info structure -- -- outputs the yy_trans_info structure with the two elements, element_v and -- element_n. Formats the output with spaces and carriage returns. procedure TRANSITION_STRUCT_OUT(ELEMENT_V, ELEMENT_N : in INTEGER) is begin INT_IO.PUT(ELEMENT_V, 7); TEXT_IO.PUT(", "); INT_IO.PUT(ELEMENT_N, 5); TEXT_IO.PUT(","); DATAPOS := DATAPOS + TRANS_STRUCT_PRINT_LENGTH; if (DATAPOS >= 75) then TEXT_IO.NEW_LINE; DATALINE := DATALINE + 1; if (DATALINE mod 10 = 0) then TEXT_IO.NEW_LINE; end if; DATAPOS := 0; end if; end TRANSITION_STRUCT_OUT; function SET_YY_TRAILING_HEAD_MASK(SRC : in INTEGER) return INTEGER is begin if (CHECK_YY_TRAILING_HEAD_MASK(SRC) = 0) then return SRC + YY_TRAILING_HEAD_MASK; else return SRC; end if; end SET_YY_TRAILING_HEAD_MASK; function CHECK_YY_TRAILING_HEAD_MASK(SRC : in INTEGER) return INTEGER is begin if (SRC >= YY_TRAILING_HEAD_MASK) then return YY_TRAILING_HEAD_MASK; else return 0; end if; end CHECK_YY_TRAILING_HEAD_MASK; function SET_YY_TRAILING_MASK(SRC : in INTEGER) return INTEGER is begin if (CHECK_YY_TRAILING_MASK(SRC) = 0) then return SRC + YY_TRAILING_MASK; else return SRC; end if; end SET_YY_TRAILING_MASK; function CHECK_YY_TRAILING_MASK(SRC : in INTEGER) return INTEGER is begin -- this test is whether both bits are on, or whether onlyy TRAIL_MASK is set if ((SRC >= YY_TRAILING_HEAD_MASK + YY_TRAILING_MASK) or (( CHECK_YY_TRAILING_HEAD_MASK(SRC) = 0) and (SRC >= YY_TRAILING_MASK))) then return YY_TRAILING_MASK; else return 0; end if; end CHECK_YY_TRAILING_MASK; function ISLOWER(C : in CHARACTER) return BOOLEAN is begin return (C in 'a' .. 'z'); end ISLOWER; function ISUPPER(C : in CHARACTER) return BOOLEAN is begin return (C in 'A' .. 'Z'); end ISUPPER; function ISDIGIT(C : in CHARACTER) return BOOLEAN is begin return (C in '0' .. '9'); end ISDIGIT; function TOLOWER(C : in INTEGER) return INTEGER is begin return C - CHARACTER'POS('A') + CHARACTER'POS('a'); end TOLOWER; procedure SYNERR(STR : in STRING) is use TEXT_IO; begin SYNTAXERROR := TRUE; TEXT_IO.PUT(STANDARD_ERROR, "Syntax error at line "); INT_IO.PUT(STANDARD_ERROR, LINENUM); TEXT_IO.PUT(STANDARD_ERROR, STR); TEXT_IO.NEW_LINE(STANDARD_ERROR); end SYNERR; end misc;
-- { dg-do run } with Interfaces; use Interfaces; procedure Conv_Real is Small : constant := 10.0**(-9); type Time_Type is delta Small range -2**63 * Small .. (2**63-1) * Small; for Time_Type'Small use Small; for Time_Type'Size use 64; procedure Cache (Seconds_Per_GDS_Cycle : in Time_Type) is Cycles_Per_Second : constant Time_Type := (1.0 / Seconds_Per_GDS_Cycle); begin if Integer_32 (Seconds_Per_GDS_Cycle * Cycles_Per_Second) /= 1 then raise Program_Error; end if; end Cache; begin Cache (0.035); end;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> -- -- 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; with WSDL.AST.Bindings; pragma Unreferenced (WSDL.AST.Bindings); -- GNAT Pro 7.2.0w (20130423): package is needed to access to type's -- components. with WSDL.AST.Descriptions; pragma Unreferenced (WSDL.AST.Descriptions); -- GNAT Pro 7.2.0w (20130423): package is needed to access to type's -- components. with WSDL.AST.Faults; pragma Unreferenced (WSDL.AST.Faults); -- GNAT Pro 7.2.0w (20130423): package is needed to access to type's -- components. with WSDL.AST.Interfaces; pragma Unreferenced (WSDL.AST.Interfaces); -- XXX GNAT 20130108 reports that unit is not referenced. with WSDL.AST.Operations; pragma Unreferenced (WSDL.AST.Operations); -- XXX GNAT 20130108 reports that unit is not referenced. package body WSDL.Name_Resolvers is use type League.Strings.Universal_String; use type WSDL.AST.Interface_Operation_Access; function Resolve_Binding (Root : not null WSDL.AST.Description_Access; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String) return WSDL.AST.Binding_Access; -- Resolves binding component by qualified name. function Resolve_Interface (Root : not null WSDL.AST.Description_Access; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String) return WSDL.AST.Interface_Access; -- Resolves name of interface component. function Resolve_Interface_Fault (Node : not null WSDL.AST.Interface_Access; Name : WSDL.AST.Qualified_Name) return WSDL.AST.Interface_Fault_Access; -- Resolves name of interface operation component. function Resolve_Interface_Operation (Node : not null WSDL.AST.Interface_Access; Local_Name : League.Strings.Universal_String) return WSDL.AST.Interface_Operation_Access; -- Resolves name of interface operation component. procedure Resolve_Interface_Operation (Node : not null WSDL.AST.Interface_Access; Local_Name : League.Strings.Universal_String; Result : out WSDL.AST.Interface_Operation_Access); ------------------- -- Enter_Binding -- ------------------- overriding procedure Enter_Binding (Self : in out Name_Resolver; Node : not null WSDL.AST.Binding_Access; Control : in out WSDL.Iterators.Traverse_Control) is pragma Unreferenced (Control); begin -- Resolve interface component when necessary. if not Node.Interface_Name.Local_Name.Is_Empty then Node.Interface_Node := Resolve_Interface (Self.Root, Node.Interface_Name.Namespace_URI, Node.Interface_Name.Local_Name); end if; end Enter_Binding; ------------------------- -- Enter_Binding_Fault -- ------------------------- overriding procedure Enter_Binding_Fault (Self : in out Name_Resolver; Node : not null WSDL.AST.Binding_Fault_Access; Control : in out WSDL.Iterators.Traverse_Control) is begin -- Resolve interface fault component. Node.Interface_Fault := Resolve_Interface_Fault (Node.Parent.Interface_Node, Node.Ref); end Enter_Binding_Fault; ----------------------------- -- Enter_Binding_Operation -- ----------------------------- overriding procedure Enter_Binding_Operation (Self : in out Name_Resolver; Node : not null WSDL.AST.Binding_Operation_Access; Control : in out WSDL.Iterators.Traverse_Control) is pragma Unreferenced (Self); pragma Unreferenced (Control); begin -- It is unclear from the specification how namespace URI should be -- used. From the other side, operations are identified uniquely in the -- interface. Node.Interface_Operation := Resolve_Interface_Operation (Node.Parent.Interface_Node, Node.Ref.Local_Name); end Enter_Binding_Operation; -------------------- -- Enter_Endpoint -- -------------------- overriding procedure Enter_Endpoint (Self : in out Name_Resolver; Node : not null WSDL.AST.Endpoints.Endpoint_Access; Control : in out WSDL.Iterators.Traverse_Control) is pragma Unreferenced (Control); begin Node.Binding := Resolve_Binding (Self.Root, Node.Binding_Name.Namespace_URI, Node.Binding_Name.Local_Name); end Enter_Endpoint; --------------------- -- Enter_Interface -- --------------------- overriding procedure Enter_Interface (Self : in out Name_Resolver; Node : not null WSDL.AST.Interface_Access; Control : in out WSDL.Iterators.Traverse_Control) is pragma Unreferenced (Control); begin for J of Node.Extends loop Node.Extended_Interfaces.Append (Resolve_Interface (Self.Root, J.Namespace_URI, J.Local_Name)); end loop; end Enter_Interface; ------------------- -- Enter_Service -- ------------------- overriding procedure Enter_Service (Self : in out Name_Resolver; Node : not null WSDL.AST.Services.Service_Access; Control : in out WSDL.Iterators.Traverse_Control) is pragma Unreferenced (Control); begin -- Resolve interface by qualified name. Node.Interface_Node := Resolve_Interface (Self.Root, Node.Interface_Name.Namespace_URI, Node.Interface_Name.Local_Name); end Enter_Service; --------------------- -- Resolve_Binding -- --------------------- function Resolve_Binding (Root : not null WSDL.AST.Description_Access; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String) return WSDL.AST.Binding_Access is begin -- QName-resolution-1064: "A Description component MUST NOT have such -- broken references." if Root.Target_Namespace /= Namespace_URI then raise Program_Error; end if; if not Root.Bindings.Contains (Local_Name) then raise Program_Error; end if; return Root.Bindings.Element (Local_Name); end Resolve_Binding; ----------------------- -- Resolve_Interface -- ----------------------- function Resolve_Interface (Root : not null WSDL.AST.Description_Access; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String) return WSDL.AST.Interface_Access is begin -- QName-resolution-1064: "A Description component MUST NOT have such -- broken references." if Root.Target_Namespace /= Namespace_URI then raise Program_Error; end if; if not Root.Interfaces.Contains (Local_Name) then raise Program_Error; end if; return Root.Interfaces.Element (Local_Name); end Resolve_Interface; ----------------------------- -- Resolve_Interface_Fault -- ----------------------------- function Resolve_Interface_Fault (Node : not null WSDL.AST.Interface_Access; Name : WSDL.AST.Qualified_Name) return WSDL.AST.Interface_Fault_Access is use type WSDL.AST.Interface_Fault_Access; Result : WSDL.AST.Interface_Fault_Access; begin if Node.Parent.Target_Namespace = Name.Namespace_URI and then Node.Interface_Faults.Contains (Name.Local_Name) then return Node.Interface_Faults.Element (Name.Local_Name); end if; for J of Node.Extended_Interfaces loop Result := Resolve_Interface_Fault (J, Name); if Result /= null then return Result; end if; end loop; raise Program_Error; end Resolve_Interface_Fault; --------------------------------- -- Resolve_Interface_Operation -- --------------------------------- procedure Resolve_Interface_Operation (Node : not null WSDL.AST.Interface_Access; Local_Name : League.Strings.Universal_String; Result : out WSDL.AST.Interface_Operation_Access) is begin Result := null; if Node.Interface_Operations.Contains (Local_Name) then Result := Node.Interface_Operations.Element (Local_Name); return; end if; for J of Node.Extended_Interfaces loop Resolve_Interface_Operation (J, Local_Name, Result); if Result /= null then return; end if; end loop; end Resolve_Interface_Operation; --------------------------------- -- Resolve_Interface_Operation -- --------------------------------- function Resolve_Interface_Operation (Node : not null WSDL.AST.Interface_Access; Local_Name : League.Strings.Universal_String) return WSDL.AST.Interface_Operation_Access is Aux : WSDL.AST.Interface_Operation_Access; begin Resolve_Interface_Operation (Node, Local_Name, Aux); if Aux /= null then return Aux; else raise Program_Error; end if; end Resolve_Interface_Operation; -------------- -- Set_Root -- -------------- procedure Set_Root (Self : in out Name_Resolver'Class; Root : WSDL.AST.Description_Access) is begin Self.Root := Root; end Set_Root; end WSDL.Name_Resolvers;
with Ada.Text_IO, Ada.Integer_Text_IO; procedure User_Input is I : Integer; begin Ada.Text_IO.Put ("Enter a string: "); declare S : String := Ada.Text_IO.Get_Line; begin Ada.Text_IO.Put_Line (S); end; Ada.Text_IO.Put ("Enter an integer: "); Ada.Integer_Text_IO.Get(I); Ada.Text_IO.Put_Line (Integer'Image(I)); end User_Input;
with Ada.Strings.Unbounded; package Offmt_Lib.Storage is type Store_Result (Success : Boolean) is record case Success is when True => null; when False => Msg : Ada.Strings.Unbounded.Unbounded_String; end case; end record; function Store (Map : Trace_Map; Filename : String) return Store_Result; type Load_Result (Success : Boolean) is record case Success is when True => Map : Trace_Map; when False => Msg : Ada.Strings.Unbounded.Unbounded_String; end case; end record; function Load (Filename : String) return Load_Result; end Offmt_Lib.Storage;
----------------------------------------------------------------------- -- awa-wikis-writers -- Wiki HTML writer -- Copyright (C) 2011, 2012, 2013, 2014, 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Strings; package body AWA.Wikis.Writers.Html is use AWA.Wikis.Documents; -- ------------------------------ -- Wiki to HTML writer -- ------------------------------ -- Set the output writer. -- ------------------------------ procedure Set_Writer (Document : in out Html_Writer; Writer : in ASF.Contexts.Writer.Response_Writer_Access) is begin Document.Writer := Writer; end Set_Writer; -- ------------------------------ -- Add a section header in the document. -- ------------------------------ overriding procedure Add_Header (Document : in out Html_Writer; Header : in Unbounded_Wide_Wide_String; Level : in Positive) is begin Document.Close_Paragraph; Document.Add_Blockquote (0); case Level is when 1 => Document.Writer.Write_Wide_Element ("h1", Header); when 2 => Document.Writer.Write_Wide_Element ("h2", Header); when 3 => Document.Writer.Write_Wide_Element ("h3", Header); when 4 => Document.Writer.Write_Wide_Element ("h4", Header); when 5 => Document.Writer.Write_Wide_Element ("h5", Header); when 6 => Document.Writer.Write_Wide_Element ("h6", Header); when others => Document.Writer.Write_Wide_Element ("h3", Header); end case; end Add_Header; -- ------------------------------ -- Add a line break (<br>). -- ------------------------------ overriding procedure Add_Line_Break (Document : in out Html_Writer) is begin Document.Writer.Write_Raw ("<br />"); end Add_Line_Break; -- ------------------------------ -- Add a paragraph (<p>). Close the previous paragraph if any. -- The paragraph must be closed at the next paragraph or next header. -- ------------------------------ overriding procedure Add_Paragraph (Document : in out Html_Writer) is begin Document.Close_Paragraph; Document.Need_Paragraph := True; end Add_Paragraph; -- ------------------------------ -- Add a blockquote (<blockquote>). The level indicates the blockquote nested level. -- The blockquote must be closed at the next header. -- ------------------------------ overriding procedure Add_Blockquote (Document : in out Html_Writer; Level : in Natural) is begin if Document.Quote_Level /= Level then Document.Close_Paragraph; Document.Need_Paragraph := True; end if; while Document.Quote_Level < Level loop Document.Writer.Start_Element ("blockquote"); Document.Quote_Level := Document.Quote_Level + 1; end loop; while Document.Quote_Level > Level loop Document.Writer.End_Element ("blockquote"); Document.Quote_Level := Document.Quote_Level - 1; end loop; end Add_Blockquote; -- ------------------------------ -- Add a list item (<li>). Close the previous paragraph and list item if any. -- The list item will be closed at the next list item, next paragraph or next header. -- ------------------------------ overriding procedure Add_List_Item (Document : in out Html_Writer; Level : in Positive; Ordered : in Boolean) is begin if Document.Has_Paragraph then Document.Writer.End_Element ("p"); Document.Has_Paragraph := False; end if; if Document.Has_Item then Document.Writer.End_Element ("li"); Document.Has_Item := False; end if; Document.Need_Paragraph := False; Document.Open_Paragraph; while Document.Current_Level < Level loop if Ordered then Document.Writer.Start_Element ("ol"); else Document.Writer.Start_Element ("ul"); end if; Document.Current_Level := Document.Current_Level + 1; Document.List_Styles (Document.Current_Level) := Ordered; end loop; end Add_List_Item; procedure Close_Paragraph (Document : in out Html_Writer) is begin if Document.Has_Paragraph then Document.Writer.End_Element ("p"); end if; if Document.Has_Item then Document.Writer.End_Element ("li"); end if; while Document.Current_Level > 0 loop if Document.List_Styles (Document.Current_Level) then Document.Writer.End_Element ("ol"); else Document.Writer.End_Element ("ul"); end if; Document.Current_Level := Document.Current_Level - 1; end loop; Document.Has_Paragraph := False; Document.Has_Item := False; end Close_Paragraph; procedure Open_Paragraph (Document : in out Html_Writer) is begin if Document.Need_Paragraph then Document.Writer.Start_Element ("p"); Document.Has_Paragraph := True; Document.Need_Paragraph := False; end if; if Document.Current_Level > 0 and not Document.Has_Item then Document.Writer.Start_Element ("li"); Document.Has_Item := True; end if; end Open_Paragraph; -- ------------------------------ -- Add an horizontal rule (<hr>). -- ------------------------------ overriding procedure Add_Horizontal_Rule (Document : in out Html_Writer) is begin Document.Close_Paragraph; Document.Add_Blockquote (0); Document.Writer.Start_Element ("hr"); Document.Writer.End_Element ("hr"); end Add_Horizontal_Rule; -- ------------------------------ -- Add a link. -- ------------------------------ overriding procedure Add_Link (Document : in out Html_Writer; Name : in Unbounded_Wide_Wide_String; Link : in Unbounded_Wide_Wide_String; Language : in Unbounded_Wide_Wide_String; Title : in Unbounded_Wide_Wide_String) is begin Document.Open_Paragraph; Document.Writer.Start_Element ("a"); if Length (Title) > 0 then Document.Writer.Write_Wide_Attribute ("title", Title); end if; if Length (Language) > 0 then Document.Writer.Write_Wide_Attribute ("lang", Language); end if; Document.Writer.Write_Wide_Attribute ("href", Link); Document.Writer.Write_Wide_Text (Name); Document.Writer.End_Element ("a"); end Add_Link; -- ------------------------------ -- Add an image. -- ------------------------------ overriding procedure Add_Image (Document : in out Html_Writer; Link : in Unbounded_Wide_Wide_String; Alt : in Unbounded_Wide_Wide_String; Position : in Unbounded_Wide_Wide_String; Description : in Unbounded_Wide_Wide_String) is pragma Unreferenced (Position); begin Document.Open_Paragraph; Document.Writer.Start_Element ("img"); if Length (Alt) > 0 then Document.Writer.Write_Wide_Attribute ("alt", Alt); end if; if Length (Description) > 0 then Document.Writer.Write_Wide_Attribute ("longdesc", Description); end if; Document.Writer.Write_Wide_Attribute ("src", Link); Document.Writer.End_Element ("img"); end Add_Image; -- ------------------------------ -- Add a quote. -- ------------------------------ overriding procedure Add_Quote (Document : in out Html_Writer; Quote : in Unbounded_Wide_Wide_String; Link : in Unbounded_Wide_Wide_String; Language : in Unbounded_Wide_Wide_String) is begin Document.Open_Paragraph; Document.Writer.Start_Element ("q"); if Length (Language) > 0 then Document.Writer.Write_Wide_Attribute ("lang", Language); end if; if Length (Link) > 0 then Document.Writer.Write_Wide_Attribute ("cite", Link); end if; Document.Writer.Write_Wide_Text (Quote); Document.Writer.End_Element ("q"); end Add_Quote; HTML_BOLD : aliased constant String := "b"; HTML_ITALIC : aliased constant String := "i"; HTML_CODE : aliased constant String := "tt"; HTML_SUPERSCRIPT : aliased constant String := "sup"; HTML_SUBSCRIPT : aliased constant String := "sub"; HTML_STRIKEOUT : aliased constant String := "del"; -- HTML_UNDERLINE : aliased constant String := "ins"; HTML_PREFORMAT : aliased constant String := "pre"; type String_Array_Access is array (Documents.Format_Type) of Util.Strings.Name_Access; HTML_ELEMENT : constant String_Array_Access := (BOLD => HTML_BOLD'Access, ITALIC => HTML_ITALIC'Access, CODE => HTML_CODE'Access, SUPERSCRIPT => HTML_SUPERSCRIPT'Access, SUBSCRIPT => HTML_SUBSCRIPT'Access, STRIKEOUT => HTML_STRIKEOUT'Access, PREFORMAT => HTML_PREFORMAT'Access); -- ------------------------------ -- Add a text block with the given format. -- ------------------------------ overriding procedure Add_Text (Document : in out Html_Writer; Text : in Unbounded_Wide_Wide_String; Format : in AWA.Wikis.Documents.Format_Map) is begin Document.Open_Paragraph; for I in Format'Range loop if Format (I) then Document.Writer.Start_Element (HTML_ELEMENT (I).all); end if; end loop; Document.Writer.Write_Wide_Text (Text); for I in reverse Format'Range loop if Format (I) then Document.Writer.End_Element (HTML_ELEMENT (I).all); end if; end loop; end Add_Text; -- ------------------------------ -- Add a text block that is pre-formatted. -- ------------------------------ procedure Add_Preformatted (Document : in out Html_Writer; Text : in Unbounded_Wide_Wide_String; Format : in Unbounded_Wide_Wide_String) is begin Document.Close_Paragraph; if Format = "html" then Document.Writer.Write (Text); else Document.Writer.Start_Element ("pre"); Document.Writer.Write_Wide_Text (Text); Document.Writer.End_Element ("pre"); end if; end Add_Preformatted; -- ------------------------------ -- Finish the document after complete wiki text has been parsed. -- ------------------------------ overriding procedure Finish (Document : in out Html_Writer) is begin Document.Close_Paragraph; Document.Add_Blockquote (0); end Finish; end AWA.Wikis.Writers.Html;
----------------------------------------------------------------------- -- awa-commands-drivers -- Driver for AWA commands for server or admin tool -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Command_Line; with Servlet.Core; package body AWA.Commands.Drivers is use Ada.Strings.Unbounded; use AWA.Applications; function "-" (Message : in String) return String is (Message); Help_Command : aliased AWA.Commands.Drivers.Help_Command_Type; -- ------------------------------ -- Setup the command before parsing the arguments and executing it. -- ------------------------------ overriding procedure Setup (Command : in out Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Context_Type) is begin GC.Set_Usage (Config => Config, Usage => Command.Get_Name & " [arguments]", Help => Command.Get_Description); AWA.Commands.Setup_Command (Config, Context); end Setup; -- ------------------------------ -- Write the help associated with the command. -- ------------------------------ overriding procedure Help (Command : in out Command_Type; Name : in String; Context : in out Context_Type) is pragma Unreferenced (Command, Context); begin null; end Help; -- ------------------------------ -- Setup the command before parsing the arguments and executing it. -- ------------------------------ overriding procedure Setup (Command : in out Application_Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Context_Type) is begin GC.Define_Switch (Config => Config, Output => Command.Application_Name'Access, Switch => "-a:", Long_Switch => "--application=", Argument => "NAME", Help => -("Defines the name or URI of the application")); AWA.Commands.Setup_Command (Config, Context); end Setup; function Is_Application (Command : in Application_Command_Type; URI : in String) return Boolean is begin return Command.Application_Name.all = URI; end Is_Application; overriding procedure Execute (Command : in out Application_Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Context_Type) is pragma Unreferenced (Name); procedure Find (URI : in String; App : in Servlet.Core.Servlet_Registry_Access); Count : Natural := 0; Selected : Application_Access; App_Name : Unbounded_String; procedure Find (URI : in String; App : in Servlet.Core.Servlet_Registry_Access) is begin if App.all in Application'Class then if Command.Is_Application (URI) then App_Name := To_Unbounded_String (URI (URI'First + 1 .. URI'Last)); Selected := Application'Class (App.all)'Unchecked_Access; Count := Count + 1; elsif Command.Application_Name'Length = 0 then App_Name := To_Unbounded_String (URI (URI'First + 1 .. URI'Last)); Selected := Application'Class (App.all)'Unchecked_Access; Count := Count + 1; end if; end if; end Find; begin WS.Iterate (Find'Access); if Count /= 1 then Context.Console.Notice (N_ERROR, -("No application found")); return; end if; Configure (Selected.all, To_String (App_Name), Context); Application_Command_Type'Class (Command).Execute (Selected.all, Args, Context); end Execute; -- ------------------------------ -- Print the command usage. -- ------------------------------ procedure Usage (Args : in Argument_List'Class; Context : in out Context_Type; Name : in String := "") is begin GC.Display_Help (Context.Command_Config); if Name'Length > 0 then Driver.Usage (Args, Context, Name); end if; Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); end Usage; -- ------------------------------ -- Execute the command with its arguments. -- ------------------------------ procedure Execute (Name : in String; Args : in Argument_List'Class; Context : in out Context_Type) is begin Driver.Execute (Name, Args, Context); end Execute; procedure Run (Context : in out Context_Type; Arguments : out Util.Commands.Dynamic_Argument_List) is begin GC.Getopt (Config => Context.Command_Config); Util.Commands.Parsers.GNAT_Parser.Get_Arguments (Arguments, GC.Get_Argument); if Context.Config_File'Length = 0 then Context.Load_Configuration (Driver_Name & ".properties"); else Context.Load_Configuration (Context.Config_File.all); end if; if Context.Debug or Context.Verbose or Context.Dump then Configure_Logs (Root => Context.Global_Config.Get ("log4j.rootCategory", ""), Debug => Context.Debug, Dump => Context.Dump, Verbose => Context.Verbose); end if; declare Cmd_Name : constant String := Arguments.Get_Command_Name; begin if Cmd_Name'Length = 0 then Context.Console.Notice (N_ERROR, -("Missing command name to execute.")); Usage (Arguments, Context); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); return; end if; Execute (Cmd_Name, Arguments, Context); exception when GNAT.Command_Line.Invalid_Parameter => Context.Console.Notice (N_ERROR, -("Missing option parameter")); raise Error; end; end Run; begin Driver.Add_Command ("help", -("print some help"), Help_Command'Access); end AWA.Commands.Drivers;
Pragma Ada_2012; Pragma Wide_Character_Encoding( UTF8 ); with Risi_Script.Types.Implementation, Ada.Characters.Handling; Package Risi_Script.Types.Patterns is Use Risi_Script.Types.Implementation; --------------------- -- PATTERN TYPES -- --------------------- --#TODO: Implement the pattern-types; they should have to- and from- --# string conversion functions. Type Half_Pattern(<>) is private; Type Three_Quarter_Pattern(<>) is private; Type Full_Pattern(<>) is private; Type Extended_Pattern(<>) is private; Type Square_Pattern(<>) is private; Type Cubic_Pattern(<>) is private; Type Power_Pattern(<>) is private; -- Pattern to String conversion. Function "+"( Pattern : Half_Pattern ) return String; Function "+"( Pattern : Three_Quarter_Pattern ) return String; Function "+"( Pattern : Full_Pattern ) return String; Function "+"( Pattern : Extended_Pattern ) return String; Function "+"( Pattern : Square_Pattern ) return String; Function "+"( Pattern : Cubic_Pattern ) return String; Function "+"( Pattern : Power_Pattern ) return String; -- String to Pattern conversion. -- Function "+"( Text : String ) return Half_Pattern; -- Function "+"( Text : String ) return Three_Quarter_Pattern; -- Function "+"( Text : String ) return Full_Pattern; -- Function "+"( Text : String ) return Extended_Pattern; -- Function "+"( Text : String ) return Square_Pattern; -- Function "+"( Text : String ) return Cubic_Pattern; -- Function "+"( Text : String ) return Power_Pattern; Function Match( Pattern : Half_Pattern; Indicators : Indicator_String ) return Boolean; Function Create( Input : Variable_List ) return Half_Pattern; ------------------ -- ATP Packet -- ------------------ -- Type ATP_Packet is private; -- function Create( Input : Variable_List ) return ATP_Packet; Private ---------------------------------- -- ELEMENTS FOR PATTERN TYPES -- ---------------------------------- Use Risi_Script.Types, Risi_Script.Types.Implementation; Type Enumeration_Length(Enum : Enumeration) is record case Enum is when RT_String | RT_Array | RT_Hash => Length : Natural; when others => Null; end case; end record; Type Pattern_Element is ( Half, Three_Quarter, Full ); Subtype Extended_Pattern_Element is Pattern_Element Range Half..Full; type Varying_Element( Element : Extended_Pattern_Element ) is record case Element is when Half => Half_Value : Enumeration; when Three_Quarter => TQ_Value : not null access Enumeration_Length; when Full => Full_Value : Representation; end case; end record; Type Half_Pattern is array (Positive range <>) of Enumeration; Type Three_Quarter_Pattern is array (Positive range <>) of not null access Enumeration_Length; Type Full_Pattern is array (Positive range <>) of Representation; Type Extended_Pattern is array (Positive range <>) of not null access Varying_Element; Type Square_Pattern is null record; Type Cubic_Pattern is null record; Type Power_Pattern is null record; -- Type ATP_Packet is record -- null; -- end record; -- function Create( Input : Variable_List ) return ATP_Packet is (null record); Package Conversions is -- Pattern to String conversion. Function Convert( Pattern : Half_Pattern ) return String; Function Convert( Pattern : Three_Quarter_Pattern ) return String; Function Convert( Pattern : Full_Pattern ) return String; Function Convert( Pattern : Extended_Pattern ) return String; Function Convert( Pattern : Square_Pattern ) return String; Function Convert( Pattern : Cubic_Pattern ) return String; Function Convert( Pattern : Power_Pattern ) return String; -- String to Pattern conversion. -- Function Convert( Text : String ) return Half_Pattern; -- Function Convert( Text : String ) return Three_Quarter_Pattern; -- Function Convert( Text : String ) return Full_Pattern; -- Function Convert( Text : String ) return Extended_Pattern; -- Function Convert( Text : String ) return Square_Pattern; -- Function Convert( Text : String ) return Cubic_Pattern; -- Function Convert( Text : String ) return Power_Pattern; end Conversions; Use Conversions; -- Pattern to String conversion. Function "+"( Pattern : Half_Pattern ) return String renames Convert; Function "+"( Pattern : Three_Quarter_Pattern ) return String renames Convert; Function "+"( Pattern : Full_Pattern ) return String renames Convert; Function "+"( Pattern : Extended_Pattern ) return String renames Convert; Function "+"( Pattern : Square_Pattern ) return String renames Convert; Function "+"( Pattern : Cubic_Pattern ) return String renames Convert; Function "+"( Pattern : Power_Pattern ) return String renames Convert; -- String to Pattern conversion. -- Function "+"( Text : String ) return Half_Pattern renames Convert; -- Function "+"( Text : String ) return Three_Quarter_Pattern renames Convert; -- Function "+"( Text : String ) return Full_Pattern renames Convert; -- Function "+"( Text : String ) return Extended_Pattern renames Convert; -- Function "+"( Text : String ) return Square_Pattern renames Convert; -- Function "+"( Text : String ) return Cubic_Pattern renames Convert; -- Function "+"( Text : String ) return Power_Pattern renames Convert; End Risi_Script.Types.Patterns;
with Ada.Text_IO; use Ada.Text_IO; with Resources; with Lib_A; with Tests_Config; procedure Tests is package My_Resources is new Resources (Tests_Config.Crate_Name); begin Put_Line ("Prefix_Path: " & My_Resources.Prefix_Path); Put_Line ("Lib_A Prefix_Path: " & Lib_A.Resources.Prefix_Path); Put_Line ("Test Resource_Path: " & My_Resources.Resource_Path); Put_Line ("Lib_A Resource_Path: " & Lib_A.Resources.Resource_Path); Lib_A.Print_Content; end Tests;
pragma License (Unrestricted); with Ada.Text_IO; package Ada.Long_Integer_Text_IO is new Text_IO.Integer_IO (Long_Integer);
with Vectores_Genericos; package Vectores_Luminosidad is new Vectores_Genericos( Max => 10, Elemento => Float );
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- generic type Index is (<>); type Element is private; type Element_Array is array (Index range <>) of aliased Element; Default_Terminator : Element; package Interfaces.C.Pointers is pragma Preelaborate (Pointers); type Pointer is access all Element; function Value (Ref : in Pointer; Terminator : in Element := Default_Terminator) return Element_Array; function Value (Ref : in Pointer; Length : in ptrdiff_t) return Element_Array; Pointer_Error : exception; -- C-style Pointer arithmetic function "+" (Left : in Pointer; Right : in ptrdiff_t) return Pointer; function "+" (Left : in ptrdiff_t; Right : in Pointer) return Pointer; function "-" (Left : in Pointer; Right : in ptrdiff_t) return Pointer; function "-" (Left : in Pointer; Right : in Pointer) return ptrdiff_t; procedure Increment (Ref : in out Pointer); procedure Decrement (Ref : in out Pointer); pragma Convention (Intrinsic, "+"); pragma Convention (Intrinsic, "-"); pragma Convention (Intrinsic, Increment); pragma Convention (Intrinsic, Decrement); function Virtual_Length (Ref : in Pointer; Terminator : in Element := Default_Terminator) return ptrdiff_t; procedure Copy_Terminated_Array (Source : in Pointer; Target : in Pointer; Limit : in ptrdiff_t := ptrdiff_t'Last; Terminator : in Element := Default_Terminator); procedure Copy_Array (Source : in Pointer; Target : in Pointer; Length : in ptrdiff_t); end Interfaces.C.Pointers;
-- -- Copyright 2021 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- package body Edc_Client.Alpha.Common is -- LUT for codes for possible single letter positions SL_Position_Codes : constant array (1 .. 8) of Character := (1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8'); -- LUT for codes for possible double letter positions DL_Position_Codes : constant array (1 .. 4) of Character := (1 => '1', 2 => '2', 3 => '3', 4 => '4'); procedure Show_Single_Letter (Position : Integer; Block : Character; Value : String) is Command : String := "ABNPC"; begin Command (2) := Block; Command (4) := SL_Position_Codes (Position); Command (5) := Value (Value'First); Transmitter (Command); end Show_Single_Letter; procedure Show_Double_Letters (Position : Integer; Block : Character; Value : String) is Command : String := "ABBPCC"; begin Command (2) := Block; Command (4) := DL_Position_Codes (Position); Command (5 .. 6) := Value (Value'First .. Value'First + 1); Transmitter (Command); end Show_Double_Letters; procedure Show_Four_Letters (Position : Integer; Block : Character; Value : String) is Command : String := "ABW1CCCC"; begin Command (2) := Block; Command (4) := DL_Position_Codes (Position); Command (5 .. 8) := Value (Value'First .. Value'First + 3); Transmitter (Command); end Show_Four_Letters; end Edc_Client.Alpha.Common;
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: -- $Revision: 1.21 $ -- $Date: 2009/12/26 17:38:58 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux; with Ada.Unchecked_Deallocation; with Ada.Unchecked_Conversion; -- | -- |===================================================================== -- | man page form_fieldtype.3x -- |===================================================================== -- | package body Terminal_Interface.Curses.Forms.Field_Types is use type System.Address; pragma Warnings (Off); function To_Argument_Access is new Ada.Unchecked_Conversion (System.Address, Argument_Access); pragma Warnings (On); function Get_Fieldtype (F : Field) return C_Field_Type; pragma Import (C, Get_Fieldtype, "field_type"); function Get_Arg (F : Field) return System.Address; pragma Import (C, Get_Arg, "field_arg"); -- | -- |===================================================================== -- | man page form_field_validation.3x -- |===================================================================== -- | -- | -- | function Get_Type (Fld : Field) return Field_Type_Access is Low_Level : constant C_Field_Type := Get_Fieldtype (Fld); Arg : Argument_Access; begin if Low_Level = Null_Field_Type then return null; else if Low_Level = M_Builtin_Router or else Low_Level = M_Generic_Type or else Low_Level = M_Choice_Router or else Low_Level = M_Generic_Choice then Arg := To_Argument_Access (Get_Arg (Fld)); if Arg = null then raise Form_Exception; else return Arg.Typ; end if; else raise Form_Exception; end if; end if; end Get_Type; function Make_Arg (Args : System.Address) return System.Address is -- Actually args is a double indirected pointer to the arguments -- of a C variable argument list. In theory it is now quite -- complicated to write portable routine that reads the arguments, -- because one has to know the growth direction of the stack and -- the sizes of the individual arguments. -- Fortunately we are only interested in the first argument (#0), -- we know its size and for the first arg we don't care about -- into which stack direction we have to proceed. We simply -- resolve the double indirection and thats it. type V is access all System.Address; function To_Access is new Ada.Unchecked_Conversion (System.Address, V); begin return To_Access (To_Access (Args).all).all; end Make_Arg; function Copy_Arg (Usr : System.Address) return System.Address is begin return Usr; end Copy_Arg; procedure Free_Arg (Usr : System.Address) is procedure Free_Type is new Ada.Unchecked_Deallocation (Field_Type'Class, Field_Type_Access); procedure Freeargs is new Ada.Unchecked_Deallocation (Argument, Argument_Access); To_Be_Free : Argument_Access := To_Argument_Access (Usr); Low_Level : C_Field_Type; begin if To_Be_Free /= null then if To_Be_Free.Usr /= System.Null_Address then Low_Level := To_Be_Free.Cft; if Low_Level.Freearg /= null then Low_Level.Freearg (To_Be_Free.Usr); end if; end if; if To_Be_Free.Typ /= null then Free_Type (To_Be_Free.Typ); end if; Freeargs (To_Be_Free); end if; end Free_Arg; procedure Wrap_Builtin (Fld : Field; Typ : Field_Type'Class; Cft : C_Field_Type := C_Builtin_Router) is Usr_Arg : constant System.Address := Get_Arg (Fld); Low_Level : constant C_Field_Type := Get_Fieldtype (Fld); Arg : Argument_Access; Res : Eti_Error; function Set_Fld_Type (F : Field := Fld; Cf : C_Field_Type := Cft; Arg1 : Argument_Access) return C_Int; pragma Import (C, Set_Fld_Type, "set_field_type"); begin pragma Assert (Low_Level /= Null_Field_Type); if Cft /= C_Builtin_Router and then Cft /= C_Choice_Router then raise Form_Exception; else Arg := new Argument'(Usr => System.Null_Address, Typ => new Field_Type'Class'(Typ), Cft => Get_Fieldtype (Fld)); if Usr_Arg /= System.Null_Address then if Low_Level.Copyarg /= null then Arg.Usr := Low_Level.Copyarg (Usr_Arg); else Arg.Usr := Usr_Arg; end if; end if; Res := Set_Fld_Type (Arg1 => Arg); if Res /= E_Ok then Eti_Exception (Res); end if; end if; end Wrap_Builtin; function Field_Check_Router (Fld : Field; Usr : System.Address) return C_Int is Arg : constant Argument_Access := To_Argument_Access (Usr); begin pragma Assert (Arg /= null and then Arg.Cft /= Null_Field_Type and then Arg.Typ /= null); if Arg.Cft.Fcheck /= null then return Arg.Cft.Fcheck (Fld, Arg.Usr); else return 1; end if; end Field_Check_Router; function Char_Check_Router (Ch : C_Int; Usr : System.Address) return C_Int is Arg : constant Argument_Access := To_Argument_Access (Usr); begin pragma Assert (Arg /= null and then Arg.Cft /= Null_Field_Type and then Arg.Typ /= null); if Arg.Cft.Ccheck /= null then return Arg.Cft.Ccheck (Ch, Arg.Usr); else return 1; end if; end Char_Check_Router; function Next_Router (Fld : Field; Usr : System.Address) return C_Int is Arg : constant Argument_Access := To_Argument_Access (Usr); begin pragma Assert (Arg /= null and then Arg.Cft /= Null_Field_Type and then Arg.Typ /= null); if Arg.Cft.Next /= null then return Arg.Cft.Next (Fld, Arg.Usr); else return 1; end if; end Next_Router; function Prev_Router (Fld : Field; Usr : System.Address) return C_Int is Arg : constant Argument_Access := To_Argument_Access (Usr); begin pragma Assert (Arg /= null and then Arg.Cft /= Null_Field_Type and then Arg.Typ /= null); if Arg.Cft.Prev /= null then return Arg.Cft.Prev (Fld, Arg.Usr); else return 1; end if; end Prev_Router; -- ----------------------------------------------------------------------- -- function C_Builtin_Router return C_Field_Type is Res : Eti_Error; T : C_Field_Type; begin if M_Builtin_Router = Null_Field_Type then T := New_Fieldtype (Field_Check_Router'Access, Char_Check_Router'Access); if T = Null_Field_Type then raise Form_Exception; else Res := Set_Fieldtype_Arg (T, Make_Arg'Access, Copy_Arg'Access, Free_Arg'Access); if Res /= E_Ok then Eti_Exception (Res); end if; end if; M_Builtin_Router := T; end if; pragma Assert (M_Builtin_Router /= Null_Field_Type); return M_Builtin_Router; end C_Builtin_Router; -- ----------------------------------------------------------------------- -- function C_Choice_Router return C_Field_Type is Res : Eti_Error; T : C_Field_Type; begin if M_Choice_Router = Null_Field_Type then T := New_Fieldtype (Field_Check_Router'Access, Char_Check_Router'Access); if T = Null_Field_Type then raise Form_Exception; else Res := Set_Fieldtype_Arg (T, Make_Arg'Access, Copy_Arg'Access, Free_Arg'Access); if Res /= E_Ok then Eti_Exception (Res); end if; Res := Set_Fieldtype_Choice (T, Next_Router'Access, Prev_Router'Access); if Res /= E_Ok then Eti_Exception (Res); end if; end if; M_Choice_Router := T; end if; pragma Assert (M_Choice_Router /= Null_Field_Type); return M_Choice_Router; end C_Choice_Router; end Terminal_Interface.Curses.Forms.Field_Types;
----------------------------------------------------------------------- -- awa-storages-servlets -- Serve files saved in the storage service -- Copyright (C) 2012, 2016, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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; with Servlet.Core; with ASF.Requests; with ASF.Responses; -- == Storage Servlet == -- The <tt>Storage_Servlet</tt> type is the servlet that allows to retrieve the file -- content that was uploaded. package AWA.Storages.Servlets is type Get_Type is (DEFAULT, AS_CONTENT_DISPOSITION, INVALID); -- The <b>Storage_Servlet</b> represents the component that will handle -- an HTTP request received by the server. type Storage_Servlet is new Servlet.Core.Servlet with private; -- Called by the servlet container to indicate to a servlet that the servlet -- is being placed into service. overriding procedure Initialize (Server : in out Storage_Servlet; Context : in Servlet.Core.Servlet_Registry'Class); -- Called by the server (via the service method) to allow a servlet to handle -- a GET request. -- -- Overriding this method to support a GET request also automatically supports -- an HTTP HEAD request. A HEAD request is a GET request that returns no body -- in the response, only the request header fields. -- -- When overriding this method, read the request data, write the response headers, -- get the response's writer or output stream object, and finally, write the -- response data. It's best to include content type and encoding. -- When using a PrintWriter object to return the response, set the content type -- before accessing the PrintWriter object. -- -- The servlet container must write the headers before committing the response, -- because in HTTP the headers must be sent before the response body. -- -- Where possible, set the Content-Length header (with the -- Response.Set_Content_Length method), to allow the servlet container -- to use a persistent connection to return its response to the client, -- improving performance. The content length is automatically set if the entire -- response fits inside the response buffer. -- -- When using HTTP 1.1 chunked encoding (which means that the response has a -- Transfer-Encoding header), do not set the Content-Length header. -- -- The GET method should be safe, that is, without any side effects for which -- users are held responsible. For example, most form queries have no side effects. -- If a client request is intended to change stored data, the request should use -- some other HTTP method. -- -- The GET method should also be idempotent, meaning that it can be safely repeated. -- Sometimes making a method safe also makes it idempotent. For example, repeating -- queries is both safe and idempotent, but buying a product online or modifying -- data is neither safe nor idempotent. -- -- If the request is incorrectly formatted, Do_Get returns an HTTP "Bad Request" overriding procedure Do_Get (Server : in Storage_Servlet; Request : in out ASF.Requests.Request'Class; Response : in out ASF.Responses.Response'Class); -- Load the data content that correspond to the GET request and get the name as well -- as mime-type and date. procedure Load (Server : in Storage_Servlet; Request : in out ASF.Requests.Request'Class; Name : out Ada.Strings.Unbounded.Unbounded_String; Mime : out Ada.Strings.Unbounded.Unbounded_String; Date : out Ada.Calendar.Time; Data : out ADO.Blob_Ref); -- Get the expected return mode (content disposition for download or inline). function Get_Format (Server : in Storage_Servlet; Request : in ASF.Requests.Request'Class) return Get_Type; private type Storage_Servlet is new Servlet.Core.Servlet with null record; end AWA.Storages.Servlets;
with Asis; -- GNAT-specific: with A4G.Int_Knds; with Types; with a_nodes_h; with Dot; private with Ada.Containers.Doubly_Linked_Lists; package Asis_Adapter.Element is type Class is tagged private; -- Initialized -- Process an element and all of its components: -- Raises Internal_Error for unhandled internal exceptions. procedure Process_Element_Tree (This : in out Class; Element : in Asis.Element; Outputs : in Outputs_Record); ----------------------------------------------------------------------------- -- This encapsulates the identity of an Element, since sometimes a -- Node_ID gets reused! -- type Element_ID is record Node_ID : Types.Node_ID := Types.Error; Kind : A4G.Int_Knds.Internal_Element_Kinds := A4G.Int_Knds.Not_An_Element; end record; -- To get an a_nodes_h.Element_ID: -- Asis.Element -> Get_Element_ID -> To_Element_ID -> a_nodes_h.Element_ID -- or -- Asis.Element -> Get_Element_ID -> a_nodes_h.Element_ID -- -- To get a string for DOT or text output: -- a_nodes_h.Element_ID -> To_String -> String (e.g. Element_12001) -- function Get_Element_ID (Element : in Asis.Element) return Element_ID; -- Turns Node_ID and Kind into one number. Currently (GNAT GPL 2017 ASIS) -- there are about 800 values in A4G.Int_Knds.Internal_Element_Kinds, so -- we multiply Node_ID by 1000 and add Kind. Assuming a 32-bit int for -- a_nodes_h.Element_ID, this means we cannot process Elements with a Node_ID -- over 1,000,000. -- -- TODO: Move to anhS function To_Element_ID (This : in Element_ID) return a_nodes_h.Element_ID; function Get_Element_ID (Element : in Asis.Element) return a_nodes_h.Element_ID; function To_String (This : in a_nodes_h.Element_ID) return String; -- END Element_ID support ----------------------------------------------------------------------------- -- Add an array of Element IDs to Dot_Label and maybe Dot_Edge, and return -- an Element_ID_List: -- LEAKS: function To_Element_ID_List (Dot_Label : in out Dot.HTML_Like_Labels.Class; Outputs : in out Outputs_Record; This_Element_ID : in a_nodes_h.Element_ID; Elements_In : in Asis.Element_List; Dot_Label_Name : in String; Add_Edges : in Boolean := False; This_Is_Unit : in Boolean := False) return a_nodes_h.Element_ID_List; private -- For debuggng: Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Element"; package Element_ID_Lists is new Ada.Containers.Doubly_Linked_Lists (Element_Type => a_nodes_h.Element_ID, "=" => IC."="); -- Make type and operations directly visible: type Element_ID_List is new Element_ID_Lists.List with null record; -- Can't be limited because generic Asis.Iterator.Traverse_Element doesn't -- want limited state information: type Class is tagged -- Initialized record -- Current, in-progress intermediate output products. These need to be -- turned into stacks if they are ever used in Post_Operation. Now -- their usage ends at the end of Pre_Operation: Dot_Node : Dot.Node_Stmt.Class; -- Initialized Dot_Label : Dot.HTML_Like_Labels.Class; -- Initialized A_Element : a_nodes_h.Element_Struct := anhS.Default_Element_Struct; -- Used when making dot edges to child nodes. Treated s a stack: Element_IDs : Element_ID_List; -- Element_ID : a_nodes_h.Element_ID := anhS.Invalid_Element_ID; -- I would like to just pass Outputs through and not store it in the -- object, since it is all pointers and we doesn't need to store their -- values between calls to Process_Element_Tree. Outputs has to go into -- State_Information in the Traverse_Element instatiation, though, so -- we'll put it in the object and pass that: Outputs : Outputs_Record; -- Initialized end record; -- Helper methods for use by children: -- String procedure Add_To_Dot_Label (This : in out Class; Name : in String; Value : in String); -- Wide_String -- Add <Name> => <Value> to the label, and print it if trace is on: procedure Add_To_Dot_Label (This : in out Class; Name : in String; Value : in Wide_String); -- Element_ID -- Add <Name> => <Value> to the label, and print it if trace is on: procedure Add_To_Dot_Label (This : in out Class; Name : in String; Value : in a_nodes_h.Element_ID); -- Boolean -- Add <Name> => <Value> to the label, and print it if trace is on: procedure Add_To_Dot_Label (This : in out Class; Name : in String; Value : in Boolean); -- String: -- Add <Value> to the label, and print it if trace is on: procedure Add_To_Dot_Label (This : in out Class; Value : in String); type Ada_Versions is (Ada_83, Ada_95, Ada_2005, Ada_2012, Ada_2020); pragma Ordered (Ada_Versions); Supported_Ada_Version : constant Ada_Versions := Ada_95; -- If Ada_Version <= Supported_Ada_Version then: -- Add to dot label: ASIS_PROCESSING => -- "NOT_IMPLEMENTED_COMPLETELY" -- and increment the Not_Implemented count -- Otherwise: -- Add to dot label: ASIS_PROCESSING => -- Ada_Version & "_FEATURE_NOT_IMPLEMENTED_IN_" & Supported_Ada_Version procedure Add_Not_Implemented (This : in out Class; Ada_Version : in Ada_Versions := Supported_Ada_Version); procedure Add_Dot_Edge (This : in out Class; From : in a_nodes_h.Element_ID; To : in a_nodes_h.Element_ID; Label : in String); -- Add an edge and a dot label: procedure Add_To_Dot_Label_And_Edge (This : in out Class; Label : in String; To : in a_nodes_h.Element_ID); function Add_Operator_Kind (State : in out Class; Element : in Asis.Element) return a_nodes_h.Operator_Kinds; function To_Element_ID_List (This : in out Class; Elements_In : in Asis.Element_List; Dot_Label_Name : in String; Add_Edges : in Boolean := False) return a_nodes_h.Element_ID_List; procedure Add_Element_List (This : in out Class; Elements_In : in Asis.Element_List; Dot_Label_Name : in String; List_Out : out a_nodes_h.Element_ID_List; Add_Edges : in Boolean := False); end Asis_Adapter.Element;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-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 the copyright holder 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. -- -- -- ------------------------------------------------------------------------------ -- A simple example that blinks all the LEDs simultaneously, w/o tasking. -- It does not use the various convenience functions defined elsewhere, but -- instead works directly with the GPIO driver to configure and control the -- LEDs. -- Note that this code is independent of the specific MCU device and board -- in use because we use names and constants that are common across all of -- them. For example, "All_LEDs" refers to different GPIO pins on different -- boards, and indeed defines a different number of LEDs on different boards. -- The gpr file determines which board is actually used. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); -- The "last chance handler" is the user-defined routine that is called when -- an exception is propagated. We need it in the executable, therefore it -- must be somewhere in the closure of the context clauses. with STM32.Device; use STM32.Device; with STM32.Board; use STM32.Board; with STM32.GPIO; use STM32.GPIO; with Ada.Real_Time; use Ada.Real_Time; procedure Blinky is Period : constant Time_Span := Milliseconds (200); -- arbitrary Next_Release : Time := Clock; procedure Initialize_LEDs; -- Enables the clock and configures the GPIO pins and port connected to the -- LEDs on the target board so that we can drive them via GPIO commands. -- Note that the STM32.Board package provides a procedure (with the same -- name) to do this directly, for convenience, but we do not use it here -- for the sake of illustration. procedure Initialize_LEDs is Configuration : GPIO_Port_Configuration; begin Enable_Clock (All_LEDs); Configuration.Mode := Mode_Out; Configuration.Output_Type := Push_Pull; Configuration.Speed := Speed_100MHz; Configuration.Resistors := Floating; Configure_IO (All_LEDs, Configuration); end Initialize_LEDs; begin Initialize_LEDs; loop Toggle (All_LEDs); Next_Release := Next_Release + Period; delay until Next_Release; end loop; end Blinky;
-- ----------------------------------------------------------------- -- -- -- -- This 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 software 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 library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- ----------------------------------------------------------------- -- -- ----------------------------------------------------------------- -- -- This is a translation, to the Ada programming language, of the -- -- original C test files written by Sam Lantinga - www.libsdl.org -- -- translation made by Antonio F. Vargas - www.adapower.net/~avargas -- -- ----------------------------------------------------------------- -- with System; with Interfaces.C; with Ada.Unchecked_Conversion; with SDL.Types; use SDL.Types; package TortureThread_Sprogs is package C renames Interfaces.C; use type C.int; function To_Address is new Ada.Unchecked_Conversion (C.int, System.Address); NUMTHREADS : constant := 10; type time_for_threads_to_die_Array is array (C.int range 0 .. NUMTHREADS - 1) of Uint8; pragma Convention (C, time_for_threads_to_die_Array); time_for_threads_to_die : time_for_threads_to_die_Array; pragma Volatile (time_for_threads_to_die); function SubThreadFunc (data : System.Address) return C.int; pragma Convention (C, SubThreadFunc); function ThreadFunc (data : System.Address) return C.int; pragma Convention (C, ThreadFunc); end TortureThread_Sprogs;
----------------------------------------------------------------------------- -- Base class for the implementation of EEPROM memory connected via -- I2C bus. -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with HAL; with HAL.I2C; package EEPROM_I2C is ----------------------------------------------------------------------------- -- List of all implemented/supported chips -- The data sheets will be added into this repository type EEPROM_Chip is (EEC_MC24XX01, -- MicroChip 24XX01/24LC01B EEC_MC24XX02, -- MicroChip 24XX02/24LC02B EEC_MC24XX16 -- MicroChip 24LC16B ); ----------------------------------------------------------------------------- -- Some EEPROMs have a so called t_WC time, which requires a break -- between writes in batches. -- This can be byte or page write cycles. -- As this library should not be tied to any platform, -- The user of the library has to provide the delay procedure type Proc_Delay_Callback_MS is not null access procedure (MS : Integer); ----------------------------------------------------------------------------- -- This is the EEPROM definition. type EEPROM is interface; type Any_EEPROM is access all EEPROM'Class; type EEPROM_Memory (-- which chip is it C_Type_of_Chip : EEPROM_Chip; -- the size of addressing the EEPROM C_Memory_Address_Size : HAL.I2C.I2C_Memory_Address_Size; C_Size_In_Bytes : HAL.UInt32; C_Size_In_Bits : HAL.UInt32; C_Number_Of_Blocks : HAL.UInt16; C_Bytes_Per_Block : HAL.UInt16; C_Number_Of_Pages : HAL.UInt16; C_Bytes_Per_Page : HAL.UInt16; C_Max_Byte_Address : HAL.UInt16; C_Write_Delay_MS : Integer; C_Delay_Callback : Proc_Delay_Callback_MS; -- the address of the EEPROM on the bus I2C_Addr : HAL.I2C.I2C_Address; -- the port where the EEPROM is connected to I2C_Port : not null HAL.I2C.Any_I2C_Port ) is new EEPROM with null record; type Any_EEPROM_Memory is access all EEPROM_Memory'Class; ----------------------------------------------------------------------------- -- EEPROM status of last operation. type EEPROM_Status is ( -- all operations were successful Ok, -- returned, if the requested memory address of -- the EEPROM is out of range: -- Mem_Addr > Mem_Addr_Size -- In this case, no I2C operation is started Address_Out_Of_Range, -- returned, if the requested data to write is -- too big. -- This means, that the relation: -- Mem_Addr + Data'Size > Size_In_Bytes Data_Too_Big, -- Is set, -- if anything is not OK with the I2C operation I2C_Not_Ok ); ----------------------------------------------------------------------------- -- Aggregation of the status of last operation. -- Always check this, before assuming, that it worked. type EEPROM_Operation_Result is record E_Status : EEPROM_Status; -- Carries the last status of the I2C operation executed I2C_Status : HAL.I2C.I2C_Status; end record; ----------------------------------------------------------------------------- -- Returns the type of chip of this specific EEPROM. function Type_of_Chip (This : in out EEPROM_Memory) return EEPROM_Chip; ----------------------------------------------------------------------------- -- As there are different sizes for EEPROMs, this function checks -- the memory address for being valid or out of range. function Is_Valid_Memory_Address (This : in out EEPROM_Memory; Mem_Addr : HAL.UInt16) return Boolean; ----------------------------------------------------------------------------- -- Returns the address size of this specific EEPROM. function Mem_Addr_Size (This : in out EEPROM_Memory) return HAL.I2C.I2C_Memory_Address_Size; ----------------------------------------------------------------------------- -- Returns the size in bytes of this specific EEPROM. function Size_In_Bytes (This : in out EEPROM_Memory) return HAL.UInt32; ----------------------------------------------------------------------------- -- Returns the size in bits of this specific EEPROM. function Size_In_Bits (This : in out EEPROM_Memory) return HAL.UInt32; ----------------------------------------------------------------------------- -- Returns the number of blocks of this specific EEPROM. function Number_Of_Blocks (This : in out EEPROM_Memory) return HAL.UInt16; ----------------------------------------------------------------------------- -- Returns the number of blocks of this specific EEPROM. function Bytes_Per_Block (This : in out EEPROM_Memory) return HAL.UInt16; ----------------------------------------------------------------------------- -- Returns the number of pages of this specific EEPROM. function Number_Of_Pages (This : in out EEPROM_Memory) return HAL.UInt16; ----------------------------------------------------------------------------- -- Returns the number of bytes per page for this specific EEPROM. function Bytes_Per_Page (This : in out EEPROM_Memory) return HAL.UInt16; type EEPROM_Effective_Address is record I2C_Address : HAL.I2C.I2C_Address; Mem_Addr : HAL.UInt16; end record; ----------------------------------------------------------------------------- -- Reads from the EEPROM memory. -- Mem_Addr : address to start the reading from -- Data : storage to put the read data into -- the size of this array implies the number of bytes read -- Status : status of the operation -> see above for details -- Timeout_MS : time out in milliseconds can be specified. -- If the operation is not finished inside the -- time frame given, the operation will fail. procedure Read (This : in out EEPROM_Memory'Class; Mem_Addr : HAL.UInt16; Data : out HAL.I2C.I2C_Data; Status : out EEPROM_Operation_Result; Timeout_MS : Natural := 1000); ----------------------------------------------------------------------------- -- Writes from the EEPROM memory. -- Mem_Addr : address to start the writing from -- Data : storage to pull the write data from -- the size of this array implies the number of bytes written -- Status : status of the operation -> see above for details -- Timeout_MS : time out in milliseconds can be specified. -- If the operation is not finished inside the -- time frame given, the operation will fail. procedure Write (This : in out EEPROM_Memory'Class; Mem_Addr : HAL.UInt16; Data : HAL.I2C.I2C_Data; Status : out EEPROM_Operation_Result; Timeout_MS : Natural := 1000); ----------------------------------------------------------------------------- -- Wipes the EEPROM memory. -- Status : status of the operation -> see above for details procedure Wipe (This : in out EEPROM_Memory'Class; Status : out EEPROM_Operation_Result); private ----------------------------------------------------------------------------- -- Constructs the final I2C address. -- Some EEPROMs have not only addresses, but blocks, -- which are encoded into the I2C address. function Construct_I2C_Address (This : in out EEPROM_Memory'Class; Mem_Addr : HAL.UInt16) return EEPROM_Effective_Address; end EEPROM_I2C;
-- 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 = "HackerTarget" type = "api" function start() setratelimit(1) end function vertical(ctx, domain) scrape(ctx, {url=buildurl(domain)}) end function buildurl(domain) return "http://api.hackertarget.com/hostsearch/?q=" .. domain end function asn(ctx, addr) local c local cfg = datasrc_config() local resp local aurl = asnurl(addr) -- Check if the response data is in the graph database if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(aurl, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request({url=aurl}) if (err ~= nil and err ~= "") then return end if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(aurl, resp) end end local j = json.decode("{\"results\": [" .. resp .. "]}") if (j == nil or #(j.results) < 4) then return end newasn(ctx, { ['addr']=addr, asn=tonumber(j.results[2]), prefix=j.results[3], desc=j.results[4], }) end function asnurl(addr) return "https://api.hackertarget.com/aslookup/?q=" .. addr end
-- { dg-do run } procedure Pack17 is type Bitmap_T is array (Natural range <>) of Boolean; pragma Pack (Bitmap_T); type Uint8 is range 0 .. 2 ** 8 - 1; for Uint8'Size use 8; type Record_With_QImode_Variants (D : Boolean) is record C_Filler : Bitmap_T (1..7); C_Map : Bitmap_T (1..3); case D is when False => F_Bit : Boolean; F_Filler : Bitmap_T (1..7); when True => T_Int : Uint8; end case; end record; pragma Pack (Record_With_QImode_Variants); procedure Fill (R : out Record_With_QImode_Variants) is begin R.C_Filler := (True, False, True, False, True, False, True); R.C_Map := (True, False, True); R.T_Int := 17; end; RT : Record_With_QImode_Variants (D => True); begin Fill (RT); if RT.T_Int /= 17 then raise Program_Error; end if; end;
with Aof.Core.Root_Objects; with Aof.Core.Generic_Signals; with Aof.Core.Signals; with Slots; -- In this example, we will create two signals, one with no arguments -- and another with one argument. We use the "Connect" method to -- connect a slot (A.K.A. callback) to a signal. We then invoke the -- signal's "Emit" method to subsequently invoke all slots connected -- to the signal. procedure Signal_Example is -- Create a signal class containing one argument of type integer package S1_Pkg is new Aof.Core.Generic_Signals.S1 (Object => Aof.Core.Root_Objects.Root_Object, Access_Object => Aof.Core.Root_Objects.Access_Object, Param_1 => Integer); S0 : Aof.Core.Signals.Empty.Signal; S1 : S1_Pkg.Signal; begin -- Connect the slots S0.Connect(Slots.Xaa'access); S0.Connect(Slots.Xab'access); S0.Connect(Slots.Xac'access); -- Emit the signal S0.Emit; -- Connect the slots to the single argument signal. Note that the -- argument count and type must match that of the signal or you -- will get a compiler error. S1.Connect(Slots.S1a'access); S1.Connect(Slots.S1b'access); S1.Connect(Slots.S1c'access); -- Emit the signal with different values for I in 1 .. 3 loop S1.Emit(I); end loop; end Signal_Example;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . D I R E C T O R Y _ O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1998-2019, AdaCore -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Ada.IO_Exceptions; with Ada.Characters.Handling; with Ada.Strings.Fixed; with Ada.Unchecked_Deallocation; with Ada.Unchecked_Conversion; with System; use System; with System.CRTL; use System.CRTL; with GNAT.OS_Lib; package body GNAT.Directory_Operations is use Ada; Filename_Max : constant Integer := 1024; -- 1024 is the value of FILENAME_MAX in stdio.h procedure Free is new Ada.Unchecked_Deallocation (Dir_Type_Value, Dir_Type); On_Windows : constant Boolean := GNAT.OS_Lib.Directory_Separator = '\'; -- An indication that we are on Windows. Used in Get_Current_Dir, to -- deal with drive letters in the beginning of absolute paths. --------------- -- Base_Name -- --------------- function Base_Name (Path : Path_Name; Suffix : String := "") return String is function Get_File_Names_Case_Sensitive return Integer; pragma Import (C, Get_File_Names_Case_Sensitive, "__gnat_get_file_names_case_sensitive"); Case_Sensitive_File_Name : constant Boolean := Get_File_Names_Case_Sensitive = 1; function Basename (Path : Path_Name; Suffix : String := "") return String; -- This function does the job. The only difference between Basename -- and Base_Name (the parent function) is that the former is case -- sensitive, while the latter is not. Path and Suffix are adjusted -- appropriately before calling Basename under platforms where the -- file system is not case sensitive. -------------- -- Basename -- -------------- function Basename (Path : Path_Name; Suffix : String := "") return String is Cut_Start : Natural := Strings.Fixed.Index (Path, Dir_Seps, Going => Strings.Backward); Cut_End : Natural; begin -- Cut_Start point to the first basename character Cut_Start := (if Cut_Start = 0 then Path'First else Cut_Start + 1); -- Cut_End point to the last basename character Cut_End := Path'Last; -- If basename ends with Suffix, adjust Cut_End if Suffix /= "" and then Path (Path'Last - Suffix'Length + 1 .. Cut_End) = Suffix then Cut_End := Path'Last - Suffix'Length; end if; Check_For_Standard_Dirs : declare Offset : constant Integer := Path'First - Base_Name.Path'First; BN : constant String := Base_Name.Path (Cut_Start - Offset .. Cut_End - Offset); -- Here we use Base_Name.Path to keep the original casing Has_Drive_Letter : constant Boolean := OS_Lib.Path_Separator /= ':'; -- If Path separator is not ':' then we are on a DOS based OS -- where this character is used as a drive letter separator. begin if BN = "." or else BN = ".." then return ""; elsif Has_Drive_Letter and then BN'Length > 2 and then Characters.Handling.Is_Letter (BN (BN'First)) and then BN (BN'First + 1) = ':' then -- We have a DOS drive letter prefix, remove it return BN (BN'First + 2 .. BN'Last); else return BN; end if; end Check_For_Standard_Dirs; end Basename; -- Start of processing for Base_Name begin if Path'Length <= Suffix'Length then return Path; end if; if Case_Sensitive_File_Name then return Basename (Path, Suffix); else return Basename (Characters.Handling.To_Lower (Path), Characters.Handling.To_Lower (Suffix)); end if; end Base_Name; ---------------- -- Change_Dir -- ---------------- procedure Change_Dir (Dir_Name : Dir_Name_Str) is C_Dir_Name : constant String := Dir_Name & ASCII.NUL; begin if chdir (C_Dir_Name) /= 0 then raise Directory_Error; end if; end Change_Dir; ----------- -- Close -- ----------- procedure Close (Dir : in out Dir_Type) is Discard : Integer; pragma Warnings (Off, Discard); function closedir (directory : DIRs) return Integer; pragma Import (C, closedir, "__gnat_closedir"); begin if not Is_Open (Dir) then raise Directory_Error; end if; Discard := closedir (DIRs (Dir.all)); Free (Dir); end Close; -------------- -- Dir_Name -- -------------- function Dir_Name (Path : Path_Name) return Dir_Name_Str is Last_DS : constant Natural := Strings.Fixed.Index (Path, Dir_Seps, Going => Strings.Backward); begin if Last_DS = 0 then -- There is no directory separator, returns current working directory return "." & Dir_Separator; else return Path (Path'First .. Last_DS); end if; end Dir_Name; ----------------- -- Expand_Path -- ----------------- function Expand_Path (Path : Path_Name; Mode : Environment_Style := System_Default) return Path_Name is Environment_Variable_Char : Character; pragma Import (C, Environment_Variable_Char, "__gnat_environment_char"); Result : OS_Lib.String_Access := new String (1 .. 200); Result_Last : Natural := 0; procedure Append (C : Character); procedure Append (S : String); -- Append to Result procedure Double_Result_Size; -- Reallocate Result, doubling its size function Is_Var_Prefix (C : Character) return Boolean; pragma Inline (Is_Var_Prefix); procedure Read (K : in out Positive); -- Update Result while reading current Path starting at position K. If -- a variable is found, call Var below. procedure Var (K : in out Positive); -- Translate variable name starting at position K with the associated -- environment value. ------------ -- Append -- ------------ procedure Append (C : Character) is begin if Result_Last = Result'Last then Double_Result_Size; end if; Result_Last := Result_Last + 1; Result (Result_Last) := C; end Append; procedure Append (S : String) is begin while Result_Last + S'Length - 1 > Result'Last loop Double_Result_Size; end loop; Result (Result_Last + 1 .. Result_Last + S'Length) := S; Result_Last := Result_Last + S'Length; end Append; ------------------------ -- Double_Result_Size -- ------------------------ procedure Double_Result_Size is New_Result : constant OS_Lib.String_Access := new String (1 .. 2 * Result'Last); begin New_Result (1 .. Result_Last) := Result (1 .. Result_Last); OS_Lib.Free (Result); Result := New_Result; end Double_Result_Size; ------------------- -- Is_Var_Prefix -- ------------------- function Is_Var_Prefix (C : Character) return Boolean is begin return (C = Environment_Variable_Char and then Mode = System_Default) or else (C = '$' and then (Mode = UNIX or else Mode = Both)) or else (C = '%' and then (Mode = DOS or else Mode = Both)); end Is_Var_Prefix; ---------- -- Read -- ---------- procedure Read (K : in out Positive) is P : Character; begin For_All_Characters : loop if Is_Var_Prefix (Path (K)) then P := Path (K); -- Could be a variable if K < Path'Last then if Path (K + 1) = P then -- Not a variable after all, this is a double $ or %, -- just insert one in the result string. Append (P); K := K + 1; else -- Let's parse the variable Var (K); end if; else -- We have an ending $ or % sign Append (P); end if; else -- This is a standard character, just add it to the result Append (Path (K)); end if; -- Skip to next character K := K + 1; exit For_All_Characters when K > Path'Last; end loop For_All_Characters; end Read; --------- -- Var -- --------- procedure Var (K : in out Positive) is P : constant Character := Path (K); T : Character; E : Positive; begin K := K + 1; if P = '%' or else Path (K) = '{' then -- Set terminator character if P = '%' then T := '%'; else T := '}'; K := K + 1; end if; -- Look for terminator character, k point to the first character -- for the variable name. E := K; loop E := E + 1; exit when Path (E) = T or else E = Path'Last; end loop; if Path (E) = T then -- OK found, translate with environment value declare Env : OS_Lib.String_Access := OS_Lib.Getenv (Path (K .. E - 1)); begin Append (Env.all); OS_Lib.Free (Env); end; else -- No terminator character, not a variable after all or a -- syntax error, ignore it, insert string as-is. Append (P); -- Add prefix character if T = '}' then -- If we were looking for curly bracket Append ('{'); -- terminator, add the curly bracket end if; Append (Path (K .. E)); end if; else -- The variable name is everything from current position to first -- non letter/digit character. E := K; -- Check that first character is a letter if Characters.Handling.Is_Letter (Path (E)) then E := E + 1; Var_Name : loop exit Var_Name when E > Path'Last; if Characters.Handling.Is_Letter (Path (E)) or else Characters.Handling.Is_Digit (Path (E)) then E := E + 1; else exit Var_Name; end if; end loop Var_Name; E := E - 1; declare Env : OS_Lib.String_Access := OS_Lib.Getenv (Path (K .. E)); begin Append (Env.all); OS_Lib.Free (Env); end; else -- This is not a variable after all Append ('$'); Append (Path (E)); end if; end if; K := E; end Var; -- Start of processing for Expand_Path begin declare K : Positive := Path'First; begin Read (K); declare Returned_Value : constant String := Result (1 .. Result_Last); begin OS_Lib.Free (Result); return Returned_Value; end; end; end Expand_Path; -------------------- -- File_Extension -- -------------------- function File_Extension (Path : Path_Name) return String is First : Natural := Strings.Fixed.Index (Path, Dir_Seps, Going => Strings.Backward); Dot : Natural; begin if First = 0 then First := Path'First; end if; Dot := Strings.Fixed.Index (Path (First .. Path'Last), ".", Going => Strings.Backward); if Dot = 0 or else Dot = Path'Last then return ""; else return Path (Dot .. Path'Last); end if; end File_Extension; --------------- -- File_Name -- --------------- function File_Name (Path : Path_Name) return String is begin return Base_Name (Path); end File_Name; --------------------- -- Format_Pathname -- --------------------- function Format_Pathname (Path : Path_Name; Style : Path_Style := System_Default) return String is N_Path : String := Path; K : Positive := N_Path'First; Prev_Dirsep : Boolean := False; begin if Dir_Separator = '\' and then Path'Length > 1 and then Path (K .. K + 1) = "\\" then if Style = UNIX then N_Path (K .. K + 1) := "//"; end if; K := K + 2; end if; for J in K .. Path'Last loop if Strings.Maps.Is_In (Path (J), Dir_Seps) then if not Prev_Dirsep then case Style is when UNIX => N_Path (K) := '/'; when DOS => N_Path (K) := '\'; when System_Default => N_Path (K) := Dir_Separator; end case; K := K + 1; end if; Prev_Dirsep := True; else N_Path (K) := Path (J); K := K + 1; Prev_Dirsep := False; end if; end loop; return N_Path (N_Path'First .. K - 1); end Format_Pathname; --------------------- -- Get_Current_Dir -- --------------------- Max_Path : Integer; pragma Import (C, Max_Path, "__gnat_max_path_len"); function Get_Current_Dir return Dir_Name_Str is Current_Dir : String (1 .. Max_Path + 1); Last : Natural; begin Get_Current_Dir (Current_Dir, Last); return Current_Dir (1 .. Last); end Get_Current_Dir; procedure Get_Current_Dir (Dir : out Dir_Name_Str; Last : out Natural) is Path_Len : Natural := Max_Path; Buffer : String (Dir'First .. Dir'First + Max_Path + 1); procedure Local_Get_Current_Dir (Dir : System.Address; Length : System.Address); pragma Import (C, Local_Get_Current_Dir, "__gnat_get_current_dir"); begin Local_Get_Current_Dir (Buffer'Address, Path_Len'Address); if Path_Len = 0 then raise Ada.IO_Exceptions.Use_Error with "current directory does not exist"; end if; Last := (if Dir'Length > Path_Len then Dir'First + Path_Len - 1 else Dir'Last); Dir (Buffer'First .. Last) := Buffer (Buffer'First .. Last); -- By default, the drive letter on Windows is in upper case if On_Windows and then Last > Dir'First and then Dir (Dir'First + 1) = ':' then Dir (Dir'First) := Ada.Characters.Handling.To_Upper (Dir (Dir'First)); end if; end Get_Current_Dir; ------------- -- Is_Open -- ------------- function Is_Open (Dir : Dir_Type) return Boolean is begin return Dir /= Null_Dir and then System.Address (Dir.all) /= System.Null_Address; end Is_Open; -------------- -- Make_Dir -- -------------- procedure Make_Dir (Dir_Name : Dir_Name_Str) is C_Dir_Name : constant String := Dir_Name & ASCII.NUL; begin if CRTL.mkdir (C_Dir_Name, Unspecified) /= 0 then raise Directory_Error; end if; end Make_Dir; ---------- -- Open -- ---------- procedure Open (Dir : out Dir_Type; Dir_Name : Dir_Name_Str) is function opendir (file_name : String) return DIRs; pragma Import (C, opendir, "__gnat_opendir"); C_File_Name : constant String := Dir_Name & ASCII.NUL; begin Dir := new Dir_Type_Value'(Dir_Type_Value (opendir (C_File_Name))); if not Is_Open (Dir) then Free (Dir); Dir := Null_Dir; raise Directory_Error; end if; end Open; ---------- -- Read -- ---------- procedure Read (Dir : Dir_Type; Str : out String; Last : out Natural) is Filename_Addr : Address; Filename_Len : aliased Integer; Buffer : array (0 .. Filename_Max + 12) of Character; -- 12 is the size of the dirent structure (see dirent.h), without the -- field for the filename. function readdir_gnat (Directory : System.Address; Buffer : System.Address; Last : not null access Integer) return System.Address; pragma Import (C, readdir_gnat, "__gnat_readdir"); begin if not Is_Open (Dir) then raise Directory_Error; end if; Filename_Addr := readdir_gnat (System.Address (Dir.all), Buffer'Address, Filename_Len'Access); if Filename_Addr = System.Null_Address then Last := 0; return; end if; Last := (if Str'Length > Filename_Len then Str'First + Filename_Len - 1 else Str'Last); declare subtype Path_String is String (1 .. Filename_Len); type Path_String_Access is access Path_String; function Address_To_Access is new Ada.Unchecked_Conversion (Source => Address, Target => Path_String_Access); Path_Access : constant Path_String_Access := Address_To_Access (Filename_Addr); begin for J in Str'First .. Last loop Str (J) := Path_Access (J - Str'First + 1); end loop; end; end Read; ------------------------- -- Read_Is_Thread_Safe -- ------------------------- function Read_Is_Thread_Safe return Boolean is function readdir_is_thread_safe return Integer; pragma Import (C, readdir_is_thread_safe, "__gnat_readdir_is_thread_safe"); begin return (readdir_is_thread_safe /= 0); end Read_Is_Thread_Safe; ---------------- -- Remove_Dir -- ---------------- procedure Remove_Dir (Dir_Name : Dir_Name_Str; Recursive : Boolean := False) is C_Dir_Name : constant String := Dir_Name & ASCII.NUL; Last : Integer; Str : String (1 .. Filename_Max); Success : Boolean; Current_Dir : Dir_Type; begin -- Remove the directory only if it is empty if not Recursive then if rmdir (C_Dir_Name) /= 0 then raise Directory_Error; end if; -- Remove directory and all files and directories that it may contain else Open (Current_Dir, Dir_Name); loop Read (Current_Dir, Str, Last); exit when Last = 0; if GNAT.OS_Lib.Is_Directory (Dir_Name & Dir_Separator & Str (1 .. Last)) then if Str (1 .. Last) /= "." and then Str (1 .. Last) /= ".." then -- Recursive call to remove a subdirectory and all its -- files. Remove_Dir (Dir_Name & Dir_Separator & Str (1 .. Last), True); end if; else GNAT.OS_Lib.Delete_File (Dir_Name & Dir_Separator & Str (1 .. Last), Success); if not Success then raise Directory_Error; end if; end if; end loop; Close (Current_Dir); Remove_Dir (Dir_Name); end if; end Remove_Dir; end GNAT.Directory_Operations;
with lace.Strings.fixed, ada.Characters.handling, ada.Strings.hash; package body lace.Text is -- Construction -- function to_Text (From : in String; Trim : in Boolean := False) return Item is begin return to_Text (From, capacity => From'Length, trim => Trim); end to_Text; function to_Text (From : in String; Capacity : in Natural; Trim : in Boolean := False) return Item is the_String : constant String := (if Trim then lace.Strings.fixed.Trim (From, ada.Strings.Both) else From); Self : Item (Capacity); begin Self.Length := the_String'Length; Self.Data (1 .. Self.Length) := the_String; return Self; end to_Text; function "+" (From : in String) return Item is begin return to_Text (From); end "+"; -- Attributes -- procedure String_is (Self : in out Item; Now : in String) is begin Self.Data (1 .. Now'Length) := Now; Self.Length := Now'Length; end String_is; function to_String (Self : in Item) return String is begin return Self.Data (1 .. Self.Length); end to_String; function is_Empty (Self : in Item) return Boolean is begin return Self.Length = 0; end is_Empty; function Length (Self : in Item) return Natural is begin return Self.Length; end Length; function Image (Self : in Item) return String is begin return "(Capacity =>" & Self.Capacity'Image & "," & " Length =>" & Self.Length 'Image & "," & " Data => '" & to_String (Self) & "')"; end Image; function Hashed (Self : in Item) return ada.Containers.Hash_type is begin return ada.strings.Hash (Self.Data (1 .. Self.Length)); end Hashed; overriding function "=" (Left, Right : in Item) return Boolean is begin if Left.Length /= Right.Length then return False; end if; return to_String (Left) = to_String (Right); end "="; function to_Lowercase (Self : in Item) return Item is use ada.Characters.handling; Result : Item := Self; begin for i in 1 .. Self.Length loop Result.Data (i) := to_Lower (Self.Data (i)); end loop; return Result; end to_Lowercase; function mono_Spaced (Self : in Item) return Item is Result : Item (Self.Capacity); Prior : Character := 'a'; Length : Natural := 0; begin for i in 1 .. Self.Length loop if Self.Data (i) = ' ' and Prior = ' ' then null; else Length := Length + 1; Result.Data (Length) := Self.Data (i); Prior := Self.Data (i); end if; end loop; Result.Length := Length; return Result; end mono_Spaced; -- Streams -- function Item_input (Stream : access Ada.Streams.Root_Stream_Type'Class) return Item is Capacity : Positive; Length : Natural; begin Positive'read (Stream, Capacity); Natural 'read (Stream, Length); declare Data : String (1 .. Capacity); begin String'read (Stream, Data (1 .. Length)); return (capacity => Capacity, data => Data, length => Length); end; end Item_input; procedure Item_output (Stream : access Ada.Streams.Root_Stream_Type'Class; the_Item : in Item) is begin Positive'write (Stream, the_Item.Capacity); Natural 'write (Stream, the_Item.Length); String 'write (Stream, the_Item.Data (1 .. the_Item.Length)); end Item_output; procedure Write (Stream : access ada.streams.Root_Stream_Type'Class; Self : in Item) is begin Natural'write (Stream, Self.Length); String 'write (Stream, Self.Data (1 .. Self.Length)); end Write; procedure Read (Stream : access ada.streams.Root_Stream_Type'Class; Self : out Item) is begin Natural'read (Stream, Self.Length); String 'read (Stream, Self.Data (1 .. Self.Length)); end Read; end lace.Text;
-- File: homework_one.adb -- Name: Andrew Albanese -- Date: 1/20/2018 -- Purpose: Calculate points surplus or deficit -- based on hours taken and GPA with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure homework_one is -- Personal data to be modified name: constant String := "Andrew Albanese"; -- Student name hours_attempted: constant Natural := 143; -- Hours taken gpa: constant Float := 2.3; -- Current GPA -- End of personal data to be modified earned_points: Float; -- Points actually attained -- Requirements Required_GPA: constant := 2.0; -- GPA required to graduate required_points: Float; -- Points needed to graduate -- Points calculations surplus, deficit: Float; -- Points above or below required begin -- Calculation earned_points := Float(hours_attempted) * gpa; required_points := Required_GPA * Float(hours_attempted); -- Calculate both even though one will not be needed surplus := earned_points - required_points; deficit := required_points - earned_points; -- Output put_line("Name: " & name); put_line("Hours:" & hours_attempted'img); put("GPA: "); put(item => gpa, fore => 1, aft => 3, exp => 0); new_line; put("Grade Points: "); put(earned_points, 1, 2, 0); new_line; -- Surplus or deficit if earned_points > Required_GPA then put("Points above 2.0: "); put(surplus, fore => 1, aft => 2, exp => 0); new_line; else put("Points below 2.0: "); put(deficit, fore => 1, aft => 2, exp => 0); new_line; end if; end homework_one;
with Ada.Containers.Hashed_Sets; package Text.Sets is new Ada.Containers.Hashed_Sets (Reference, Hash, Text."=");
with Libadalang.Analysis; use Libadalang.Analysis; with Rejuvenation.Navigation; use Rejuvenation.Navigation; package Rewriters is type Rewriter is tagged private; -- To be usable in an Ada.Containers.Vectors, -- a Rewriter can't be abstract and can't be an interface function Rewrite (R : Rewriter; Node : Ada_Node'Class; Top_Level : Boolean := True) return String; function Rewrite_Context (R : Rewriter; Node : Ada_Node'Class) return Ada_Node with Post => Is_Reflexive_Ancestor (Rewrite_Context'Result, Node); type Any_Rewriter is access Rewriter'Class; type Any_Constant_Rewriter is access constant Rewriter'Class; private type Rewriter is tagged null record; function Rewrite_Context (R : Rewriter; Node : Ada_Node'Class) return Ada_Node is (Node.As_Ada_Node); end Rewriters;
-- -- Copyright (C) 2019, AdaCore -- -- This spec has been automatically generated from ATSAMV71Q21.svd pragma Ada_2012; pragma Style_Checks (Off); with System; package Interfaces.SAM.UART is pragma Preelaborate; pragma No_Elaboration_Code_All; --------------- -- Registers -- --------------- subtype UART_UART_CR_RSTRX_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_RSTTX_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_RXEN_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_RXDIS_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_TXEN_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_TXDIS_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_RSTSTA_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_REQCLR_Field is Interfaces.SAM.Bit; subtype UART_UART_CR_DBGE_Field is Interfaces.SAM.Bit; -- Control Register type UART_UART_CR_Register is record -- unspecified Reserved_0_1 : Interfaces.SAM.UInt2 := 16#0#; -- Write-only. Reset Receiver RSTRX : UART_UART_CR_RSTRX_Field := 16#0#; -- Write-only. Reset Transmitter RSTTX : UART_UART_CR_RSTTX_Field := 16#0#; -- Write-only. Receiver Enable RXEN : UART_UART_CR_RXEN_Field := 16#0#; -- Write-only. Receiver Disable RXDIS : UART_UART_CR_RXDIS_Field := 16#0#; -- Write-only. Transmitter Enable TXEN : UART_UART_CR_TXEN_Field := 16#0#; -- Write-only. Transmitter Disable TXDIS : UART_UART_CR_TXDIS_Field := 16#0#; -- Write-only. Reset Status RSTSTA : UART_UART_CR_RSTSTA_Field := 16#0#; -- unspecified Reserved_9_11 : Interfaces.SAM.UInt3 := 16#0#; -- Write-only. Request Clear REQCLR : UART_UART_CR_REQCLR_Field := 16#0#; -- unspecified Reserved_13_14 : Interfaces.SAM.UInt2 := 16#0#; -- Write-only. Debug Enable DBGE : UART_UART_CR_DBGE_Field := 16#0#; -- unspecified Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_CR_Register use record Reserved_0_1 at 0 range 0 .. 1; RSTRX at 0 range 2 .. 2; RSTTX at 0 range 3 .. 3; RXEN at 0 range 4 .. 4; RXDIS at 0 range 5 .. 5; TXEN at 0 range 6 .. 6; TXDIS at 0 range 7 .. 7; RSTSTA at 0 range 8 .. 8; Reserved_9_11 at 0 range 9 .. 11; REQCLR at 0 range 12 .. 12; Reserved_13_14 at 0 range 13 .. 14; DBGE at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Receiver Digital Filter type UART_MR_FILTER_Field is ( -- UART does not filter the receive line. Disabled, -- UART filters the receive line using a three-sample filter (16x-bit -- clock) (2 over 3 majority). Enabled) with Size => 1; for UART_MR_FILTER_Field use (Disabled => 0, Enabled => 1); -- Parity Type type UART_MR_PAR_Field is ( -- Even Parity Even, -- Odd Parity Odd, -- Space: parity forced to 0 Space, -- Mark: parity forced to 1 Mark, -- No parity No) with Size => 3; for UART_MR_PAR_Field use (Even => 0, Odd => 1, Space => 2, Mark => 3, No => 4); -- Baud Rate Source Clock type UART_MR_BRSRCCK_Field is ( -- The baud rate is driven by the peripheral clock Periph_Clk, -- The baud rate is driven by a PMC-programmable clock PCK (see section -- Power Management Controller (PMC)). Pmc_Pck) with Size => 1; for UART_MR_BRSRCCK_Field use (Periph_Clk => 0, Pmc_Pck => 1); -- Channel Mode type UART_MR_CHMODE_Field is ( -- Normal mode Normal, -- Automatic echo Automatic, -- Local loopback Local_Loopback, -- Remote loopback Remote_Loopback) with Size => 2; for UART_MR_CHMODE_Field use (Normal => 0, Automatic => 1, Local_Loopback => 2, Remote_Loopback => 3); -- Mode Register type UART_UART_MR_Register is record -- unspecified Reserved_0_3 : Interfaces.SAM.UInt4 := 16#0#; -- Receiver Digital Filter FILTER : UART_MR_FILTER_Field := Interfaces.SAM.UART.Disabled; -- unspecified Reserved_5_8 : Interfaces.SAM.UInt4 := 16#0#; -- Parity Type PAR : UART_MR_PAR_Field := Interfaces.SAM.UART.Even; -- Baud Rate Source Clock BRSRCCK : UART_MR_BRSRCCK_Field := Interfaces.SAM.UART.Periph_Clk; -- unspecified Reserved_13_13 : Interfaces.SAM.Bit := 16#0#; -- Channel Mode CHMODE : UART_MR_CHMODE_Field := Interfaces.SAM.UART.Normal; -- unspecified Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_MR_Register use record Reserved_0_3 at 0 range 0 .. 3; FILTER at 0 range 4 .. 4; Reserved_5_8 at 0 range 5 .. 8; PAR at 0 range 9 .. 11; BRSRCCK at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; CHMODE at 0 range 14 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype UART_UART_IER_RXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_IER_TXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_IER_OVRE_Field is Interfaces.SAM.Bit; subtype UART_UART_IER_FRAME_Field is Interfaces.SAM.Bit; subtype UART_UART_IER_PARE_Field is Interfaces.SAM.Bit; subtype UART_UART_IER_TXEMPTY_Field is Interfaces.SAM.Bit; subtype UART_UART_IER_CMP_Field is Interfaces.SAM.Bit; -- Interrupt Enable Register type UART_UART_IER_Register is record -- Write-only. Enable RXRDY Interrupt RXRDY : UART_UART_IER_RXRDY_Field := 16#0#; -- Write-only. Enable TXRDY Interrupt TXRDY : UART_UART_IER_TXRDY_Field := 16#0#; -- unspecified Reserved_2_4 : Interfaces.SAM.UInt3 := 16#0#; -- Write-only. Enable Overrun Error Interrupt OVRE : UART_UART_IER_OVRE_Field := 16#0#; -- Write-only. Enable Framing Error Interrupt FRAME : UART_UART_IER_FRAME_Field := 16#0#; -- Write-only. Enable Parity Error Interrupt PARE : UART_UART_IER_PARE_Field := 16#0#; -- unspecified Reserved_8_8 : Interfaces.SAM.Bit := 16#0#; -- Write-only. Enable TXEMPTY Interrupt TXEMPTY : UART_UART_IER_TXEMPTY_Field := 16#0#; -- unspecified Reserved_10_14 : Interfaces.SAM.UInt5 := 16#0#; -- Write-only. Enable Comparison Interrupt CMP : UART_UART_IER_CMP_Field := 16#0#; -- unspecified Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_IER_Register use record RXRDY at 0 range 0 .. 0; TXRDY at 0 range 1 .. 1; Reserved_2_4 at 0 range 2 .. 4; OVRE at 0 range 5 .. 5; FRAME at 0 range 6 .. 6; PARE at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; TXEMPTY at 0 range 9 .. 9; Reserved_10_14 at 0 range 10 .. 14; CMP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype UART_UART_IDR_RXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_IDR_TXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_IDR_OVRE_Field is Interfaces.SAM.Bit; subtype UART_UART_IDR_FRAME_Field is Interfaces.SAM.Bit; subtype UART_UART_IDR_PARE_Field is Interfaces.SAM.Bit; subtype UART_UART_IDR_TXEMPTY_Field is Interfaces.SAM.Bit; subtype UART_UART_IDR_CMP_Field is Interfaces.SAM.Bit; -- Interrupt Disable Register type UART_UART_IDR_Register is record -- Write-only. Disable RXRDY Interrupt RXRDY : UART_UART_IDR_RXRDY_Field := 16#0#; -- Write-only. Disable TXRDY Interrupt TXRDY : UART_UART_IDR_TXRDY_Field := 16#0#; -- unspecified Reserved_2_4 : Interfaces.SAM.UInt3 := 16#0#; -- Write-only. Disable Overrun Error Interrupt OVRE : UART_UART_IDR_OVRE_Field := 16#0#; -- Write-only. Disable Framing Error Interrupt FRAME : UART_UART_IDR_FRAME_Field := 16#0#; -- Write-only. Disable Parity Error Interrupt PARE : UART_UART_IDR_PARE_Field := 16#0#; -- unspecified Reserved_8_8 : Interfaces.SAM.Bit := 16#0#; -- Write-only. Disable TXEMPTY Interrupt TXEMPTY : UART_UART_IDR_TXEMPTY_Field := 16#0#; -- unspecified Reserved_10_14 : Interfaces.SAM.UInt5 := 16#0#; -- Write-only. Disable Comparison Interrupt CMP : UART_UART_IDR_CMP_Field := 16#0#; -- unspecified Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_IDR_Register use record RXRDY at 0 range 0 .. 0; TXRDY at 0 range 1 .. 1; Reserved_2_4 at 0 range 2 .. 4; OVRE at 0 range 5 .. 5; FRAME at 0 range 6 .. 6; PARE at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; TXEMPTY at 0 range 9 .. 9; Reserved_10_14 at 0 range 10 .. 14; CMP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype UART_UART_IMR_RXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_IMR_TXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_IMR_OVRE_Field is Interfaces.SAM.Bit; subtype UART_UART_IMR_FRAME_Field is Interfaces.SAM.Bit; subtype UART_UART_IMR_PARE_Field is Interfaces.SAM.Bit; subtype UART_UART_IMR_TXEMPTY_Field is Interfaces.SAM.Bit; subtype UART_UART_IMR_CMP_Field is Interfaces.SAM.Bit; -- Interrupt Mask Register type UART_UART_IMR_Register is record -- Read-only. Mask RXRDY Interrupt RXRDY : UART_UART_IMR_RXRDY_Field; -- Read-only. Disable TXRDY Interrupt TXRDY : UART_UART_IMR_TXRDY_Field; -- unspecified Reserved_2_4 : Interfaces.SAM.UInt3; -- Read-only. Mask Overrun Error Interrupt OVRE : UART_UART_IMR_OVRE_Field; -- Read-only. Mask Framing Error Interrupt FRAME : UART_UART_IMR_FRAME_Field; -- Read-only. Mask Parity Error Interrupt PARE : UART_UART_IMR_PARE_Field; -- unspecified Reserved_8_8 : Interfaces.SAM.Bit; -- Read-only. Mask TXEMPTY Interrupt TXEMPTY : UART_UART_IMR_TXEMPTY_Field; -- unspecified Reserved_10_14 : Interfaces.SAM.UInt5; -- Read-only. Mask Comparison Interrupt CMP : UART_UART_IMR_CMP_Field; -- unspecified Reserved_16_31 : Interfaces.SAM.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_IMR_Register use record RXRDY at 0 range 0 .. 0; TXRDY at 0 range 1 .. 1; Reserved_2_4 at 0 range 2 .. 4; OVRE at 0 range 5 .. 5; FRAME at 0 range 6 .. 6; PARE at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; TXEMPTY at 0 range 9 .. 9; Reserved_10_14 at 0 range 10 .. 14; CMP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype UART_UART_SR_RXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_TXRDY_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_OVRE_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_FRAME_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_PARE_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_TXEMPTY_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_CMP_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_SWES_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_CLKREQ_Field is Interfaces.SAM.Bit; subtype UART_UART_SR_WKUPREQ_Field is Interfaces.SAM.Bit; -- Status Register type UART_UART_SR_Register is record -- Read-only. Receiver Ready RXRDY : UART_UART_SR_RXRDY_Field; -- Read-only. Transmitter Ready TXRDY : UART_UART_SR_TXRDY_Field; -- unspecified Reserved_2_4 : Interfaces.SAM.UInt3; -- Read-only. Overrun Error OVRE : UART_UART_SR_OVRE_Field; -- Read-only. Framing Error FRAME : UART_UART_SR_FRAME_Field; -- Read-only. Parity Error PARE : UART_UART_SR_PARE_Field; -- unspecified Reserved_8_8 : Interfaces.SAM.Bit; -- Read-only. Transmitter Empty TXEMPTY : UART_UART_SR_TXEMPTY_Field; -- unspecified Reserved_10_14 : Interfaces.SAM.UInt5; -- Read-only. Comparison Match CMP : UART_UART_SR_CMP_Field; -- unspecified Reserved_16_20 : Interfaces.SAM.UInt5; -- Read-only. SleepWalking Enable Status SWES : UART_UART_SR_SWES_Field; -- Read-only. Clock Request CLKREQ : UART_UART_SR_CLKREQ_Field; -- Read-only. Wake-Up Request WKUPREQ : UART_UART_SR_WKUPREQ_Field; -- unspecified Reserved_24_31 : Interfaces.SAM.Byte; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_SR_Register use record RXRDY at 0 range 0 .. 0; TXRDY at 0 range 1 .. 1; Reserved_2_4 at 0 range 2 .. 4; OVRE at 0 range 5 .. 5; FRAME at 0 range 6 .. 6; PARE at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; TXEMPTY at 0 range 9 .. 9; Reserved_10_14 at 0 range 10 .. 14; CMP at 0 range 15 .. 15; Reserved_16_20 at 0 range 16 .. 20; SWES at 0 range 21 .. 21; CLKREQ at 0 range 22 .. 22; WKUPREQ at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype UART_UART_RHR_RXCHR_Field is Interfaces.SAM.Byte; -- Receive Holding Register type UART_UART_RHR_Register is record -- Read-only. Received Character RXCHR : UART_UART_RHR_RXCHR_Field; -- unspecified Reserved_8_31 : Interfaces.SAM.UInt24; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_RHR_Register use record RXCHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype UART_UART_THR_TXCHR_Field is Interfaces.SAM.Byte; -- Transmit Holding Register type UART_UART_THR_Register is record -- Write-only. Character to be Transmitted TXCHR : UART_UART_THR_TXCHR_Field := 16#0#; -- unspecified Reserved_8_31 : Interfaces.SAM.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_THR_Register use record TXCHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype UART_UART_BRGR_CD_Field is Interfaces.SAM.UInt16; -- Baud Rate Generator Register type UART_UART_BRGR_Register is record -- Clock Divisor CD : UART_UART_BRGR_CD_Field := 16#0#; -- unspecified Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_BRGR_Register use record CD at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype UART_UART_CMPR_VAL1_Field is Interfaces.SAM.Byte; -- Comparison Mode type UART_CMPR_CMPMODE_Field is ( -- Any character is received and comparison function drives CMP flag. Flag_Only, -- Comparison condition must be met to start reception. Start_Condition) with Size => 1; for UART_CMPR_CMPMODE_Field use (Flag_Only => 0, Start_Condition => 1); subtype UART_UART_CMPR_CMPPAR_Field is Interfaces.SAM.Bit; subtype UART_UART_CMPR_VAL2_Field is Interfaces.SAM.Byte; -- Comparison Register type UART_UART_CMPR_Register is record -- First Comparison Value for Received Character VAL1 : UART_UART_CMPR_VAL1_Field := 16#0#; -- unspecified Reserved_8_11 : Interfaces.SAM.UInt4 := 16#0#; -- Comparison Mode CMPMODE : UART_CMPR_CMPMODE_Field := Interfaces.SAM.UART.Flag_Only; -- unspecified Reserved_13_13 : Interfaces.SAM.Bit := 16#0#; -- Compare Parity CMPPAR : UART_UART_CMPR_CMPPAR_Field := 16#0#; -- unspecified Reserved_15_15 : Interfaces.SAM.Bit := 16#0#; -- Second Comparison Value for Received Character VAL2 : UART_UART_CMPR_VAL2_Field := 16#0#; -- unspecified Reserved_24_31 : Interfaces.SAM.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_CMPR_Register use record VAL1 at 0 range 0 .. 7; Reserved_8_11 at 0 range 8 .. 11; CMPMODE at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; CMPPAR at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; VAL2 at 0 range 16 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype UART_UART_WPMR_WPEN_Field is Interfaces.SAM.Bit; -- Write Protection Key type UART_WPMR_WPKEY_Field is ( -- Reset value for the field Uart_Wpmr_Wpkey_Field_Reset, -- Writing any other value in this field aborts the write -- operation.Always reads as 0. Passwd) with Size => 24; for UART_WPMR_WPKEY_Field use (Uart_Wpmr_Wpkey_Field_Reset => 0, Passwd => 5587282); -- Write Protection Mode Register type UART_UART_WPMR_Register is record -- Write Protection Enable WPEN : UART_UART_WPMR_WPEN_Field := 16#0#; -- unspecified Reserved_1_7 : Interfaces.SAM.UInt7 := 16#0#; -- Write Protection Key WPKEY : UART_WPMR_WPKEY_Field := Uart_Wpmr_Wpkey_Field_Reset; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_WPMR_Register use record WPEN at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; WPKEY at 0 range 8 .. 31; end record; subtype UART_UART_VERSION_VERSION_Field is Interfaces.SAM.UInt12; subtype UART_UART_VERSION_MFN_Field is Interfaces.SAM.UInt3; -- Version Register type UART_UART_VERSION_Register is record -- Read-only. Hardware Module Version VERSION : UART_UART_VERSION_VERSION_Field; -- unspecified Reserved_12_15 : Interfaces.SAM.UInt4; -- Read-only. Metal Fix Number MFN : UART_UART_VERSION_MFN_Field; -- unspecified Reserved_19_31 : Interfaces.SAM.UInt13; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UART_UART_VERSION_Register use record VERSION at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; MFN at 0 range 16 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Universal Asynchronous Receiver Transmitter type UART_Peripheral is record -- Control Register UART_CR : aliased UART_UART_CR_Register; -- Mode Register UART_MR : aliased UART_UART_MR_Register; -- Interrupt Enable Register UART_IER : aliased UART_UART_IER_Register; -- Interrupt Disable Register UART_IDR : aliased UART_UART_IDR_Register; -- Interrupt Mask Register UART_IMR : aliased UART_UART_IMR_Register; -- Status Register UART_SR : aliased UART_UART_SR_Register; -- Receive Holding Register UART_RHR : aliased UART_UART_RHR_Register; -- Transmit Holding Register UART_THR : aliased UART_UART_THR_Register; -- Baud Rate Generator Register UART_BRGR : aliased UART_UART_BRGR_Register; -- Comparison Register UART_CMPR : aliased UART_UART_CMPR_Register; -- Write Protection Mode Register UART_WPMR : aliased UART_UART_WPMR_Register; -- Version Register UART_VERSION : aliased UART_UART_VERSION_Register; end record with Volatile; for UART_Peripheral use record UART_CR at 16#0# range 0 .. 31; UART_MR at 16#4# range 0 .. 31; UART_IER at 16#8# range 0 .. 31; UART_IDR at 16#C# range 0 .. 31; UART_IMR at 16#10# range 0 .. 31; UART_SR at 16#14# range 0 .. 31; UART_RHR at 16#18# range 0 .. 31; UART_THR at 16#1C# range 0 .. 31; UART_BRGR at 16#20# range 0 .. 31; UART_CMPR at 16#24# range 0 .. 31; UART_WPMR at 16#E4# range 0 .. 31; UART_VERSION at 16#FC# range 0 .. 31; end record; -- Universal Asynchronous Receiver Transmitter UART0_Periph : aliased UART_Peripheral with Import, Address => System'To_Address (16#400E0800#); -- Universal Asynchronous Receiver Transmitter UART1_Periph : aliased UART_Peripheral with Import, Address => System'To_Address (16#400E0A00#); -- Universal Asynchronous Receiver Transmitter UART2_Periph : aliased UART_Peripheral with Import, Address => System'To_Address (16#400E1A00#); -- Universal Asynchronous Receiver Transmitter UART3_Periph : aliased UART_Peripheral with Import, Address => System'To_Address (16#400E1C00#); -- Universal Asynchronous Receiver Transmitter UART4_Periph : aliased UART_Peripheral with Import, Address => System'To_Address (16#400E1E00#); end Interfaces.SAM.UART;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> -- -- 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$ ------------------------------------------------------------------------------ -- SOAP message decoder process events from SAX parser. ------------------------------------------------------------------------------ with League.Strings; with XML.SAX.Attributes; with XML.SAX.Content_Handlers; with XML.SAX.Error_Handlers; with XML.SAX.Parse_Exceptions; with XML.SAX.Lexical_Handlers; private with Web_Services.SOAP.Payloads.Decoders; private with Web_Services.SOAP.Headers.Decoders; with Web_Services.SOAP.Messages; package Web_Services.SOAP.Message_Decoders is type SOAP_Message_Decoder is limited new XML.SAX.Content_Handlers.SAX_Content_Handler and XML.SAX.Error_Handlers.SAX_Error_Handler and XML.SAX.Lexical_Handlers.SAX_Lexical_Handler with private; function Success (Self : SOAP_Message_Decoder'Class) return Boolean; function Message (Self : SOAP_Message_Decoder'Class) return Web_Services.SOAP.Messages.SOAP_Message_Access; private type States is (Initial, -- Initial state. SOAP_Envelope, -- SOAP Envelope element has been processed. SOAP_Header, -- SOAP Header element has been processed. Header_Element, -- SOAP Header child element has been processed. Header_Ignore, -- Ignore child and grandchildren of SOAP Header. SOAP_Body, -- SOAP Body element has beed processed. Body_Element, -- SOAP Body child element has been processed. Body_Ignore); -- Ignore child and grandchildren of SOAP Header. type Modes is (Strict, -- Strict mode: all 'SHOULD' assertions are -- checked. Conformant); -- Relaxed mode to pass SOAP conformance testsuite; -- some 'SHOULD' assertions aren't checked. type SOAP_Message_Decoder is limited new XML.SAX.Content_Handlers.SAX_Content_Handler and XML.SAX.Error_Handlers.SAX_Error_Handler and XML.SAX.Lexical_Handlers.SAX_Lexical_Handler with record Mode : Modes := Conformant; State : States := Initial; Depth : Natural := 0; Payload_Decoder : Web_Services.SOAP.Payloads.Decoders.SOAP_Payload_Decoder_Access; Header_Decoder : Web_Services.SOAP.Headers.Decoders.SOAP_Header_Decoder_Access; Message : Web_Services.SOAP.Messages.SOAP_Message_Access; Success : Boolean := True; end record; overriding procedure Characters (Self : in out SOAP_Message_Decoder; Text : League.Strings.Universal_String; Success : in out Boolean); overriding procedure End_Element (Self : in out SOAP_Message_Decoder; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Error (Self : in out SOAP_Message_Decoder; Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception; Success : in out Boolean); -- Stops processing of the message. overriding function Error_String (Self : SOAP_Message_Decoder) return League.Strings.Universal_String; -- Returns error information as string. overriding procedure Fatal_Error (Self : in out SOAP_Message_Decoder; Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception); -- Stops processing of the message. overriding procedure Processing_Instruction (Self : in out SOAP_Message_Decoder; Target : League.Strings.Universal_String; Data : League.Strings.Universal_String; Success : in out Boolean); -- Handles processing instructions in XML stream. Processing instructions -- are prohibited in SOAP messages, this subprogram always sets Success to -- False. overriding procedure Start_Document (Self : in out SOAP_Message_Decoder; Success : in out Boolean); -- Handles start of processing of document. Used for initialization. overriding procedure Start_DTD (Self : in out SOAP_Message_Decoder; Name : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Start_Element (Self : in out SOAP_Message_Decoder; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Attributes : XML.SAX.Attributes.SAX_Attributes; Success : in out Boolean); end Web_Services.SOAP.Message_Decoders;
pragma License (Unrestricted); -- extended unit private with System.Unbounded_Allocators; package System.Storage_Pools.Unbounded is -- Separated storage pool for local scope. -- The compiler (gcc) does not support scope-based automatic deallocation. -- Instead, some custom pool, like System.Pool_Local.Unbounded_Reclaim_Pool -- of GNAT runtime, using separated storage by every pool object and -- having different lifetime from the standard storage pool can be used -- for deallocating all of allocated from each pool object, at once. -- This package provides the similar pool. pragma Preelaborate; type Unbounded_Pool is limited new Root_Storage_Pool with private; pragma Unreferenced_Objects (Unbounded_Pool); -- [gcc-4.8] warnings private type Unbounded_Pool is limited new Root_Storage_Pool with record Allocator : Unbounded_Allocators.Unbounded_Allocator; end record; pragma Finalize_Storage_Only (Unbounded_Pool); overriding procedure Initialize (Object : in out Unbounded_Pool); overriding procedure Finalize (Object : in out Unbounded_Pool); overriding procedure Allocate ( Pool : in out Unbounded_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); overriding procedure Deallocate ( Pool : in out Unbounded_Pool; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); overriding function Storage_Size (Pool : Unbounded_Pool) return Storage_Elements.Storage_Count is (Storage_Elements.Storage_Count'Last); end System.Storage_Pools.Unbounded;
package body Simple_Parse is function Next_Word(S: String; Point: in out Positive) return String is Start: Positive := Point; Stop: Natural; begin while Start <= S'Last and then S(Start) = ' ' loop Start := Start + 1; end loop; -- now S(Start) is the first non-space, -- or Start = S'Last+1 if S is empty or space-only Stop := Start-1; -- now S(Start .. Stop) = "" while Stop < S'Last and then S(Stop+1) /= ' ' loop Stop := Stop + 1; end loop; -- now S(Stop+1) is the first sopace after Start -- or Stop = S'Last if there is no such space Point := Stop+1; return S(Start .. Stop); end Next_Word; end Simple_Parse;
----------------------------------------------------------------------- -- Faces Context Tests - Unit tests for ASF.Contexts.Faces -- Copyright (C) 2010, 2011, 2012, 2013, 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.IO_Exceptions; with Ada.Unchecked_Deallocation; with Util.Test_Caller; with EL.Variables.Default; with ASF.Contexts.Flash; with ASF.Contexts.Faces.Mockup; package body ASF.Contexts.Faces.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Contexts.Faces"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin -- To document what is tested, register the test methods for each -- operation that is tested. Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Add_Message", Test_Add_Message'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Max_Severity", Test_Max_Severity'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Message", Test_Get_Messages'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Queue_Exception", Test_Queue_Exception'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Flash", Test_Flash_Context'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Attribute", Test_Get_Attribute'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Bean", Test_Get_Bean'Access); Caller.Add_Test (Suite, "Test ASF.Helpers.Beans.Get_Bean", Test_Get_Bean_Helper'Access); Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Mockup", Test_Mockup_Faces_Context'Access); end Add_Tests; -- ------------------------------ -- Setup the faces context for the unit test. -- ------------------------------ procedure Setup (T : in out Test; Context : in out Faces_Context) is begin T.Form := new ASF.Applications.Tests.Form_Bean; T.ELContext := new EL.Contexts.Default.Default_Context; T.Root_Resolver := new EL.Contexts.Default.Default_ELResolver; T.Variables := new EL.Variables.Default.Default_Variable_Mapper; T.ELContext.Set_Resolver (T.Root_Resolver.all'Access); T.ELContext.Set_Variable_Mapper (T.Variables.all'Access); Context.Set_ELContext (T.ELContext.all'Access); T.Root_Resolver.Register (Ada.Strings.Unbounded.To_Unbounded_String ("dumbledore"), EL.Objects.To_Object (String '("albus"))); T.Root_Resolver.Register (Ada.Strings.Unbounded.To_Unbounded_String ("potter"), EL.Objects.To_Object (String '("harry"))); T.Root_Resolver.Register (Ada.Strings.Unbounded.To_Unbounded_String ("hogwarts"), EL.Objects.To_Object (T.Form.all'Access, EL.Objects.STATIC)); end Setup; -- ------------------------------ -- Cleanup the test instance. -- ------------------------------ overriding procedure Tear_Down (T : in out Test) is procedure Free is new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_Context'Class, EL.Contexts.Default.Default_Context_Access); procedure Free is new Ada.Unchecked_Deallocation (EL.Variables.Variable_Mapper'Class, EL.Variables.Variable_Mapper_Access); procedure Free is new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_ELResolver'Class, EL.Contexts.Default.Default_ELResolver_Access); procedure Free is new Ada.Unchecked_Deallocation (ASF.Applications.Tests.Form_Bean'Class, ASF.Applications.Tests.Form_Bean_Access); begin ASF.Contexts.Faces.Restore (null); Free (T.ELContext); Free (T.Variables); Free (T.Root_Resolver); Free (T.Form); end Tear_Down; -- ------------------------------ -- Test getting an attribute from the faces context. -- ------------------------------ procedure Test_Get_Attribute (T : in out Test) is Ctx : Faces_Context; Name : EL.Objects.Object; begin T.Setup (Ctx); Name := Ctx.Get_Attribute ("dumbledore"); T.Assert (not EL.Objects.Is_Null (Name), "Null attribute returned"); Util.Tests.Assert_Equals (T, "albus", EL.Objects.To_String (Name), "Invalid attribute"); Name := Ctx.Get_Attribute ("potter"); T.Assert (not EL.Objects.Is_Null (Name), "Null attribute returned"); Util.Tests.Assert_Equals (T, "harry", EL.Objects.To_String (Name), "Invalid attribute"); Name := Ctx.Get_Attribute ("voldemort"); T.Assert (EL.Objects.Is_Null (Name), "Oops... is there any horcrux left?"); end Test_Get_Attribute; -- ------------------------------ -- Test getting a bean object from the faces context. -- ------------------------------ procedure Test_Get_Bean (T : in out Test) is use type Util.Beans.Basic.Readonly_Bean_Access; Ctx : Faces_Context; Bean : Util.Beans.Basic.Readonly_Bean_Access; begin T.Setup (Ctx); Bean := Ctx.Get_Bean ("dumbledore"); T.Assert (Bean = null, "Dumbledore should not be a bean"); Bean := Ctx.Get_Bean ("hogwarts"); T.Assert (Bean /= null, "hogwarts should be a bean"); end Test_Get_Bean; -- ------------------------------ -- Test getting a bean object from the faces context and doing a conversion. -- ------------------------------ procedure Test_Get_Bean_Helper (T : in out Test) is use type ASF.Applications.Tests.Form_Bean_Access; Ctx : aliased Faces_Context; Bean : ASF.Applications.Tests.Form_Bean_Access; begin T.Setup (Ctx); Bean := Get_Form_Bean ("hogwarts"); T.Assert (Bean = null, "A bean was found while the faces context does not exist!"); ASF.Contexts.Faces.Set_Current (Ctx'Unchecked_Access, null); Bean := Get_Form_Bean ("hogwarts"); T.Assert (Bean /= null, "hogwarts should be a bean"); Bean := Get_Form_Bean ("dumbledore"); T.Assert (Bean = null, "Dumbledore should not be a bean"); ASF.Contexts.Faces.Restore (null); end Test_Get_Bean_Helper; -- ------------------------------ -- Test the faces message queue. -- ------------------------------ procedure Test_Add_Message (T : in out Test) is Ctx : Faces_Context; begin Ctx.Add_Message (Client_Id => "", Message => "msg1"); Ctx.Add_Message (Client_Id => "", Message => "msg1"); Ctx.Add_Message (Client_Id => "", Message => "msg2"); Ctx.Add_Message (Client_Id => "", Message => "msg3"); Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => INFO); Ctx.Add_Message (Client_Id => "warn", Message => "msg3", Severity => WARN); Ctx.Add_Message (Client_Id => "error", Message => "msg3", Severity => ERROR); Ctx.Add_Message (Client_Id => "fatal", Message => "msg3", Severity => FATAL); T.Assert (Ctx.Get_Maximum_Severity = FATAL, "Add message failed"); end Test_Add_Message; procedure Test_Max_Severity (T : in out Test) is Ctx : Faces_Context; begin T.Assert (Ctx.Get_Maximum_Severity = NONE, "Invalid max severity with no message"); Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => INFO); T.Assert (Ctx.Get_Maximum_Severity = INFO, "Invalid max severity with info message"); Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => WARN); T.Assert (Ctx.Get_Maximum_Severity = WARN, "Invalid max severity with warn message"); Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => FATAL); T.Assert (Ctx.Get_Maximum_Severity = FATAL, "Invalid max severity with warn message"); end Test_Max_Severity; procedure Test_Get_Messages (T : in out Test) is Ctx : Faces_Context; begin -- Iterator on an empty message list. declare Iter : constant Vectors.Cursor := Ctx.Get_Messages (Client_Id => ""); begin T.Assert (not Vectors.Has_Element (Iter), "Iterator should indicate no message"); end; Ctx.Add_Message (Client_Id => "info", Message => "msg1", Severity => INFO); declare Iter : constant Vectors.Cursor := Ctx.Get_Messages (Client_Id => "info"); M : Message; begin T.Assert (Vectors.Has_Element (Iter), "Iterator should indicate a message"); M := Vectors.Element (Iter); Assert_Equals (T, "msg1", Get_Summary (M), "Invalid message"); Assert_Equals (T, "msg1", Get_Detail (M), "Invalid details"); T.Assert (INFO = Get_Severity (M), "Invalid severity"); end; end Test_Get_Messages; -- ------------------------------ -- Test adding some exception in the faces context. -- ------------------------------ procedure Test_Queue_Exception (T : in out Test) is procedure Raise_Exception (Depth : in Natural; Excep : in Natural); procedure Check_Exception (Event : in Events.Exceptions.Exception_Event'Class; Remove : out Boolean; Context : in out Faces_Context'Class); Ctx : Faces_Context; Cnt : Natural := 0; procedure Raise_Exception (Depth : in Natural; Excep : in Natural) is begin if Depth > 0 then Raise_Exception (Depth - 1, Excep); end if; case Excep is when 1 => raise Constraint_Error with "except code 1"; when 2 => raise Ada.IO_Exceptions.Name_Error; when others => raise Program_Error with "Testing program error"; end case; end Raise_Exception; procedure Check_Exception (Event : in Events.Exceptions.Exception_Event'Class; Remove : out Boolean; Context : in out Faces_Context'Class) is pragma Unreferenced (Context, Event); begin Cnt := Cnt + 1; Remove := False; end Check_Exception; begin -- Create some exceptions and queue them. for I in 1 .. 3 loop begin Raise_Exception (3, I); exception when E : others => Ctx.Queue_Exception (E); end; end loop; Ctx.Iterate_Exception (Check_Exception'Access); Util.Tests.Assert_Equals (T, 3, Cnt, "3 exception should have been queued"); end Test_Queue_Exception; -- ------------------------------ -- Test the flash instance. -- ------------------------------ procedure Test_Flash_Context (T : in out Test) is use type ASF.Contexts.Faces.Flash_Context_Access; Ctx : Faces_Context; Flash : aliased ASF.Contexts.Flash.Flash_Context; begin Ctx.Set_Flash (Flash'Unchecked_Access); T.Assert (Ctx.Get_Flash /= null, "Null flash context returned"); end Test_Flash_Context; -- ------------------------------ -- Test the mockup faces context. -- ------------------------------ procedure Test_Mockup_Faces_Context (T : in out Test) is use type ASF.Requests.Request_Access; use type ASF.Responses.Response_Access; use type EL.Contexts.ELContext_Access; begin ASF.Applications.Tests.Initialize_Test_Application; declare Ctx : Mockup.Mockup_Faces_Context; begin Ctx.Set_Method ("GET"); Ctx.Set_Path_Info ("something.html"); T.Assert (Current /= null, "There is no current faces context (mockup failed)"); T.Assert (Current.Get_Request /= null, "There is no current request"); T.Assert (Current.Get_Response /= null, "There is no current response"); T.Assert (Current.Get_Application /= null, "There is no current application"); T.Assert (Current.Get_ELContext /= null, "There is no current ELcontext"); end; T.Assert (Current = null, "There is a current faces context but it shoudl be null"); end Test_Mockup_Faces_Context; end ASF.Contexts.Faces.Tests;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Wide_Wide_Characters.Handling; package body Program.Units.Vectors is ------------ -- Append -- ------------ procedure Append (Self : in out Unit_Vector; Value : not null Program.Compilation_Units.Compilation_Unit_Access) is begin Self.Data.Append (Value); end Append; ----------- -- Clear -- ----------- procedure Clear (Self : in out Unit_Vector) is begin Self.Data.Clear; end Clear; ------------- -- Element -- ------------- overriding function Element (Self : Unit_Vector; Index : Positive) return not null Program.Compilation_Units.Compilation_Unit_Access is begin return Self.Data (Index); end Element; --------------- -- Find_Unit -- --------------- overriding function Find_Unit (Self : Unit_Vector; Name : Text) return Program.Compilation_Units.Compilation_Unit_Access is use Ada.Wide_Wide_Characters.Handling; Name_To_Lower : constant Text := To_Lower (Name); begin for J of Self.Data loop if To_Lower (J.Full_Name) = Name_To_Lower then return J; end if; end loop; return null; end Find_Unit; ---------------- -- Get_Length -- ---------------- overriding function Get_Length (Self : Unit_Vector) return Positive is begin return Self.Data.Last_Index; end Get_Length; end Program.Units.Vectors;
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32H743x.svd pragma Restrictions (No_Elaboration_Code); with System; -- STM32H743x package STM32_SVD is pragma Preelaborate; -------------------- -- Base addresses -- -------------------- COMP_Base : constant System.Address := System'To_Address (16#58003800#); CRS_Base : constant System.Address := System'To_Address (16#40008400#); DAC_Base : constant System.Address := System'To_Address (16#40007400#); BDMA_Base : constant System.Address := System'To_Address (16#58025400#); DMA2D_Base : constant System.Address := System'To_Address (16#52001000#); DMAMUX2_Base : constant System.Address := System'To_Address (16#58025800#); FMC_Base : constant System.Address := System'To_Address (16#52004000#); CEC_Base : constant System.Address := System'To_Address (16#40006C00#); HSEM_Base : constant System.Address := System'To_Address (16#58026400#); I2C1_Base : constant System.Address := System'To_Address (16#40005400#); I2C2_Base : constant System.Address := System'To_Address (16#40005800#); I2C3_Base : constant System.Address := System'To_Address (16#40005C00#); I2C4_Base : constant System.Address := System'To_Address (16#58001C00#); GPIOA_Base : constant System.Address := System'To_Address (16#58020000#); GPIOB_Base : constant System.Address := System'To_Address (16#58020400#); GPIOC_Base : constant System.Address := System'To_Address (16#58020800#); GPIOD_Base : constant System.Address := System'To_Address (16#58020C00#); GPIOE_Base : constant System.Address := System'To_Address (16#58021000#); GPIOF_Base : constant System.Address := System'To_Address (16#58021400#); GPIOG_Base : constant System.Address := System'To_Address (16#58021800#); GPIOH_Base : constant System.Address := System'To_Address (16#58021C00#); GPIOI_Base : constant System.Address := System'To_Address (16#58022000#); GPIOJ_Base : constant System.Address := System'To_Address (16#58022400#); GPIOK_Base : constant System.Address := System'To_Address (16#58022800#); JPEG_Base : constant System.Address := System'To_Address (16#52003000#); MDMA_Base : constant System.Address := System'To_Address (16#52000000#); QUADSPI_Base : constant System.Address := System'To_Address (16#52005000#); RNG_Base : constant System.Address := System'To_Address (16#48021800#); RTC_Base : constant System.Address := System'To_Address (16#58004000#); SAI4_Base : constant System.Address := System'To_Address (16#58005400#); SAI1_Base : constant System.Address := System'To_Address (16#40015800#); SAI2_Base : constant System.Address := System'To_Address (16#40015C00#); SAI3_Base : constant System.Address := System'To_Address (16#40016000#); SDMMC1_Base : constant System.Address := System'To_Address (16#52007000#); SDMMC2_Base : constant System.Address := System'To_Address (16#48022400#); VREFBUF_Base : constant System.Address := System'To_Address (16#58003C00#); IWDG_Base : constant System.Address := System'To_Address (16#58004800#); WWDG_Base : constant System.Address := System'To_Address (16#50003000#); PWR_Base : constant System.Address := System'To_Address (16#58024800#); SPI1_Base : constant System.Address := System'To_Address (16#40013000#); SPI2_Base : constant System.Address := System'To_Address (16#40003800#); SPI3_Base : constant System.Address := System'To_Address (16#40003C00#); SPI4_Base : constant System.Address := System'To_Address (16#40013400#); SPI5_Base : constant System.Address := System'To_Address (16#40015000#); SPI6_Base : constant System.Address := System'To_Address (16#58001400#); LTDC_Base : constant System.Address := System'To_Address (16#50001000#); SPDIFRX_Base : constant System.Address := System'To_Address (16#40004000#); ADC3_Base : constant System.Address := System'To_Address (16#58026000#); ADC1_Base : constant System.Address := System'To_Address (16#40022000#); ADC2_Base : constant System.Address := System'To_Address (16#40022100#); ADC3_Common_Base : constant System.Address := System'To_Address (16#58026300#); ADC12_Common_Base : constant System.Address := System'To_Address (16#40022300#); DMAMUX1_Base : constant System.Address := System'To_Address (16#40020800#); CRC_Base : constant System.Address := System'To_Address (16#58024C00#); RCC_Base : constant System.Address := System'To_Address (16#58024400#); LPTIM1_Base : constant System.Address := System'To_Address (16#40002400#); LPTIM2_Base : constant System.Address := System'To_Address (16#58002400#); LPTIM3_Base : constant System.Address := System'To_Address (16#58002800#); LPTIM4_Base : constant System.Address := System'To_Address (16#58002C00#); LPTIM5_Base : constant System.Address := System'To_Address (16#58003000#); LPUART1_Base : constant System.Address := System'To_Address (16#58000C00#); SYSCFG_Base : constant System.Address := System'To_Address (16#58000400#); EXTI_Base : constant System.Address := System'To_Address (16#58000000#); DELAY_Block_SDMMC1_Base : constant System.Address := System'To_Address (16#52008000#); DELAY_Block_QUADSPI_Base : constant System.Address := System'To_Address (16#52006000#); DELAY_Block_SDMMC2_Base : constant System.Address := System'To_Address (16#48022800#); Flash_Base : constant System.Address := System'To_Address (16#52002000#); AXI_Base : constant System.Address := System'To_Address (16#51000000#); DCMI_Base : constant System.Address := System'To_Address (16#48020000#); OTG1_HS_GLOBAL_Base : constant System.Address := System'To_Address (16#40040000#); OTG2_HS_GLOBAL_Base : constant System.Address := System'To_Address (16#40080000#); OTG1_HS_HOST_Base : constant System.Address := System'To_Address (16#40040400#); OTG2_HS_HOST_Base : constant System.Address := System'To_Address (16#40080400#); OTG1_HS_DEVICE_Base : constant System.Address := System'To_Address (16#40040800#); OTG2_HS_DEVICE_Base : constant System.Address := System'To_Address (16#40080800#); OTG1_HS_PWRCLK_Base : constant System.Address := System'To_Address (16#40040E00#); OTG2_HS_PWRCLK_Base : constant System.Address := System'To_Address (16#40080E00#); Ethernet_DMA_Base : constant System.Address := System'To_Address (16#40029000#); Ethernet_MTL_Base : constant System.Address := System'To_Address (16#40028C00#); Ethernet_MAC_Base : constant System.Address := System'To_Address (16#40028000#); DMA1_Base : constant System.Address := System'To_Address (16#40020000#); DMA2_Base : constant System.Address := System'To_Address (16#40020400#); HRTIM_Master_Base : constant System.Address := System'To_Address (16#40017400#); HRTIM_TIMA_Base : constant System.Address := System'To_Address (16#40017480#); HRTIM_TIMB_Base : constant System.Address := System'To_Address (16#40017500#); HRTIM_TIMC_Base : constant System.Address := System'To_Address (16#40017580#); HRTIM_TIMD_Base : constant System.Address := System'To_Address (16#40017600#); HRTIM_TIME_Base : constant System.Address := System'To_Address (16#40017680#); HRTIM_Common_Base : constant System.Address := System'To_Address (16#40017780#); DFSDM_Base : constant System.Address := System'To_Address (16#40017000#); TIM16_Base : constant System.Address := System'To_Address (16#40014400#); TIM17_Base : constant System.Address := System'To_Address (16#40014800#); TIM15_Base : constant System.Address := System'To_Address (16#40014000#); USART1_Base : constant System.Address := System'To_Address (16#40011000#); USART2_Base : constant System.Address := System'To_Address (16#40004400#); USART3_Base : constant System.Address := System'To_Address (16#40004800#); UART4_Base : constant System.Address := System'To_Address (16#40004C00#); UART5_Base : constant System.Address := System'To_Address (16#40005000#); USART6_Base : constant System.Address := System'To_Address (16#40011400#); UART7_Base : constant System.Address := System'To_Address (16#40007800#); UART8_Base : constant System.Address := System'To_Address (16#40007C00#); TIM1_Base : constant System.Address := System'To_Address (16#40010000#); TIM8_Base : constant System.Address := System'To_Address (16#40010400#); FDCAN1_Base : constant System.Address := System'To_Address (16#4000A000#); FDCAN2_Base : constant System.Address := System'To_Address (16#4000A400#); CAN_CCU_Base : constant System.Address := System'To_Address (16#4000A800#); MDIOS_Base : constant System.Address := System'To_Address (16#40009400#); OPAMP_Base : constant System.Address := System'To_Address (16#40009000#); SWPMI_Base : constant System.Address := System'To_Address (16#40008800#); TIM2_Base : constant System.Address := System'To_Address (16#40000000#); TIM3_Base : constant System.Address := System'To_Address (16#40000400#); TIM4_Base : constant System.Address := System'To_Address (16#40000800#); TIM5_Base : constant System.Address := System'To_Address (16#40000C00#); TIM12_Base : constant System.Address := System'To_Address (16#40001800#); TIM13_Base : constant System.Address := System'To_Address (16#40001C00#); TIM14_Base : constant System.Address := System'To_Address (16#40002000#); TIM6_Base : constant System.Address := System'To_Address (16#40001000#); TIM7_Base : constant System.Address := System'To_Address (16#40001400#); NVIC_Base : constant System.Address := System'To_Address (16#E000E100#); MPU_Base : constant System.Address := System'To_Address (16#E000ED90#); STK_Base : constant System.Address := System'To_Address (16#E000E010#); NVIC_STIR_Base : constant System.Address := System'To_Address (16#E000EF00#); FPU_CPACR_Base : constant System.Address := System'To_Address (16#E000ED88#); SCB_ACTRL_Base : constant System.Address := System'To_Address (16#E000E008#); FPU_Base : constant System.Address := System'To_Address (16#E000EF34#); SCB_Base : constant System.Address := System'To_Address (16#E000ED00#); PF_Base : constant System.Address := System'To_Address (16#E000ED78#); AC_Base : constant System.Address := System'To_Address (16#E000EF90#); end STM32_SVD;
package HAL.SPI with SPARK_Mode => Off is type SPI_Status is (Ok, Err_Error, Err_Timeout, Busy); type SPI_Data_Size is (Data_Size_8b, Data_Size_16b); type SPI_Data_8b is array (Natural range <>) of Byte; type SPI_Data_16b is array (Natural range <>) of Short; type SPI_Port is limited interface; type SPI_Port_Ref is not null access all SPI_Port'Class; function Data_Size (Port : SPI_Port) return SPI_Data_Size is abstract; procedure Transmit (Port : in out SPI_Port; Data : SPI_Data_8b; Status : out SPI_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_8b; procedure Transmit (Port : in out SPI_Port; Data : SPI_Data_16b; Status : out SPI_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_16b; procedure Receive (Port : in out SPI_Port; Data : out SPI_Data_8b; Status : out SPI_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_8b; procedure Receive (Port : in out SPI_Port; Data : out SPI_Data_16b; Status : out SPI_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_16b; end HAL.SPI;
with Extended_Real; with Extended_Real.Elementary_Functions; with Extended_Real.IO; with Ada.Numerics.Generic_Elementary_Functions; with Text_IO; use Text_IO; procedure e_function_demo_1 is type Real is digits 15; package mth is new Ada.Numerics.Generic_Elementary_Functions (Real); use mth; package ext is new Extended_Real (Real); use ext; package fnc is new Ext.Elementary_Functions (Sqrt, Log, Exp, Arcsin); use fnc; package eio is new Ext.IO; use eio; package rio is new Text_IO.Float_IO (Real); use rio; Delta_2 : e_Real; Z0, Z1, Z2, Z3, Z4, Difference1 : e_Real; Junk1 : constant e_Real := E_Quarter_Pi * Make_Extended (0.273); Junk2 : constant e_Real := E_Quarter_Pi * Make_Extended (0.233); Junk3 : constant e_Real := E_Inverse_Sqrt_2; -- 1/SQRT(2) Test_Vector_Seed : Real; N : Positive; Two_Digit : constant e_Digit := Make_e_Digit (2.0); Half : constant e_Real := Make_Extended (0.5); Limit : constant Integer := 1200; -- Number of test runs for some procedures. Can't exceed 1200 because -- some tests use (10.0**0.25)**Limit. e_Real_Decimals : constant := Desired_Decimal_Digit_Precision; ----------- -- Pause -- ----------- procedure Pause (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9 : string := "") is Continue : Character := ' '; begin new_line; if S0 /= "" then put_line (S0); end if; if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; if S8 /= "" then put_line (S8); end if; if S9 /= "" then put_line (S9); end if; new_line; begin put ("Type a character to continue: "); get_immediate (Continue); exception when others => null; end; new_line; end Pause; ---------------------------------- -- Print_Extended_Real_Settings -- ---------------------------------- procedure Print_Extended_Real_Settings is Bits_In_Radix : constant := Desired_No_Of_Bits_In_Radix; begin new_line(1); put (" Desired_Decimal_Digit_Precision ="); put (Integer'Image(Desired_Decimal_Digit_Precision)); new_line(1); new_line(1); put ("Number of decimal digits of precision requested: "); put (Integer'Image(Desired_Decimal_Digit_Precision)); new_line(1); put ("Number of digits in use (including 2 guard digits): "); put (e_Integer'Image(e_Real_Machine_Mantissa)); new_line(1); put ("These digits are not decimal; they have Radix: 2**("); put (e_Integer'Image(Bits_In_Radix)); put(")"); new_line(1); put ("In other words, each of these digits is in range: 0 .. 2**("); put (e_Integer'Image(Bits_In_Radix)); put(")"); put (" - 1."); new_line(1); put ("Number of decimal digits per actual digit is approx: 9"); new_line(2); put("Guard digits (digits of extra precision) are appended to the end of"); new_line(1); put("each number. There are always 2 guard digits. This adds up to 18"); new_line(1); put("decimal digits of extra precision. The arithmetic operators, (""*"","); new_line(1); put("""/"", ""+"" etc) usually produce results that are correct to all"); new_line(1); put("digits except the final (guard) digit."); Pause; new_line(2); put("If a number is correct to all digits except the final (guard) digit,"); new_line(1); put("expect errors of the order:"); new_line(2); put(e_Real_Image (e_Real_Model_Epsilon / (One+One)**Bits_In_Radix, aft => 10)); new_line(2); put("If you lose 2 digits of accuracy (i.e. both guard digits) instead"); new_line(1); put("of 1 (as in the above case) then you lose another 9 decimal digits"); new_line(1); put("of accuracy. In this case expect errors of the order:"); new_line(2); put(e_Real_Image (e_Real_Model_Epsilon, aft => 10)); new_line(1); new_line(1); put ("The above number, by the way, is: e_Real_Model_Epsilon."); new_line(2); put ("Most computationally intensive floating pt. calculations will"); new_line(1); put ("lose 2 guard digits of accuracy at the minimum."); Pause; end Print_Extended_Real_Settings; --------------------------- -- Test_Cos_and_Arccos_4 -- --------------------------- -- Test rel. error in large Z1 limit. procedure Test_Cos_and_Arccos_4 is I1 : constant Integer := -Limit; I2 :constant Integer := 0; Max_Error : e_Real; -- init essential begin Z1 := Junk1; for I in I1..I2 loop Z1 := (Z1 / (Z1 + (+(1.77827941**I)))); Z2 := Cos (Arccos (Z1)); Difference1 := Abs ((Z2 - Z1) / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Cos_and_Arccos_4; -- Test rel. error in small Z1 limit. procedure Test_Cos_and_Arccos_3 is I1 : constant Integer := -Limit; I2 :constant Integer := 0; Max_Error : e_Real; -- init essential begin Z1 := Junk1; for I in I1..I2 loop Z1 := Abs(Z1); Z1 := -(Z1 / (Z1 + (+(1.77827941**I))**2)); Z2 := Cos (Arccos (Z1)); Difference1 := Abs ((Z2 - Z1) / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Cos_and_Arccos_3; -- Can't test relative error in small Z1 limit, only absolute, -- because Cos (Arccos (Z1)) simply doesn't reproduce Z1 for finite -- numbers of digits. Recall Arcos just calls Arcsin. procedure Test_Cos_and_Arccos_2 is I1 : constant Integer := -Limit/2; I2 :constant Integer := Limit/2; Max_Error : e_Real; -- init essential begin Z1 := Junk1; for I in I1..I2 loop Z1 := (Z1 / (Z1 + (+(1.77827941**I)))); Z2 := Cos (Arccos (Z1)); Difference1 := Abs (Z2 - Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Cos_and_Arccos_2; -- Can't test relative error in small Z1 limit, only absolute, -- because Cos (Arccos (Z1)) simply doesn't reproduce Z1 for finite -- numbers of digits. Recall Arcos just calls Arcsin. procedure Test_Cos_and_Arccos_1 is I1 : constant Integer := -Limit/2; I2 :constant Integer := Limit/2; Max_Error : e_Real; -- init essential begin Z1 := Junk1; for I in I1..I2 loop Z1 := Abs(Z1); Z1 := -(Z1 / (Z1 + (+(1.77827941**I))**2)); Z2 := Cos (Arccos (Z1)); Difference1 := Abs (Z2 - Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Cos_and_Arccos_1; -- Superficial test of Sin(X) and Arcsin(X). procedure Test_Sin_and_Arcsin_1 is I1 : constant Integer := -Limit; I2 : constant Integer := 0; Max_Error : e_Real; -- init essential begin Z1 := Junk1; for I in I1..I2 loop Z1 := Z1 / (Z1 + (+(1.77827941**I))); Z2 := Sin (Arcsin (Z1)); Difference1 := Abs ((Z2 - Z1) / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sin_and_Arcsin_1; procedure Test_Sin_and_Arcsin_2 is I1 : constant Integer := -Limit; I2 : constant Integer := Limit+5; Max_Error : e_Real; -- init essential begin Z1 := Junk1; for I in I1..I2 loop Z1 := Z1 / (Z1 + (+(1.77827941**I))); Z2 := Sin (Arcsin (Z1)); Difference1 := Abs ((Z2 - Z1) / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sin_and_Arcsin_2; procedure Test_Sin_and_Arcsin_3 is Max_Error : e_Real; -- init essential I1 : constant Integer := -Limit/2; I2 : constant Integer := Limit+5; begin Z1 := Junk1; for I in I1..I2 loop Z1 := Abs(Z1); Z1 := -Z1 / (Z1 + (+(1.77827941**I))); Z2 := Sin (Arcsin (Z1)); Difference1 := Abs (Z2/Z1 - One); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sin_and_Arcsin_3; -- test: Sin(X)**2 + Cos(X)**2 - 1. procedure Test_Sin_and_Cos_0 (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Junk2 + Z1; Z2 := Sin(Z1)**2 + Cos(Z1)**2; Difference1 := Abs (One - Z2); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sin_and_Cos_0; -- test: Sin(X)**2 + Cos(X)**2 - 1. procedure Test_Sin_and_Cos_2 is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; Shift : constant e_Digit := Make_e_Digit (2.0**(-27)); begin Z1 := e_Inverse_Sqrt_2; for I in 1 .. No_of_Trials loop Z1 := Z1 + Shift * (Shift * e_Real_Model_Epsilon); Z2 := Sin(Z1)**2 + Cos(Z1)**2; Difference1 := Abs (One - Z2); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sin_and_Cos_2; procedure Test_Tan_and_Arctan_2 (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 4_000; begin Z1 := Abs (Junk1 * (+Test_Vector_Seed)); for I in 1 .. No_of_Trials loop Z1 := Z1 + Junk2; Z2 := Arctan (Z1); --Z4 := Sin(Z2) / Cos(Z2); -- Z1 - Sin(Z2) / Cos(Z2) not ok if cos=0 Z3 := Sin(Z2); Z4 := Cos(Z2) * Z1; Difference1 := Abs ((Z3 - Z4) / Z3); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Tan_and_Arctan_2; procedure Test_Tan_and_Arctan (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 1000; Digit_Trials : constant e_Digit := Make_e_Digit (Real (No_of_Trials)); dZ : constant e_Real := Two_Digit * e_Quarter_pi / Digit_Trials; begin for I in 1 .. No_of_Trials loop Z1 := Make_e_Digit (Real(I)) * dZ; --Z2 := Sin(Z1) / Cos(Z1); Z2 := Divide (Sin(Z1), Cos(Z1)); Z4 := Arctan (Z2); Difference1 := Abs ((Z4 - Z1) / (Z1)); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; Z1 := Abs (Junk1 * (+Test_Vector_Seed)); for I in 0 .. No_of_Trials loop Z1 := Z1 / (Z1 + One); Z1 := Two_Digit * Z1 * e_Quarter_pi; --Z2 := Sin(Z1) / Cos(Z1); Z2 := Divide (Sin(Z1), Cos(Z1)); Z4 := Arctan (Z2); Difference1 := Abs ((Z4 - Z1) / (Z1)); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; Z1 := One / Abs (Junk1 * (+Test_Vector_Seed)); for I in 0 .. No_of_Trials loop Z1 := Z1 / (Z1 + One); Z1 := Two_Digit * Z1 * e_Quarter_pi; --Z2 := Sin(Z1) / Cos(Z1); Z2 := Divide (Sin(Z1), Cos(Z1)); Z4 := Arctan (Z2); Difference1 := Abs ((Z4 - Z1) / (Z1)); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; Z1 := Abs (Junk1 * (+Test_Vector_Seed)); for I in 0 .. No_of_Trials loop Z1 := Z1 / (Z1 + (+(1.77827941**I))); Z1 := Two_Digit * Z1 * e_Quarter_pi; --Z1 := Z1 / (Z1 + One); --Z2 := Sin(Z1) / Cos(Z1); Z2 := Divide (Sin(Z1), Cos(Z1)); Z4 := Arctan (Z2); Difference1 := Abs ((Z4 - Z1) / (Z1)); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; Z1 := Abs (Junk1 * (+Test_Vector_Seed)); for I in -No_of_Trials .. 0 loop Z1 := Z1 / (Z1 + (+(1.77827941**I))); Z1 := Two_Digit * Z1 * e_Quarter_pi; --Z1 := Z1 / (Z1 + One); --Z2 := Sin(Z1) / Cos(Z1); Z2 := Divide (Sin(Z1), Cos(Z1)); Z4 := Arctan (Z2); Difference1 := Abs ((Z4 - Z1) / (Z1)); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Tan_and_Arctan; procedure Test_Sin_and_Cos_1 (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Junk2; Z2 := Two_Digit * Sin(Z1) * Cos(Z1); Z3 := Sin (Two_Digit * Z1); --Difference1 := Abs (Z3 / Z2 - One); Difference1 := Abs ((Z3 - Z2) / Z2); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sin_and_Cos_1; -------------- -- Test_Log -- -------------- procedure Test_Log (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Log (Z1); Z2 := Exp (Z2); -- should bring it back to Z1 Difference1 := Abs (One - Z2 / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Log; ---------------- -- Test_Log_2 -- ---------------- -- Verified that Log(2) is correct by independent calc of Log_2. -- Now check other arguments using Log(A*B) = ... procedure Test_Log_2 (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential Log_Z0 : e_Real; No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); Log_Z0 := Log (Z0); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Log (Z1*Z0); Z3 := Log (Z1) + Log_Z0; Difference1 := Abs (One - Z3 / Z2); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Log_2; ----------------------------- -- Test_Exp_w_Integer_Args -- ----------------------------- -- Verified that Exp is correct by independent calc of Log_2. -- Now check other arguments using Exp(A+B) = ... procedure Test_Exp_w_Integer_Args (Test_Vector_Seed : Integer := 0) is Max_Error : e_Real; -- init essential Exp_Z0 : e_Real; No_of_Trials : constant Integer := 500_000; begin Z0 := (+Real (2 + Test_Vector_Seed)); Z1 := (+0.0); Exp_Z0 := Exp (Z0); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Exp (Z1 + Z0); Z3 := Exp (Z1) * Exp_Z0; Difference1 := Abs (Z3/Z2 - One); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Exp_w_Integer_Args; -------------- -- Test_Exp -- -------------- procedure Test_Exp (Test_Vector_Seed : Real) is Max_Error, Exp_Z0 : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk3 * (+Test_Vector_Seed); Exp_Z0 := Exp (Z0); for I in 1..No_of_Trials loop Z1 := Z1 + Z0; Z2 := Exp (Z1 + Z0); Z3 := Exp (Z1) * Exp_Z0; Difference1 := Abs (Z3/Z2 - One); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Exp; ----------------- -- Test_Sqrt_2 -- ----------------- -- uses ** to calculate SQRT(X). Square and -- compare with X; square and divide by X to compare w. 1.0. procedure Test_Sqrt_2 (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Z1**(Half); Difference1 := Abs (One - (Z2 * Z2) / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sqrt_2; ---------------------------- -- Test_Reciprocal_Sqrt_2 -- ---------------------------- -- uses ** to calculate SQRT(X). Square and -- compare with X; square and divide by X to compare w. 1.0. procedure Test_Reciprocal_Sqrt_2 (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 10_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Z1**(-Half); --Difference1 := Abs (One/Z1 - (Z2 * Z2)) * Z1; Difference1 := Abs (One - (Z2 * Z2) * Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Reciprocal_Sqrt_2; -------------------------- -- Test_Reciprocal_Sqrt -- -------------------------- -- uses Newton's method to calculate SQRT(X). Square and -- compare with X; square and divide by X to compare w. 1.0. procedure Test_Reciprocal_Sqrt (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 50_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Reciprocal_Sqrt (Z1); Difference1 := Abs (One - (Z2 * Z2) * Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Reciprocal_Sqrt; --------------- -- Test_Sqrt -- --------------- -- uses Newton's method to calculate SQRT(X). Square and -- compare with X; square and divide by X to compare w. 1.0. procedure Test_Sqrt (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 50_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1..No_of_Trials loop Z1 := Z1 + Z0; Z2 := Sqrt (Z1); Z2 := Z2 * Z2; --Difference1 := Abs ((Z1 - Z2) / Z1); Difference1 := Abs (One - Z2 / Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Sqrt; --------------------- -- Test_Reciprocal -- --------------------- -- uses Newton's method to calculate Inverse of (X). -- compare with X; mult. by X to compare w. 1.0. procedure Test_Reciprocal (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 50_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Reciprocal(Z1); Difference1 := Abs (One - Z1 * Z2); --Difference1 := Abs (One / Z1 - Z2) * Z1; if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Reciprocal; ---------------------- -- Test_Divide_stnd -- ---------------------- -- uses Newton's method to calculate X/Y -- compare with X; mult. by Y to compare w. X. procedure Test_Divide_stnd (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 50_000; begin Z2 := Junk1 * (+Test_Vector_Seed); Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Z2 + Z2 + Junk1; Z3 := Z2 / Z1; --Z3 := Divide (Z2, Z1); Difference1 := Abs (Z2 - Z3 * Z1) / Z2; if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Z2 + Z2 + Junk1; Z3 := Z1 / Z2; --Z3 := Divide (Z1, Z2); Difference1 := Abs (Z1 - Z3 * Z2) / Z1; if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Divide_stnd; ----------------- -- Test_Divide -- ----------------- -- uses Newton's method to calculate X/Y -- compare with X; mult. by Y to compare w. X. procedure Test_Divide (Test_Vector_Seed : Real) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 50_000; begin Z2 := Junk1 * (+Test_Vector_Seed); Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Z2 + Z2 + Junk1; --Z3 := Z2 / Z1; Z3 := Divide (Z2, Z1); --Difference1 := Abs (Z2 - Z3 * Z1) / Z2; Difference1 := Divide (Abs (Z2 - Z3 * Z1), Z2); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; for I in 1 .. No_of_Trials loop Z1 := Z1 + Z0; Z2 := Z2 + Z2 + Junk1; --Z3 := Z1 / Z2; Z3 := Divide (Z1, Z2); --Difference1 := Abs (Z1 - Z3 * Z2) / Z1; Difference1 := Divide (Abs (Z1 - Z3 * Z2), Z1); if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Divide; --------------- -- Test_Root -- --------------- -- uses Newton's method to calculate Inverse of Nth root of (X). -- compare with X; ** and mult by X to compare w. 1.0. procedure Test_Root (Test_Vector_Seed : Real; N : Positive) is Max_Error : e_Real; -- init essential No_of_Trials : constant Integer := 50_000; begin Z1 := Junk1 * (+Test_Vector_Seed); Z0 := Junk2 * (+Test_Vector_Seed); for I in 1..No_of_Trials loop Z1 := Z0 + Z1; Z2 := Reciprocal_Nth_Root (Z1, N); Z3 := Z2 ** N; -- so should be just Reciprocal of Z1 Difference1 := One - Z1 * Z3; if Are_Not_Equal (Difference1, Zero) then if Difference1 > Max_Error then Max_Error := Difference1; end if; end if; end loop; put ("Estimated Max Error: "); put (e_Real_Image (Max_Error, Aft => Integer'Min (40, e_Real_Decimals))); new_line(1); end Test_Root; begin Print_Extended_Real_Settings; new_line; Pause ( "Some tests of Sin and Cos. ", "10_000 trials are performed for each number printed below.", "Test 1. calculate: Sin**2 + Cos**2 - 1." ); new_line(2); Test_Sin_and_Cos_2; Test_Vector_Seed := 1.2345657891234E+24; -- near max arg for Cos Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+8; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+0; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-7; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-31; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-93; Test_Sin_and_Cos_0 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-233; Test_Sin_and_Cos_0 (Test_Vector_Seed); new_line; put ("Sin (2X) - 2*Sin (X)*Cos (X):"); new_line(2); Test_Vector_Seed := 1.2345657891234E+24; Test_Sin_and_Cos_1 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Sin_and_Cos_1 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Sin_and_Cos_1 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+0; Test_Sin_and_Cos_1 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Sin_and_Cos_1 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-6; Test_Sin_and_Cos_1 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Sin_and_Cos_1 (Test_Vector_Seed); -- Arcsin_Stuff Pause ("Some tests of Sin and Arcsin. "); new_line(2); Test_Sin_and_Arcsin_1; Test_Sin_and_Arcsin_2; Test_Sin_and_Arcsin_3; new_line; put_Line ("Some tests of Cos and Arccos. "); new_line; Test_Cos_and_Arccos_1; Test_Cos_and_Arccos_2; Test_Cos_and_Arccos_3; Test_Cos_and_Arccos_4; Pause ("Test of Sin (Arctan(X)) / Cos (Arctan(X)) = X", "4_000 trials are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+3; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Test_Vector_Seed := 2.2345657891234E00; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E00; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Test_Vector_Seed := 5.2345657891234E-1; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-10; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-99; Test_Tan_and_Arctan_2 (Test_Vector_Seed); Pause ("Test of Arctan (Sin(X) / Cos(X)) = X.", "5_000 trials are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+54; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 2.2345657891234E00; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E00; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 5.2345657891234E-1; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-10; Test_Tan_and_Arctan (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-99; Test_Tan_and_Arctan (Test_Vector_Seed); Pause ("Test of Exp (Log (X)) = X for small and large arguments.", "10_000 trials are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+99; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E00; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-10; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-34; Test_Log (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-99; Test_Log (Test_Vector_Seed); Pause ("Test of Log (X*Y) = Log (X) + Log (Y).", "10_000 trials are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+99; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+18; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+0; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-10; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-34; Test_Log_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-99; Test_Log_2 (Test_Vector_Seed); -- Exp_Stuff Pause ( "Test Exp (X+Y) = Exp (X) * Exp (Y).", "10_000 trials are performed for each number printed below:" ); Test_Vector_Seed := +0.2345657891234E+1; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := +1.2345657891234E+4; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := +1.2345657891234E+3; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E+3; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E-4; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := +1.2345657891234E-4; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E+1; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := +1.2345657891234E+1; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E+0; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E-1; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := +1.2345657891234E-1; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E-10; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := +1.2345657891234E-16; Test_Exp(Test_Vector_Seed); Test_Vector_Seed := -1.2345657891234E-16; Test_Exp(Test_Vector_Seed); new_line; pause ("Start simple test of Log and Exp routines. "); new_line; put_line("compare exp(0.25) with actual:"); put (Exp(0.25)); new_line; put (Make_Real(Exp(Make_Extended(0.25)))); new_line; put_line("compare exp(0.2) with actual:"); put (Exp(0.2)); new_line; put (Make_Real(Exp(Make_Extended(0.2)))); new_line; put_line("compare exp(0.28) with actual:"); put (Exp(0.28)); new_line; put (Make_Real(Exp(Make_Extended(0.28)))); new_line; put_line("compare exp(1.0) with actual:"); put (Exp(1.0)); new_line; put (Make_Real(Exp(Make_Extended(1.0)))); new_line; put_line("compare exp(20.0) with actual:"); put (Exp(20.0)); new_line; put (Make_Real(Exp(Make_Extended(20.0)))); new_line; put_line("compare exp(-20.0) with actual:"); put (Exp(-20.0)); new_line; put (Make_Real(Exp(Make_Extended(-20.0)))); new_line; put_line("compare log(2.0) with actual:"); put (Log(2.0)); new_line; put (Make_Real(Log(Make_Extended(2.0)))); new_line; put_line("compare log(1.01) with actual:"); put (Log(1.01)); new_line; put (Make_Real(Log(Make_Extended(1.01)))); new_line; put_line("compare log(1.0E34) with actual:"); put (Log(1.0E34)); new_line; put (Make_Real(Log(Make_Extended(1.0E34)))); new_line; new_line(1); new_line(1); Pause ("Check Sin and Cos at a few specific arguments."); new_line(1); put ("Check Sin (0.25*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Sin (E_Quarter_Pi) - Sqrt(Make_Extended(0.5)); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (0.50*Pi) = 1.0. Estimated error = "); Delta_2 := One - Sin (Two_Digit * E_Quarter_Pi); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (0.75*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Sin (Make_e_Digit(5.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (1.25*Pi) =-Sqrt(0.5). Estimated error = "); Delta_2 := Sin (Make_e_Digit(5.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (1.5*Pi) = (-1.0). Estimated error = "); Delta_2 := Sin (Make_e_Digit(6.0)*E_Quarter_Pi) + One; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (1.75*Pi) =-Sqrt(0.5). Estimated error = "); Delta_2 := Sin (Make_e_Digit (7.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (2.25*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Sin (Make_e_Digit(9.0)*E_Quarter_Pi) - e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (2.5*Pi) = 1.0. Estimated error = "); Delta_2 := Sin (Make_e_Digit(10.0) * E_Quarter_Pi) - One; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (2.75*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Sin (Make_e_Digit(11.0)*E_Quarter_Pi) - e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (3.0*Pi) = 0.0. Estimated error = "); Delta_2 := Sin (Make_e_Digit(12.0)*E_Quarter_Pi); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (3.0*Pi) = (-1.0). Estimated error = "); Delta_2 := Cos (Make_e_Digit(12.0)*E_Quarter_Pi) + One; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (2.75*Pi) =-Sqrt(0.5). Estimated error = "); Delta_2 := Cos (Make_e_Digit(11.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (2.5*Pi) = 0.0. Estimated error = "); Delta_2 := Cos (Make_e_Digit(10.0)*E_Quarter_Pi); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (2.25*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Cos (Make_e_Digit(9.0)*E_Quarter_Pi) - e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (2.0*Pi) = 1.0. Estimated error = "); Delta_2 := Cos (Make_e_Digit(8.0)*E_Quarter_Pi) - One; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (1.75*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Cos (Make_e_Digit(7.0)*E_Quarter_Pi) - e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (1.5*Pi) = 0.0. Estimated error = "); Delta_2 := Cos (Make_e_Digit(6.0)*E_Quarter_Pi); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (1.25*Pi) =-Sqrt(0.5). Estimated error = "); Delta_2 := Cos (Make_e_Digit(5.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (1.0*Pi) =-1.0. Estimated error = "); Delta_2 := Cos (Make_e_Digit(4.0)*E_Quarter_Pi) + One; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (0.5*Pi) = 0.0. Estimated error = "); Delta_2 := Cos (Two_Digit*E_Quarter_Pi); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (0.25*Pi) = Sqrt(0.5). Estimated error = "); Delta_2 := Cos (E_Quarter_Pi) - Sqrt(Make_Extended(0.5)); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (-0.25*Pi) = Sqrt(0.5) Estimated error = "); Delta_2 := Cos (-E_Quarter_Pi) - Sqrt(Make_Extended(0.5)); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Cos (129.25*Pi) =-Sqrt(0.5). Estimated error = "); Delta_2 := Cos (Make_e_Digit(517.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check Sin (129.75*Pi) =-Sqrt(0.5). Estimated error = "); Delta_2 := Sin (Make_e_Digit (519.0)*E_Quarter_Pi) + e_Inverse_Sqrt_2; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); new_line(1); Pause ("Some more spot checks."); new_line(1); Z0 := E_Pi; for I in 1..10 loop Z0 := Z0 * Z0; end loop; Z1 := E_Pi**(2**10); put ("Check Pi**1024 - Pi*Pi*Pi*..*Pi*Pi*Pi: Estimated error = "); Delta_2 := One - Z1/Z0; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Check 2.0 * (1/SQRT(2.0)**2) - 1.0: Estimated error = "); Delta_2 := e_Inverse_Sqrt_2**2 - (+0.5); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Arccos(1/sqrt(2)) - Arcsin(1/sqrt(2)): Estimated error = "); Delta_2 := Arccos(E_Inverse_Sqrt_2) - Arcsin(E_Inverse_Sqrt_2); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Arccos(-1/sqrt(2)) - 1.5 Pi/4: Estimated error = "); Delta_2 := Arccos(-e_Inverse_Sqrt_2) - Two_Digit*e_Quarter_Pi - e_Quarter_Pi; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Arcsin(-1/sqrt(2)) + Pi/4: Estimated error = "); Delta_2 := Arcsin(-e_Inverse_Sqrt_2) + e_Quarter_Pi; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Arccos(0) - Pi/2: Estimated error = "); Delta_2 := Arccos(Zero) - Two_Digit*e_Quarter_Pi; put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); put ("Arccos(-1) - Pi: Estimated error = "); Delta_2 := (Arccos(-One) - e_Pi); put (e_Real_Image (Delta_2, Aft => Integer'Min (10, e_Real_Decimals))); new_line(1); Pause ( "Test Exp (X+Y) = Exp (X) * Exp (Y) using integer valued Arguments.", "500_000 trials are performed for each number printed below:" ); Test_Exp_w_Integer_Args; new_line; Pause ( "Test of Sqrt routine.", "50_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+134; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+74; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+27; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+8; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-4; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-14; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-34; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-70; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-173; Test_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-273; Test_Sqrt (Test_Vector_Seed); new_line; Pause ( "Test of Sqrt routine using the ""**"" operator.", "10_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+134; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+74; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+27; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+8; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-4; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-14; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-34; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-70; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-173; Test_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-273; Test_Sqrt_2 (Test_Vector_Seed); new_line; Pause ( "Test of the standard ""/"" routine.", "Test calculates A - (A/B)*B.", "Use of both ""/"" and ""*"" usually means a loss of 2 guard digits accuracy.", "100_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+273; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+123; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+08; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-18; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-28; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-39; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-78; Test_Divide_stnd(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-178; Test_Divide_stnd(Test_Vector_Seed); new_line; Pause ( "Test of Newton-Raphson Divide (A,B) routine.", "Test calculates A - Divide (A,B)*B. The Newton-Raphson Divide is designed", "to minimize A - Divide (A,B)*B, and does so consistently better than the", "stnd ""/"" (schoolboy algorithm). It doesn't do the division more accurately.", "It is however quite a bit faster than the standard ""/"" operator.", "100_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+273; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+123; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+08; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-18; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-28; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-39; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-78; Test_Divide(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-178; Test_Divide(Test_Vector_Seed); new_line; Pause ( "Test of Reciprocal routine Reciprocal(A) = 1/A.", "Test calculates 1.0 - A*Reciprocal(A). The Newton-Raphson iteration is designed", "to minimize 1.0 - A*Reciprocal(A), and does so consistently better than using", "the standard ""/"" to get 1.0/A. It doesn't do the division more accurately.", "It is however quite a bit faster than the standard ""/"" operator.", "50_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+273; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+123; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+10; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+08; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-3; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-18; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-28; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-39; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-78; Test_Reciprocal(Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-178; Test_Reciprocal(Test_Vector_Seed); Pause ( "Test of Reciprocal_Sqrt routine.", "50_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+273; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+173; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+27; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+8; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-4; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-14; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-34; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-70; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-173; Test_Reciprocal_Sqrt (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-273; Test_Reciprocal_Sqrt (Test_Vector_Seed); new_line; Pause ( "Test of 1 / Sqrt routine using the ""**"" operator.", "10_000 tests are performed for each number printed below:" ); Test_Vector_Seed := 1.2345657891234E+273; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+173; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+34; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+27; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+8; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+3; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E+1; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-1; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-4; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-8; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-14; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-34; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 9.9345657891234E-70; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-173; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Test_Vector_Seed := 1.2345657891234E-273; Test_Reciprocal_Sqrt_2 (Test_Vector_Seed); Pause ( "Test of Reciprocal_Nth_Root routine.", "5_000 tests are performed for each number printed below:" ); for N in 1..4 loop new_line; put ("N = "); put(Integer'Image(N)); new_line; Test_Vector_Seed := 1.2345657891234E+123; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+34; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+27; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+18; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+8; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+3; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+1; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-1; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-3; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 9.9345657891234E-14; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-17; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-33; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-70; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-112; Test_Root(Test_Vector_Seed, N); end loop; for M in 17..18 loop N := 123*M; new_line; put ("N = "); put(Integer'Image(N)); new_line; Test_Vector_Seed := 1.2345657891234E+34; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+27; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E+8; Test_root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-8; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-17; Test_Root(Test_Vector_Seed, N); Test_Vector_Seed := 1.2345657891234E-33; Test_Root(Test_Vector_Seed, N); end loop; -- Reciprocal(Z2) is generally 2 or more times faster than "/" -- declare Char : Character := ' '; begin --Z1 := Junk1 * (+1.23456789123E+12); --Z2 := Junk2 * (+1.234567891234E+00); --new_line; --put_Line ("Benchmark of division. Enter a real 1.0 to start: "); --get (Char); --put_line("Start bench 3, 5_000_000 divisions: "); --for I in 1..5_000_000 loop --Z1 := Z1 / Z2; --end loop; --put_line("End of bench 3."); --new_line; --put_Line ("Benchmark of alt. division. Enter a real 1.0 to start: "); --get (Char); --put_line("Start bench 4, 5_000_000 divisions: "); --for I in 1..5_000_000 loop --Z1 := Z1 * Reciprocal(Z2); --end loop; --put_line("End of bench 4."); --end; end;