content
stringlengths
23
1.05M
-- Auto_Counters_Suite.C_Resources_Tests -- Unit tests for Auto_Counters Unique_C_Resources and Smart_C_Resources -- packages -- Copyright (c) 2016, James Humphry - see LICENSE file for details with AUnit.Assertions; with Unique_C_Resources; with Smart_C_Resources; with Basic_Counters; package body Auto_Counters_Suite.C_Resources_Tests is use AUnit.Assertions; Net_Resources_Allocated : Integer := 0; type Dummy_Resource is new Boolean; function Make_Resource return Dummy_Resource is begin Net_Resources_Allocated := Net_Resources_Allocated + 1; return True; end Make_Resource; procedure Release_Resource (X : in Dummy_Resource) is pragma Unreferenced (X); begin Net_Resources_Allocated := Net_Resources_Allocated - 1; end Release_Resource; package Unique_Dummy_Resources is new Unique_C_Resources(T => Dummy_Resource, Initialize => Make_Resource, Finalize => Release_Resource); subtype Unique_Dummy_Resource is Unique_Dummy_Resources.Unique_T; use type Unique_Dummy_Resources.Unique_T; subtype Unique_Dummy_Resource_No_Default is Unique_Dummy_Resources.Unique_T_No_Default; use type Unique_Dummy_Resources.Unique_T_No_Default; package Smart_Dummy_Resources is new Smart_C_Resources(T => Dummy_Resource, Initialize => Make_Resource, Finalize => Release_Resource, Counters => Basic_Counters.Basic_Counters_Spec); subtype Smart_Dummy_Resource is Smart_Dummy_Resources.Smart_T; use type Smart_Dummy_Resources.Smart_T; subtype Smart_Dummy_Resource_No_Default is Smart_Dummy_Resources.Smart_T_No_Default; use type Smart_Dummy_Resources.Smart_T_No_Default; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T: in out C_Resource_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Check_Unique_C_Resource'Access, "Check Unique_T C resource handling"); Register_Routine (T, Check_Smart_C_Resource'Access, "Check Smart_T C resource handling"); end Register_Tests; ---------- -- Name -- ---------- function Name (T : C_Resource_Test) return Test_String is pragma Unreferenced (T); begin return Format ("Tests of Unique_C_Resources and Smart_C_Resources"); end Name; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out C_Resource_Test) is begin null; end Set_Up; ----------------------------- -- Check_Unique_C_Resource -- ----------------------------- procedure Check_Unique_C_Resource (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); begin Net_Resources_Allocated := 0; declare UDR1 : Unique_Dummy_Resource; begin Assert (Net_Resources_Allocated = 1, "Default initialization of a Unique_T did not call the " & "initialization routine"); Assert (UDR1.Element = True, "Default initialization of a Unique_T did not set up " & "the contents correctly"); end; Assert (Net_Resources_Allocated = 0, "Destruction of a Unique_T did not call the finalization " & "routine"); declare UDR2 : constant Unique_Dummy_Resource_No_Default := Unique_Dummy_Resources.Make_Unique_T(False); begin Assert (Net_Resources_Allocated = 0, "Non-default initialization of a Unique_T_No_Default called " & "the initialization routine"); Assert (UDR2.Element = False, "Default initialization of a Unique_T did not set up " & "the contents correctly"); end; Assert (Net_Resources_Allocated = -1, "Destruction of a Unique_T_No_Default did not call the " & "finalization routine"); end Check_Unique_C_Resource; ---------------------------- -- Check_Smart_C_Resource -- ---------------------------- procedure Check_Smart_C_Resource (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); SDR1 : Smart_Dummy_Resource; begin Assert (SDR1.Element = True, "Default initialization of a Smart_T did not set up " & "the contents correctly"); Assert (SDR1.Unique, "Default initialization of a Smart_T did not set up " & "the reference counter properly"); Net_Resources_Allocated := 0; declare SDR2 : Smart_Dummy_Resource; begin Assert (Net_Resources_Allocated = 1, "Default initialization of a second independent Smart_T did " & "not call the initialization routine"); Assert (SDR2.Element = True, "Default initialization of a second independent Smart_T " & "did not set up the contents correctly"); Assert (SDR2.Use_Count = 1, "Default initialization of a second independent Smart_T " & "did not set up the reference counter properly"); end; Assert (Net_Resources_Allocated = 0, "Destruction of a second independent Smart_T did not call the " & "finalization routine"); declare SDR3 : constant Smart_Dummy_Resource_No_Default := Smart_Dummy_Resources.Make_Smart_T(False); begin Assert (SDR3.Element = False, "Explicit of a second independent Smart_T " & "did not set up the contents correctly"); end; Net_Resources_Allocated := 0; declare SDR4 : constant Smart_Dummy_Resource := SDR1; begin Assert (Net_Resources_Allocated = 0, "Copying a Smart_T called the initialization again"); Assert (SDR1 = SDR4, "Copying a Smart_T did not copy the contents"); Assert (SDR4.Use_Count = 2, "Copying a Smart_T did not increment the Use_Count"); end; Assert (SDR1.Use_Count = 1, "Destroying a copied Smart_T did not decrement the Use_Count"); Assert (Net_Resources_Allocated = 0, "Destruction of a copied Smart_T called the finalization " & "finalization routine although the original still exists"); end Check_Smart_C_Resource; end Auto_Counters_Suite.C_Resources_Tests ;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- An activity edge is an abstract class for directed connections between two -- activity nodes. -- -- Activity edges can be contained in interruptible regions. ------------------------------------------------------------------------------ limited with AMF.UML.Activities; limited with AMF.UML.Activity_Edges.Collections; limited with AMF.UML.Activity_Groups.Collections; limited with AMF.UML.Activity_Nodes; limited with AMF.UML.Activity_Partitions.Collections; limited with AMF.UML.Interruptible_Activity_Regions; with AMF.UML.Redefinable_Elements; limited with AMF.UML.Structured_Activity_Nodes; limited with AMF.UML.Value_Specifications; package AMF.UML.Activity_Edges is pragma Preelaborate; type UML_Activity_Edge is limited interface and AMF.UML.Redefinable_Elements.UML_Redefinable_Element; type UML_Activity_Edge_Access is access all UML_Activity_Edge'Class; for UML_Activity_Edge_Access'Storage_Size use 0; not overriding function Get_Activity (Self : not null access constant UML_Activity_Edge) return AMF.UML.Activities.UML_Activity_Access is abstract; -- Getter of ActivityEdge::activity. -- -- Activity containing the edge. not overriding procedure Set_Activity (Self : not null access UML_Activity_Edge; To : AMF.UML.Activities.UML_Activity_Access) is abstract; -- Setter of ActivityEdge::activity. -- -- Activity containing the edge. not overriding function Get_Guard (Self : not null access constant UML_Activity_Edge) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is abstract; -- Getter of ActivityEdge::guard. -- -- Specification evaluated at runtime to determine if the edge can be -- traversed. not overriding procedure Set_Guard (Self : not null access UML_Activity_Edge; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is abstract; -- Setter of ActivityEdge::guard. -- -- Specification evaluated at runtime to determine if the edge can be -- traversed. not overriding function Get_In_Group (Self : not null access constant UML_Activity_Edge) return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is abstract; -- Getter of ActivityEdge::inGroup. -- -- Groups containing the edge. not overriding function Get_In_Partition (Self : not null access constant UML_Activity_Edge) return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is abstract; -- Getter of ActivityEdge::inPartition. -- -- Partitions containing the edge. not overriding function Get_In_Structured_Node (Self : not null access constant UML_Activity_Edge) return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is abstract; -- Getter of ActivityEdge::inStructuredNode. -- -- Structured activity node containing the edge. not overriding procedure Set_In_Structured_Node (Self : not null access UML_Activity_Edge; To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is abstract; -- Setter of ActivityEdge::inStructuredNode. -- -- Structured activity node containing the edge. not overriding function Get_Interrupts (Self : not null access constant UML_Activity_Edge) return AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access is abstract; -- Getter of ActivityEdge::interrupts. -- -- Region that the edge can interrupt. not overriding procedure Set_Interrupts (Self : not null access UML_Activity_Edge; To : AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access) is abstract; -- Setter of ActivityEdge::interrupts. -- -- Region that the edge can interrupt. not overriding function Get_Redefined_Edge (Self : not null access constant UML_Activity_Edge) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is abstract; -- Getter of ActivityEdge::redefinedEdge. -- -- Inherited edges replaced by this edge in a specialization of the -- activity. not overriding function Get_Source (Self : not null access constant UML_Activity_Edge) return AMF.UML.Activity_Nodes.UML_Activity_Node_Access is abstract; -- Getter of ActivityEdge::source. -- -- Node from which tokens are taken when they traverse the edge. not overriding procedure Set_Source (Self : not null access UML_Activity_Edge; To : AMF.UML.Activity_Nodes.UML_Activity_Node_Access) is abstract; -- Setter of ActivityEdge::source. -- -- Node from which tokens are taken when they traverse the edge. not overriding function Get_Target (Self : not null access constant UML_Activity_Edge) return AMF.UML.Activity_Nodes.UML_Activity_Node_Access is abstract; -- Getter of ActivityEdge::target. -- -- Node to which tokens are put when they traverse the edge. not overriding procedure Set_Target (Self : not null access UML_Activity_Edge; To : AMF.UML.Activity_Nodes.UML_Activity_Node_Access) is abstract; -- Setter of ActivityEdge::target. -- -- Node to which tokens are put when they traverse the edge. not overriding function Get_Weight (Self : not null access constant UML_Activity_Edge) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is abstract; -- Getter of ActivityEdge::weight. -- -- The minimum number of tokens that must traverse the edge at the same -- time. not overriding procedure Set_Weight (Self : not null access UML_Activity_Edge; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is abstract; -- Setter of ActivityEdge::weight. -- -- The minimum number of tokens that must traverse the edge at the same -- time. end AMF.UML.Activity_Edges;
with Interfaces; use Interfaces; ... type Octet is new Interfaces.Unsigned_8; type Octet_String is array (Positive range <>) of Octet;
-- -- Jan & Uwe R. Zimmer, Australia, July 2011 -- with Ada.Real_Time; use Ada.Real_Time; package Timing is function Timer return Time_Span; end Timing;
with Ada.Text_IO; with Ast_Printers; with Exprs; use Exprs; with Tokens; use Tokens; procedure Test_Ast with SPARK_Mode => Off is Test_Expr, U, N, G, F : Expr_Handle; begin Create_Num_Literal (123, N); Create_Unary (New_Token (T_MINUS, "-", 1), N, U); Create_Float_Literal (45.67, F); Create_Grouping (F, G); Create_Binary (U, New_Token (T_STAR, "*", 1), G, Test_Expr); Ada.Text_IO.Put_Line (Ast_Printers.Print (Exprs.Retrieve (Test_Expr))); end Test_Ast;
-- -- Copyright 2021 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with Interfaces; with HAL; with Matrix_Area_Word; with Matrix_Area_Double_Word; package body Execute.Matrices is -------------------------------------------------------------------------- -- Conversion functions from Character/String to UInt? -------------------------------------------------------------------------- function Convert_To_UInt4 (Value : Character) return HAL.UInt4; subtype Byte_Input_String is String (1 .. 2); function Convert_To_UInt8 (Value : Byte_Input_String) return HAL.UInt8; function Convert_To_UInt16 (Value : Standard.Execute.Matrix_Value_Type) return HAL.UInt16; -------------------------------------------------------------------------- -- see .ads -------------------------------------------------------------------------- procedure Execute (Cmd : Matrix_Command) is Value : constant Standard.Execute.Matrix_Value_Type := Cmd.Value; Byte_Num : HAL.UInt8; begin if Cmd.Block = Block_0 then case Cmd.Command is when Byte_0 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Word.Byte_0.Show (Number => Byte_Num); when Byte_1 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Word.Byte_1.Show (Number => Byte_Num); when Word_0 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Word.Byte_1.Show (Number => Byte_Num); Byte_Num := Convert_To_UInt8 (Value (3 .. 4)); Matrix_Area_Word.Byte_0.Show (Number => Byte_Num); when others => null; end case; else case Cmd.Command is when Byte_0 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_0.Show (Number => Byte_Num); when Byte_1 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_1.Show (Number => Byte_Num); when Byte_2 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_2.Show (Number => Byte_Num); when Byte_3 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_3.Show (Number => Byte_Num); when Word_0 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_1.Show (Number => Byte_Num); Byte_Num := Convert_To_UInt8 (Value (3 .. 4)); Matrix_Area_Double_Word.Byte_0.Show (Number => Byte_Num); when Word_1 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_3.Show (Number => Byte_Num); Byte_Num := Convert_To_UInt8 (Value (3 .. 4)); Matrix_Area_Double_Word.Byte_2.Show (Number => Byte_Num); when Double_Word_0 => Byte_Num := Convert_To_UInt8 (Value (1 .. 2)); Matrix_Area_Double_Word.Byte_3.Show (Number => Byte_Num); Byte_Num := Convert_To_UInt8 (Value (3 .. 4)); Matrix_Area_Double_Word.Byte_2.Show (Number => Byte_Num); Byte_Num := Convert_To_UInt8 (Value (5 .. 6)); Matrix_Area_Double_Word.Byte_1.Show (Number => Byte_Num); Byte_Num := Convert_To_UInt8 (Value (7 .. 8)); Matrix_Area_Double_Word.Byte_0.Show (Number => Byte_Num); end case; end if; end Execute; -------------------------------------------------------------------------- -- Convert one character representing -- a hex digit into an UInt4 value (Nibble) -------------------------------------------------------------------------- function Convert_To_UInt4 (Value : Character) return HAL.UInt4 is RetVal : HAL.UInt4; begin if Value = '0' then RetVal := 0; elsif Value = '1' then RetVal := 1; elsif Value = '2' then RetVal := 2; elsif Value = '3' then RetVal := 3; elsif Value = '4' then RetVal := 4; elsif Value = '5' then RetVal := 5; elsif Value = '6' then RetVal := 6; elsif Value = '7' then RetVal := 7; elsif Value = '8' then RetVal := 8; elsif Value = '9' then RetVal := 9; elsif Value = 'A' then RetVal := 10; elsif Value = 'B' then RetVal := 11; elsif Value = 'C' then RetVal := 12; elsif Value = 'D' then RetVal := 13; elsif Value = 'E' then RetVal := 14; elsif Value = 'F' then RetVal := 15; end if; return RetVal; end Convert_To_UInt4; -------------------------------------------------------------------------- -- Convert two characters representing -- a two hex digit number into an UInt8 value (Byte) -------------------------------------------------------------------------- function Convert_To_UInt8 (Value : Byte_Input_String) return HAL.UInt8 is LSB_U : constant Interfaces.Unsigned_8 := Interfaces.Unsigned_8 (Convert_To_UInt4 (Value (2))); MSB_U : constant Interfaces.Unsigned_8 := Interfaces.Unsigned_8 (Convert_To_UInt4 (Value (1))); RetVal : HAL.UInt8; use Interfaces; begin RetVal := HAL.UInt8 (Interfaces.Shift_Left (MSB_U, 4) + LSB_U); return RetVal; end Convert_To_UInt8; -------------------------------------------------------------------------- -- Convert four characters representing -- a four hex digit number into an UInt16 value (Word) -------------------------------------------------------------------------- function Convert_To_UInt16 (Value : Standard.Execute.Matrix_Value_Type) return HAL.UInt16 is use Interfaces; MSB_S : constant Byte_Input_String := Value (1 .. 2); MSB_U : constant Unsigned_8 := Unsigned_8 (Convert_To_UInt8 (MSB_S)); LSB_S : constant Byte_Input_String := Value (3 .. 4); LSB_U : constant Unsigned_8 := Unsigned_8 (Convert_To_UInt8 (LSB_S)); RetVal : HAL.UInt16; begin RetVal := HAL.UInt16 (Interfaces.Shift_Left (MSB_U, 8) + LSB_U); return RetVal; end Convert_To_UInt16; end Execute.Matrices;
with Ada.Text_IO; package body Problem_04 is package IO renames Ada.Text_IO; procedure Solve is begin for Larger in reverse 100 .. 999 loop for Smaller in reverse 100 .. Larger loop declare word : constant String := Positive'Image(Larger * Smaller); lower : Positive := word'First; upper : Positive := word'Last; begin while word(lower) = ' ' loop lower := lower + 1; end loop; while lower < upper loop if word(lower) /= word(upper) then goto Next_Number; end if; lower := lower + 1; upper := upper - 1; end loop; IO.Put_Line(word); -- This isn't strictly true, but it happens to work out -- for this particular problem. (For example 998*998 > 999*100) return; end; end loop; <<Next_Number>> null; end loop; end Solve; end Problem_04;
-- This spec has been automatically generated from STM32WL5x_CM4.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.Flash is pragma Preelaborate; --------------- -- Registers -- --------------- subtype ACR_LATENCY_Field is HAL.UInt3; -- Access control register type ACR_Register is record -- Latency LATENCY : ACR_LATENCY_Field := 16#0#; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Prefetch enable PRFTEN : Boolean := False; -- Instruction cache enable ICEN : Boolean := True; -- Data cache enable DCEN : Boolean := True; -- Instruction cache reset ICRST : Boolean := False; -- Data cache reset DCRST : Boolean := False; -- unspecified Reserved_13_14 : HAL.UInt2 := 16#0#; -- CPU1 programm erase suspend request PES : Boolean := False; -- Flash User area empty EMPTY : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ACR_Register use record LATENCY at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; PRFTEN at 0 range 8 .. 8; ICEN at 0 range 9 .. 9; DCEN at 0 range 10 .. 10; ICRST at 0 range 11 .. 11; DCRST at 0 range 12 .. 12; Reserved_13_14 at 0 range 13 .. 14; PES at 0 range 15 .. 15; EMPTY at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; -- Flash access control register 2 type ACR2_Register is record -- CFI privileged mode enable PRIVMODE : Boolean := False; -- Flash user hide protection area access disable HDPADIS : Boolean := False; -- CPU2 Software debug enable C2SWDBGEN : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ACR2_Register use record PRIVMODE at 0 range 0 .. 0; HDPADIS at 0 range 1 .. 1; C2SWDBGEN at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Status register type SR_Register is record -- End of operation EOP : Boolean := False; -- Operation error OPERR : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Programming error PROGERR : Boolean := False; -- Write protected error WRPERR : Boolean := False; -- Programming alignment error PGAERR : Boolean := False; -- Size error SIZERR : Boolean := False; -- Programming sequence error PGSERR : Boolean := False; -- Fast programming data miss error MISERR : Boolean := False; -- Fast programming error FASTERR : Boolean := False; -- unspecified Reserved_10_12 : HAL.UInt3 := 16#0#; -- Read-only. User Option OPTIVAL indication OPTVN : Boolean := False; -- PCROP read error RDERR : Boolean := False; -- Option validity error OPTVERR : Boolean := False; -- Read-only. Busy BSY : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Read-only. Programming or erase configuration busy CFGBSY : Boolean := False; -- Read-only. Programming / erase operation suspended PESD : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record EOP at 0 range 0 .. 0; OPERR at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; PROGERR at 0 range 3 .. 3; WRPERR at 0 range 4 .. 4; PGAERR at 0 range 5 .. 5; SIZERR at 0 range 6 .. 6; PGSERR at 0 range 7 .. 7; MISERR at 0 range 8 .. 8; FASTERR at 0 range 9 .. 9; Reserved_10_12 at 0 range 10 .. 12; OPTVN at 0 range 13 .. 13; RDERR at 0 range 14 .. 14; OPTVERR at 0 range 15 .. 15; BSY at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CFGBSY at 0 range 18 .. 18; PESD at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; subtype CR_PNB_Field is HAL.UInt7; -- Flash control register type CR_Register is record -- Programming PG : Boolean := False; -- Page erase PER : Boolean := False; -- Mass erase MER : Boolean := False; -- Page number PNB : CR_PNB_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- Start STRT : Boolean := False; -- Options modification start OPTSTRT : Boolean := False; -- Fast programming FSTPG : Boolean := False; -- unspecified Reserved_19_23 : HAL.UInt5 := 16#0#; -- End of operation interrupt enable EOPIE : Boolean := False; -- Error interrupt enable ERRIE : Boolean := False; -- PCROP read error interrupt enable RDERRIE : Boolean := False; -- Force the option byte loading OBL_LAUNCH : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Options Lock OPTLOCK : Boolean := True; -- FLASH_CR Lock LOCK : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record PG at 0 range 0 .. 0; PER at 0 range 1 .. 1; MER at 0 range 2 .. 2; PNB at 0 range 3 .. 9; Reserved_10_15 at 0 range 10 .. 15; STRT at 0 range 16 .. 16; OPTSTRT at 0 range 17 .. 17; FSTPG at 0 range 18 .. 18; Reserved_19_23 at 0 range 19 .. 23; EOPIE at 0 range 24 .. 24; ERRIE at 0 range 25 .. 25; RDERRIE at 0 range 26 .. 26; OBL_LAUNCH at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; OPTLOCK at 0 range 30 .. 30; LOCK at 0 range 31 .. 31; end record; subtype ECCR_ADDR_ECC_Field is HAL.UInt17; subtype ECCR_CPUID_Field is HAL.UInt3; -- Flash ECC register type ECCR_Register is record -- Read-only. ECC fail address ADDR_ECC : ECCR_ADDR_ECC_Field := 16#0#; -- unspecified Reserved_17_19 : HAL.UInt3 := 16#0#; -- Read-only. System Flash ECC fail SYSF_ECC : Boolean := False; -- unspecified Reserved_21_23 : HAL.UInt3 := 16#0#; -- ECC correction interrupt enable ECCCIE : Boolean := False; -- unspecified Reserved_25_25 : HAL.Bit := 16#0#; -- Read-only. CPU identification CPUID : ECCR_CPUID_Field := 16#0#; -- unspecified Reserved_29_29 : HAL.Bit := 16#0#; -- ECC correction ECCC : Boolean := False; -- ECC detection ECCD : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ECCR_Register use record ADDR_ECC at 0 range 0 .. 16; Reserved_17_19 at 0 range 17 .. 19; SYSF_ECC at 0 range 20 .. 20; Reserved_21_23 at 0 range 21 .. 23; ECCCIE at 0 range 24 .. 24; Reserved_25_25 at 0 range 25 .. 25; CPUID at 0 range 26 .. 28; Reserved_29_29 at 0 range 29 .. 29; ECCC at 0 range 30 .. 30; ECCD at 0 range 31 .. 31; end record; subtype OPTR_RDP_Field is HAL.UInt8; subtype OPTR_BOR_LEV_Field is HAL.UInt3; -- Flash option register type OPTR_Register is record -- Read protection level RDP : OPTR_RDP_Field := 16#AA#; -- System security enabled flag ESE : Boolean := False; -- BOR reset Level BOR_LEV : OPTR_BOR_LEV_Field := 16#0#; -- nRST_STOP nRST_STOP : Boolean := True; -- nRST_STDBY nRST_STDBY : Boolean := True; -- nRSTSHDW nRST_SHDW : Boolean := True; -- unspecified Reserved_15_15 : HAL.Bit := 16#1#; -- Independent watchdog selection IWDG_SW : Boolean := True; -- Independent watchdog counter freeze in Stop mode IWDG_STOP : Boolean := True; -- Independent watchdog counter freeze in Standby mode IWDG_STDBY : Boolean := True; -- Window watchdog selection WWDG_SW : Boolean := True; -- unspecified Reserved_20_22 : HAL.UInt3 := 16#7#; -- Boot configuration nBOOT1 : Boolean := True; -- SRAM2 parity check enable SRAM2_PE : Boolean := True; -- SRAM2 Erase when system reset SRAM2_RST : Boolean := True; -- Software BOOT0 selection nSWBOOT0 : Boolean := True; -- nBOOT0 option bit nBOOT0 : Boolean := True; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#3#; -- CPU1 CM4 Unique Boot entry enable option bit BOOT_LOCK : Boolean := False; -- CPU2 CM0+ Unique Boot entry enable option bit C2BOOT_LOCK : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OPTR_Register use record RDP at 0 range 0 .. 7; ESE at 0 range 8 .. 8; BOR_LEV at 0 range 9 .. 11; nRST_STOP at 0 range 12 .. 12; nRST_STDBY at 0 range 13 .. 13; nRST_SHDW at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; IWDG_SW at 0 range 16 .. 16; IWDG_STOP at 0 range 17 .. 17; IWDG_STDBY at 0 range 18 .. 18; WWDG_SW at 0 range 19 .. 19; Reserved_20_22 at 0 range 20 .. 22; nBOOT1 at 0 range 23 .. 23; SRAM2_PE at 0 range 24 .. 24; SRAM2_RST at 0 range 25 .. 25; nSWBOOT0 at 0 range 26 .. 26; nBOOT0 at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; BOOT_LOCK at 0 range 30 .. 30; C2BOOT_LOCK at 0 range 31 .. 31; end record; subtype PCROP1ASR_PCROP1A_STRT_Field is HAL.UInt8; -- Flash PCROP zone A Start address register type PCROP1ASR_Register is record -- PCROP1A area start offset PCROP1A_STRT : PCROP1ASR_PCROP1A_STRT_Field := 16#FF#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#FFFFFF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PCROP1ASR_Register use record PCROP1A_STRT at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype PCROP1AER_PCROP1A_END_Field is HAL.UInt8; -- Flash PCROP zone A End address register type PCROP1AER_Register is record -- PCROP area end offset PCROP1A_END : PCROP1AER_PCROP1A_END_Field := 16#0#; -- unspecified Reserved_8_30 : HAL.UInt23 := 16#7FFFFF#; -- PCROP area preserved when RDP level decreased PCROP_RDP : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PCROP1AER_Register use record PCROP1A_END at 0 range 0 .. 7; Reserved_8_30 at 0 range 8 .. 30; PCROP_RDP at 0 range 31 .. 31; end record; subtype WRP1AR_WRP1A_STRT_Field is HAL.UInt7; subtype WRP1AR_WRP1A_END_Field is HAL.UInt7; -- Flash WRP area A address register type WRP1AR_Register is record -- Bank 1 WRP first area start offset WRP1A_STRT : WRP1AR_WRP1A_STRT_Field := 16#7F#; -- unspecified Reserved_7_15 : HAL.UInt9 := 16#1FF#; -- Bank 1 WRP first area A end offset WRP1A_END : WRP1AR_WRP1A_END_Field := 16#0#; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#1FF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for WRP1AR_Register use record WRP1A_STRT at 0 range 0 .. 6; Reserved_7_15 at 0 range 7 .. 15; WRP1A_END at 0 range 16 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype WRP1BR_WRP1B_STRT_Field is HAL.UInt7; subtype WRP1BR_WRP1B_END_Field is HAL.UInt7; -- Flash WRP area B address register type WRP1BR_Register is record -- Bank 1 WRP second area B end offset WRP1B_STRT : WRP1BR_WRP1B_STRT_Field := 16#7F#; -- unspecified Reserved_7_15 : HAL.UInt9 := 16#1FF#; -- Bank 1 WRP second area B start offset WRP1B_END : WRP1BR_WRP1B_END_Field := 16#0#; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#1FF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for WRP1BR_Register use record WRP1B_STRT at 0 range 0 .. 6; Reserved_7_15 at 0 range 7 .. 15; WRP1B_END at 0 range 16 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype PCROP1BSR_PCROP1B_STRT_Field is HAL.UInt8; -- Flash PCROP zone B Start address register type PCROP1BSR_Register is record -- Bank 1 WRP second area B end offset PCROP1B_STRT : PCROP1BSR_PCROP1B_STRT_Field := 16#FF#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#FFFFFF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PCROP1BSR_Register use record PCROP1B_STRT at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype PCROP1BER_PCROP1B_END_Field is HAL.UInt8; -- Flash PCROP zone B End address register type PCROP1BER_Register is record -- PCROP1B area end offset PCROP1B_END : PCROP1BER_PCROP1B_END_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#FFFFFF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PCROP1BER_Register use record PCROP1B_END at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype IPCCBR_IPCCDBA_Field is HAL.UInt14; -- Flash IPCC data buffer address register type IPCCBR_Register is record -- IPCCDBA IPCCDBA : IPCCBR_IPCCDBA_Field := 16#3FFF#; -- unspecified Reserved_14_31 : HAL.UInt18 := 16#3FFFF#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IPCCBR_Register use record IPCCDBA at 0 range 0 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; -- Flash CPU2 access control register type C2ACR_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- CPU2 Prefetch enable PRFTEN : Boolean := False; -- CPU2 Instruction cache enable ICEN : Boolean := True; -- unspecified Reserved_10_10 : HAL.Bit := 16#1#; -- CPU2 Instruction cache reset ICRST : Boolean := False; -- unspecified Reserved_12_14 : HAL.UInt3 := 16#0#; -- CPU2 program / erase suspend request PES : Boolean := False; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2ACR_Register use record Reserved_0_7 at 0 range 0 .. 7; PRFTEN at 0 range 8 .. 8; ICEN at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; ICRST at 0 range 11 .. 11; Reserved_12_14 at 0 range 12 .. 14; PES at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Flash CPU2 status register type C2SR_Register is record -- End of operation EOP : Boolean := False; -- Operation error OPERR : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Programming error PROGERR : Boolean := False; -- WRPERR WRPERR : Boolean := False; -- PGAERR PGAERR : Boolean := False; -- Size error SIZERR : Boolean := False; -- Programming sequence error PGSERR : Boolean := False; -- Fast programming data miss error MISERR : Boolean := False; -- Fast programming error FASTERR : Boolean := False; -- unspecified Reserved_10_13 : HAL.UInt4 := 16#0#; -- PCROP read error RDERR : Boolean := False; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Read-only. BSY BSY : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Read-only. CFGBSY CFGBSY : Boolean := False; -- Read-only. PESD PESD : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2SR_Register use record EOP at 0 range 0 .. 0; OPERR at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; PROGERR at 0 range 3 .. 3; WRPERR at 0 range 4 .. 4; PGAERR at 0 range 5 .. 5; SIZERR at 0 range 6 .. 6; PGSERR at 0 range 7 .. 7; MISERR at 0 range 8 .. 8; FASTERR at 0 range 9 .. 9; Reserved_10_13 at 0 range 10 .. 13; RDERR at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; BSY at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CFGBSY at 0 range 18 .. 18; PESD at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; subtype C2CR_PNB_Field is HAL.UInt7; -- Flash CPU2 control register type C2CR_Register is record -- Programming PG : Boolean := False; -- Page erase PER : Boolean := False; -- Mass erase MER : Boolean := False; -- Page number selection PNB : C2CR_PNB_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- Start STRT : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Fast programming FSTPG : Boolean := False; -- unspecified Reserved_19_23 : HAL.UInt5 := 16#0#; -- End of operation interrupt enable EOPIE : Boolean := False; -- Error interrupt enable ERRIE : Boolean := False; -- RDERRIE RDERRIE : Boolean := False; -- unspecified Reserved_27_31 : HAL.UInt5 := 16#18#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for C2CR_Register use record PG at 0 range 0 .. 0; PER at 0 range 1 .. 1; MER at 0 range 2 .. 2; PNB at 0 range 3 .. 9; Reserved_10_15 at 0 range 10 .. 15; STRT at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; FSTPG at 0 range 18 .. 18; Reserved_19_23 at 0 range 19 .. 23; EOPIE at 0 range 24 .. 24; ERRIE at 0 range 25 .. 25; RDERRIE at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; subtype SFR_SFSA_Field is HAL.UInt7; subtype SFR_HDPSA_Field is HAL.UInt7; -- Flash secure Flash start address register type SFR_Register is record -- Secure Flash start address SFSA : SFR_SFSA_Field := 16#7F#; -- Flash security disabled FSD : Boolean := True; -- unspecified Reserved_8_11 : HAL.UInt4 := 16#F#; -- DDS DDS : Boolean := False; -- unspecified Reserved_13_15 : HAL.UInt3 := 16#7#; -- User Flash hide protection area start address HDPSA : SFR_HDPSA_Field := 16#7F#; -- User Flash hide protection area disabled HDPAD : Boolean := True; -- unspecified Reserved_24_30 : HAL.UInt7 := 16#7F#; -- sub-GHz radio SPI security disable SUBGHSPISD : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SFR_Register use record SFSA at 0 range 0 .. 6; FSD at 0 range 7 .. 7; Reserved_8_11 at 0 range 8 .. 11; DDS at 0 range 12 .. 12; Reserved_13_15 at 0 range 13 .. 15; HDPSA at 0 range 16 .. 22; HDPAD at 0 range 23 .. 23; Reserved_24_30 at 0 range 24 .. 30; SUBGHSPISD at 0 range 31 .. 31; end record; subtype SRRVR_SBRV_Field is HAL.UInt16; subtype SRRVR_SBRSA_Field is HAL.UInt5; subtype SRRVR_SNBRSA_Field is HAL.UInt5; -- Flash secure SRAM start address and CPU2 reset vector register type SRRVR_Register is record -- CPU2 boot reset vector SBRV : SRRVR_SBRV_Field := 16#8000#; -- unspecified Reserved_16_17 : HAL.UInt2 := 16#3#; -- Secure backup SRAM2 start address SBRSA : SRRVR_SBRSA_Field := 16#1F#; -- backup SRAM2 security disable BRSD : Boolean := True; -- unspecified Reserved_24_24 : HAL.Bit := 16#1#; -- Secure non-backup SRAM1 start address SNBRSA : SRRVR_SNBRSA_Field := 16#1F#; -- NBRSD NBRSD : Boolean := True; -- C2OPT C2OPT : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SRRVR_Register use record SBRV at 0 range 0 .. 15; Reserved_16_17 at 0 range 16 .. 17; SBRSA at 0 range 18 .. 22; BRSD at 0 range 23 .. 23; Reserved_24_24 at 0 range 24 .. 24; SNBRSA at 0 range 25 .. 29; NBRSD at 0 range 30 .. 30; C2OPT at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Flash type FLASH_Peripheral is record -- Access control register ACR : aliased ACR_Register; -- Flash access control register 2 ACR2 : aliased ACR2_Register; -- Flash key register KEYR : aliased HAL.UInt32; -- Option byte key register OPTKEYR : aliased HAL.UInt32; -- Status register SR : aliased SR_Register; -- Flash control register CR : aliased CR_Register; -- Flash ECC register ECCR : aliased ECCR_Register; -- Flash option register OPTR : aliased OPTR_Register; -- Flash PCROP zone A Start address register PCROP1ASR : aliased PCROP1ASR_Register; -- Flash PCROP zone A End address register PCROP1AER : aliased PCROP1AER_Register; -- Flash WRP area A address register WRP1AR : aliased WRP1AR_Register; -- Flash WRP area B address register WRP1BR : aliased WRP1BR_Register; -- Flash PCROP zone B Start address register PCROP1BSR : aliased PCROP1BSR_Register; -- Flash PCROP zone B End address register PCROP1BER : aliased PCROP1BER_Register; -- Flash IPCC data buffer address register IPCCBR : aliased IPCCBR_Register; -- Flash CPU2 access control register C2ACR : aliased C2ACR_Register; -- Flash CPU2 status register C2SR : aliased C2SR_Register; -- Flash CPU2 control register C2CR : aliased C2CR_Register; -- Flash secure Flash start address register SFR : aliased SFR_Register; -- Flash secure SRAM start address and CPU2 reset vector register SRRVR : aliased SRRVR_Register; end record with Volatile; for FLASH_Peripheral use record ACR at 16#0# range 0 .. 31; ACR2 at 16#4# range 0 .. 31; KEYR at 16#8# range 0 .. 31; OPTKEYR at 16#C# range 0 .. 31; SR at 16#10# range 0 .. 31; CR at 16#14# range 0 .. 31; ECCR at 16#18# range 0 .. 31; OPTR at 16#20# range 0 .. 31; PCROP1ASR at 16#24# range 0 .. 31; PCROP1AER at 16#28# range 0 .. 31; WRP1AR at 16#2C# range 0 .. 31; WRP1BR at 16#30# range 0 .. 31; PCROP1BSR at 16#34# range 0 .. 31; PCROP1BER at 16#38# range 0 .. 31; IPCCBR at 16#3C# range 0 .. 31; C2ACR at 16#5C# range 0 .. 31; C2SR at 16#60# range 0 .. 31; C2CR at 16#64# range 0 .. 31; SFR at 16#80# range 0 .. 31; SRRVR at 16#84# range 0 .. 31; end record; -- Flash FLASH_Periph : aliased FLASH_Peripheral with Import, Address => FLASH_Base; end STM32_SVD.Flash;
-- BinToAsc.Base32 -- Binary data to ASCII codecs - Base64 codec as in RFC4648 -- Copyright (c) 2015, James Humphry - see LICENSE file for details with Ada.Characters.Handling; package body BinToAsc.Base32 is use Ada.Characters.Handling; function Make_Base32_Reverse_Alphabet return Reverse_Alphabet_Lookup is begin return R : Reverse_Alphabet_Lookup := Make_Reverse_Alphabet(Alphabet, Case_Sensitive) do if Allow_Homoglyphs then if R('1') = Invalid_Character_Input then if R('l') /= Invalid_Character_Input then R('1') := R('l'); elsif R('I') /= Invalid_Character_Input then R('1') := R('I'); end if; end if; if R('0') = Invalid_Character_Input then if R('O') /= Invalid_Character_Input then R('0') := R('O'); elsif R('o') /= Invalid_Character_Input then R('0') := R('o'); end if; end if; end if; end return; end Make_Base32_Reverse_Alphabet; Reverse_Alphabet : constant Reverse_Alphabet_Lookup := Make_Base32_Reverse_Alphabet; -- -- Base32_To_String -- procedure Reset (C : out Base32_To_String) is begin C := (State => Ready, Next_Index => 0, Buffer => (others => 0)); end Reset; procedure Process (C : in out Base32_To_String; Input : in Bin; Output : out String; Output_Length : out Natural) is begin C.Buffer(C.Next_Index) := Input; if C.Next_Index /= 4 then Output := (others => ' '); Output_Length := 0; C.Next_Index := C.Next_Index + 1; else C.Next_Index := 0; Output := ( Alphabet(C.Buffer(0) / 8), Alphabet((C.Buffer(0) and 2#00000111#) * 4 or C.Buffer(1) / 64), Alphabet((C.Buffer(1) and 2#00111111#) / 2), Alphabet((C.Buffer(1) and 2#00000001#) * 16 or C.Buffer(2) / 16), Alphabet((C.Buffer(2) and 2#00001111#) * 2 or C.Buffer(3) / 128), Alphabet((C.Buffer(3) and 2#01111111#) / 4), Alphabet((C.Buffer(3) and 2#00000011#) * 8 or C.Buffer(4) / 32), Alphabet(C.Buffer(4) and 2#00011111#), others => ' ' ); Output_Length := 8; end if; end Process; procedure Process (C : in out Base32_To_String; Input : in Bin_Array; Output : out String; Output_Length : out Natural) is Output_Index : Integer := Output'First; begin for I in Input'Range loop C.Buffer(C.Next_Index) := Input(I); if C.Next_Index /= 4 then C.Next_Index := C.Next_Index + 1; else C.Next_Index := 0; Output (Output_Index .. Output_Index + 7) := ( Alphabet(C.Buffer(0) / 8), Alphabet((C.Buffer(0) and 2#00000111#) * 4 or C.Buffer(1) / 64), Alphabet((C.Buffer(1) and 2#00111111#) / 2), Alphabet((C.Buffer(1) and 2#00000001#) * 16 or C.Buffer(2) / 16), Alphabet((C.Buffer(2) and 2#00001111#) * 2 or C.Buffer(3) / 128), Alphabet((C.Buffer(3) and 2#01111111#) / 4), Alphabet((C.Buffer(3) and 2#00000011#) * 8 or C.Buffer(4) / 32), Alphabet(C.Buffer(4) and 2#00011111#) ); Output_Index := Output_Index + 8; end if; end loop; Output_Length := Output_Index - Output'First; end Process; procedure Complete (C : in out Base32_To_String; Output : out String; Output_Length : out Natural) is begin C.State := Completed; case C.Next_Index is when 0 => Output := (others => ' '); Output_Length := 0; when 1 => Output := ( Alphabet(C.Buffer(0) / 8), Alphabet((C.Buffer(0) and 2#00000111#) * 4), Padding, Padding, Padding, Padding, Padding, Padding, others => ' '); Output_Length := 8; when 2 => Output := ( Alphabet(C.Buffer(0) / 8), Alphabet((C.Buffer(0) and 2#00000111#) * 4 or C.Buffer(1) / 64), Alphabet((C.Buffer(1) and 2#00111111#) / 2), Alphabet((C.Buffer(1) and 2#00000001#) * 16), Padding, Padding, Padding, Padding, others => ' '); Output_Length := 8; when 3 => Output := ( Alphabet(C.Buffer(0) / 8), Alphabet((C.Buffer(0) and 2#00000111#) * 4 or C.Buffer(1) / 64), Alphabet((C.Buffer(1) and 2#00111111#) / 2), Alphabet((C.Buffer(1) and 2#00000001#) * 16 or C.Buffer(2) / 16), Alphabet((C.Buffer(2) and 2#00001111#) * 2), Padding, Padding, Padding, others => ' '); Output_Length := 8; when 4 => Output := ( Alphabet(C.Buffer(0) / 8), Alphabet((C.Buffer(0) and 2#00000111#) * 4 or C.Buffer(1) / 64), Alphabet((C.Buffer(1) and 2#00111111#) / 2), Alphabet((C.Buffer(1) and 2#00000001#) * 16 or C.Buffer(2) / 16), Alphabet((C.Buffer(2) and 2#00001111#) * 2 or C.Buffer(3) / 128), Alphabet((C.Buffer(3) and 2#01111111#) / 4), Alphabet((C.Buffer(3) and 2#00000011#) * 8), Padding, others => ' '); Output_Length := 8; end case; end Complete; function To_String_Private is new BinToAsc.To_String(Codec => Base32_To_String); function To_String (Input : in Bin_Array) return String renames To_String_Private; -- -- Base32_To_Bin -- function Padding_Characters_Effect(X : Bin_Array_Index) return Bin_Array_Index is (case X is when 0 => 0, when 1 => 1, when 3 => 2, when 4 => 3, when 6 => 4, when others => 0); -- The Process routines should have caught invalid padding lengths and set -- the status to 'Failed' so the 'others' clause is not a problem here. procedure Reset (C : out Base32_To_Bin) is begin C := (State => Ready, Next_Index => 0, Buffer => (others => 0), Padding_Length => 0); end Reset; procedure Process (C : in out Base32_To_Bin; Input : in Character; Output : out Bin_Array; Output_Length : out Bin_Array_Index) is Input_Bin : Bin; begin if Input = Padding then Input_Bin := 0; C.Padding_Length := C.Padding_Length + 1; if C.Padding_Length > 6 then -- No reason to ever have more than six padding characters in Base32 -- input C.State := Failed; end if; elsif C.Padding_Length > 0 then -- After the first padding character, only a second padding character -- can be valid C.State := Failed; else Input_Bin := Reverse_Alphabet(Input); if Input_Bin = Invalid_Character_Input then C.State := Failed; end if; end if; if not (C.State = Failed) then C.Buffer(C.Next_Index) := Input_Bin; if C.Next_Index /= 7 then Output := (others => 0); Output_Length := 0; C.Next_Index := C.Next_Index + 1; elsif C.Padding_Length = 2 or C.Padding_Length = 5 then Output := (others => 0); Output_Length := 0; C.State := Failed; else C.Next_Index := 0; Output := ( C.Buffer(0) * 8 + C.Buffer(1) / 4, (C.Buffer(1) and 2#00011#) * 64 or C.Buffer(2) * 2 or C.Buffer(3) / 16, (C.Buffer(3) and 2#01111#) * 16 or C.Buffer(4) / 2, (C.Buffer(4) and 2#00001#) * 128 or C.Buffer(5) * 4 or C.Buffer(6) / 8, (C.Buffer(6) and 2#00111#) * 32 or C.Buffer(7), others => 0); Output_Length := 5 - Padding_Characters_Effect(C.Padding_Length); end if; else Output := (others => 0); Output_Length := 0; end if; end Process; procedure Process (C : in out Base32_To_Bin; Input : in String; Output : out Bin_Array; Output_Length : out Bin_Array_Index) is Input_Bin : Bin; Output_Index : Bin_Array_Index := Output'First; begin for I in Input'Range loop if Input(I) = Padding then Input_Bin := 0; C.Padding_Length := C.Padding_Length + 1; if C.Padding_Length > 6 then -- No reason to ever have more than six padding characters in -- Base64 input C.State := Failed; exit; end if; elsif C.Padding_Length > 0 then -- After the first padding character, only a second padding -- character can be valid C.State := Failed; exit; else Input_Bin := Reverse_Alphabet(Input(I)); if Input_Bin = Invalid_Character_Input then C.State := Failed; exit; end if; end if; C.Buffer(C.Next_Index) := Input_Bin; if C.Next_Index /= 7 then C.Next_Index := C.Next_Index + 1; elsif C.Padding_Length = 2 or C.Padding_Length = 5 then C.State := Failed; else C.Next_Index := 0; Output(Output_Index .. Output_Index + 4) := ( C.Buffer(0) * 8 + C.Buffer(1) / 4, (C.Buffer(1) and 2#00011#) * 64 or C.Buffer(2) * 2 or C.Buffer(3) / 16, (C.Buffer(3) and 2#01111#) * 16 or C.Buffer(4) / 2, (C.Buffer(4) and 2#00001#) * 128 or C.Buffer(5) * 4 or C.Buffer(6) / 8, (C.Buffer(6) and 2#00111#) * 32 or C.Buffer(7)); Output_Index := Output_Index + 5; end if; end loop; if C.State = Failed then Output := (others => 0); Output_Length := 0; else Output(Output_Index .. Output'Last) := (others => 0); Output_Length := Bin_Array_Index'Max(0, Output_Index - Output'First - Padding_Characters_Effect(C.Padding_Length)); end if; end Process; procedure Complete (C : in out Base32_To_Bin; Output : out Bin_Array; Output_Length : out Bin_Array_Index) is begin if C.Next_Index /= 0 then C.State := Failed; elsif C.State = Ready then C.State := Completed; end if; Output := (others => 0); Output_Length := 0; end Complete; function To_Bin_Private is new BinToAsc.To_Bin(Codec => Base32_To_Bin); function To_Bin (Input : in String) return Bin_Array renames To_Bin_Private; begin -- The following Compile_Time_Error test is silently ignored by GNAT GPL 2015, -- although it does appear to be a static boolean expression as required by -- the user guide. It works if converted to a run-time test so it has been -- left in, in the hope that in a future version of GNAT it will actually be -- tested. pragma Warnings (GNATprove, Off, "Compile_Time_Error"); pragma Compile_Time_Error ((for some X in 1..Alphabet'Last => (for some Y in 0..X-1 => (Alphabet(Y) = Alphabet(X) or (not Case_Sensitive and To_Lower(Alphabet(Y)) = To_Lower(Alphabet(X))) ) ) ), "Duplicate letter in alphabet for Base32 codec."); pragma Warnings (GNATprove, On, "Compile_Time_Error"); end BinToAsc.Base32;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . M M A P . U N I X -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007-2016, AdaCore -- -- -- -- 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. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Declaration of off_t/mmap/munmap. This particular implementation -- supposes off_t is long. with System.OS_Lib; with Interfaces.C; package System.Mmap.Unix is type Mmap_Prot is new Interfaces.C.int; -- PROT_NONE : constant Mmap_Prot := 16#00#; -- PROT_EXEC : constant Mmap_Prot := 16#04#; PROT_READ : constant Mmap_Prot := 16#01#; PROT_WRITE : constant Mmap_Prot := 16#02#; type Mmap_Flags is new Interfaces.C.int; -- MAP_NONE : constant Mmap_Flags := 16#00#; -- MAP_FIXED : constant Mmap_Flags := 16#10#; MAP_SHARED : constant Mmap_Flags := 16#01#; MAP_PRIVATE : constant Mmap_Flags := 16#02#; type off_t is new Long_Integer; function Mmap (Start : Address := Null_Address; Length : Interfaces.C.size_t; Prot : Mmap_Prot := PROT_READ; Flags : Mmap_Flags := MAP_PRIVATE; Fd : System.OS_Lib.File_Descriptor; Offset : off_t) return Address; pragma Import (C, Mmap, "mmap"); function Munmap (Start : Address; Length : Interfaces.C.size_t) return Integer; pragma Import (C, Munmap, "munmap"); function Is_Mapping_Available return Boolean is (True); -- Wheter memory mapping is actually available on this system. It is an -- error to use Create_Mapping and Dispose_Mapping if this is False. end System.Mmap.Unix;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . T A S K _ A T T R I B U T E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2014-2015, 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. -- -- -- ------------------------------------------------------------------------------ with System.Parameters; use System.Parameters; with System.Tasking.Initialization; use System.Tasking.Initialization; with System.Task_Primitives.Operations; package body System.Tasking.Task_Attributes is package STPO renames System.Task_Primitives.Operations; type Index_Info is record Used : Boolean; -- Used is True if a given index is used by an instantiation of -- Ada.Task_Attributes, False otherwise. Require_Finalization : Boolean; -- Require_Finalization is True if the attribute requires finalization end record; Index_Array : array (1 .. Max_Attribute_Count) of Index_Info := (others => (False, False)); -- Note that this package will use an efficient implementation with no -- locks and no extra dynamic memory allocation if Attribute can fit in a -- System.Address type and Initial_Value is 0 (or null for an access type). function Next_Index (Require_Finalization : Boolean) return Integer is Self_Id : constant Task_Id := STPO.Self; begin Task_Lock (Self_Id); for J in Index_Array'Range loop if not Index_Array (J).Used then Index_Array (J).Used := True; Index_Array (J).Require_Finalization := Require_Finalization; Task_Unlock (Self_Id); return J; end if; end loop; Task_Unlock (Self_Id); raise Storage_Error with "Out of task attributes"; end Next_Index; -------------- -- Finalize -- -------------- procedure Finalize (Index : Integer) is Self_Id : constant Task_Id := STPO.Self; begin pragma Assert (Index in Index_Array'Range); Task_Lock (Self_Id); Index_Array (Index).Used := False; Task_Unlock (Self_Id); end Finalize; -------------------------- -- Require_Finalization -- -------------------------- function Require_Finalization (Index : Integer) return Boolean is begin pragma Assert (Index in Index_Array'Range); return Index_Array (Index).Require_Finalization; end Require_Finalization; end System.Tasking.Task_Attributes;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P A N D E R -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, 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. -- -- -- ------------------------------------------------------------------------------ -- This procedure performs any required expansion for the specified node. -- The argument is the node that is a candidate for possible expansion. -- If no expansion is required, then Expand returns without doing anything. -- If the node does need expansion, then the subtree is replaced by the -- tree corresponding to the required rewriting. This tree is a syntactic -- tree, except that all Entity fields must be correctly set on all -- direct names, since the expander presumably knows what it wants, and in -- any case it doesn't work to have the semantic analyzer perform visibility -- analysis on these trees (they may have references to non-visible runtime -- routines etc.) There are a few exceptions to this rule in special cases, -- but they must be documented clearly. -- Expand is called in two different situations: -- Nodes that are not subexpressions (Nkind not in N_Subexpr) -- In this case, Expand is called from the body of Sem, immediately -- after completing semantic analysis by calling the corresponding -- Analyze_N_xxx procedure. If expansion occurs, the given node must -- be replaced with another node that is also not a subexpression. -- This seems naturally to be the case, since it is hard to imagine any -- situation in which it would make sense to replace a non-expression -- subtree with an expression. Once the substitution is completed, the -- Expand routine must call Analyze on the resulting node to do any -- required semantic analysis. Note that references to children copied -- from the old tree won't be reanalyzed, since their Analyzed flag -- is set. -- Nodes that are subexpressions (Nkind in N_Subexpr) -- In this case, Expand is called from Sem_Res.Resolve after completing -- the resolution of the subexpression (this means that the expander sees -- the fully typed subtree). If expansion occurs, the given node must be -- replaced by a node that is also a subexpression. Again it is hard -- to see how this restriction could possibly be violated. Once the -- substitution is completed, the Expand routine must first call Analyze -- on the resulting node to do any required semantic analysis, and then -- call Resolve on the node to set the type (typically the type will be -- the same as the original type of the input node, but this is not -- always the case). -- In both these cases, Replace or Rewrite must be used to achieve the -- expansion of the node, since the Expander routine is only passed the -- Node_Id of the node to be expanded, and the resulting expanded Node_Id -- must be the same (the parameter to Expand is mode in, not mode in-out). -- For nodes other than subexpressions, it is not necessary to preserve the -- original tree in the Expand routines, unlike the case for modifications -- to the tree made in the semantic analyzer. This is because anyone who is -- interested in working with the original tree is required to compile in -- semantics checks only mode. Thus Replace may be freely used in such -- instances. -- For subexpressions, preservation of the original tree is required because -- of the need for conformance checking of default expressions, which occurs -- on expanded trees. This means that Replace should not ever be used on -- on subexpression nodes. Instead use Rewrite. -- Note: the front end avoids calls to any of the expand routines if code -- is not being generated. This is done for three reasons: -- 1. Make sure tree does not get mucked up by the expander if no -- code is being generated, and is thus usable by ASIS etc. -- 2. Save time, since expansion is not needed if a compilation is -- being done only to check the semantics, or if code generation -- has been canceled due to previously detected errors. -- 3. Allow the expand routines to assume that the tree is error free. -- This results from the fact that code generation mode is always -- cancelled when any error occurs. -- If we ever decide to implement a feature allowing object modules to be -- generated even if errors have been detected, then point 3 will no longer -- hold, and the expand routines will have to be modified to operate properly -- in the presence of errors (for many reasons this is not currently true). -- Note: a consequence of this approach is that error messages must never -- be generated in the expander, since this would mean that such error -- messages are not generated when the expander is not being called. -- Expansion is the last stage of analyzing a node, so Expand sets the -- Analyzed flag of the node being analyzed as its last action. This is -- done even if expansion is off (in this case, the only effect of the -- call to Expand is to set the Analyzed flag to True). with Types; use Types; package Expander is -- The flag Opt.Expander_Active controls whether expansion is active -- (True) or deactivated (False). When expansion is deactivated all -- calls to expander routines have no effect. To temporarily disable -- expansion, always call the routines defined below, do NOT change -- Expander_Active directly. -- -- You should not use this flag to test if you are currently processing -- a generic spec or body. Use the flag Inside_A_Generic instead (see -- the spec of package Sem). -- -- There is no good reason for permanently changing the value of this flag -- except after detecting a syntactic or semantic error. In this event -- this flag is set to False to disable all subsequent expansion activity. -- -- In general this flag should be used as a read only value. The only -- exceptions where it makes sense to temporarily change its value are: -- -- (a) when starting/completing the processing of a generic definition -- or declaration (see routines Start_Generic_Processing and -- End_Generic_Processing in Sem_Ch12) -- -- (b) when starting/completing the preanalysis of an expression -- (see the spec of package Sem for more info on preanalysis.) -- -- Note that when processing a spec expression (In_Spec_Expression -- is True) or performing semantic analysis of a generic spec or body -- (Inside_A_Generic) or when performing preanalysis (Full_Analysis is -- False) the Expander_Active flag is False. procedure Expand (N : Node_Id); -- Expand node N, as described above procedure Expander_Mode_Save_And_Set (Status : Boolean); -- Saves the current setting of the Expander_Active flag on an internal -- stack and then sets the flag to the given value. -- -- Note: this routine has no effect in GNATprove mode. In this mode, -- a very light expansion is performed on specific nodes and -- Expander_Active is set to False. -- In situations such as the call to Instantiate_Bodies in Frontend, -- Expander_Mode_Save_And_Set may be called to temporarily turn the -- expander on, but this will have no effect in GNATprove mode. procedure Expander_Mode_Restore; -- Restores the setting of the Expander_Active flag using the top entry -- pushed onto the stack by Expander_Mode_Save_And_Reset, popping the -- stack, except that if any errors have been detected, then the state of -- the flag is left set to False. Disabled for GNATprove mode (see above). end Expander;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Element_Vectors; with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Array_Component_Associations; with Program.Element_Visitors; package Program.Nodes.Array_Component_Associations is pragma Preelaborate; type Array_Component_Association is new Program.Nodes.Node and Program.Elements.Array_Component_Associations .Array_Component_Association and Program.Elements.Array_Component_Associations .Array_Component_Association_Text with private; function Create (Choices : Program.Element_Vectors.Element_Vector_Access; Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access; Component_Value : Program.Elements.Expressions.Expression_Access; Box_Token : Program.Lexical_Elements.Lexical_Element_Access) return Array_Component_Association; type Implicit_Array_Component_Association is new Program.Nodes.Node and Program.Elements.Array_Component_Associations .Array_Component_Association with private; function Create (Choices : Program.Element_Vectors.Element_Vector_Access; Component_Value : Program.Elements.Expressions.Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Array_Component_Association with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Array_Component_Association is abstract new Program.Nodes.Node and Program.Elements.Array_Component_Associations .Array_Component_Association with record Choices : Program.Element_Vectors.Element_Vector_Access; Component_Value : Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : in out Base_Array_Component_Association'Class); overriding procedure Visit (Self : not null access Base_Array_Component_Association; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Choices (Self : Base_Array_Component_Association) return Program.Element_Vectors.Element_Vector_Access; overriding function Component_Value (Self : Base_Array_Component_Association) return Program.Elements.Expressions.Expression_Access; overriding function Is_Array_Component_Association (Self : Base_Array_Component_Association) return Boolean; overriding function Is_Association (Self : Base_Array_Component_Association) return Boolean; type Array_Component_Association is new Base_Array_Component_Association and Program.Elements.Array_Component_Associations .Array_Component_Association_Text with record Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access; Box_Token : Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Array_Component_Association_Text (Self : in out Array_Component_Association) return Program.Elements.Array_Component_Associations .Array_Component_Association_Text_Access; overriding function Arrow_Token (Self : Array_Component_Association) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Box_Token (Self : Array_Component_Association) return Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Array_Component_Association is new Base_Array_Component_Association with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Array_Component_Association_Text (Self : in out Implicit_Array_Component_Association) return Program.Elements.Array_Component_Associations .Array_Component_Association_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Array_Component_Association) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Array_Component_Association) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Array_Component_Association) return Boolean; end Program.Nodes.Array_Component_Associations;
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with bits_types_h; with bits_types_struct_timespec_h; package bits_struct_stat_h is -- unsupported macro: st_atime st_atim.tv_sec -- unsupported macro: st_mtime st_mtim.tv_sec -- unsupported macro: st_ctime st_ctim.tv_sec -- Definition for struct stat. -- Copyright (C) 2020-2021 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- The GNU C Library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- The GNU C Library 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 -- Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library. If not, see -- <https://www.gnu.org/licenses/>. -- Device. type stat_array1037 is array (0 .. 2) of aliased bits_types_h.uu_syscall_slong_t; type stat is record st_dev : aliased bits_types_h.uu_dev_t; -- /usr/include/bits/struct_stat.h:28 st_ino : aliased bits_types_h.uu_ino_t; -- /usr/include/bits/struct_stat.h:33 st_nlink : aliased bits_types_h.uu_nlink_t; -- /usr/include/bits/struct_stat.h:41 st_mode : aliased bits_types_h.uu_mode_t; -- /usr/include/bits/struct_stat.h:42 st_uid : aliased bits_types_h.uu_uid_t; -- /usr/include/bits/struct_stat.h:44 st_gid : aliased bits_types_h.uu_gid_t; -- /usr/include/bits/struct_stat.h:45 uu_pad0 : aliased int; -- /usr/include/bits/struct_stat.h:47 st_rdev : aliased bits_types_h.uu_dev_t; -- /usr/include/bits/struct_stat.h:49 st_size : aliased bits_types_h.uu_off_t; -- /usr/include/bits/struct_stat.h:54 st_blksize : aliased bits_types_h.uu_blksize_t; -- /usr/include/bits/struct_stat.h:58 st_blocks : aliased bits_types_h.uu_blkcnt_t; -- /usr/include/bits/struct_stat.h:60 st_atim : aliased bits_types_struct_timespec_h.timespec; -- /usr/include/bits/struct_stat.h:71 st_mtim : aliased bits_types_struct_timespec_h.timespec; -- /usr/include/bits/struct_stat.h:72 st_ctim : aliased bits_types_struct_timespec_h.timespec; -- /usr/include/bits/struct_stat.h:73 uu_glibc_reserved : aliased stat_array1037; -- /usr/include/bits/struct_stat.h:86 end record with Convention => C_Pass_By_Copy; -- /usr/include/bits/struct_stat.h:26 -- File serial number. -- 32bit file serial number. -- File mode. -- Link count. -- Link count. -- File mode. -- User ID of the file's owner. -- Group ID of the file's group. -- Device number, if device. -- Size of file, in bytes. -- Size of file, in bytes. -- Optimal block size for I/O. -- Number 512-byte blocks allocated. -- Number 512-byte blocks allocated. -- Nanosecond resolution timestamps are stored in a format -- equivalent to 'struct timespec'. This is the type used -- whenever possible but the Unix namespace rules do not allow the -- identifier 'timespec' to appear in the <sys/stat.h> header. -- Therefore we have to handle the use of this header in strictly -- standard-compliant sources special. -- Time of last access. -- Time of last modification. -- Time of last status change. -- Time of last access. -- Nscecs of last access. -- Time of last modification. -- Nsecs of last modification. -- Time of last status change. -- Nsecs of last status change. -- File serial number. -- Note stat64 has the same shape as stat for x86-64. -- Device. type stat64_array1037 is array (0 .. 2) of aliased bits_types_h.uu_syscall_slong_t; type stat64 is record st_dev : aliased bits_types_h.uu_dev_t; -- /usr/include/bits/struct_stat.h:101 st_ino : aliased bits_types_h.uu_ino64_t; -- /usr/include/bits/struct_stat.h:103 st_nlink : aliased bits_types_h.uu_nlink_t; -- /usr/include/bits/struct_stat.h:104 st_mode : aliased bits_types_h.uu_mode_t; -- /usr/include/bits/struct_stat.h:105 st_uid : aliased bits_types_h.uu_uid_t; -- /usr/include/bits/struct_stat.h:112 st_gid : aliased bits_types_h.uu_gid_t; -- /usr/include/bits/struct_stat.h:113 uu_pad0 : aliased int; -- /usr/include/bits/struct_stat.h:115 st_rdev : aliased bits_types_h.uu_dev_t; -- /usr/include/bits/struct_stat.h:116 st_size : aliased bits_types_h.uu_off_t; -- /usr/include/bits/struct_stat.h:117 st_blksize : aliased bits_types_h.uu_blksize_t; -- /usr/include/bits/struct_stat.h:123 st_blocks : aliased bits_types_h.uu_blkcnt64_t; -- /usr/include/bits/struct_stat.h:124 st_atim : aliased bits_types_struct_timespec_h.timespec; -- /usr/include/bits/struct_stat.h:132 st_mtim : aliased bits_types_struct_timespec_h.timespec; -- /usr/include/bits/struct_stat.h:133 st_ctim : aliased bits_types_struct_timespec_h.timespec; -- /usr/include/bits/struct_stat.h:134 uu_glibc_reserved : aliased stat64_array1037; -- /usr/include/bits/struct_stat.h:144 end record with Convention => C_Pass_By_Copy; -- /usr/include/bits/struct_stat.h:99 -- File serial number. -- Link count. -- File mode. -- 32bit file serial number. -- File mode. -- Link count. -- User ID of the file's owner. -- Group ID of the file's group. -- Device number, if device. -- Size of file, in bytes. -- Device number, if device. -- Size of file, in bytes. -- Optimal block size for I/O. -- Nr. 512-byte blocks allocated. -- Nanosecond resolution timestamps are stored in a format -- equivalent to 'struct timespec'. This is the type used -- whenever possible but the Unix namespace rules do not allow the -- identifier 'timespec' to appear in the <sys/stat.h> header. -- Therefore we have to handle the use of this header in strictly -- standard-compliant sources special. -- Time of last access. -- Time of last modification. -- Time of last status change. -- Time of last access. -- Nscecs of last access. -- Time of last modification. -- Nsecs of last modification. -- Time of last status change. -- Nsecs of last status change. -- File serial number. -- Tell code we have these members. -- Nanosecond resolution time values are supported. end bits_struct_stat_h;
package body impact.d3.collision.Detector.discrete is overriding procedure addContactPoint (Self : in out btStorageResult; normalOnBInWorld : in math.Vector_3; pointInWorld : in math.Vector_3; depth : in math.Real ) is begin if depth < Self.m_distance then Self.m_normalOnSurfaceB := normalOnBInWorld; Self.m_closestPointInB := pointInWorld; Self.m_distance := depth; end if; end addContactPoint; end impact.d3.collision.Detector.discrete;
with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; procedure Loop_And_Half is I : Positive := 1; begin loop Put(Item => I, Width => 1); exit when I = 10; Put(", "); I := I + 1; end loop; New_Line; end Loop_And_Half;
with Control; with Ada.Real_Time;use Ada.Real_Time; package body Blinker is protected body Cmd_Type_Access is procedure Send( Cmd : Command_To_Type ) is --binary semaphore begin Command_Is_New := False; if Command_To.Cmd /= Cmd.Cmd then Command_To := Cmd; Command_Is_New := True; end if; end Send; entry Receive( Cmd : out Command_To_Type) when Command_Is_New is begin Cmd := Command_To; end Receive; end Cmd_Type_Access; task body Blinker_Type is Next_Time : Time := Clock + Milliseconds(250); Blinker_Stopped: Boolean := False; On : Boolean := False; Command : Command_To_Type; begin loop Protected_Command.Receive(Command); --if Command.Receiver = Id then case Command.Cmd is --when QUIT => -- Control.Put_Line("Quit"); -- exit; when START => Blinker_Stopped := False; On := not On; if On then Control.Put_Line("B"& Id_Type'Image(Command.Receiver) & "S"); else Control.Put_Line("B" & Id_Type'Image(Command.Receiver) & "E"); end if; case Id is when R => Control.Toggle_LedR; when L => Control.Toggle_LedL; when E => Control.Toggle_LedL; Control.Toggle_LedR; when others => null; end case; when STOP => if not Blinker_Stopped then Control.Put_Line("ABS"); Blinker_Stopped := True; Control.Off_LedL; Control.Off_LedR; end if; end case; --end if; Next_Time := Next_Time + Milliseconds(250); delay until Next_Time; end loop; end Blinker_Type; end Blinker;
with Units; use Units; with Units.Navigation; use Units.Navigation; package config is end config;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with GBA.Memory; use GBA.Memory; with GBA.Display.Palettes; use GBA.Display.Palettes; package GBA.Display.Tiles is type Tile_Data_4 is array (1 .. 8, 1 .. 8) of Color_Index_16 with Pack, Size => 32 * 8; type Tile_Data_8 is array (1 .. 8, 1 .. 8) of Color_Index_256 with Pack, Size => 64 * 8; type Tile_Block_Index is range 0 .. 3 with Size => 2; type Screen_Block_Index is range 0 .. 31 with Size => 5; function Tile_Block_Address (Ix : Tile_Block_Index) return Address with Pure_Function, Inline_Always; function Screen_Block_Address (Ix : Screen_Block_Index) return Address with Pure_Function, Inline_Always; -- These types are defined separately for a couple of reasons: -- - Indexing into different regions of tile data -- - Representing 64-byte offsets in 256-color mode for OBJ, -- but always 32-byte offsets for BGs. type BG_Tile_Index is range 0 .. 1023 with Size => 10; type OBJ_Tile_Index is range 0 .. 1023 with Size => 10; type Screen_Entry_16 is record Tile : BG_Tile_Index; Flip_Horizontal : Boolean; Flip_Vertical : Boolean; Palette_Index : Palette_Index_16; -- ignored in 256-color mode end record with Size => 16; for Screen_Entry_16 use record Tile at 0 range 0 .. 9; Flip_Horizontal at 0 range 10 .. 10; Flip_Vertical at 0 range 11 .. 11; Palette_Index at 0 range 12 .. 15; end record; subtype Affine_BG_Tile_Index is BG_Tile_Index range 0 .. 255; type Screen_Entry_8 is record Tile : Affine_BG_Tile_Index; end record with Size => 8; for Screen_Entry_8 use record Tile at 0 range 0 .. 7; end record; OBJ_Tile_Memory_Start : constant Video_RAM_Address := 16#6010000#; OBJ_Tile_Memory_4 : array (OBJ_Tile_Index) of Tile_Data_4 with Import, Volatile, Address => OBJ_Tile_Memory_Start; OBJ_Tile_Memory_8 : array (OBJ_Tile_Index range 0 .. 511) of Tile_Data_8 with Import, Volatile, Address => OBJ_Tile_Memory_Start; type Tile_Block_4 is array (BG_Tile_Index range <>) of Tile_Data_4 with Pack; type Tile_Block_4_Ptr is access all Tile_Block_4 with Storage_Size => 0; type Tile_Block_8 is array (BG_Tile_Index range <>) of Tile_Data_8 with Pack; type Tile_Block_8_Ptr is access all Tile_Block_8 with Storage_Size => 0; type Screen_Block_16 is array (1 .. 32, 1 .. 32) of Screen_Entry_16 with Pack; type Screen_Block_16_Ptr is access all Screen_Block_16 with Storage_Size => 0; -- Affine background map data is variably-sized. -- Rather than 32x32 chunks, the whole map is -- a large square, of up to 128x128 tiles. type Screen_Block_8 is array (Positive range <>, Positive range <>) of Screen_Entry_8 with Pack; type Screen_Block_8_Ptr is access all Screen_Block_8 with Storage_Size => 0; end GBA.Display.Tiles;
--=========================================================================== -- -- This package is the implementation -- for the Tiny RP2040 board -- --=========================================================================== -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with RP.Clock; with RP.Device; package body Tiny is ------------------------------------------------------ -- see .ads procedure Initialize is begin RP.Clock.Initialize (Tiny.XOSC_Frequency); RP.Clock.Enable (RP.Clock.PERI); RP.Device.Timer.Enable; -- configure the LEDs on the board -- I am sure, that 99% of users want it this way Tiny.LED_Red.Configure (RP.GPIO.Output); Tiny.LED_Green.Configure (RP.GPIO.Output); Tiny.LED_Blue.Configure (RP.GPIO.Output); Tiny.Switch_Off (Tiny.LED_Red); Tiny.Switch_Off (Tiny.LED_Green); Tiny.Switch_Off (Tiny.LED_Blue); end Initialize; ------------------------------------------------------ -- see .ads procedure Switch_On (This : in out RP.GPIO.GPIO_Point) is begin This.Clear; end Switch_On; ------------------------------------------------------ -- see .ads procedure Switch_Off (This : in out RP.GPIO.GPIO_Point) is begin This.Set; end Switch_Off; ------------------------------------------------------ -- see .ads procedure Toggle (This : in out RP.GPIO.GPIO_Point) is begin if This.Get then Switch_On (This => This); else Switch_Off (This => This); end if; end Toggle; end Tiny;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Slim.Message_Visiters; package body Slim.Messages.BUTN is List : constant Field_Description_Array := ((Uint_32_Field, 1), -- Time (Uint_8_Field, 4)); -- Button code ------------ -- Button -- ------------ not overriding function Button (Self : BUTN_Message) return Button_Kind is begin if Self.Data_8 (1 .. 3) = (0, 1, 0) then case Self.Data_8 (4) is when 16#5B# => return Knob_Right; when 16#5A# => return Knob_Left; when 16#23# => return Preset_1; when 16#17# => return Pause; when 16#0E# => return Knob_Push; when 16#0D# => return Back; when 16#10# => return Rewind; when 16#11# => return Forward; when 16#12# => return Play; when 16#19# => return Volume_Up; when 16#1A# => return Volume_Down; when others => return Something_Else; end case; end if; return Something_Else; end Button; ---------- -- Read -- ---------- overriding function Read (Data : not null access League.Stream_Element_Vectors .Stream_Element_Vector) return BUTN_Message is begin return Result : BUTN_Message do Read_Fields (Result, List, Data.all); end return; end Read; ----------- -- Visit -- ----------- overriding procedure Visit (Self : not null access BUTN_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class) is begin Visiter.BUTN (Self); end Visit; ----------- -- Write -- ----------- overriding procedure Write (Self : BUTN_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector) is begin Tag := "BUTN"; Write_Fields (Self, List, Data); end Write; end Slim.Messages.BUTN;
package PP_F_Exact is -- Various SPARK functions for use in SPARK assertions. -- These functions are then featured in VCs and PolyPaver will -- understand their meaning. For each of these functions, -- its semantics is the exact real interpretation of its name. -- -- The F in the package name stands for the Float type. -- -- Ideally all occurences of Float in this package would be -- replaced with Real and all floating point types would -- be subtypes of Real. -- Unfortunately, such type Real is not available in SPARK. --# function Square (X : Float) return Float; --# function Int_Power (X : Float; N : Integer) return Float; --# function Sqrt (X : Float) return Float; --# function Exp (X : Float) return Float; --# function Sin (X : Float) return Float; --# function Cos (X : Float) return Float; --# function Pi return Float; --# function Integral (Lo,Hi,Integrand : Float) return Float; --# function Integration_Variable return Float; --# function Interval(Low, High : Float) return Float; --# function Contained_In(Inner, Outer : Float) return Boolean; --# function Is_Range(Variable : Float; Min : Float; Max : Float) return Boolean; --# function Eps_Abs(Prec : Integer) return Float; --# function Eps_Rel(Prec : Integer) return Float; --# function Plus_Minus_Eps_Abs(Prec : Integer) return Float; --# function Plus_Minus_Eps_Rel(Prec : Integer) return Float; end PP_F_Exact;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.RED_BLACK_TREES.GENERIC_BOUNDED_SET_OPERATIONS -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-2019, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ -- Tree_Type is used to implement ordered containers. This package declares -- set-based tree operations. with Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations; generic with package Tree_Operations is new Generic_Bounded_Operations (<>); type Set_Type is new Tree_Operations.Tree_Types.Tree_Type with private; use Tree_Operations.Tree_Types, Tree_Operations.Tree_Types.Implementation; with procedure Assign (Target : in out Set_Type; Source : Set_Type); with procedure Insert_With_Hint (Dst_Set : in out Set_Type; Dst_Hint : Count_Type; Src_Node : Node_Type; Dst_Node : out Count_Type); with function Is_Less (Left, Right : Node_Type) return Boolean; package Ada.Containers.Red_Black_Trees.Generic_Bounded_Set_Operations is pragma Pure; procedure Set_Union (Target : in out Set_Type; Source : Set_Type); -- Attempts to insert each element of Source in Target. If Target is -- busy then Program_Error is raised. We say "attempts" here because -- if these are unique-element sets, then the insertion should fail -- (not insert a new item) when the insertion item from Source is -- equivalent to an item already in Target. If these are multisets -- then of course the attempt should always succeed. function Set_Union (Left, Right : Set_Type) return Set_Type; -- Makes a copy of Left, and attempts to insert each element of -- Right into the copy, then returns the copy. procedure Set_Intersection (Target : in out Set_Type; Source : Set_Type); -- Removes elements from Target that are not equivalent to items in -- Source. If Target is busy then Program_Error is raised. function Set_Intersection (Left, Right : Set_Type) return Set_Type; -- Returns a set comprising all the items in Left equivalent to items in -- Right. procedure Set_Difference (Target : in out Set_Type; Source : Set_Type); -- Removes elements from Target that are equivalent to items in Source. If -- Target is busy then Program_Error is raised. function Set_Difference (Left, Right : Set_Type) return Set_Type; -- Returns a set comprising all the items in Left not equivalent to items -- in Right. procedure Set_Symmetric_Difference (Target : in out Set_Type; Source : Set_Type); -- Removes from Target elements that are equivalent to items in Source, -- and inserts into Target items from Source not equivalent elements in -- Target. If Target is busy then Program_Error is raised. function Set_Symmetric_Difference (Left, Right : Set_Type) return Set_Type; -- Returns a set comprising the union of the elements in Left not -- equivalent to items in Right, and the elements in Right not equivalent -- to items in Left. function Set_Subset (Subset : Set_Type; Of_Set : Set_Type) return Boolean; -- Returns False if Subset contains at least one element not equivalent to -- any item in Of_Set; returns True otherwise. function Set_Overlap (Left, Right : Set_Type) return Boolean; -- Returns True if at least one element of Left is equivalent to an item in -- Right; returns False otherwise. end Ada.Containers.Red_Black_Trees.Generic_Bounded_Set_Operations;
------------------------------------------------------------------------------ -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . E X E C U T I V E . T H R E A D S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2005 The European Space Agency -- -- Copyright (C) 2003-2006, 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, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, 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. -- -- The executive was developed by the Real-Time Systems Group at the -- -- Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ with System.Parameters; -- Used for Size_Type with System.Executive.Parameters; -- Used for Default_Stack_Size with System.Executive.Protection; -- Used for Enter_Kernel -- Leave_Kernel with System.Executive.Threads.Queues; pragma Elaborate (System.Executive.Threads.Queues); -- Used for Extract_From_Ready -- Insert_At_Tail -- Insert_At_Head -- Change_Priority -- Running_Thread -- Environment_Thread_Id with Unchecked_Conversion; package body System.Executive.Threads is use System.Executive.CPU_Primitives; use System.Executive.Time; use System.Executive.Parameters; use type System.Address; use type System.Parameters.Size_Type; type Ada_05_Record is record Anonymous_Access : access Integer; end record; ----------------- -- Local data -- ----------------- Main_Priority : Integer := -1; pragma Import (C, Main_Priority, "__gl_main_priority"); --------------------- -- Local functions -- --------------------- function New_Stack (Size : System.Parameters.Size_Type) return System.Address; -- Create a new stack of Size bytes. If there is not enough free space -- returns System.Null_Address. -------------- -- Get_ATCB -- -------------- function Get_ATCB return System.Address is begin return System.Executive.Threads.Queues.Running_Thread.ATCB; end Get_ATCB; ------------------ -- Get_Priority -- ------------------ function Get_Priority (Id : Thread_Id) return System.Any_Priority is begin -- This function does not need to be protected by Enter_Kernel and -- Leave_Kernel, because the Active_Priority value is only updated -- by Set_Priority (atomically). Moreover, Active_Priority is -- marked as Volatile. return Id.Active_Priority; end Get_Priority; ---------------- -- Initialize -- ---------------- procedure Initialize is Base_Priority : System.Any_Priority; begin Protection.Enter_Kernel; -- If priority is not specified then the default priority will be used if Main_Priority not in System.Any_Priority then Base_Priority := System.Default_Priority; else Base_Priority := Main_Priority; end if; -- The environment thread is created. This thread executes the -- main procedure of the program. -- The active priority is initially equal to the base priority Queues.Environment_Thread_Id.Base_Priority := Base_Priority; Queues.Environment_Thread_Id.Active_Priority := Base_Priority; -- Insert environment thread into the ready queue Queues.Insert_At_Head (Queues.Environment_Thread_Id); -- The currently executing thread is the environment thread Queues.Running_Thread := Queues.Environment_Thread_Id; -- Store stack information Queues.Environment_Thread_Id.Top_Of_Stack := Top_Of_Environment_Stack; Queues.Environment_Thread_Id.Stack_Size := Environment_Stack_Size; -- Initialize the saved registers, including the program -- counter and the stack pointer for the environment -- thread. The stack for the environment thread must be created -- first. Initialize_Context (Queues.Environment_Thread_Id.Context'Access, System.Null_Address, System.Null_Address, Base_Priority, Top_Of_Environment_Stack); -- Initialize alarm status Queues.Environment_Thread_Id.Alarm_Time := System.Executive.Time.Time'Last; Queues.Environment_Thread_Id.Next_Alarm := Null_Thread_Id; Protection.Leave_Kernel; end Initialize; --------------- -- New_Stack -- --------------- type Stack_Element is new Natural; for Stack_Element'Size use 64; -- The elements in the stack must be 64 bits wide to allow double -- word data movements. subtype Range_Of_Stack is System.Parameters.Size_Type range 1 .. (System.Executive.Parameters.Stack_Area_Size / (Stack_Element'Size / 8) + 1); type Stack_Space is array (Range_Of_Stack) of Stack_Element; -- The total space for stacks is equal to the Stack_Area_Size -- defined in System.Executive.Parameters (in bytes), rounded -- to the upper 8 bytes bound. Stack : Stack_Space; for Stack'Alignment use Standard'Maximum_Alignment; -- Object to store all the stacks. It represents the stack -- space. The stack must be aligned to the maximum. Index : Range_Of_Stack := Range_Of_Stack'Last; -- Index points to the top of the free stack space function New_Stack (Size : System.Parameters.Size_Type) return System.Address is Real_Size : constant System.Parameters.Size_Type := (Size / (Stack_Element'Size / 8)) + 1; -- Translate Size into bytes to eight bytes size Old_Index : Range_Of_Stack; begin -- If we try to allocate more stack than available System.Null_Address -- is returned. Otherwise return address of the top of the stack. if (Index - Range_Of_Stack'First) < Real_Size then return System.Null_Address; else Old_Index := Index; Index := Index - Real_Size; return Stack (Old_Index)'Address; end if; end New_Stack; -------------- -- Set_ATCB -- -------------- procedure Set_ATCB (ATCB : System.Address) is begin -- Set_ATCB is only called in the initialization of the task, and -- just by the owner of the thread, so there is no need of explicit -- kernel protection when calling this function. System.Executive.Threads.Queues.Running_Thread.ATCB := ATCB; end Set_ATCB; ------------------ -- Set_Priority -- ------------------ procedure Set_Priority (Priority : System.Any_Priority) is begin Protection.Enter_Kernel; -- The Ravenscar profile does not allow dynamic priority changes. Tasks -- change their priority only when they inherit the ceiling priority of -- a PO (Ceiling Locking policy). Hence, the task must be running when -- changing the priority. It is not possible to change the priority of -- another thread within the Ravenscar profile, so that is why -- Running_Thread is used. -- Priority changes are only possible as a result of inheriting -- the ceiling priority of a protected object. Hence, it can -- never be set a priority which is lower than the base -- priority of the thread. pragma Assert (Priority >= Queues.Running_Thread.Base_Priority); Queues.Change_Priority (Queues.Running_Thread, Priority); Protection.Leave_Kernel; end Set_Priority; ----------- -- Sleep -- ----------- procedure Sleep is begin Protection.Enter_Kernel; Queues.Extract_From_Ready (Queues.Running_Thread); -- The currently executing thread is now blocked, and it will leave -- the CPU when executing the Leave_Kernel procedure. Protection.Leave_Kernel; -- Now the thread has been awaken again and it is executing end Sleep; ------------------- -- Thread_Create -- ------------------- procedure Thread_Create (Id : out Thread_Id; Code : System.Address; Arg : System.Address; Priority : System.Any_Priority; Stack_Size : System.Parameters.Size_Type) is Stack_Address : System.Address; begin Protection.Enter_Kernel; -- Create the stack Stack_Address := New_Stack (Stack_Size); if Stack_Address = System.Null_Address then -- If there is not enough stack then the thread cannot be created. -- Return an invalid identifier for signaling the problem. Id := Null_Thread_Id; else -- The first free position is assigned to the new thread Id := Queues.New_Thread_Descriptor; -- If the maximum number of threads supported by the kernel has been -- exceeded, a Null_Thread_Id is returned. if Id /= Null_Thread_Id then -- Set the base and active priority Id.Base_Priority := Priority; Id.Active_Priority := Priority; -- Insert task inside the ready list (as last within its priority) Queues.Insert_At_Tail (Id); -- Store stack information Id.Top_Of_Stack := Stack_Address; Id.Stack_Size := Stack_Size; -- Initialize the saved registers, including the program -- counter and stack pointer. The thread will execute the -- Thread_Caller procedure and the stack pointer points to -- the top of the stack assigned to the thread. Initialize_Context (Id.Context'Access, Code, Arg, Priority, Stack_Address); -- Initialize alarm status Id.Alarm_Time := System.Executive.Time.Time'Last; Id.Next_Alarm := Null_Thread_Id; end if; end if; Protection.Leave_Kernel; end Thread_Create; ----------------- -- Thread_Self -- ----------------- function Thread_Self return Thread_Id is begin -- Return the thread that is currently executing return Queues.Running_Thread; end Thread_Self; ------------ -- Wakeup -- ------------ procedure Wakeup (Id : Thread_Id) is begin Protection.Enter_Kernel; -- Insert the thread at the tail of its active priority so that the -- thread will resume execution. System.Executive.Threads.Queues.Insert_At_Tail (Id); Protection.Leave_Kernel; end Wakeup; ----------- -- Yield -- ----------- procedure Yield is begin Protection.Enter_Kernel; -- Move the currently running thread to the tail of its active priority Queues.Extract_From_Ready (Queues.Running_Thread); Queues.Insert_At_Tail (Queues.Running_Thread); Protection.Leave_Kernel; end Yield; end System.Executive.Threads;
with Ada.Exceptions; use Ada.Exceptions; -- TODO clean with Ada.Text_Io; with Posix; with Posix.Io; package body Util is package ATIO renames Ada.Text_Io; package PIO renames Posix.Io; procedure Verbose_Print (Msg : String) is -- TODO rename Debug_Print? begin -- TODO define type for severity? Info, Debug, Warning, Error? if Verbose then -- TODO prepend with "Iictl: "? ATIO.Put_Line (Msg); -- TODO print to stderr? end if; end Verbose_Print; function Is_Fifo_Up (Srv_Path : String) Return Boolean is -- TODO rename Is_Fifo_Up as Is_In_Fifo_Up? -- TODO rename Srv_Path as Dir_Path? -- TODO take Posix_String? use type Posix.Error_Code; In_Path : Posix.Posix_String := Posix.To_Posix_String (Srv_Path & "/in"); Fd : PIO.File_Descriptor; begin -- It's up if it's possible to open wronly without error -- TODO Is_Pathname ()? -- TODO check ps environ TODO relying on FIFO is stupid: Check PIDs Fd := PIO.Open (In_Path, PIO.Write_Only, PIO.Non_Blocking); -- TODO Close return True; exception when Error : Posix.Posix_Error => if Posix.Get_Error_Code = Posix.Enxio then return False; -- Fifo is down else raise Posix.Posix_Error with Exception_Message (Error); -- TODO better solution end if; -- TODO NO_SUCH_FILE_OR_DIRECTORY => return False; end Is_Fifo_Up; function Is_Integral (Text : String) return Boolean is Dummy : Integer; begin Dummy := Integer'Value (Text); return True; exception when others => return False; end; end Util;
package body OpenGL.Texture is -- -- Mappings between enumeration types and OpenGL constants. -- function Environment_Target_To_Constant (Target : in Environment_Target_t) return Thin.Enumeration_t is begin case Target is when Texture_Environment => return Thin.GL_TEXTURE_ENV; when Texture_Filter_Control => return Thin.GL_TEXTURE_FILTER_CONTROL; when Point_Sprite => return Thin.GL_POINT_SPRITE; end case; end Environment_Target_To_Constant; function Environment_Parameter_To_Constant (Value : in Environment_Parameter_t) return Thin.Enumeration_t is begin case Value is when Texture_Env_Mode => return Thin.GL_TEXTURE_ENV_MODE; when Texture_LOD_Bias => return Thin.GL_TEXTURE_LOD_BIAS; when Combine_RGB => return Thin.GL_COMBINE_RGB; when Combine_Alpha => return Thin.GL_COMBINE_ALPHA; when Source0_RGB => return Thin.GL_SRC0_RGB; when Source1_RGB => return Thin.GL_SRC1_RGB; when Source2_RGB => return Thin.GL_SRC2_RGB; when Source0_Alpha => return Thin.GL_SRC0_ALPHA; when Source1_Alpha => return Thin.GL_SRC1_ALPHA; when Source2_Alpha => return Thin.GL_SRC2_ALPHA; when Operand0_RGB => return Thin.GL_OPERAND0_RGB; when Operand1_RGB => return Thin.GL_OPERAND1_RGB; when Operand2_RGB => return Thin.GL_OPERAND2_RGB; when Operand0_Alpha => return Thin.GL_OPERAND0_ALPHA; when Operand1_Alpha => return Thin.GL_OPERAND1_ALPHA; when Operand2_Alpha => return Thin.GL_OPERAND2_ALPHA; when RGB_Scale => return Thin.GL_RGB_SCALE; when Alpha_Scale => return Thin.GL_ALPHA_SCALE; when Coord_Replace => return Thin.GL_COORD_REPLACE; end case; end Environment_Parameter_To_Constant; function Target_To_Constant (Value : in Target_t) return Thin.Enumeration_t is begin case Value is when Texture_1D => return Thin.GL_TEXTURE_1D; when Texture_2D => return Thin.GL_TEXTURE_2D; when Texture_3D => return Thin.GL_TEXTURE_3D; when Texture_Cube_Map => return Thin.GL_TEXTURE_CUBE_MAP; when Texture_Rectangle_ARB => return Thin.GL_TEXTURE_RECTANGLE_ARB; end case; end Target_To_Constant; function Texture_Parameter_To_Constant (Value : in Texture_Parameter_t) return Thin.Enumeration_t is begin case Value is when Texture_Min_Filter => return Thin.GL_TEXTURE_MIN_FILTER; when Texture_Mag_Filter => return Thin.GL_TEXTURE_MAG_FILTER; when Texture_Min_LOD => return Thin.GL_TEXTURE_MIN_LOD; when Texture_Max_LOD => return Thin.GL_TEXTURE_MAX_LOD; when Texture_Base_Level => return Thin.GL_TEXTURE_BASE_LEVEL; when Texture_Max_Level => return Thin.GL_TEXTURE_MAX_LEVEL; when Texture_Wrap_S => return Thin.GL_TEXTURE_WRAP_S; when Texture_Wrap_T => return Thin.GL_TEXTURE_WRAP_T; when Texture_Wrap_R => return Thin.GL_TEXTURE_WRAP_R; when Texture_Priority => return Thin.GL_TEXTURE_PRIORITY; when Texture_Compare_Mode => return Thin.GL_TEXTURE_COMPARE_MODE; when Texture_Compare_Func => return Thin.GL_TEXTURE_COMPARE_FUNC; when Depth_Texture_Mode => return Thin.GL_DEPTH_TEXTURE_MODE; when Generate_Mipmap => return Thin.GL_GENERATE_MIPMAP; end case; end Texture_Parameter_To_Constant; function Storage_To_Constant (Value : in Storage_Parameter_t) return Thin.Enumeration_t is begin case Value is when Pack_Swap_Bytes => return Thin.GL_PACK_SWAP_BYTES; when Pack_LSB_First => return Thin.GL_PACK_LSB_FIRST; when Pack_Row_Length => return Thin.GL_PACK_ROW_LENGTH; when Pack_Image_Height => return Thin.GL_PACK_IMAGE_HEIGHT; when Pack_Skip_Pixels => return Thin.GL_PACK_SKIP_PIXELS; when Pack_Skip_Rows => return Thin.GL_PACK_SKIP_ROWS; when Pack_Skip_Images => return Thin.GL_PACK_SKIP_IMAGES; when Pack_Alignment => return Thin.GL_PACK_ALIGNMENT; when Unpack_Swap_Bytes => return Thin.GL_UNPACK_SWAP_BYTES; when Unpack_LSB_First => return Thin.GL_UNPACK_LSB_FIRST; when Unpack_Row_Length => return Thin.GL_UNPACK_ROW_LENGTH; when Unpack_Image_Height => return Thin.GL_UNPACK_IMAGE_HEIGHT; when Unpack_Skip_Pixels => return Thin.GL_UNPACK_SKIP_PIXELS; when Unpack_Skip_Rows => return Thin.GL_UNPACK_SKIP_ROWS; when Unpack_Skip_Images => return Thin.GL_UNPACK_SKIP_IMAGES; when Unpack_Alignment => return Thin.GL_UNPACK_ALIGNMENT; end case; end Storage_To_Constant; function Target_1D_To_Constant (Target : in Target_1D_t) return Thin.Enumeration_t is begin case Target is when Texture_1D => return Thin.GL_TEXTURE_1D; when Proxy_Texture_1D => return Thin.GL_PROXY_TEXTURE_1D; when Texture_Rectangle_ARB => return Thin.GL_TEXTURE_RECTANGLE_ARB; end case; end Target_1D_To_Constant; function Target_2D_To_Constant (Target : in Target_2D_t) return Thin.Enumeration_t is begin case Target is when Proxy_Texture_2D => return Thin.GL_PROXY_TEXTURE_2D; when Proxy_Texture_Cube_Map => return Thin.GL_PROXY_TEXTURE_CUBE_MAP; when Texture_2D => return Thin.GL_TEXTURE_2D; when Texture_Cube_Map_Negative_X => return Thin.GL_TEXTURE_CUBE_MAP_NEGATIVE_X; when Texture_Cube_Map_Negative_Y => return Thin.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y; when Texture_Cube_Map_Negative_Z => return Thin.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; when Texture_Cube_Map_Positive_X => return Thin.GL_TEXTURE_CUBE_MAP_POSITIVE_X; when Texture_Cube_Map_Positive_Y => return Thin.GL_TEXTURE_CUBE_MAP_POSITIVE_Y; when Texture_Cube_Map_Positive_Z => return Thin.GL_TEXTURE_CUBE_MAP_POSITIVE_Z; when Texture_Rectangle_ARB => return Thin.GL_TEXTURE_RECTANGLE_ARB; end case; end Target_2D_To_Constant; function Target_3D_To_Constant (Target : in Target_3D_t) return Thin.Enumeration_t is begin case Target is when Texture_3D => return Thin.GL_TEXTURE_3D; when Proxy_Texture_3D => return Thin.GL_PROXY_TEXTURE_3D; when Texture_Rectangle_ARB => return Thin.GL_TEXTURE_RECTANGLE_ARB; end case; end Target_3D_To_Constant; function Format_To_Constant (Format : in Format_t) return Thin.Enumeration_t is begin case Format is when Color_Index => return Thin.GL_COLOR_INDEX; when Red => return Thin.GL_RED; when Green => return Thin.GL_GREEN; when Blue => return Thin.GL_BLUE; when Alpha => return Thin.GL_ALPHA; when RGB => return Thin.GL_RGB; when BGR => return Thin.GL_BGR; when RGBA => return Thin.GL_RGBA; when BGRA => return Thin.GL_BGRA; when Luminance => return Thin.GL_LUMINANCE; when Luminance_Alpha => return Thin.GL_LUMINANCE_ALPHA; end case; end Format_To_Constant; function Internal_To_Constant (Format : in Internal_Format_t) return Thin.Integer_t is begin case Format is when Alpha => return Thin.GL_ALPHA; when Alpha_4 => return Thin.GL_ALPHA4; when Alpha_8 => return Thin.GL_ALPHA8; when Alpha_12 => return Thin.GL_ALPHA12; when Alpha_16 => return Thin.GL_ALPHA16; when Compressed_Alpha => return Thin.GL_COMPRESSED_ALPHA; when Compressed_Luminance => return Thin.GL_COMPRESSED_LUMINANCE; when Compressed_Luminance_Alpha => return Thin.GL_COMPRESSED_LUMINANCE_ALPHA; when Compressed_Intensity => return Thin.GL_COMPRESSED_INTENSITY; when Compressed_RGB => return Thin.GL_COMPRESSED_RGB; when Compressed_RGBA => return Thin.GL_COMPRESSED_RGBA; when Luminance => return Thin.GL_LUMINANCE; when Luminance_4 => return Thin.GL_LUMINANCE4; when Luminance_8 => return Thin.GL_LUMINANCE8; when Luminance_12 => return Thin.GL_LUMINANCE12; when Luminance_16 => return Thin.GL_LUMINANCE16; when Luminance_Alpha => return Thin.GL_LUMINANCE_ALPHA; when Luminance_4_Alpha_4 => return Thin.GL_LUMINANCE4_ALPHA4; when Luminance_6_Alpha_2 => return Thin.GL_LUMINANCE6_ALPHA2; when Luminance_8_Alpha_8 => return Thin.GL_LUMINANCE8_ALPHA8; when Luminance_12_Alpha_4 => return Thin.GL_LUMINANCE12_ALPHA4; when Luminance_12_Alpha_12 => return Thin.GL_LUMINANCE12_ALPHA12; when Luminance_16_Alpha_16 => return Thin.GL_LUMINANCE16_ALPHA16; when Intensity => return Thin.GL_INTENSITY; when Intensity_4 => return Thin.GL_INTENSITY4; when Intensity_8 => return Thin.GL_INTENSITY8; when Intensity_12 => return Thin.GL_INTENSITY12; when Intensity_16 => return Thin.GL_INTENSITY16; when R3_G3_B2 => return Thin.GL_R3_G3_B2; when RGB => return Thin.GL_RGB; when RGB_4 => return Thin.GL_RGB4; when RGB_5 => return Thin.GL_RGB5; when RGB_8 => return Thin.GL_RGB8; when RGB_10 => return Thin.GL_RGB10; when RGB_12 => return Thin.GL_RGB12; when RGB_16 => return Thin.GL_RGB16; when RGBA => return Thin.GL_RGBA; when RGBA_2 => return Thin.GL_RGBA2; when RGBA_4 => return Thin.GL_RGBA4; when RGB5_A1 => return Thin.GL_RGB5_A1; when RGBA_8 => return Thin.GL_RGBA8; when RGB10_A2 => return Thin.GL_RGB10_A2; when RGBA_12 => return Thin.GL_RGBA12; when RGBA_16 => return Thin.GL_RGBA16; when SLuminance => return Thin.GL_SLUMINANCE; when SLuminance_8 => return Thin.GL_SLUMINANCE8; when SLuminance_Alpha => return Thin.GL_SLUMINANCE_ALPHA; when SLuminance_8_Alpha_8 => return Thin.GL_SLUMINANCE8_ALPHA8; when SRGB => return Thin.GL_SRGB; when SRGB_8 => return Thin.GL_SRGB8; when SRGB_Alpha => return Thin.GL_SRGB_ALPHA; when SRGB_8_Alpha_8 => return Thin.GL_SRGB8_ALPHA8; end case; end Internal_To_Constant; function Data_Type_To_Constant (Data_Type : in Data_Type_t) return Thin.Enumeration_t is begin case Data_Type is when Unsigned_Byte => return Thin.GL_UNSIGNED_BYTE; when Byte => return Thin.GL_BYTE; when Bitmap => return Thin.GL_BITMAP; when Unsigned_Short => return Thin.GL_UNSIGNED_SHORT; when Short => return Thin.GL_SHORT; when Unsigned_Integer => return Thin.GL_UNSIGNED_INT; when Integer => return Thin.GL_INT; when Float => return Thin.GL_FLOAT; when Unsigned_Byte_3_3_2 => return Thin.GL_UNSIGNED_BYTE_3_3_2; when Unsigned_Byte_2_3_3_Rev => return Thin.GL_UNSIGNED_BYTE_2_3_3_REV; when Unsigned_Short_5_6_5 => return Thin.GL_UNSIGNED_SHORT_5_6_5; when Unsigned_Short_5_6_5_Rev => return Thin.GL_UNSIGNED_SHORT_5_6_5_REV; when Unsigned_Short_4_4_4_4 => return Thin.GL_UNSIGNED_SHORT_4_4_4_4; when Unsigned_Short_4_4_4_4_Rev => return Thin.GL_UNSIGNED_SHORT_4_4_4_4_REV; when Unsigned_Short_5_5_5_1 => return Thin.GL_UNSIGNED_SHORT_5_5_5_1; when Unsigned_Short_1_5_5_5_Rev => return Thin.GL_UNSIGNED_SHORT_1_5_5_5_REV; when Unsigned_Integer_8_8_8_8 => return Thin.GL_UNSIGNED_INT_8_8_8_8; when Unsigned_Integer_8_8_8_8_Rev => return Thin.GL_UNSIGNED_INT_8_8_8_8_REV; when Unsigned_Integer_10_10_10_2 => return Thin.GL_UNSIGNED_INT_10_10_10_2; when Unsigned_Integer_2_10_10_10_Rev => return Thin.GL_UNSIGNED_INT_2_10_10_10_REV; end case; end Data_Type_To_Constant; -- -- Environment -- procedure Environment (Target : in Environment_Target_t; Parameter : in Environment_Parameter_t; Value : in Standard.Integer) is begin Thin.Tex_Envi (Target => Environment_Target_To_Constant (Target), Parameter => Environment_Parameter_To_Constant (Parameter), Value => Thin.Integer_t (Value)); end Environment; procedure Environment (Target : in Environment_Target_t; Parameter : in Environment_Parameter_t; Value : in Standard.Float) is begin Thin.Tex_Envf (Target => Environment_Target_To_Constant (Target), Parameter => Environment_Parameter_To_Constant (Parameter), Value => Thin.Float_t (Value)); end Environment; -- -- Pixel_Store -- procedure Pixel_Store (Parameter : in Storage_Parameter_t; Value : in Standard.Integer) is begin Thin.Pixel_Storei (Parameter => Storage_To_Constant (Parameter), Value => Thin.Integer_t (Value)); end Pixel_Store; procedure Pixel_Store (Parameter : in Storage_Parameter_t; Value : in Standard.Float) is begin Thin.Pixel_Storef (Parameter => Storage_To_Constant (Parameter), Value => Thin.Float_t (Value)); end Pixel_Store; -- -- Parameter -- procedure Parameter (Target : in Target_t; Parameter : in Texture_Parameter_t; Value : in Standard.Integer) is begin Thin.Tex_Parameteri (Target => Target_To_Constant (Target), Parameter => Texture_Parameter_To_Constant (Parameter), Value => Thin.Integer_t (Value)); end Parameter; procedure Parameter (Target : in Target_t; Parameter : in Texture_Parameter_t; Value : in Standard.Float) is begin Thin.Tex_Parameterf (Target => Target_To_Constant (Target), Parameter => Texture_Parameter_To_Constant (Parameter), Value => Thin.Float_t (Value)); end Parameter; -- -- Image_3D -- procedure Image_3D (Target : in Target_3D_t; Level : in Natural; Internal_Format : in Internal_Format_t; Width : in Positive; Height : in Positive; Depth : in Positive; Border : in Border_Width_t; Format : in Format_t; Data : in Data_Array_t; Data_Type : in Data_Type_t) is begin Thin.Tex_Image_3D (Target => Target_3D_To_Constant (Target), Level => Thin.Integer_t (Level), Internal_Format => Internal_To_Constant (Internal_Format), Width => Thin.Size_t (Width), Height => Thin.Size_t (Height), Depth => Thin.Size_t (Depth), Border => Thin.Integer_t (Border), Format => Format_To_Constant (Format), Data_Type => Data_Type_To_Constant (Data_Type), Data => Data (Data'First)'Address); end Image_3D; -- -- Image_2D -- procedure Image_2D (Target : in Target_2D_t; Level : in Natural; Internal_Format : in Internal_Format_t; Width : in Positive; Height : in Positive; Border : in Border_Width_t; Format : in Format_t; Data : in Data_Array_t; Data_Type : in Data_Type_t) is begin Thin.Tex_Image_2D (Target => Target_2D_To_Constant (Target), Level => Thin.Integer_t (Level), Internal_Format => Internal_To_Constant (Internal_Format), Width => Thin.Size_t (Width), Height => Thin.Size_t (Height), Border => Thin.Integer_t (Border), Format => Format_To_Constant (Format), Data_Type => Data_Type_To_Constant (Data_Type), Data => Data (Data'First)'Address); end Image_2D; -- -- Image_1D -- procedure Image_1D (Target : in Target_1D_t; Level : in Natural; Internal_Format : in Internal_Format_t; Width : in Positive; Border : in Border_Width_t; Format : in Format_t; Data : in Data_Array_t; Data_Type : in Data_Type_t) is begin Thin.Tex_Image_1D (Target => Target_1D_To_Constant (Target), Level => Thin.Integer_t (Level), Internal_Format => Internal_To_Constant (Internal_Format), Width => Thin.Size_t (Width), Border => Thin.Integer_t (Border), Format => Format_To_Constant (Format), Data_Type => Data_Type_To_Constant (Data_Type), Data => Data (Data'First)'Address); end Image_1D; -- -- Generate -- procedure Generate (Textures : in out Index_Array_t) is begin Thin.Gen_Textures (Size => Textures'Length, Textures => Textures (Textures'First)'Address); end Generate; -- -- Bind -- procedure Bind (Target : in Target_t; Texture : in Index_t) is begin Thin.Bind_Texture (Target => Target_To_Constant (Target), Texture => Thin.Unsigned_Integer_t (Texture)); end Bind; -- -- Blend_Function -- function Blend_Factor_To_Constant (Blend_Factor : in Blend_Factor_t) return Thin.Enumeration_t is begin case Blend_Factor is when Blend_Zero => return Thin.GL_ZERO; when Blend_One => return Thin.GL_ONE; when Blend_Source_Color => return Thin.GL_SRC_COLOR; when Blend_One_Minus_Source_Color => return Thin.GL_ONE_MINUS_SRC_COLOR; when Blend_Target_Color => return Thin.GL_DST_COLOR; when Blend_One_Minus_Target_Color => return Thin.GL_ONE_MINUS_DST_COLOR; when Blend_Source_Alpha => return Thin.GL_SRC_ALPHA; when Blend_One_Minus_Source_Alpha => return Thin.GL_ONE_MINUS_SRC_ALPHA; when Blend_Target_Alpha => return Thin.GL_DST_ALPHA; when Blend_One_Minus_Target_Alpha => return Thin.GL_ONE_MINUS_DST_ALPHA; when Blend_Constant_Color => return Thin.GL_CONSTANT_COLOR; when Blend_One_Minus_Constant_Color => return Thin.GL_ONE_MINUS_CONSTANT_COLOR; when Blend_Constant_Alpha => return Thin.GL_CONSTANT_ALPHA; when Blend_One_Minus_Constant_Alpha => return Thin.GL_ONE_MINUS_CONSTANT_ALPHA; when Blend_Source_Alpha_Saturate => return Thin.GL_SRC_ALPHA_SATURATE; end case; end Blend_Factor_To_Constant; procedure Blend_Function (Source_Factor : in Blend_Factor_t; Target_Factor : in Blend_Factor_t) is begin Thin.Blend_Func (Source_Factor => Blend_Factor_To_Constant (Source_Factor), Target_Factor => Blend_Factor_To_Constant (Target_Factor)); end Blend_Function; end OpenGL.Texture;
-- { dg-do compile } procedure Atomic2 is type Big is array (1..4) of Integer; type Arr is array (1..10) of Big; pragma Atomic_Components (Arr); -- { dg-warning "cannot be guaranteed" } begin null; end;
private with Ada.Containers.Vectors, System.Address_To_Access_Conversions, Interfaces.C.Strings; package FLTK.Text_Buffers is type Text_Buffer is new Wrapper with private; type Text_Buffer_Reference (Data : access Text_Buffer'Class) is limited null record with Implicit_Dereference => Data; subtype Position is Natural; type Modification is (Insert, Restyle, Delete, None); type Modify_Callback is access procedure (Action : in Modification; Place : in Position; Length : in Natural; Deleted_Text : in String); type Predelete_Callback is access procedure (Place : in Position; Length : in Natural); package Forge is function Create (Requested_Size : in Natural := 0; Preferred_Gap_Size : in Natural := 1024) return Text_Buffer; end Forge; procedure Add_Modify_Callback (This : in out Text_Buffer; Func : in Modify_Callback); procedure Add_Predelete_Callback (This : in out Text_Buffer; Func : in Predelete_Callback); procedure Remove_Modify_Callback (This : in out Text_Buffer; Func : in Modify_Callback); procedure Remove_Predelete_Callback (This : in out Text_Buffer; Func : in Predelete_Callback); procedure Call_Modify_Callbacks (This : in out Text_Buffer); procedure Call_Predelete_Callbacks (This : in out Text_Buffer); procedure Enable_Callbacks (This : in out Text_Buffer); procedure Disable_Callbacks (This : in out Text_Buffer); procedure Load_File (This : in out Text_Buffer; Name : in String; Buffer : in Natural := 128 * 1024); procedure Append_File (This : in out Text_Buffer; Name : in String; Buffer : in Natural := 128 * 1024); procedure Insert_File (This : in out Text_Buffer; Name : in String; Place : in Position; Buffer : in Natural := 128 * 1024); procedure Output_File (This : in Text_Buffer; Name : in String; Start, Finish : in Position; Buffer : in Natural := 128 * 1024); procedure Save_File (This : in Text_Buffer; Name : in String; Buffer : in Natural := 128 * 1024); procedure Insert_Text (This : in out Text_Buffer; Place : in Position; Text : in String); procedure Append_Text (This : in out Text_Buffer; Text : in String); procedure Replace_Text (This : in out Text_Buffer; Start, Finish : in Position; Text : in String); procedure Remove_Text (This : in out Text_Buffer; Start, Finish : in Position); function Get_Entire_Text (This : in Text_Buffer) return String; procedure Set_Entire_Text (This : in out Text_Buffer; Text : in String); function Byte_At (This : in Text_Buffer; Place : in Position) return Character; function Character_At (This : in Text_Buffer; Place : in Position) return Character; function Text_At (This : in Text_Buffer; Start, Finish : in Position) return String; function Next_Char (This : in Text_Buffer; Place : in Position) return Character; function Prev_Char (This : in Text_Buffer; Place : in Position) return Character; function Count_Displayed_Characters (This : in Text_Buffer; Start, Finish : in Position) return Integer; function Count_Lines (This : in Text_Buffer; Start, Finish : in Position) return Integer; function Length (This : in Text_Buffer) return Natural; function Get_Tab_Width (This : in Text_Buffer) return Natural; procedure Set_Tab_Width (This : in out Text_Buffer; To : in Natural); function Get_Selection (This : in Text_Buffer; Start, Finish : out Position) return Boolean; function Get_Secondary_Selection (This : in Text_Buffer; Start, Finish : out Position) return Boolean; procedure Set_Selection (This : in out Text_Buffer; Start, Finish : in Position); procedure Set_Secondary_Selection (This : in out Text_Buffer; Start, Finish : in Position); function Has_Selection (This : in Text_Buffer) return Boolean; function Has_Secondary_Selection (This : in Text_Buffer) return Boolean; function Selection_Text (This : in Text_Buffer) return String; function Secondary_Selection_Text (This : in Text_Buffer) return String; procedure Replace_Selection (This : in out Text_Buffer; Text : in String); procedure Replace_Secondary_Selection (This : in out Text_Buffer; Text : in String); procedure Remove_Selection (This : in out Text_Buffer); procedure Remove_Secondary_Selection (This : in out Text_Buffer); procedure Unselect (This : in out Text_Buffer); procedure Secondary_Unselect (This : in out Text_Buffer); procedure Get_Highlight (This : in Text_Buffer; Start, Finish : out Position); procedure Set_Highlight (This : in out Text_Buffer; Start, Finish : in Position); function Get_Highlighted_Text (This : in Text_Buffer) return String; procedure Unhighlight (This : in out Text_Buffer); function Findchar_Forward (This : in Text_Buffer; Start_At : in Position; Item : in Character; Found_At : out Position) return Boolean; function Findchar_Backward (This : in Text_Buffer; Start_At : in Position; Item : in Character; Found_At : out Position) return Boolean; function Search_Forward (This : in Text_Buffer; Start_At : in Position; Item : in String; Found_At : out Position; Match_Case : in Boolean := False) return Boolean; function Search_Backward (This : in Text_Buffer; Start_At : in Position; Item : in String; Found_At : out Position; Match_Case : in Boolean := False) return Boolean; function Word_Start (This : in Text_Buffer; Place : in Position) return Position; function Word_End (This : in Text_Buffer; Place : in Position) return Position; function Line_Start (This : in Text_Buffer; Place : in Position) return Position; function Line_End (This : in Text_Buffer; Place : in Position) return Position; function Line_Text (This : in Text_Buffer; Place : in Position) return String; -- only takes into account newline characters, not word wrap function Skip_Lines (This : in out Text_Buffer; Start : in Position; Lines : in Natural) return Position; -- only takes into account newline characters, not word wrap function Rewind_Lines (This : in out Text_Buffer; Start : in Position; Lines : in Natural) return Position; function Skip_Displayed_Characters (This : in Text_Buffer; Start : in Position; Chars : in Natural) return Position; procedure Can_Undo (This : in out Text_Buffer; Flag : in Boolean); procedure Copy (This : in out Text_Buffer; From : in Text_Buffer; Start, Finish : in Position; Insert_Pos : in Position); function UTF8_Align (This : in Text_Buffer; Place : in Position) return Position; private package Modify_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Modify_Callback); package Predelete_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Predelete_Callback); type Text_Buffer is new Wrapper with record CB_Active : Boolean; Modify_CBs : Modify_Vectors.Vector; Predelete_CBs : Predelete_Vectors.Vector; High_From, High_To : Natural := 0; end record; overriding procedure Finalize (This : in out Text_Buffer); procedure Modify_Callback_Hook (Pos, Inserted, Deleted, Restyled : in Interfaces.C.int; Text : in Interfaces.C.Strings.chars_ptr; UD : in System.Address); pragma Convention (C, Modify_Callback_Hook); procedure Predelete_Callback_Hook (Pos, Deleted : in Interfaces.C.int; UD : in System.Address); pragma Convention (C, Predelete_Callback_Hook); package Text_Buffer_Convert is new System.Address_To_Access_Conversions (Text_Buffer); pragma Inline (Add_Modify_Callback); pragma Inline (Add_Predelete_Callback); pragma Inline (Remove_Modify_Callback); pragma Inline (Remove_Predelete_Callback); pragma Inline (Call_Modify_Callbacks); pragma Inline (Call_Predelete_Callbacks); pragma Inline (Enable_Callbacks); pragma Inline (Disable_Callbacks); pragma Inline (Load_File); pragma Inline (Append_File); pragma Inline (Insert_File); pragma Inline (Output_File); pragma Inline (Save_File); pragma Inline (Insert_Text); pragma Inline (Append_Text); pragma Inline (Replace_Text); pragma Inline (Remove_Text); pragma Inline (Get_Entire_Text); pragma Inline (Set_Entire_Text); pragma Inline (Byte_At); pragma Inline (Character_At); pragma Inline (Text_At); pragma Inline (Next_Char); pragma Inline (Prev_Char); pragma Inline (Count_Displayed_Characters); pragma Inline (Count_Lines); pragma Inline (Length); pragma Inline (Get_Tab_Width); pragma Inline (Set_Tab_Width); pragma Inline (Get_Selection); pragma Inline (Get_Secondary_Selection); pragma Inline (Set_Selection); pragma Inline (Set_Secondary_Selection); pragma Inline (Has_Selection); pragma Inline (Has_Secondary_Selection); pragma Inline (Selection_Text); pragma Inline (Secondary_Selection_Text); pragma Inline (Replace_Selection); pragma Inline (Replace_Secondary_Selection); pragma Inline (Remove_Selection); pragma Inline (Remove_Secondary_Selection); pragma Inline (Unselect); pragma Inline (Secondary_Unselect); pragma Inline (Get_Highlight); pragma Inline (Set_Highlight); pragma Inline (Get_Highlighted_Text); pragma Inline (Unhighlight); pragma Inline (Findchar_Forward); pragma Inline (Findchar_Backward); pragma Inline (Search_Forward); pragma Inline (Search_Backward); pragma Inline (Word_Start); pragma Inline (Word_End); pragma Inline (Line_Start); pragma Inline (Line_End); pragma Inline (Line_Text); pragma Inline (Skip_Lines); pragma Inline (Rewind_Lines); pragma Inline (Skip_Displayed_Characters); pragma Inline (Can_Undo); pragma Inline (Copy); pragma Inline (UTF8_Align); end FLTK.Text_Buffers;
-- { dg-do compile } package body Varsize3_1 is end Varsize3_1;
with openGL.Errors, openGL.Tasks, ada.unchecked_Deallocation; package body openGL.Buffer is use type a_Name; --------------- -- Buffer Name -- function new_vbo_Name return a_Name is Name : aliased a_Name; begin Tasks.check; glGenBuffers (1, Name'unchecked_Access); return Name; end new_vbo_Name; procedure free (vbo_Name : in a_Name) is Name : aliased a_Name := vbo_Name; begin Tasks.check; glDeleteBuffers (1, Name'unchecked_Access); end free; pragma Unreferenced (free); ---------- -- Object -- procedure verify_Name (Self : in out Object'Class) is begin if Self.Name = 0 then Self.Name := new_vbo_Name; end if; end verify_Name; function Name (Self : in Object) return Buffer.a_Name is begin return Self.Name; end Name; procedure enable (Self : in Object'Class) is pragma assert (Self.Name > 0); begin Tasks.check; glBindBuffer (to_GL_Enum (Self.Kind), Self.Name); openGL.Errors.log; end enable; procedure destroy (Self : in out Object'Class) is begin Tasks.check; glBindBuffer (to_GL_Enum (Self.Kind), 0); openGL.Errors.log; glDeleteBuffers (1, Self.Name'Access); openGL.Errors.log; Self.Name := 0; end destroy; procedure free (Self : in out View) is procedure deallocate is new ada.unchecked_Deallocation (Buffer.Object'Class, Buffer.view); begin if Self /= null then Self.destroy; deallocate (Self); end if; end free; function Length (Self : in Object) return Positive is begin return Self.Length; end Length; ------------------------- -- 'array' Buffer Object -- overriding function Kind (Self : in array_Object) return Buffer.a_Kind is pragma Unreferenced (Self); begin return array_Buffer; end Kind; --------------------------------- -- 'element array' Buffer object -- overriding function Kind (Self : in element_array_Object) return Buffer.a_Kind is pragma Unreferenced (Self); begin return element_array_Buffer; end Kind; end openGL.Buffer;
----------------------------------------------------------------------- -- util-processes-os -- System specific and low level operations -- Copyright (C) 2011, 2012 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.Unchecked_Deallocation; package body Util.Processes.Os is use Util.Systems.Os; use type Interfaces.C.size_t; type Pipe_Type is array (0 .. 1) of File_Type; procedure Close (Pipes : in out Pipe_Type); -- ------------------------------ -- Create the output stream to read/write on the process input/output. -- Setup the file to be closed on exec. -- ------------------------------ function Create_Stream (File : in File_Type) return Util.Streams.Raw.Raw_Stream_Access is Stream : constant Util.Streams.Raw.Raw_Stream_Access := new Util.Streams.Raw.Raw_Stream; Status : constant Integer := Sys_Fcntl (File, F_SETFL, FD_CLOEXEC); pragma Unreferenced (Status); begin Stream.Initialize (File); return Stream; end Create_Stream; -- ------------------------------ -- Wait for the process to exit. -- ------------------------------ overriding procedure Wait (Sys : in out System_Process; Proc : in out Process'Class; Timeout : in Duration) is pragma Unreferenced (Sys, Timeout); use type Util.Streams.Output_Stream_Access; Result : Integer; Wpid : Integer; begin -- Close the input stream pipe if there is one. if Proc.Input /= null then Util.Streams.Raw.Raw_Stream'Class (Proc.Input.all).Close; end if; Wpid := Sys_Waitpid (Integer (Proc.Pid), Result'Address, 0); if Wpid = Integer (Proc.Pid) then Proc.Exit_Value := Result / 256; if Result mod 256 /= 0 then Proc.Exit_Value := (Result mod 256) * 1000; end if; end if; end Wait; -- ------------------------------ -- Terminate the process by sending a signal on Unix and exiting the process on Windows. -- This operation is not portable and has a different behavior between Unix and Windows. -- Its intent is to stop the process. -- ------------------------------ overriding procedure Stop (Sys : in out System_Process; Proc : in out Process'Class; Signal : in Positive := 15) is pragma Unreferenced (Sys); Result : Integer; pragma Unreferenced (Result); begin Result := Sys_Kill (Integer (Proc.Pid), Integer (Signal)); end Stop; -- ------------------------------ -- Close both ends of the pipe (used to cleanup in case or error). -- ------------------------------ procedure Close (Pipes : in out Pipe_Type) is Result : Integer; pragma Unreferenced (Result); begin if Pipes (0) /= NO_FILE then Result := Sys_Close (Pipes (0)); Pipes (0) := NO_FILE; end if; if Pipes (1) /= NO_FILE then Result := Sys_Close (Pipes (1)); Pipes (1) := NO_FILE; end if; end Close; -- ------------------------------ -- Spawn a new process. -- ------------------------------ overriding procedure Spawn (Sys : in out System_Process; Proc : in out Process'Class; Mode : in Pipe_Mode := NONE) is use Util.Streams.Raw; use Interfaces.C.Strings; use type Interfaces.C.int; procedure Cleanup; -- Suppress all checks to make sure the child process will not raise any exception. pragma Suppress (All_Checks); Result : Integer; pragma Unreferenced (Result); Stdin_Pipes : aliased Pipe_Type := (others => NO_FILE); Stdout_Pipes : aliased Pipe_Type := (others => NO_FILE); Stderr_Pipes : aliased Pipe_Type := (others => NO_FILE); procedure Cleanup is begin Close (Stdin_Pipes); Close (Stdout_Pipes); Close (Stderr_Pipes); end Cleanup; begin -- Since checks are disabled, verify by hand that the argv table is correct. if Sys.Argv = null or else Sys.Argc < 1 or else Sys.Argv (0) = Null_Ptr then raise Program_Error with "Invalid process argument list"; end if; -- Setup the pipes. if Mode = READ or Mode = READ_WRITE or Mode = READ_ALL then if Sys_Pipe (Stdout_Pipes'Address) /= 0 then raise Process_Error with "Cannot create stdout pipe"; end if; end if; if Mode = WRITE or Mode = READ_WRITE or Mode = READ_WRITE_ALL then if Sys_Pipe (Stdin_Pipes'Address) /= 0 then Cleanup; raise Process_Error with "Cannot create stdin pipe"; end if; end if; if Mode = READ_ERROR then if Sys_Pipe (Stderr_Pipes'Address) /= 0 then Cleanup; raise Process_Error with "Cannot create stderr pipe"; end if; end if; -- Create the new process by using vfork instead of fork. The parent process is blocked -- until the child executes the exec or exits. The child process uses the same stack -- as the parent. Proc.Pid := Sys_VFork; if Proc.Pid = 0 then -- Do not use any Ada type while in the child process. if Mode = READ_ALL or Mode = READ_WRITE_ALL then Result := Sys_Dup2 (Stdout_Pipes (1), STDERR_FILENO); end if; if Stderr_Pipes (1) /= NO_FILE then if Stderr_Pipes (1) /= STDERR_FILENO then Result := Sys_Dup2 (Stderr_Pipes (1), STDERR_FILENO); Result := Sys_Close (Stderr_Pipes (1)); end if; Result := Sys_Close (Stderr_Pipes (0)); elsif Sys.Err_File /= Null_Ptr then -- Redirect the process error to a file. declare Fd : File_Type; begin if Sys.Err_Append then Fd := Sys_Open (Sys.Err_File, O_CREAT + O_WRONLY + O_APPEND, 8#644#); else Fd := Sys_Open (Sys.Err_File, O_CREAT + O_WRONLY + O_TRUNC, 8#644#); end if; if Fd < 0 then Sys_Exit (254); end if; Result := Sys_Dup2 (Fd, STDOUT_FILENO); Result := Sys_Close (Fd); end; end if; if Stdout_Pipes (1) /= NO_FILE then if Stdout_Pipes (1) /= STDOUT_FILENO then Result := Sys_Dup2 (Stdout_Pipes (1), STDOUT_FILENO); Result := Sys_Close (Stdout_Pipes (1)); end if; Result := Sys_Close (Stdout_Pipes (0)); elsif Sys.Out_File /= Null_Ptr then -- Redirect the process output to a file. declare Fd : File_Type; begin if Sys.Out_Append then Fd := Sys_Open (Sys.Out_File, O_CREAT + O_WRONLY + O_APPEND, 8#644#); else Fd := Sys_Open (Sys.Out_File, O_CREAT + O_WRONLY + O_TRUNC, 8#644#); end if; if Fd < 0 then Sys_Exit (254); end if; Result := Sys_Dup2 (Fd, STDOUT_FILENO); Result := Sys_Close (Fd); end; end if; if Stdin_Pipes (0) /= NO_FILE then if Stdin_Pipes (0) /= STDIN_FILENO then Result := Sys_Dup2 (Stdin_Pipes (0), STDIN_FILENO); Result := Sys_Close (Stdin_Pipes (0)); end if; Result := Sys_Close (Stdin_Pipes (1)); elsif Sys.In_File /= Null_Ptr then -- Redirect the process input to a file. declare Fd : File_Type; begin Fd := Sys_Open (Sys.Out_File, O_RDONLY, 8#644#); if Fd < 0 then Sys_Exit (254); end if; Result := Sys_Dup2 (Fd, STDIN_FILENO); Result := Sys_Close (Fd); end; end if; Result := Sys_Execvp (Sys.Argv (0), Sys.Argv.all); Sys_Exit (255); end if; -- Process creation failed, cleanup and raise an exception. if Proc.Pid < 0 then Cleanup; raise Process_Error with "Cannot create process"; end if; if Stdin_Pipes (1) /= NO_FILE then Result := Sys_Close (Stdin_Pipes (0)); Proc.Input := Create_Stream (Stdin_Pipes (1)).all'Access; end if; if Stdout_Pipes (0) /= NO_FILE then Result := Sys_Close (Stdout_Pipes (1)); Proc.Output := Create_Stream (Stdout_Pipes (0)).all'Access; end if; if Stderr_Pipes (0) /= NO_FILE then Result := Sys_Close (Stderr_Pipes (1)); Proc.Error := Create_Stream (Stderr_Pipes (0)).all'Access; end if; end Spawn; procedure Free is new Ada.Unchecked_Deallocation (Name => Ptr_Ptr_Array, Object => Ptr_Array); -- ------------------------------ -- Append the argument to the process argument list. -- ------------------------------ overriding procedure Append_Argument (Sys : in out System_Process; Arg : in String) is begin if Sys.Argv = null then Sys.Argv := new Ptr_Array (0 .. 10); elsif Sys.Argc = Sys.Argv'Last - 1 then declare N : constant Ptr_Ptr_Array := new Ptr_Array (0 .. Sys.Argc + 32); begin N (0 .. Sys.Argc) := Sys.Argv (0 .. Sys.Argc); Free (Sys.Argv); Sys.Argv := N; end; end if; Sys.Argv (Sys.Argc) := Interfaces.C.Strings.New_String (Arg); Sys.Argc := Sys.Argc + 1; Sys.Argv (Sys.Argc) := Interfaces.C.Strings.Null_Ptr; end Append_Argument; -- ------------------------------ -- Set the process input, output and error streams to redirect and use specified files. -- ------------------------------ overriding procedure Set_Streams (Sys : in out System_Process; Input : in String; Output : in String; Error : in String; Append_Output : in Boolean; Append_Error : in Boolean) is begin if Input'Length > 0 then Sys.In_File := Interfaces.C.Strings.New_String (Input); end if; if Output'Length > 0 then Sys.Out_File := Interfaces.C.Strings.New_String (Output); Sys.Out_Append := Append_Output; end if; if Error'Length > 0 then Sys.Err_File := Interfaces.C.Strings.New_String (Error); Sys.Err_Append := Append_Error; end if; end Set_Streams; -- ------------------------------ -- Deletes the storage held by the system process. -- ------------------------------ overriding procedure Finalize (Sys : in out System_Process) is begin if Sys.Argv /= null then for I in Sys.Argv'Range loop Interfaces.C.Strings.Free (Sys.Argv (I)); end loop; Free (Sys.Argv); end if; Interfaces.C.Strings.Free (Sys.In_File); Interfaces.C.Strings.Free (Sys.Out_File); Interfaces.C.Strings.Free (Sys.Err_File); end Finalize; end Util.Processes.Os;
-- BinToAsc_Suite.Base64_Tests -- Unit tests for BinToAsc -- Copyright (c) 2015, James Humphry - see LICENSE file for details with AUnit.Assertions; with System.Storage_Elements; with Ada.Assertions; package body BinToAsc_Suite.Base64_Tests is use AUnit.Assertions; use System.Storage_Elements; use RFC4648; use type RFC4648.Codec_State; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T: in out Base64_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Check_Symmetry'Access, "Check the Encoder and Decoder are a symmetrical pair"); Register_Routine (T, Check_Length'Access, "Check the Encoder and Decoder handle variable-length input successfully"); Register_Routine (T, Check_Test_Vectors_To_String'Access, "Check test vectors from RFC4648, binary -> string"); Register_Routine (T, Check_Test_Vectors_To_Bin'Access, "Check test vectors from RFC4648, string -> binary"); Register_Routine (T, Check_Test_Vectors_Incremental_To_String'Access, "Check test vectors from RFC4648, incrementally, binary -> string"); Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin'Access, "Check test vectors from RFC4648, incrementally, string -> binary"); Register_Routine (T, Check_Test_Vectors_By_Char_To_String'Access, "Check test vectors from RFC4648, character-by-character, binary -> string"); Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin'Access, "Check test vectors from RFC4648, character-by-character, string -> binary"); Register_Routine (T, Check_Padding'Access, "Check correct Base64 padding is enforced"); Register_Routine (T, Check_Junk_Rejection'Access, "Check Base64 decoder will reject junk input"); Register_Routine (T, Check_Junk_Rejection_By_Char'Access, "Check Base64 decoder will reject junk input (single character)"); end Register_Tests; ---------- -- Name -- ---------- function Name (T : Base64_Test) return Test_String is pragma Unreferenced (T); begin return Format ("Tests of Base64 codec from RFC4648"); end Name; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out Base64_Test) is begin null; end Set_Up; ------------------- -- Check_Padding -- ------------------- -- These procedures cannot be nested inside Check_Padding due to access -- level restrictions procedure Should_Raise_Exception_Excess_Padding is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base64.To_Bin("Zm9vYg==="); end; procedure Should_Raise_Exception_Insufficient_Padding is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base64.To_Bin("Zm9vYg="); end; procedure Check_Padding (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base64_Decoder : RFC4648.Base64.Base64_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Assert_Exception(Should_Raise_Exception_Excess_Padding'Access, "Base64 decoder did not reject excessive padding"); Assert_Exception(Should_Raise_Exception_Insufficient_Padding'Access, "Base64 decoder did not reject insufficient padding"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg===", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject excessive padding"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg==", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => "=", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject excessive padding when presented " & "as a one-char string after the initial valid input"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg=", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => "==", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject excessive padding when presented " & "as a == after the initial valid but incompletely padded " & "input"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg==", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => '=', Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject excessive padding when presented " & "as a separate character after the initial valid input"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg=", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject inadequate padding"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject inadequate padding"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9v=Yg==", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject non-padding characters appearing " & " after the first padding Character in a single input"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9v=", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => "Zm9", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject non-padding input presented " & " after an initial input ended with padding"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9v=", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => 'C', Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject non-padding input char presented " & " after an initial input ended with padding"); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9vYg", Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => '=', Output => Result_Bin, Output_Length => Result_Length); Base64_Decoder.Process(Input => "Zm", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed or Result_Length /= 0, "Base64 decoder did not reject non-padding string presented " & " after a padding char presented on its own"); end Check_Padding; -------------------------- -- Check_Junk_Rejection -- -------------------------- -- This procedure cannot be nested inside Check_Junk_Rejection due to access -- level restrictions procedure Should_Raise_Exception_From_Junk is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base64.To_Bin("Zm9v:mFy"); end; procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base64_Decoder : RFC4648.Base64.Base64_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Assert_Exception(Should_Raise_Exception_From_Junk'Access, "Base64 decoder did not reject junk input."); Base64_Decoder.Reset; Base64_Decoder.Process(Input => "Zm9v:mFy", Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed, "Base64 decoder did not reject junk input."); Assert(Result_Length = 0, "Base64 decoder rejected junk input but did not return 0 " & "length output."); begin Base64_Decoder.Process(Input => "Zm", Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base64_Decoder.State = Failed, "Base64 decoder reset its state on valid input after junk input."); Assert(Result_Length = 0, "Base64 decoder rejected input after a junk input but did " & "not return 0 length output."); begin Base64_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base64_Decoder.State = Failed, "Base16 decoder allowed successful completion after junk input."); Assert(Result_Length = 0, "Base64 decoder completed after a junk input did " & "not return 0 length output."); end Check_Junk_Rejection; ---------------------------------- -- Check_Junk_Rejection_By_Char -- ---------------------------------- procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base64_Decoder : RFC4648.Base64.Base64_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Base64_Decoder.Reset; Base64_Decoder.Process(Input => '@', Output => Result_Bin, Output_Length => Result_Length); Assert(Base64_Decoder.State = Failed, "Base64 decoder did not reject junk input character."); Assert(Result_Length = 0, "Base64 decoder rejected junk input but did not return 0 " & "length output."); begin Base64_Decoder.Process(Input => '6', Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base64_Decoder.State = Failed, "Base64 decoder reset its state on valid input after junk input " & "character."); Assert(Result_Length = 0, "Base64 decoder rejected input after a junk input char but did " & "not return 0 length output."); begin Base64_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base64_Decoder.State = Failed, "Base64 decoder allowed successful completion after junk input " & "char."); Assert(Result_Length = 0, "Base64 decoder completed after a junk input char did " & "not return 0 length output."); end Check_Junk_Rejection_By_Char; end BinToAsc_Suite.Base64_Tests;
with C3GA; with Points; package Geometric_Objects is function Set_Line (L1, L2 : C3GA.Normalized_Point) return C3GA.Line; end Geometric_Objects;
----------------------------------------------------------------------- -- objects.cache -- Object cache -- Copyright (C) 2009, 2010 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. ----------------------------------------------------------------------- -- The <b>ADO.Objects.Cache</b> holds a cache of object records. -- The cache maintains a set of objects that were loaded for a given session. -- -- The cache is not thread-safe. package body ADO.Objects.Cache is -- ------------------------------ -- Insert the object in the cache. -- The reference counter associated with the object is incremented. -- ------------------------------ procedure Insert (Cache : in out Object_Cache; Object : in Object_Record_Access) is Pos : constant Object_Set.Cursor := Cache.Objects.Find (Object); begin if Object_Set.Has_Element (Pos) then declare Current : constant Object_Record_Access := Object_Set.Element (Pos); Is_Zero : Boolean; begin if Current = Object then return; end if; Cache.Objects.Replace_Element (Pos, Object); Util.Concurrent.Counters.Decrement (Current.Counter, Is_Zero); if Is_Zero then Destroy (Current); end if; end; else Cache.Objects.Insert (Object); end if; Util.Concurrent.Counters.Increment (Object.Counter); end Insert; -- ------------------------------ -- Insert the object in the cache -- The reference counter associated with the object is incremented. -- ------------------------------ procedure Insert (Cache : in out Object_Cache; Object : in Object_Ref'Class) is begin if Object.Object /= null then Insert (Cache, Object.Object); end if; end Insert; -- ------------------------------ -- Check if the object is contained in the cache -- ------------------------------ function Contains (Cache : in Object_Cache; Key : in Object_Key) return Boolean is pragma Unreferenced (Cache, Key); begin return False; end Contains; function Find (Cache : in Object_Cache; Key : in Object_Key) return Object_Record_Access is pragma Unreferenced (Cache, Key); begin return null; end Find; procedure Find (Cache : in Object_Cache; Object : in out Object_Ref'Class; Key : in Object_Key) is pragma Unreferenced (Cache, Object, Key); begin null; end Find; -- ------------------------------ -- Remove the object from the cache. The reference counter associated -- with the object is decremented. -- Do nothing if the object is not in the cache. -- ------------------------------ procedure Remove (Cache : in out Object_Cache; Object : in Object_Record_Access) is Pos : Object_Set.Cursor := Cache.Objects.Find (Object); begin if Object_Set.Has_Element (Pos) then declare Current : constant Object_Record_Access := Object_Set.Element (Pos); Is_Zero : Boolean; begin Cache.Objects.Delete (Pos); Util.Concurrent.Counters.Decrement (Current.Counter, Is_Zero); if Is_Zero then Destroy (Current); end if; end; end if; end Remove; -- ------------------------------ -- Remove all object in the cache. -- ------------------------------ procedure Remove_All (Cache : in out Object_Cache) is pragma Unreferenced (Cache); begin null; end Remove_All; -- ------------------------------ -- Remove the object from the cache. -- Do nothing if the object is not in the cache. -- ------------------------------ procedure Remove (Cache : in out Object_Cache; Object : in Object_Ref) is begin if Object.Object /= null then Remove (Cache, Object.Object); end if; end Remove; -- ------------------------------ -- Remove the object from the cache. -- Do nothing if the object is not in the cache. -- ------------------------------ procedure Remove (Cache : in out Object_Cache; Object : in Object_Key) is pragma Unreferenced (Cache, Object); -- Item : aliased Object_Record (Key_Type => Object.Of_Type); begin -- Item.Key := Object; -- Remove (Cache, Item'Unchecked_Access); null; end Remove; -- ------------------------------ -- The cache is a <b>Hashed_Set</b> in which the object record pointers -- are stored. The hash and comparison methods are based on the object key -- and object type. -- ------------------------------ function Hash (Item : Object_Record_Access) return Hash_Type is begin if Item = null then return 0; else return Hash (Item.Key); end if; end Hash; -- ------------------------------ -- Compare whether the two objects pointed to by Left and Right have the same -- object key. -- ------------------------------ function Equivalent_Elements (Left, Right : Object_Record_Access) return Boolean is begin if Left = Right then return True; end if; if Left = null or else Right = null then return False; end if; if Left.all'Size /= Right.all'Size then return False; end if; if Left.Key /= Right.Key then return False; end if; return True; end Equivalent_Elements; -- ------------------------------ -- Finalize the object cache by removing all entries -- ------------------------------ overriding procedure Finalize (Cache : in out Object_Cache) is begin Remove_All (Cache); end Finalize; end ADO.Objects.Cache;
with STM32.Device; use STM32.Device; with STM32.Timers; use STM32.Timers; package body Inverter_ADC is function To_Voltage (Value : in UInt16) return Voltage with Inline; procedure Initialize_ADC_Timer; -- Initialize the timer to start ADCs convertions. -------------------- -- Initialize_ADC -- -------------------- procedure Initialize_ADC is All_Regular_Conversions : constant Regular_Channel_Conversions := (1 => (Channel => ADC_Battery_V_Point.Channel, Sample_Time => Sample_32P5_Cycles), 2 => (Channel => ADC_Battery_I_Point.Channel, Sample_Time => Sample_32P5_Cycles), 3 => (Channel => ADC_Output_V_Point.Channel, Sample_Time => Sample_32P5_Cycles)); begin -- Initialize GPIO for analog input for Reading of ADC_Reading_Settings loop STM32.Device.Enable_Clock (Reading.GPIO_Entry); Reading.GPIO_Entry.Configure_IO (Config => GPIO_Port_Configuration'(Mode => Mode_Analog, others => <>)); end loop; -- Select clock source for ADCs (PLL2 is already on). Select_Clock_Source (Sensor_ADC.all, Source => PLL2P); -- Initialize ADC mode Enable_Clock (Sensor_ADC.all); Reset_All_ADC_Units; Configure_Common_Properties (Sensor_ADC.all, Mode => Independent, Prescaler => Div_2, Clock_Mode => Asynchronous, DMA_Mode => Regular_Data_In_DR, Sampling_Delay => Sampling_Delay_5_Cycles); -- arbitrary Configure_Unit (Sensor_ADC.all, Resolution => ADC_Resolution_12_Bits, Alignment => Right_Aligned); -- Conversions are triggered by Sensor Timer. Configure_Regular_Conversions (Sensor_ADC.all, Continuous => False, -- externally triggered Trigger => (Enabler => Trigger_Rising_Edge, Event => Sensor_Trigger_Event), Conversions => All_Regular_Conversions); -- Either rising or falling edge should work. Note that the Event must -- match the timer used! Enable_Interrupts (Sensor_ADC.all, Source => Regular_Channel_Conversion_Complete); -- Each conversion generates an interrupt signalling conversion complete. -- Finally, enable the used ADCs Enable (Sensor_ADC.all); -- Start the timer that trigger ADC conversions Initialize_ADC_Timer; Initialized := True; end Initialize_ADC; -------------------------- -- Initialize_ADC_Timer -- -------------------------- procedure Initialize_ADC_Timer is ADC_Timer : constant access Timer := Sensor_Timer'Access; Computed_Prescaler : UInt32; Computed_Period : UInt32; begin -- Initialize the sensor timer Enable_Clock (ADC_Timer.all); Compute_Prescaler_And_Period (ADC_Timer, Requested_Frequency => Sensor_Frequency_Hz, Prescaler => Computed_Prescaler, Period => Computed_Period); Computed_Period := Computed_Period - 1; Configure (ADC_Timer.all, Prescaler => UInt16 (Computed_Prescaler), Period => Computed_Period, Clock_Divisor => Div1, Counter_Mode => Up); Select_Output_Trigger (ADC_Timer.all, Update); Enable (ADC_Timer.all); end Initialize_ADC_Timer; ---------------- -- To_Voltage -- ---------------- function To_Voltage (Value : in UInt16) return Voltage is begin return Voltage (ADC_V_Per_Lsb * Float (Value)); end To_Voltage; ---------------- -- Get_Sample -- ---------------- function Get_Sample (Reading : in ADC_Reading) return Voltage is begin if Reading'Valid then return To_Voltage (Regular_Samples (Reading)); else return 0.0; end if; end Get_Sample; ------------------ -- Battery_Gain -- ------------------ -- Battery gain is 1.0 when battery voltage is minimum -- and 0.667 when battery voltage is maximum. function Battery_Gain (V_Setpoint : Battery_V_Range := Battery_V_Range'First; V_Actual : Voltage := Get_Sample (V_Battery)) return Gain_Range is begin if (V_Actual / Battery_Relation < Battery_V_Range'First) then return 0.0; elsif (V_Actual / Battery_Relation > Battery_V_Range'Last) then return 1.0; else return V_Setpoint / V_Actual * Battery_Relation; end if; end Battery_Gain; -------------------- -- Test_V_Battery -- -------------------- function Test_V_Battery return Boolean is V_Actual : constant Voltage := Get_Sample (Reading => V_Battery); begin if (V_Actual / Battery_Relation < Battery_V_Range'First or V_Actual / Battery_Relation > Battery_V_Range'Last) then return False; else return True; end if; end Test_V_Battery; -------------------- -- Test_I_Battery -- -------------------- function Test_I_Battery return Boolean is V_Actual : constant Voltage := Get_Sample (Reading => I_Battery); begin if V_Actual > Battery_I_Range'Last then return False; else return True; end if; end Test_I_Battery; ------------------- -- Test_V_Output -- ------------------- function Test_V_Output return Boolean is V_Actual : constant Voltage := Get_Sample (Reading => V_Output); begin if (V_Actual / Output_Relation < Output_V_Range'First or V_Actual / Output_Relation > Output_V_Range'Last) then return False; else return True; end if; end Test_V_Output; -------------------- -- Is_Initialized -- -------------------- function Is_Initialized return Boolean is (Initialized); -------------------- -- Sensor Handler -- -------------------- protected body Sensor_Handler is ------------------------ -- Sensor_ADC_Handler -- ------------------------ procedure Sensor_ADC_Handler is begin if Status (Sensor_ADC.all, Flag => Regular_Channel_Conversion_Completed) then if Interrupt_Enabled (Sensor_ADC.all, Source => Regular_Channel_Conversion_Complete) then Clear_Interrupt_Pending (Sensor_ADC.all, Source => Regular_Channel_Conversion_Complete); -- Save the ADC values into a buffer Regular_Samples (Rank) := UInt16 (Conversion_Value (Sensor_ADC.all)); if Rank = ADC_Reading'Last then Rank := ADC_Reading'First; else Rank := ADC_Reading'Succ (Rank); end if; -- Calculate the new Sine_Gain based on battery voltage Sine_Gain := Battery_Gain; -- Testing the 5 kHz output with 1 Hz LED blinking. Because -- there are three regular channel conversions, this frequency -- will be three times greater. -- if Counter = 2_500 then -- Set_Toggle (Green_LED); -- Counter := 0; -- end if; -- Counter := Counter + 1; end if; end if; end Sensor_ADC_Handler; end Sensor_Handler; end Inverter_ADC;
-- -- Radoslaw Kowalski 221454 -- with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Calendar; with Rails; use Rails; package Trains is package Calendar renames Ada.Calendar; type Train (Route_Length: Integer) is record Id : Integer; Name : SU.Unbounded_String; Speed : Integer; Capacity : Integer; Route : Route_Array(1 .. Route_Length); Index : Integer; Att : Track_Ptr; end record; type Train_Ptr is access Train; procedure Connection(Self: Train_Ptr; From, To : out Track_Ptr); function Move_To(Self: Train_Ptr; T : Track_Ptr) return Float; function As_String(Self: Train_Ptr) return String; function As_Verbose_String(Self: Train_Ptr) return String; type Trains_Array is array(Integer range<>) of Train_Ptr; type Trains_Ptr is access Trains_Array; function New_Train ( Id : Integer; Name : SU.Unbounded_String; Speed : Integer; Capacity : Integer; Route : Route_Array) return Train_Ptr; task type Simulation is entry Init(S : Calendar.Time; SPH : Integer; H : Integer; M : Integer; V : Boolean); entry Simulate(T : in Train_Ptr; C : in Connections_Ptr); end Simulation; type Simulation_Ptr is access Simulation; type Time_Component_Type is delta 1.0 digits 2 range 0.0 .. 60.0; end Trains;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Incr.Lexers.Batch_Lexers is ------------------------- -- Get_Start_Condition -- ------------------------- function Get_Start_Condition (Self : Batch_Lexer'Class) return State is begin return Self.Start; end Get_Start_Condition; -------------- -- Get_Text -- -------------- function Get_Text (Self : Batch_Lexer'Class) return League.Strings.Universal_String is begin return League.Strings.To_Universal_String (Self.Buffer (1 .. Self.To)); end Get_Text; ---------------------- -- Get_Token_Length -- ---------------------- function Get_Token_Length (Self : Batch_Lexer'Class) return Positive is begin return Self.To; end Get_Token_Length; ------------------------- -- Get_Token_Lookahead -- ------------------------- function Get_Token_Lookahead (Self : Batch_Lexer'Class) return Positive is begin return Self.Next - 1; end Get_Token_Lookahead; ---------------- -- Set_Source -- ---------------- procedure Set_Source (Self : in out Batch_Lexer'Class; Source : not null Source_Access) is begin Self.Source := Source; Self.Next := 1; Self.To := 0; end Set_Source; ------------------------- -- Set_Start_Condition -- ------------------------- procedure Set_Start_Condition (Self : in out Batch_Lexer'Class; Condition : State) is begin Self.Start := Condition; end Set_Start_Condition; end Incr.Lexers.Batch_Lexers;
-- -- Copyright (C) 2021 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- -- Adafruit 16x8 LED Matrix Driver Backpack - HT16K33 Breakout -- https://www.adafruit.com/product/1427 -- with HAL; use HAL; with HT16K33; package Seven is type Device is new HT16K33.Device with private; subtype Position is Integer range 1 .. 4; subtype Digit is Integer range 0 .. 9; subtype Point_Number is Integer range 1 .. 4; procedure Set_Digit (This : in out Device; Pos : Position; Val : Digit); procedure Set_Colon (This : in out Device; On : Boolean); procedure Set_Point (This : in out Device; Num : Point_Number; On : Boolean); private Numbers : constant array (Digit) of UInt8 := (0 => 16#3F#, 1 => 16#06#, 2 => 16#5B#, 3 => 16#4F#, 4 => 16#66#, 5 => 16#6D#, 6 => 16#7D#, 7 => 16#07#, 8 => 16#7F#, 9 => 16#6F#); Points : constant array (Point_Number) of HT16K33.Output_Index := (7, 23, 55, 71); type Device is new HT16K33.Device with null record; end Seven;
pragma Style_Checks (Off); with CSS.Analysis.Parser.Lexer_dfa; use CSS.Analysis.Parser.Lexer_dfa; -- Warning: This file is automatically generated by AFLEX. -- It is useless to modify it. Change the ".Y" & ".L" files instead. with Text_IO; use Text_IO; package CSS.Analysis.Parser.Lexer_io is -- Warning: This file is automatically generated by AFLEX. -- It is useless to modify it. Change the ".Y" & ".L" files instead. user_input_file : file_type; user_output_file : file_type; NULL_IN_INPUT : exception; AFLEX_INTERNAL_ERROR : exception; UNEXPECTED_LAST_MATCH : exception; PUSHBACK_OVERFLOW : exception; AFLEX_SCANNER_JAMMED : exception; type eob_action_type is ( EOB_ACT_RESTART_SCAN, EOB_ACT_END_OF_FILE, EOB_ACT_LAST_MATCH ); YY_END_OF_BUFFER_CHAR : constant character:= ASCII.NUL; yy_n_chars : integer; -- number of characters read into yy_ch_buf -- true when we've seen an EOF for the current input file yy_eof_has_been_seen : boolean; procedure YY_INPUT (buf: out unbounded_character_array; result: out integer; max_size: in integer); function yy_get_next_buffer return eob_action_type; procedure yyUnput ( c : Character; yy_bp: in out Integer ); procedure Unput (c : Character); function Input return Character; procedure Output (c : Character); procedure Output_New_Line; function Output_Column return Text_IO.Count; function Input_Line return Text_IO.Count; function yyWrap return Boolean; procedure Open_Input (fname : in String); procedure Close_Input; procedure Create_Output (fname : in String := ""); procedure Close_Output; end CSS.Analysis.Parser.Lexer_io;
----------------------------------------------------------------------- -- net-headers -- Network headers -- Copyright (C) 2016 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. ----------------------------------------------------------------------- package Net.Headers is pragma Preelaborate; -- Convert integers to network byte order. function To_Network (Val : in Uint32) return Uint32; function To_Network (Val : in Uint16) return Uint16; -- Convert integers to host byte order. function To_Host (Val : in Uint32) return Uint32; function To_Host (Val : in Uint16) return Uint16; -- Ethernet header as defined for 802.3 Ethernet packet. type Ether_Header is record Ether_Dhost : Ether_Addr; Ether_Shost : Ether_Addr; Ether_Type : Uint16; end record; type Ether_Header_Access is access all Ether_Header; type Arp_Header is record Ar_Hdr : Uint16; Ar_Pro : Uint16; Ar_Hln : Uint8; Ar_Pln : Uint8; Ar_Op : Uint16; end record; type Ether_Arp is record Ea_Hdr : Arp_Header; Arp_Sha : Ether_Addr; Arp_Spa : Ip_Addr; Arp_Tha : Ether_Addr; Arp_Tpa : Ip_Addr; end record; type Ether_Arp_Access is access all Ether_Arp; -- ARP Ethernet packet type Arp_Packet is record Ethernet : Net.Headers.Ether_Header; Arp : Net.Headers.Ether_Arp; end record; type Arp_Packet_Access is access all Arp_Packet; -- IP packet header RFC 791. type IP_Header is record Ip_Ihl : Uint8; Ip_Tos : Uint8; Ip_Len : Uint16; Ip_Id : Uint16; Ip_Off : Uint16; Ip_Ttl : Uint8; Ip_P : Uint8; Ip_Sum : Uint16; Ip_Src : Ip_Addr; Ip_Dst : Ip_Addr; end record; type IP_Header_Access is access all IP_Header; -- UDP packet header RFC 768. type UDP_Header is record Uh_Sport : Uint16; Uh_Dport : Uint16; Uh_Ulen : Uint16; Uh_Sum : Uint16; end record; type UDP_Header_Access is access all UDP_Header; -- IGMP v2 packet header RFC 2236. type IGMP_Header is record Igmp_Type : Uint8; Igmp_Code : Uint8; Igmp_Cksum : Uint16; Igmp_Group : Ip_Addr; end record; type IGMP_Header_Access is access all IGMP_Header; IGMP_MEMBERSHIP_QUERY : constant Uint8 := 16#11#; IGMP_V1_MEMBERSHIP_REPORT : constant Uint8 := 16#12#; IGMP_V2_MEMBERSHIP_REPORT : constant Uint8 := 16#16#; IGMP_V3_MEMBERSHIP_REPORT : constant Uint8 := 16#22#; -- RFC 3376. IGMP_V2_LEAVE_GROUP : constant Uint8 := 16#17#; IGMP_DVMRP : constant Uint8 := 16#13#; IGMP_PIM : constant Uint8 := 16#14#; type TCP_Header is record Th_Sport : Uint16; Th_Dport : Uint16; Th_Seq : Uint32; Th_Ack : Uint32; Th_Off : Uint8; Th_Flags : Uint8; Th_Win : Uint16; Th_Sum : Uint16; Th_Urp : Uint16; end record; type TCP_Header_Access is access all TCP_Header; ICMP_ECHO_REPLY : constant Uint8 := 0; ICMP_UNREACHABLE : constant Uint8 := 3; ICMP_ECHO_REQUEST : constant Uint8 := 8; type ICMP_Header is record Icmp_Type : Uint8; Icmp_Code : Uint8; Icmp_Checksum : Uint16; Icmp_Id : Uint16; -- This should be an union Icmp_Seq : Uint16; end record; type ICMP_Header_Access is access all ICMP_Header; -- DHCP header as defined by RFC 1541. type DHCP_Header is record Op : Uint8; Htype : Uint8; Hlen : Uint8; Hops : Uint8; Xid1 : Uint16; Xid2 : Uint16; Secs : Uint16; Flags : Uint16; Ciaddr : Ip_Addr; Yiaddr : Ip_Addr; Siaddr : Ip_Addr; Giaddr : Ip_Addr; Chaddr : String (1 .. 16); Sname : String (1 .. 64); File : String (1 .. 128); end record; type DHCP_Header_Access is access all DHCP_Header; for DHCP_Header use record Op at 0 range 0 .. 7; Htype at 1 range 0 .. 7; Hlen at 2 range 0 .. 7; Hops at 3 range 0 .. 7; Xid1 at 4 range 0 .. 15; Xid2 at 6 range 0 .. 15; Secs at 8 range 0 .. 15; Flags at 10 range 0 .. 15; Ciaddr at 12 range 0 .. 31; Yiaddr at 16 range 0 .. 31; Siaddr at 20 range 0 .. 31; Giaddr at 24 range 0 .. 31; Chaddr at 28 range 0 .. 127; Sname at 44 range 0 .. 511; File at 108 range 0 .. 1023; end record; end Net.Headers;
generic type I is interface; with procedure P (X : I) is abstract; package gen_interface_p is end;
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C.Strings; package body SDL.Events.Keyboards is package C renames Interfaces.C; function Value (Name : in String) return SDL.Events.Keyboards.Scan_Codes is function SDL_Get_Scan_Code_From_Name (Name : in C.char_array) return SDL.Events.Keyboards.Scan_Codes with Import => True, Convention => C, External_Name => "SDL_GetScancodeFromName"; begin return SDL_Get_Scan_Code_From_Name (C.To_C (Name)); end Value; function Image (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return String is function SDL_Get_Scan_Code_Name (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetScancodeName"; begin return C.Strings.Value (SDL_Get_Scan_Code_Name (Scan_Code)); end Image; function Value (Name : in String) return SDL.Events.Keyboards.Key_Codes is function SDL_Get_Key_From_Name (Name : in C.char_array) return SDL.Events.Keyboards.Key_Codes with Import => True, Convention => C, External_Name => "SDL_GetKeyFromName"; begin return SDL_Get_Key_From_Name (C.To_C (Name)); end Value; function Image (Key_Code : in SDL.Events.Keyboards.Key_Codes) return String is function SDL_Get_Key_Name (Key_Code : in SDL.Events.Keyboards.Key_Codes) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetKeyName"; begin return C.Strings.Value (SDL_Get_Key_Name (Key_Code)); end Image; function To_Key_Code (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return SDL.Events.Keyboards.Key_Codes is function SDL_Get_Key_From_Scan_Code (Scan_Code : in SDL.Events.Keyboards.Scan_Codes) return SDL.Events.Keyboards.Key_Codes with Import => True, Convention => C, External_Name => "SDL_GetKeyFromScancode"; begin return SDL_Get_Key_From_Scan_Code (Scan_Code); end To_Key_Code; function To_Scan_Code (Key_Code : in SDL.Events.Keyboards.Key_Codes) return SDL.Events.Keyboards.Scan_Codes is function SDL_Get_Scan_Code_From_Key (Key_Code : in SDL.Events.Keyboards.Key_Codes) return SDL.Events.Keyboards.Scan_Codes with Import => True, Convention => C, External_Name => "SDL_GetScancodeFromKey"; begin return SDL_Get_Scan_Code_From_Key (Key_Code); end To_Scan_Code; end SDL.Events.Keyboards;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Real_Time; use Ada.Real_Time; procedure ExecutionTimes is package Duration_IO is new Ada.Text_IO.Fixed_IO(Duration); package Int_IO is new Ada.Text_IO.Integer_IO(Integer); function F(N : Integer) return Integer; function F(N : Integer) return Integer is X : Integer := 0; begin for Index in 1..N loop for I in 1..5000000 loop --execution time calculated for this loop X := I; end loop; end loop; return X; end F; Start : Time; Dummy : Integer; begin Put_Line("Measurement of Execution Times"); Put_Line(""); for Index in 1..50 loop Start := Clock; Dummy := F(Index); Int_IO.Put(Index, 3); Put(" : "); Duration_IO.Put(To_Duration(Clock - Start), 3, 3); Put_Line("s"); end loop; end ExecutionTimes;
----------------------------------------------------------------------- -- wiki-filters-html -- Wiki HTML filters -- Copyright (C) 2015, 2016, 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. ----------------------------------------------------------------------- private with Ada.Containers.Vectors; -- === HTML Filters === -- The `Wiki.Filters.Html` package implements a customizable HTML filter that verifies -- the HTML content embedded in the Wiki text. The HTML filter can be customized to indicate -- the HTML tags that must be accepted or ignored. By default, the filter accepts all HTML -- tags except 'script', 'noscript', 'style'. -- -- * A tag can be `Forbidden` in which case it is not passed to the document. -- If this tag contains inner HTML elements, they are passed to the document. -- By default, the `html`, `head`, `meta`, `title`, `script`, `body` are not -- passed to the document. -- * A tag can be `Hidden` in which case it is not passed to the document and -- the inner HTML elements it contains are also silently ignored. -- By default this is the case for `script`, `noscript` and `style`. -- -- The HTML filter may be declared and configured as follows: -- -- F : aliased Wiki.Filters.Html.Html_Filter_Type; -- ... -- F.Forbidden (Wiki.Filters.Html.A_TAG); -- -- With this configuration the HTML links will be ignored by the parser. -- The following configuration: -- -- F.Hide (Wiki.Filters.Html.TABLE_TAG); -- -- will remove the table and its content. -- -- The filter is added to the Wiki parser filter chain by using the <tt>Add_Filter</tt> -- operation: -- -- Engine.Add_Filter (F'Unchecked_Access); -- -- package Wiki.Filters.Html is -- ------------------------------ -- Filter type -- ------------------------------ type Html_Filter_Type is new Filter_Type with private; -- Add a simple node such as N_LINE_BREAK, N_HORIZONTAL_RULE or N_PARAGRAPH to the document. overriding procedure Add_Node (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Kind : in Wiki.Nodes.Simple_Node_Kind); -- Add a text content with the given format to the document. overriding procedure Add_Text (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Text : in Wiki.Strings.WString; Format : in Wiki.Format_Map); -- Add a section header with the given level in the document. overriding procedure Add_Header (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Header : in Wiki.Strings.WString; Level : in Natural); -- Push a HTML node with the given tag to the document. overriding procedure Push_Node (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Tag : in Wiki.Html_Tag; Attributes : in out Wiki.Attributes.Attribute_List); -- Pop a HTML node with the given tag. overriding procedure Pop_Node (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Tag : in Wiki.Html_Tag); -- Add a link. overriding procedure Add_Link (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Add an image. overriding procedure Add_Image (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Finish the document after complete wiki text has been parsed. overriding procedure Finish (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document); -- Mark the HTML tag as being forbidden. procedure Forbidden (Filter : in out Html_Filter_Type; Tag : in Html_Tag); -- Mark the HTML tag as being allowed. procedure Allowed (Filter : in out Html_Filter_Type; Tag : in Html_Tag); -- Mark the HTML tag as being hidden. The tag and its inner content including the text -- will be removed and not passed to the final document. procedure Hide (Filter : in out Html_Filter_Type; Tag : in Html_Tag); -- Mark the HTML tag as being visible. procedure Visible (Filter : in out Html_Filter_Type; Tag : in Html_Tag); -- Flush the HTML element that have not yet been closed. procedure Flush_Stack (Filter : in out Html_Filter_Type; Document : in out Wiki.Documents.Document); private use Wiki.Nodes; package Tag_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Html_Tag); subtype Tag_Vector is Tag_Vectors.Vector; subtype Tag_Cursor is Tag_Vectors.Cursor; type Html_Filter_Type is new Filter_Type with record Allowed : Tag_Boolean_Array := (UNKNOWN_TAG => False, SCRIPT_TAG => False, ROOT_HTML_TAG => False, HEAD_TAG => False, BODY_TAG => False, META_TAG => False, TITLE_TAG => False, others => True); Hidden : Tag_Boolean_Array := (UNKNOWN_TAG => False, SCRIPT_TAG => True, STYLE_TAG => True, NOSCRIPT_TAG => True, others => False); Stack : Tag_Vector; Hide_Level : Natural := 0; end record; end Wiki.Filters.Html;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J . P A R T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-2013, 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. -- -- -- ------------------------------------------------------------------------------ -- Implements the parsing of project files into a tree with Prj.Tree; use Prj.Tree; package Prj.Part is type Errout_Mode is (Always_Finalize, Finalize_If_Error, Never_Finalize); -- Whether Parse should call Errout.Finalize (which prints the error -- messages on stdout). When Never_Finalize is used, Errout is not reset -- either at the beginning of Parse. procedure Parse (In_Tree : Project_Node_Tree_Ref; Project : out Project_Node_Id; Project_File_Name : String; Errout_Handling : Errout_Mode := Always_Finalize; Packages_To_Check : String_List_Access; Store_Comments : Boolean := False; Current_Directory : String := ""; Is_Config_File : Boolean; Env : in out Prj.Tree.Environment; Target_Name : String := ""; Implicit_Project : Boolean := False); -- Parse project file and all its imported project files and create a tree. -- Return the node for the project (or Empty_Node if parsing failed). If -- Always_Errout_Finalize is True, Errout.Finalize is called in all cases, -- Otherwise, Errout.Finalize is only called if there are errors (but not -- if there are only warnings). Packages_To_Check indicates the packages -- where any unknown attribute produces an error. For other packages, an -- unknown attribute produces a warning. When Store_Comments is True, -- comments are stored in the parse tree. -- -- Current_Directory is used for optimization purposes only, avoiding extra -- system calls. -- -- Is_Config_File should be set to True if the project represents a config -- file (.cgpr) since some specific checks apply. -- -- Target_Name will be used to initialize the default project path, unless -- In_Tree.Project_Path has already been initialized (which is the -- recommended use). -- -- If Implicit_Project is True, the main project file being parsed is -- deemed to be in the current working directory, even if it is not the -- case. Implicit_Project is set to True when a tool such as gprbuild is -- invoked without a project file and is using an implicit project file -- that is virtually in the current working directory, but is physically -- in another directory. end Prj.Part;
-- { dg-do run } with Init12; use Init12; with Text_IO; use Text_IO; with Dump; procedure S12 is A11 : Arr11 := My_A11; A22 : Arr22 := My_A22; A1 : Arr1; A2 : Arr2; C1 : Integer; C2 : Integer; C3 : Integer; begin Put ("A11 :"); Dump (A11'Address, Arr11'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A11 : 12 00 ab 00 34 00 cd 00 12 00 ab 00 34 00 cd 00.*\n" } Put ("A22 :"); Dump (A22'Address, Arr22'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A22 : 00 ab 00 12 00 cd 00 34 00 ab 00 12 00 cd 00 34.*\n" } A1 := (A11(1,1), A11(1,2), A11(2,1)); C1 := A1(1); C2 := A1(2); C3 := A1(3); Put_Line("C1 :" & C1'Img); -- { dg-output "C1 : 11206674.*\n" } Put_Line("C2 :" & C2'Img); -- { dg-output "C2 : 13434932.*\n" } Put_Line("C3 :" & C3'Img); -- { dg-output "C3 : 11206674.*\n" } A1(1) := C1; A1(2) := C2; A1(3) := C3; A11(1,1) := A1(1); A11(1,2) := A1(2); A11(2,1) := A1(3); A2 := (A22(1,1), A22(1,2), A22(2,1)); C1 := A2(1); C2 := A2(2); C3 := A2(3); Put_Line("C1 :" & C1'Img); -- { dg-output "C1 : 11206674.*\n" } Put_Line("C2 :" & C2'Img); -- { dg-output "C2 : 13434932.*\n" } Put_Line("C3 :" & C3'Img); -- { dg-output "C3 : 11206674.*\n" } A2(1) := C1; A2(2) := C2; A2(3) := C3; A22(1,1) := A2(1); A22(1,2) := A2(2); A22(2,1) := A2(3); Put ("A11 :"); Dump (A11'Address, Arr11'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A11 : 12 00 ab 00 34 00 cd 00 12 00 ab 00 34 00 cd 00.*\n" } Put ("A22 :"); Dump (A22'Address, Arr22'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "A22 : 00 ab 00 12 00 cd 00 34 00 ab 00 12 00 cd 00 34.*\n" } end;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, 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.Containers.Hashed_Sets; with Asis.Declarations; with Asis.Elements; with League.Strings.Hash; with Properties.Tools; package body Properties.Declarations.Defining_Names is package String_Maps is new Ada.Containers.Hashed_Sets (Element_Type => League.Strings.Universal_String, Hash => League.Strings.Hash, Equivalent_Elements => League.Strings."=", "=" => League.Strings."="); Reserved : String_Maps.Set; Map : constant array (Asis.Operator_Kinds range Asis.An_And_Operator .. Asis.A_Not_Operator) of League.Strings.Universal_String := (Asis.An_And_Operator => League.Strings.To_Universal_String ("_and"), Asis.An_Or_Operator => League.Strings.To_Universal_String ("_or"), Asis.An_Xor_Operator => League.Strings.To_Universal_String ("_xor"), Asis.An_Equal_Operator => League.Strings.To_Universal_String ("_eq"), Asis.A_Not_Equal_Operator => League.Strings.To_Universal_String ("_ne"), Asis.A_Less_Than_Operator => League.Strings.To_Universal_String ("_lt"), Asis.A_Less_Than_Or_Equal_Operator => League.Strings.To_Universal_String ("_le"), Asis.A_Greater_Than_Operator => League.Strings.To_Universal_String ("_gt"), Asis.A_Greater_Than_Or_Equal_Operator => League.Strings.To_Universal_String ("_ge"), Asis.A_Plus_Operator => League.Strings.To_Universal_String ("_plus"), Asis.A_Minus_Operator => League.Strings.To_Universal_String ("_minus"), Asis.A_Concatenate_Operator => League.Strings.To_Universal_String ("_join"), Asis.A_Unary_Plus_Operator => League.Strings.To_Universal_String ("_nop"), Asis.A_Unary_Minus_Operator => League.Strings.To_Universal_String ("_neg"), Asis.A_Multiply_Operator => League.Strings.To_Universal_String ("_mul"), Asis.A_Divide_Operator => League.Strings.To_Universal_String ("_div"), Asis.A_Mod_Operator => League.Strings.To_Universal_String ("_mod"), Asis.A_Rem_Operator => League.Strings.To_Universal_String ("_rem"), Asis.An_Exponentiate_Operator => League.Strings.To_Universal_String ("_power"), Asis.An_Abs_Operator => League.Strings.To_Universal_String ("_abs"), Asis.A_Not_Operator => League.Strings.To_Universal_String ("_not")); function Get_Name (Name : Asis.Defining_Name) return League.Strings.Universal_String; ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Defining_Name; Name : Engines.Text_Property) return League.Strings.Universal_String is function Is_This return Boolean; function Get_Suffix return League.Strings.Universal_String; function Prev_Subprogram_Count return Natural; function Is_Subprogram (Kind : Asis.Declaration_Kinds) return Boolean; Decl : constant Asis.Declaration := Properties.Tools.Enclosing_Declaration (Element); Kind : constant Asis.Declaration_Kinds := Asis.Elements.Declaration_Kind (Decl); Text : League.Strings.Universal_String := Get_Name (Element); ---------------- -- Get_Suffix -- ---------------- function Get_Suffix return League.Strings.Universal_String is Result : League.Strings.Universal_String; begin if Is_Subprogram (Kind) and then not Asis.Elements.Is_Nil (Asis.Elements.Enclosing_Element (Decl)) then declare Count : constant Natural := Prev_Subprogram_Count; Image : Wide_Wide_String := Natural'Wide_Wide_Image (Count); begin if Count > 0 then Image (1) := '$'; Result.Append (Image); return Result; end if; end; end if; if Reserved.Contains (Text) then Result.Append ("$"); end if; return Result; end Get_Suffix; ------------------- -- Is_Subprogram -- ------------------- function Is_Subprogram (Kind : Asis.Declaration_Kinds) return Boolean is begin return Kind in Asis.A_Procedure_Declaration | Asis.A_Procedure_Body_Declaration | Asis.An_Expression_Function_Declaration | Asis.A_Procedure_Renaming_Declaration | Asis.A_Procedure_Body_Stub | Asis.A_Procedure_Instantiation | Asis.A_Function_Declaration | Asis.A_Function_Body_Declaration | Asis.A_Function_Renaming_Declaration | Asis.A_Function_Body_Stub | Asis.A_Function_Instantiation; end Is_Subprogram; ------------- -- Is_This -- ------------- function Is_This return Boolean is use type Asis.Declaration_Kinds; Proc : Asis.Declaration; begin if Kind = Asis.A_Parameter_Specification then Proc := Asis.Elements.Enclosing_Element (Decl); if Engine.Boolean.Get_Property (Proc, Engines.Is_Dispatching) and then Asis.Elements.Is_Equal (Decl, Asis.Declarations.Parameter_Profile (Proc) (1)) then return True; end if; end if; return False; end Is_This; --------------------------- -- Prev_Subprogram_Count -- --------------------------- function Prev_Subprogram_Count return Natural is Parent : constant Asis.Declaration := Properties.Tools.Enclosing_Declaration (Decl); Kind : constant Asis.Declaration_Kinds := Asis.Elements.Declaration_Kind (Parent); begin case Kind is when Asis.A_Package_Declaration => declare use type Asis.Declaration_List; Result : Natural := 0; List : constant Asis.Declaration_List := Asis.Declarations.Visible_Part_Declarative_Items (Parent) & Asis.Declarations.Private_Part_Declarative_Items (Parent); begin for J in List'Range loop if Asis.Elements.Is_Equal (Decl, List (J)) then return Result; elsif Is_Subprogram (Asis.Elements.Declaration_Kind (List (J))) then declare use type League.Strings.Universal_String; Name : constant Asis.Defining_Name := Asis.Declarations.Names (List (J)) (1); Image : constant League.Strings.Universal_String := Get_Name (Name); begin if Image = Text then Result := Result + 1; end if; end; end if; end loop; return 0; end; when others => return 0; end case; end Prev_Subprogram_Count; Link_Name : constant Wide_String := Properties.Tools.Get_Aspect (Decl, "Link_Name"); Spec : constant Asis.Declaration := (if Is_Subprogram (Kind) then Asis.Declarations.Corresponding_Declaration (Decl) else Asis.Nil_Element); begin if Link_Name = "" then if Is_This then return League.Strings.To_Universal_String ("this"); elsif not Asis.Elements.Is_Nil (Spec) and then Kind not in Asis.A_Generic_Instantiation and then not Asis.Elements.Is_Equal (Decl, Spec) then -- If this is subprogram body, return name of its specification return Engine.Text.Get_Property (Asis.Declarations.Names (Spec) (1), Name); end if; Text.Append (Get_Suffix); else Text := League.Strings.From_UTF_16_Wide_String (Link_Name); end if; return Text; end Code; -------------- -- Get_Name -- -------------- function Get_Name (Name : Asis.Defining_Name) return League.Strings.Universal_String is begin case Asis.Elements.Defining_Name_Kind (Name) is when Asis.A_Defining_Operator_Symbol => return Map (Asis.Elements.Operator_Kind (Name)); when others => declare Image : constant Wide_String := Asis.Declarations.Defining_Name_Image (Name); Text : constant League.Strings.Universal_String := League.Strings.From_UTF_16_Wide_String (Image) .To_Lowercase; begin return Text; end; end case; end Get_Name; ----------------- -- Method_Name -- ----------------- function Method_Name (Engine : access Engines.Contexts.Context; Element : Asis.Defining_Name; Name : Engines.Text_Property) return League.Strings.Universal_String is pragma Unreferenced (Engine, Name); Decl : constant Asis.Declaration := Properties.Tools.Enclosing_Declaration (Element); Link_Name : constant Wide_String := Properties.Tools.Get_Aspect (Decl, "Link_Name"); Text : League.Strings.Universal_String := Get_Name (Element); begin if Link_Name /= "" then Text := League.Strings.From_UTF_16_Wide_String (Link_Name); end if; return Text; end Method_Name; begin Reserved.Insert (League.Strings.To_Universal_String ("break")); Reserved.Insert (League.Strings.To_Universal_String ("case")); Reserved.Insert (League.Strings.To_Universal_String ("class")); Reserved.Insert (League.Strings.To_Universal_String ("catch")); Reserved.Insert (League.Strings.To_Universal_String ("const")); Reserved.Insert (League.Strings.To_Universal_String ("continue")); Reserved.Insert (League.Strings.To_Universal_String ("debugger")); Reserved.Insert (League.Strings.To_Universal_String ("default")); Reserved.Insert (League.Strings.To_Universal_String ("delete")); Reserved.Insert (League.Strings.To_Universal_String ("do")); Reserved.Insert (League.Strings.To_Universal_String ("else")); Reserved.Insert (League.Strings.To_Universal_String ("export")); Reserved.Insert (League.Strings.To_Universal_String ("extends")); Reserved.Insert (League.Strings.To_Universal_String ("finally")); Reserved.Insert (League.Strings.To_Universal_String ("for")); Reserved.Insert (League.Strings.To_Universal_String ("function")); Reserved.Insert (League.Strings.To_Universal_String ("if")); Reserved.Insert (League.Strings.To_Universal_String ("import")); Reserved.Insert (League.Strings.To_Universal_String ("in")); Reserved.Insert (League.Strings.To_Universal_String ("instanceof")); Reserved.Insert (League.Strings.To_Universal_String ("let")); Reserved.Insert (League.Strings.To_Universal_String ("new")); Reserved.Insert (League.Strings.To_Universal_String ("return")); Reserved.Insert (League.Strings.To_Universal_String ("super")); Reserved.Insert (League.Strings.To_Universal_String ("switch")); Reserved.Insert (League.Strings.To_Universal_String ("this")); Reserved.Insert (League.Strings.To_Universal_String ("throw")); Reserved.Insert (League.Strings.To_Universal_String ("try")); Reserved.Insert (League.Strings.To_Universal_String ("typeof")); Reserved.Insert (League.Strings.To_Universal_String ("var")); Reserved.Insert (League.Strings.To_Universal_String ("void")); Reserved.Insert (League.Strings.To_Universal_String ("while")); Reserved.Insert (League.Strings.To_Universal_String ("with")); Reserved.Insert (League.Strings.To_Universal_String ("yield")); Reserved.Insert (League.Strings.To_Universal_String ("self")); end Properties.Declarations.Defining_Names;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Elements.Defining_Identifiers; with Program.Lexical_Elements; with Program.Elements.Subtype_Indications; with Program.Elements.Expressions; package Program.Elements.Element_Iterator_Specifications is pragma Pure (Program.Elements.Element_Iterator_Specifications); type Element_Iterator_Specification is limited interface and Program.Elements.Declarations.Declaration; type Element_Iterator_Specification_Access is access all Element_Iterator_Specification'Class with Storage_Size => 0; not overriding function Name (Self : Element_Iterator_Specification) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; not overriding function Subtype_Indication (Self : Element_Iterator_Specification) return not null Program.Elements.Subtype_Indications .Subtype_Indication_Access is abstract; not overriding function Iterable_Name (Self : Element_Iterator_Specification) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Has_Reverse (Self : Element_Iterator_Specification) return Boolean is abstract; type Element_Iterator_Specification_Text is limited interface; type Element_Iterator_Specification_Text_Access is access all Element_Iterator_Specification_Text'Class with Storage_Size => 0; not overriding function To_Element_Iterator_Specification_Text (Self : in out Element_Iterator_Specification) return Element_Iterator_Specification_Text_Access is abstract; not overriding function Colon_Token (Self : Element_Iterator_Specification_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Of_Token (Self : Element_Iterator_Specification_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Reverse_Token (Self : Element_Iterator_Specification_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Element_Iterator_Specifications;
-- Mojang Authentication API -- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) -- -- OpenAPI spec version: 2020_06_05 -- -- -- NOTE: This package is auto generated by the swagger code generator 3.3.4. -- https://openapi-generator.tech -- Do not edit the class manually. with Swagger.Streams; with Ada.Containers.Vectors; package com.github.asyncmc.mojang.authentication.ada.model.Models is type Error_Type is record Error : Swagger.Nullable_UString; Error_Message : Swagger.Nullable_UString; end record; package Error_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Error_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Error_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Error_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Error_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Error_Type_Vectors.Vector); type GameProfileProperty_Type is record Name : Swagger.Nullable_UString; Value : Swagger.Nullable_UString; end record; package GameProfileProperty_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => GameProfileProperty_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in GameProfileProperty_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in GameProfileProperty_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out GameProfileProperty_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out GameProfileProperty_Type_Vectors.Vector); type PrivateUserData_Type is record Id : Swagger.Nullable_UString; Properties : com.github.asyncmc.mojang.authentication.ada.model.Models.GameProfileProperty_Type_Vectors.Vector; end record; package PrivateUserData_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => PrivateUserData_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in PrivateUserData_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in PrivateUserData_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out PrivateUserData_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out PrivateUserData_Type_Vectors.Vector); type ReducedUserData_Type is record Id : Swagger.Nullable_UString; Properties : com.github.asyncmc.mojang.authentication.ada.model.Models.GameProfileProperty_Type_Vectors.Vector; end record; package ReducedUserData_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ReducedUserData_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ReducedUserData_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ReducedUserData_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ReducedUserData_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ReducedUserData_Type_Vectors.Vector); type Agent_Type is record Name : Swagger.Nullable_UString; Version : Swagger.Nullable_Integer; end record; package Agent_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Agent_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Agent_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Agent_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Agent_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Agent_Type_Vectors.Vector); type ProfileId_Type is record Id : Swagger.UString; Name : Swagger.UString; end record; package ProfileId_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ProfileId_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ProfileId_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ProfileId_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ProfileId_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ProfileId_Type_Vectors.Vector); type RefreshRequest_Type is record Access_Token : Swagger.UString; Client_Token : Swagger.Nullable_UString; end record; package RefreshRequest_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => RefreshRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in RefreshRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in RefreshRequest_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out RefreshRequest_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out RefreshRequest_Type_Vectors.Vector); type AccessKeys_Type is record Access_Token : Swagger.UString; Client_Token : Swagger.Nullable_UString; end record; package AccessKeys_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => AccessKeys_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in AccessKeys_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in AccessKeys_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out AccessKeys_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out AccessKeys_Type_Vectors.Vector); type UsernamePassword_Type is record Username : Swagger.UString; Password : Swagger.UString; end record; package UsernamePassword_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => UsernamePassword_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in UsernamePassword_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in UsernamePassword_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out UsernamePassword_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out UsernamePassword_Type_Vectors.Vector); type RefreshResponse_Type is record Access_Token : Swagger.UString; Client_Token : Swagger.Nullable_UString; end record; package RefreshResponse_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => RefreshResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in RefreshResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in RefreshResponse_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out RefreshResponse_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out RefreshResponse_Type_Vectors.Vector); type AuthenticationRequest_Type is record Username : Swagger.UString; Password : Swagger.UString; end record; package AuthenticationRequest_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => AuthenticationRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in AuthenticationRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in AuthenticationRequest_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out AuthenticationRequest_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out AuthenticationRequest_Type_Vectors.Vector); type Authentication_Type is record Access_Token : Swagger.UString; Client_Token : Swagger.Nullable_UString; end record; package Authentication_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Authentication_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Authentication_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Authentication_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Authentication_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Authentication_Type_Vectors.Vector); type GameProfile_Type is record Agent : Swagger.Nullable_UString; Id : Swagger.Nullable_UString; Name : Swagger.Nullable_UString; User_Id : Swagger.Nullable_UString; Created_At : Swagger.Nullable_Long; Legacy_Profile : Swagger.Nullable_Boolean; Suspended : Swagger.Nullable_Boolean; Paid : Swagger.Nullable_Boolean; Migrated : Swagger.Nullable_Boolean; Legacy : Swagger.Nullable_Boolean; end record; package GameProfile_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => GameProfile_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in GameProfile_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in GameProfile_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out GameProfile_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out GameProfile_Type_Vectors.Vector); end com.github.asyncmc.mojang.authentication.ada.model.Models;
-- -- Check if an image is opaque (fully non-transparent). -- -- Small-size demo for the GID (Generic Image Decoder) package. -- For a larger example, look for to_bmp.adb . -- with GID; with Ada.Calendar; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Command_Line; use Ada.Command_Line; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Text_IO; use Ada.Text_IO; with Interfaces; procedure Is_opaque is procedure Blurb is begin Put_Line(Current_Error, "Is_opaque * check if an image is opaque (fully non-transparent)"); Put_Line(Current_Error, "GID (Generic Image Decoder) package version " & GID.version & " dated " & GID.reference); Put_Line(Current_Error, "URL: " & GID.web); New_Line(Current_Error); Put_Line(Current_Error, "Syntax:"); Put_Line(Current_Error, "is_opaque <image_1> [<image_2>...]"); New_Line(Current_Error); end Blurb; procedure Check_raw_image( image : in out GID.Image_descriptor; next_frame: out Ada.Calendar.Day_Duration; opaque : out Boolean ) is use Interfaces; subtype Primary_color_range is Unsigned_8; -- procedure Set_X_Y (x, y: Natural) is begin null; end Set_X_Y; -- procedure Put_Pixel ( red, green, blue : Primary_color_range; alpha : Primary_color_range ) is pragma Unreferenced (blue, green, red); begin opaque:= opaque and alpha = Primary_color_range'Last; end Put_Pixel; stars: Natural:= 0; procedure Feedback(percents: Natural) is so_far: constant Natural:= percents / 5; begin for i in stars+1..so_far loop Put( Current_Error, '*'); end loop; stars:= so_far; end Feedback; procedure Load_image is new GID.Load_image_contents( Primary_color_range, Set_X_Y, Put_Pixel, Feedback, GID.fast ); begin opaque:= True; Load_image(image, next_frame); end Check_raw_image; procedure Process(name: String) is f: Ada.Streams.Stream_IO.File_Type; i: GID.Image_descriptor; up_name: constant String:= To_Upper(name); -- next_frame: Ada.Calendar.Day_Duration:= 0.0; opaque_frame: Boolean; begin -- -- Load the image in its original format -- Open(f, In_File, name); Put_Line(Current_Error, "Checking " & name & "..."); -- GID.Load_image_header( i, Stream(f).all, try_tga => name'Length >= 4 and then up_name(up_name'Last-3..up_name'Last) = ".TGA" ); if GID.Expect_transparency(i) then Put_Line(Current_Error, ".........v.........v"); -- loop Check_raw_image(i, next_frame, opaque_frame); New_Line(Current_Error); exit when next_frame = 0.0 or not opaque_frame; end loop; if opaque_frame then Put_Line(Current_Error, " Opaque: all pixels of all frames are opaque."); else Put_Line(Current_Error, " Not opaque: at least one pixel of one frame is not opaque."); end if; else Put_Line(Current_Error, " Opaque: no transparency information."); end if; Close(f); end Process; begin if Argument_Count=0 then Blurb; return; end if; for i in 1..Argument_Count loop Process(Argument(i)); end loop; end Is_opaque;
-- Copyright 2016-2019 NXP -- All rights reserved.SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from LPC55S6x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NXP_SVD.FLASH_KEY_STORE is pragma Preelaborate; --------------- -- Registers -- --------------- -- . -- . type ACTIVATION_CODE_Registers is array (0 .. 297) of HAL.UInt32 with Volatile; subtype SBKEY_HEADER1_TYPE_Field is HAL.UInt2; subtype SBKEY_HEADER1_INDEX_Field is HAL.UInt4; subtype SBKEY_HEADER1_SIZE_Field is HAL.UInt6; -- . type SBKEY_HEADER1_Register is record -- . TYPE_k : SBKEY_HEADER1_TYPE_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- . INDEX : SBKEY_HEADER1_INDEX_Field := 16#0#; -- unspecified Reserved_12_23 : HAL.UInt12 := 16#0#; -- . SIZE : SBKEY_HEADER1_SIZE_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SBKEY_HEADER1_Register use record TYPE_k at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; INDEX at 0 range 8 .. 11; Reserved_12_23 at 0 range 12 .. 23; SIZE at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype USER_KEK_HEADER1_TYPE_Field is HAL.UInt2; subtype USER_KEK_HEADER1_INDEX_Field is HAL.UInt4; subtype USER_KEK_HEADER1_SIZE_Field is HAL.UInt6; -- . type USER_KEK_HEADER1_Register is record -- . TYPE_k : USER_KEK_HEADER1_TYPE_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- . INDEX : USER_KEK_HEADER1_INDEX_Field := 16#0#; -- unspecified Reserved_12_23 : HAL.UInt12 := 16#0#; -- . SIZE : USER_KEK_HEADER1_SIZE_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for USER_KEK_HEADER1_Register use record TYPE_k at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; INDEX at 0 range 8 .. 11; Reserved_12_23 at 0 range 12 .. 23; SIZE at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype UDS_HEADER1_TYPE_Field is HAL.UInt2; subtype UDS_HEADER1_INDEX_Field is HAL.UInt4; subtype UDS_HEADER1_SIZE_Field is HAL.UInt6; -- . type UDS_HEADER1_Register is record -- . TYPE_k : UDS_HEADER1_TYPE_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- . INDEX : UDS_HEADER1_INDEX_Field := 16#0#; -- unspecified Reserved_12_23 : HAL.UInt12 := 16#0#; -- . SIZE : UDS_HEADER1_SIZE_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for UDS_HEADER1_Register use record TYPE_k at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; INDEX at 0 range 8 .. 11; Reserved_12_23 at 0 range 12 .. 23; SIZE at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype PRINCE_REGION0_HEADER1_TYPE_Field is HAL.UInt2; subtype PRINCE_REGION0_HEADER1_INDEX_Field is HAL.UInt4; subtype PRINCE_REGION0_HEADER1_SIZE_Field is HAL.UInt6; -- . type PRINCE_REGION0_HEADER1_Register is record -- . TYPE_k : PRINCE_REGION0_HEADER1_TYPE_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- . INDEX : PRINCE_REGION0_HEADER1_INDEX_Field := 16#0#; -- unspecified Reserved_12_23 : HAL.UInt12 := 16#0#; -- . SIZE : PRINCE_REGION0_HEADER1_SIZE_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PRINCE_REGION0_HEADER1_Register use record TYPE_k at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; INDEX at 0 range 8 .. 11; Reserved_12_23 at 0 range 12 .. 23; SIZE at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype PRINCE_REGION1_HEADER1_TYPE_Field is HAL.UInt2; subtype PRINCE_REGION1_HEADER1_INDEX_Field is HAL.UInt4; subtype PRINCE_REGION1_HEADER1_SIZE_Field is HAL.UInt6; -- . type PRINCE_REGION1_HEADER1_Register is record -- . TYPE_k : PRINCE_REGION1_HEADER1_TYPE_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- . INDEX : PRINCE_REGION1_HEADER1_INDEX_Field := 16#0#; -- unspecified Reserved_12_23 : HAL.UInt12 := 16#0#; -- . SIZE : PRINCE_REGION1_HEADER1_SIZE_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PRINCE_REGION1_HEADER1_Register use record TYPE_k at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; INDEX at 0 range 8 .. 11; Reserved_12_23 at 0 range 12 .. 23; SIZE at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype PRINCE_REGION2_HEADER1_TYPE_Field is HAL.UInt2; subtype PRINCE_REGION2_HEADER1_INDEX_Field is HAL.UInt4; subtype PRINCE_REGION2_HEADER1_SIZE_Field is HAL.UInt6; -- . type PRINCE_REGION2_HEADER1_Register is record -- . TYPE_k : PRINCE_REGION2_HEADER1_TYPE_Field := 16#0#; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- . INDEX : PRINCE_REGION2_HEADER1_INDEX_Field := 16#0#; -- unspecified Reserved_12_23 : HAL.UInt12 := 16#0#; -- . SIZE : PRINCE_REGION2_HEADER1_SIZE_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PRINCE_REGION2_HEADER1_Register use record TYPE_k at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; INDEX at 0 range 8 .. 11; Reserved_12_23 at 0 range 12 .. 23; SIZE at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ----------------- -- Peripherals -- ----------------- type FLASH_KEY_STORE_Disc is ( Header0, Key_Code0, Header1, Key_Code1, Body0, Key_Code2, Body1, Key_Code3, Body2, Key_Code4, Body3, Key_Code5, Body4, Key_Code6, Body5, Key_Code7, Body6, Key_Code8, Body7, Key_Code9, Body8, Key_Code10, Body9, Key_Code11, Body10, Key_Code12, Body11, Key_Code13); -- FLASH_KEY_STORE type FLASH_KEY_STORE_Peripheral (Discriminent : FLASH_KEY_STORE_Disc := Header0) is record -- Valid Key Sore Header : 0x95959595 HEADER : aliased HAL.UInt32; -- puf discharge time in ms. puf_discharge_time_in_ms : aliased HAL.UInt32; -- . ACTIVATION_CODE : aliased ACTIVATION_CODE_Registers; case Discriminent is when Header0 => -- . SBKEY_HEADER0 : aliased HAL.UInt32; -- . USER_KEK_HEADER0 : aliased HAL.UInt32; -- . UDS_HEADER0 : aliased HAL.UInt32; -- . PRINCE_REGION0_HEADER0 : aliased HAL.UInt32; -- . PRINCE_REGION1_HEADER0 : aliased HAL.UInt32; -- . PRINCE_REGION2_HEADER0 : aliased HAL.UInt32; when Key_Code0 => -- . SBKEY_KEY_CODE0 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE0 : aliased HAL.UInt32; -- . UDS_KEY_CODE0 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE0 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE0 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE0 : aliased HAL.UInt32; when Header1 => -- . SBKEY_HEADER1 : aliased SBKEY_HEADER1_Register; -- . USER_KEK_HEADER1 : aliased USER_KEK_HEADER1_Register; -- . UDS_HEADER1 : aliased UDS_HEADER1_Register; -- . PRINCE_REGION0_HEADER1 : aliased PRINCE_REGION0_HEADER1_Register; -- . PRINCE_REGION1_HEADER1 : aliased PRINCE_REGION1_HEADER1_Register; -- . PRINCE_REGION2_HEADER1 : aliased PRINCE_REGION2_HEADER1_Register; when Key_Code1 => -- . SBKEY_KEY_CODE1 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE1 : aliased HAL.UInt32; -- . UDS_KEY_CODE1 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE1 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE1 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE1 : aliased HAL.UInt32; when Body0 => -- . SBKEY_BODY0 : aliased HAL.UInt32; -- . USER_KEK_BODY0 : aliased HAL.UInt32; -- . UDS_BODY0 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY0 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY0 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY0 : aliased HAL.UInt32; when Key_Code2 => -- . SBKEY_KEY_CODE2 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE2 : aliased HAL.UInt32; -- . UDS_KEY_CODE2 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE2 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE2 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE2 : aliased HAL.UInt32; when Body1 => -- . SBKEY_BODY1 : aliased HAL.UInt32; -- . USER_KEK_BODY1 : aliased HAL.UInt32; -- . UDS_BODY1 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY1 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY1 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY1 : aliased HAL.UInt32; when Key_Code3 => -- . SBKEY_KEY_CODE3 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE3 : aliased HAL.UInt32; -- . UDS_KEY_CODE3 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE3 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE3 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE3 : aliased HAL.UInt32; when Body2 => -- . SBKEY_BODY2 : aliased HAL.UInt32; -- . USER_KEK_BODY2 : aliased HAL.UInt32; -- . UDS_BODY2 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY2 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY2 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY2 : aliased HAL.UInt32; when Key_Code4 => -- . SBKEY_KEY_CODE4 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE4 : aliased HAL.UInt32; -- . UDS_KEY_CODE4 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE4 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE4 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE4 : aliased HAL.UInt32; when Body3 => -- . SBKEY_BODY3 : aliased HAL.UInt32; -- . USER_KEK_BODY3 : aliased HAL.UInt32; -- . UDS_BODY3 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY3 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY3 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY3 : aliased HAL.UInt32; when Key_Code5 => -- . SBKEY_KEY_CODE5 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE5 : aliased HAL.UInt32; -- . UDS_KEY_CODE5 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE5 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE5 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE5 : aliased HAL.UInt32; when Body4 => -- . SBKEY_BODY4 : aliased HAL.UInt32; -- . USER_KEK_BODY4 : aliased HAL.UInt32; -- . UDS_BODY4 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY4 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY4 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY4 : aliased HAL.UInt32; when Key_Code6 => -- . SBKEY_KEY_CODE6 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE6 : aliased HAL.UInt32; -- . UDS_KEY_CODE6 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE6 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE6 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE6 : aliased HAL.UInt32; when Body5 => -- . SBKEY_BODY5 : aliased HAL.UInt32; -- . USER_KEK_BODY5 : aliased HAL.UInt32; -- . UDS_BODY5 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY5 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY5 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY5 : aliased HAL.UInt32; when Key_Code7 => -- . SBKEY_KEY_CODE7 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE7 : aliased HAL.UInt32; -- . UDS_KEY_CODE7 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE7 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE7 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE7 : aliased HAL.UInt32; when Body6 => -- . SBKEY_BODY6 : aliased HAL.UInt32; -- . USER_KEK_BODY6 : aliased HAL.UInt32; -- . UDS_BODY6 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY6 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY6 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY6 : aliased HAL.UInt32; when Key_Code8 => -- . SBKEY_KEY_CODE8 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE8 : aliased HAL.UInt32; -- . UDS_KEY_CODE8 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE8 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE8 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE8 : aliased HAL.UInt32; when Body7 => -- . SBKEY_BODY7 : aliased HAL.UInt32; -- . USER_KEK_BODY7 : aliased HAL.UInt32; -- . UDS_BODY7 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY7 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY7 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY7 : aliased HAL.UInt32; when Key_Code9 => -- . SBKEY_KEY_CODE9 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE9 : aliased HAL.UInt32; -- . UDS_KEY_CODE9 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE9 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE9 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE9 : aliased HAL.UInt32; when Body8 => -- . SBKEY_BODY8 : aliased HAL.UInt32; -- . USER_KEK_BODY8 : aliased HAL.UInt32; -- . UDS_BODY8 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY8 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY8 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY8 : aliased HAL.UInt32; when Key_Code10 => -- . SBKEY_KEY_CODE10 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE10 : aliased HAL.UInt32; -- . UDS_KEY_CODE10 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE10 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE10 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE10 : aliased HAL.UInt32; when Body9 => -- . SBKEY_BODY9 : aliased HAL.UInt32; -- . USER_KEK_BODY9 : aliased HAL.UInt32; -- . UDS_BODY9 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY9 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY9 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY9 : aliased HAL.UInt32; when Key_Code11 => -- . SBKEY_KEY_CODE11 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE11 : aliased HAL.UInt32; -- . UDS_KEY_CODE11 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE11 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE11 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE11 : aliased HAL.UInt32; when Body10 => -- . SBKEY_BODY10 : aliased HAL.UInt32; -- . USER_KEK_BODY10 : aliased HAL.UInt32; -- . UDS_BODY10 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY10 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY10 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY10 : aliased HAL.UInt32; when Key_Code12 => -- . SBKEY_KEY_CODE12 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE12 : aliased HAL.UInt32; -- . UDS_KEY_CODE12 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE12 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE12 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE12 : aliased HAL.UInt32; when Body11 => -- . SBKEY_BODY11 : aliased HAL.UInt32; -- . USER_KEK_BODY11 : aliased HAL.UInt32; -- . UDS_BODY11 : aliased HAL.UInt32; -- . PRINCE_REGION0_BODY11 : aliased HAL.UInt32; -- . PRINCE_REGION1_BODY11 : aliased HAL.UInt32; -- . PRINCE_REGION2_BODY11 : aliased HAL.UInt32; when Key_Code13 => -- . SBKEY_KEY_CODE13 : aliased HAL.UInt32; -- . USER_KEK_KEY_CODE13 : aliased HAL.UInt32; -- . UDS_KEY_CODE13 : aliased HAL.UInt32; -- . PRINCE_REGION0_KEY_CODE13 : aliased HAL.UInt32; -- . PRINCE_REGION1_KEY_CODE13 : aliased HAL.UInt32; -- . PRINCE_REGION2_KEY_CODE13 : aliased HAL.UInt32; end case; end record with Unchecked_Union, Volatile; for FLASH_KEY_STORE_Peripheral use record HEADER at 16#0# range 0 .. 31; puf_discharge_time_in_ms at 16#4# range 0 .. 31; ACTIVATION_CODE at 16#8# range 0 .. 9535; SBKEY_HEADER0 at 16#4B0# range 0 .. 31; USER_KEK_HEADER0 at 16#4E8# range 0 .. 31; UDS_HEADER0 at 16#520# range 0 .. 31; PRINCE_REGION0_HEADER0 at 16#558# range 0 .. 31; PRINCE_REGION1_HEADER0 at 16#590# range 0 .. 31; PRINCE_REGION2_HEADER0 at 16#5C8# range 0 .. 31; SBKEY_KEY_CODE0 at 16#4B0# range 0 .. 31; USER_KEK_KEY_CODE0 at 16#4E8# range 0 .. 31; UDS_KEY_CODE0 at 16#520# range 0 .. 31; PRINCE_REGION0_KEY_CODE0 at 16#558# range 0 .. 31; PRINCE_REGION1_KEY_CODE0 at 16#590# range 0 .. 31; PRINCE_REGION2_KEY_CODE0 at 16#5C8# range 0 .. 31; SBKEY_HEADER1 at 16#4B4# range 0 .. 31; USER_KEK_HEADER1 at 16#4EC# range 0 .. 31; UDS_HEADER1 at 16#524# range 0 .. 31; PRINCE_REGION0_HEADER1 at 16#55C# range 0 .. 31; PRINCE_REGION1_HEADER1 at 16#594# range 0 .. 31; PRINCE_REGION2_HEADER1 at 16#5CC# range 0 .. 31; SBKEY_KEY_CODE1 at 16#4B4# range 0 .. 31; USER_KEK_KEY_CODE1 at 16#4EC# range 0 .. 31; UDS_KEY_CODE1 at 16#524# range 0 .. 31; PRINCE_REGION0_KEY_CODE1 at 16#55C# range 0 .. 31; PRINCE_REGION1_KEY_CODE1 at 16#594# range 0 .. 31; PRINCE_REGION2_KEY_CODE1 at 16#5CC# range 0 .. 31; SBKEY_BODY0 at 16#4B8# range 0 .. 31; USER_KEK_BODY0 at 16#4F0# range 0 .. 31; UDS_BODY0 at 16#528# range 0 .. 31; PRINCE_REGION0_BODY0 at 16#560# range 0 .. 31; PRINCE_REGION1_BODY0 at 16#598# range 0 .. 31; PRINCE_REGION2_BODY0 at 16#5D0# range 0 .. 31; SBKEY_KEY_CODE2 at 16#4B8# range 0 .. 31; USER_KEK_KEY_CODE2 at 16#4F0# range 0 .. 31; UDS_KEY_CODE2 at 16#528# range 0 .. 31; PRINCE_REGION0_KEY_CODE2 at 16#560# range 0 .. 31; PRINCE_REGION1_KEY_CODE2 at 16#598# range 0 .. 31; PRINCE_REGION2_KEY_CODE2 at 16#5D0# range 0 .. 31; SBKEY_BODY1 at 16#4BC# range 0 .. 31; USER_KEK_BODY1 at 16#4F4# range 0 .. 31; UDS_BODY1 at 16#52C# range 0 .. 31; PRINCE_REGION0_BODY1 at 16#564# range 0 .. 31; PRINCE_REGION1_BODY1 at 16#59C# range 0 .. 31; PRINCE_REGION2_BODY1 at 16#5D4# range 0 .. 31; SBKEY_KEY_CODE3 at 16#4BC# range 0 .. 31; USER_KEK_KEY_CODE3 at 16#4F4# range 0 .. 31; UDS_KEY_CODE3 at 16#52C# range 0 .. 31; PRINCE_REGION0_KEY_CODE3 at 16#564# range 0 .. 31; PRINCE_REGION1_KEY_CODE3 at 16#59C# range 0 .. 31; PRINCE_REGION2_KEY_CODE3 at 16#5D4# range 0 .. 31; SBKEY_BODY2 at 16#4C0# range 0 .. 31; USER_KEK_BODY2 at 16#4F8# range 0 .. 31; UDS_BODY2 at 16#530# range 0 .. 31; PRINCE_REGION0_BODY2 at 16#568# range 0 .. 31; PRINCE_REGION1_BODY2 at 16#5A0# range 0 .. 31; PRINCE_REGION2_BODY2 at 16#5D8# range 0 .. 31; SBKEY_KEY_CODE4 at 16#4C0# range 0 .. 31; USER_KEK_KEY_CODE4 at 16#4F8# range 0 .. 31; UDS_KEY_CODE4 at 16#530# range 0 .. 31; PRINCE_REGION0_KEY_CODE4 at 16#568# range 0 .. 31; PRINCE_REGION1_KEY_CODE4 at 16#5A0# range 0 .. 31; PRINCE_REGION2_KEY_CODE4 at 16#5D8# range 0 .. 31; SBKEY_BODY3 at 16#4C4# range 0 .. 31; USER_KEK_BODY3 at 16#4FC# range 0 .. 31; UDS_BODY3 at 16#534# range 0 .. 31; PRINCE_REGION0_BODY3 at 16#56C# range 0 .. 31; PRINCE_REGION1_BODY3 at 16#5A4# range 0 .. 31; PRINCE_REGION2_BODY3 at 16#5DC# range 0 .. 31; SBKEY_KEY_CODE5 at 16#4C4# range 0 .. 31; USER_KEK_KEY_CODE5 at 16#4FC# range 0 .. 31; UDS_KEY_CODE5 at 16#534# range 0 .. 31; PRINCE_REGION0_KEY_CODE5 at 16#56C# range 0 .. 31; PRINCE_REGION1_KEY_CODE5 at 16#5A4# range 0 .. 31; PRINCE_REGION2_KEY_CODE5 at 16#5DC# range 0 .. 31; SBKEY_BODY4 at 16#4C8# range 0 .. 31; USER_KEK_BODY4 at 16#500# range 0 .. 31; UDS_BODY4 at 16#538# range 0 .. 31; PRINCE_REGION0_BODY4 at 16#570# range 0 .. 31; PRINCE_REGION1_BODY4 at 16#5A8# range 0 .. 31; PRINCE_REGION2_BODY4 at 16#5E0# range 0 .. 31; SBKEY_KEY_CODE6 at 16#4C8# range 0 .. 31; USER_KEK_KEY_CODE6 at 16#500# range 0 .. 31; UDS_KEY_CODE6 at 16#538# range 0 .. 31; PRINCE_REGION0_KEY_CODE6 at 16#570# range 0 .. 31; PRINCE_REGION1_KEY_CODE6 at 16#5A8# range 0 .. 31; PRINCE_REGION2_KEY_CODE6 at 16#5E0# range 0 .. 31; SBKEY_BODY5 at 16#4CC# range 0 .. 31; USER_KEK_BODY5 at 16#504# range 0 .. 31; UDS_BODY5 at 16#53C# range 0 .. 31; PRINCE_REGION0_BODY5 at 16#574# range 0 .. 31; PRINCE_REGION1_BODY5 at 16#5AC# range 0 .. 31; PRINCE_REGION2_BODY5 at 16#5E4# range 0 .. 31; SBKEY_KEY_CODE7 at 16#4CC# range 0 .. 31; USER_KEK_KEY_CODE7 at 16#504# range 0 .. 31; UDS_KEY_CODE7 at 16#53C# range 0 .. 31; PRINCE_REGION0_KEY_CODE7 at 16#574# range 0 .. 31; PRINCE_REGION1_KEY_CODE7 at 16#5AC# range 0 .. 31; PRINCE_REGION2_KEY_CODE7 at 16#5E4# range 0 .. 31; SBKEY_BODY6 at 16#4D0# range 0 .. 31; USER_KEK_BODY6 at 16#508# range 0 .. 31; UDS_BODY6 at 16#540# range 0 .. 31; PRINCE_REGION0_BODY6 at 16#578# range 0 .. 31; PRINCE_REGION1_BODY6 at 16#5B0# range 0 .. 31; PRINCE_REGION2_BODY6 at 16#5E8# range 0 .. 31; SBKEY_KEY_CODE8 at 16#4D0# range 0 .. 31; USER_KEK_KEY_CODE8 at 16#508# range 0 .. 31; UDS_KEY_CODE8 at 16#540# range 0 .. 31; PRINCE_REGION0_KEY_CODE8 at 16#578# range 0 .. 31; PRINCE_REGION1_KEY_CODE8 at 16#5B0# range 0 .. 31; PRINCE_REGION2_KEY_CODE8 at 16#5E8# range 0 .. 31; SBKEY_BODY7 at 16#4D4# range 0 .. 31; USER_KEK_BODY7 at 16#50C# range 0 .. 31; UDS_BODY7 at 16#544# range 0 .. 31; PRINCE_REGION0_BODY7 at 16#57C# range 0 .. 31; PRINCE_REGION1_BODY7 at 16#5B4# range 0 .. 31; PRINCE_REGION2_BODY7 at 16#5EC# range 0 .. 31; SBKEY_KEY_CODE9 at 16#4D4# range 0 .. 31; USER_KEK_KEY_CODE9 at 16#50C# range 0 .. 31; UDS_KEY_CODE9 at 16#544# range 0 .. 31; PRINCE_REGION0_KEY_CODE9 at 16#57C# range 0 .. 31; PRINCE_REGION1_KEY_CODE9 at 16#5B4# range 0 .. 31; PRINCE_REGION2_KEY_CODE9 at 16#5EC# range 0 .. 31; SBKEY_BODY8 at 16#4D8# range 0 .. 31; USER_KEK_BODY8 at 16#510# range 0 .. 31; UDS_BODY8 at 16#548# range 0 .. 31; PRINCE_REGION0_BODY8 at 16#580# range 0 .. 31; PRINCE_REGION1_BODY8 at 16#5B8# range 0 .. 31; PRINCE_REGION2_BODY8 at 16#5F0# range 0 .. 31; SBKEY_KEY_CODE10 at 16#4D8# range 0 .. 31; USER_KEK_KEY_CODE10 at 16#510# range 0 .. 31; UDS_KEY_CODE10 at 16#548# range 0 .. 31; PRINCE_REGION0_KEY_CODE10 at 16#580# range 0 .. 31; PRINCE_REGION1_KEY_CODE10 at 16#5B8# range 0 .. 31; PRINCE_REGION2_KEY_CODE10 at 16#5F0# range 0 .. 31; SBKEY_BODY9 at 16#4DC# range 0 .. 31; USER_KEK_BODY9 at 16#514# range 0 .. 31; UDS_BODY9 at 16#54C# range 0 .. 31; PRINCE_REGION0_BODY9 at 16#584# range 0 .. 31; PRINCE_REGION1_BODY9 at 16#5BC# range 0 .. 31; PRINCE_REGION2_BODY9 at 16#5F4# range 0 .. 31; SBKEY_KEY_CODE11 at 16#4DC# range 0 .. 31; USER_KEK_KEY_CODE11 at 16#514# range 0 .. 31; UDS_KEY_CODE11 at 16#54C# range 0 .. 31; PRINCE_REGION0_KEY_CODE11 at 16#584# range 0 .. 31; PRINCE_REGION1_KEY_CODE11 at 16#5BC# range 0 .. 31; PRINCE_REGION2_KEY_CODE11 at 16#5F4# range 0 .. 31; SBKEY_BODY10 at 16#4E0# range 0 .. 31; USER_KEK_BODY10 at 16#518# range 0 .. 31; UDS_BODY10 at 16#550# range 0 .. 31; PRINCE_REGION0_BODY10 at 16#588# range 0 .. 31; PRINCE_REGION1_BODY10 at 16#5C0# range 0 .. 31; PRINCE_REGION2_BODY10 at 16#5F8# range 0 .. 31; SBKEY_KEY_CODE12 at 16#4E0# range 0 .. 31; USER_KEK_KEY_CODE12 at 16#518# range 0 .. 31; UDS_KEY_CODE12 at 16#550# range 0 .. 31; PRINCE_REGION0_KEY_CODE12 at 16#588# range 0 .. 31; PRINCE_REGION1_KEY_CODE12 at 16#5C0# range 0 .. 31; PRINCE_REGION2_KEY_CODE12 at 16#5F8# range 0 .. 31; SBKEY_BODY11 at 16#4E4# range 0 .. 31; USER_KEK_BODY11 at 16#51C# range 0 .. 31; UDS_BODY11 at 16#554# range 0 .. 31; PRINCE_REGION0_BODY11 at 16#58C# range 0 .. 31; PRINCE_REGION1_BODY11 at 16#5C4# range 0 .. 31; PRINCE_REGION2_BODY11 at 16#5FC# range 0 .. 31; SBKEY_KEY_CODE13 at 16#4E4# range 0 .. 31; USER_KEK_KEY_CODE13 at 16#51C# range 0 .. 31; UDS_KEY_CODE13 at 16#554# range 0 .. 31; PRINCE_REGION0_KEY_CODE13 at 16#58C# range 0 .. 31; PRINCE_REGION1_KEY_CODE13 at 16#5C4# range 0 .. 31; PRINCE_REGION2_KEY_CODE13 at 16#5FC# range 0 .. 31; end record; -- FLASH_KEY_STORE FLASH_KEY_STORE_Periph : aliased FLASH_KEY_STORE_Peripheral with Import, Address => System'To_Address (16#9E600#); end NXP_SVD.FLASH_KEY_STORE;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Incr.Nodes.Joints; package body Incr.Nodes.Ultra_Roots is ----------- -- Arity -- ----------- overriding function Arity (Self : Ultra_Root) return Natural is pragma Unreferenced (Self); begin return 3; end Arity; ----------- -- Child -- ----------- overriding function Child (Self : Ultra_Root; Index : Positive; Time : Version_Trees.Version) return Node_Access is begin case Index is when 1 => return Node_Access (Self.BOS); when 2 => return Versioned_Nodes.Get (Self.Root, Time); when 3 => return Node_Access (Self.EOS); when others => raise Constraint_Error; end case; end Child; ------------- -- Discard -- ------------- overriding procedure Discard (Self : in out Ultra_Root) is begin raise Program_Error with "Unimplemented"; end Discard; ------------ -- Exists -- ------------ overriding function Exists (Self : Ultra_Root; Time : Version_Trees.Version) return Boolean is pragma Unreferenced (Time, Self); begin return True; end Exists; -------------- -- Get_Flag -- -------------- overriding function Get_Flag (Self : Ultra_Root; Flag : Transient_Flags) return Boolean is pragma Unreferenced (Self, Flag); begin return True; end Get_Flag; -------------- -- Is_Token -- -------------- overriding function Is_Token (Self : Ultra_Root) return Boolean is pragma Unreferenced (Self); begin return False; end Is_Token; ---------- -- Kind -- ---------- overriding function Kind (Self : Ultra_Root) return Node_Kind is pragma Unreferenced (Self); begin return 0; end Kind; ------------------- -- Local_Changes -- ------------------- overriding function Local_Changes (Self : Ultra_Root; From : Version_Trees.Version; To : Version_Trees.Version) return Boolean is use type Version_Trees.Version; Next : Version_Trees.Version := To; Prev : Version_Trees.Version; begin loop Prev := Self.Document.History.Parent (Next); if Self.Child (2, Prev) /= Self.Child (2, Next) then return True; end if; exit when From = Prev; Next := Prev; end loop; return False; end Local_Changes; ------------------- -- Nested_Errors -- ------------------- overriding function Nested_Errors (Self : Ultra_Root; Time : Version_Trees.Version) return Boolean is Child : Nodes.Node_Access; begin for J in 1 .. 3 loop Child := Self.Child (J, Time); if Child /= null then if Child.Local_Errors (Time) or Child.Nested_Errors (Time) then return True; end if; end if; end loop; return False; end Nested_Errors; -------------------- -- Nested_Changes -- -------------------- overriding function Nested_Changes (Self : Ultra_Root; From : Version_Trees.Version; To : Version_Trees.Version) return Boolean is pragma Unreferenced (Self, From, To); begin return True; end Nested_Changes; --------------- -- On_Commit -- --------------- overriding procedure On_Commit (Self : in out Ultra_Root; Parent : Node_Access) is Root : constant Node_Access := Versioned_Nodes.Get (Self.Root, Self.Document.History.Changing); begin pragma Assert (Parent = null); Mark_Deleted_Children (Self); Self.BOS.On_Commit (Self'Unchecked_Access); if Root /= null then Root.On_Commit (Self'Unchecked_Access); end if; Self.EOS.On_Commit (Self'Unchecked_Access); end On_Commit; ------------ -- Parent -- ------------ overriding function Parent (Self : Ultra_Root; Time : Version_Trees.Version) return Node_Access is pragma Unreferenced (Self, Time); begin return null; end Parent; --------------- -- Set_Child -- --------------- overriding procedure Set_Child (Self : aliased in out Ultra_Root; Index : Positive; Value : Node_Access) is Now : constant Version_Trees.Version := Self.Document.History.Changing; Old : constant Node_Access := Self.Child (Index, Now); Ignore : Integer := 0; begin if Index /= 2 then raise Constraint_Error; elsif Old /= null then Old.Set_Parent (null); end if; Versioned_Nodes.Set (Self.Root, Value, Now, Ignore); if Value /= null then Value.Set_Parent (Self'Unchecked_Access); end if; end Set_Child; ---------- -- Span -- ---------- overriding function Span (Self : aliased in out Ultra_Root; Kind : Span_Kinds; Time : Version_Trees.Version) return Natural is Root_Span : constant Natural := Self.Child (2, Time).Span (Kind, Time); begin case Kind is when Text_Length => return Root_Span + 1; -- including end_of_stream character when Token_Count => return Root_Span + 2; -- including sentinel tokens when Line_Count => return Root_Span + 1; -- including end_of_stream character end case; end Span; ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : out Ultra_Root'Class; Root : Nodes.Node_Access) is begin Self.BOS := new Nodes.Tokens.Token (Self.Document); Nodes.Tokens.Constructors.Initialize_Ancient (Self => Self.BOS.all, Parent => Self'Unchecked_Access, Back => 0); Self.EOS := new Nodes.Tokens.Token (Self.Document); Nodes.Tokens.Constructors.Initialize_Ancient (Self => Self.EOS.all, Parent => Self'Unchecked_Access, Back => 1); if Root /= null then Nodes.Joints.Constructors.Initialize_Ancient (Self => Nodes.Joints.Joint (Root.all), Parent => Self'Unchecked_Access); end if; Versioned_Nodes.Initialize (Self.Root, Root); end Initialize; end Constructors; end Incr.Nodes.Ultra_Roots;
--=========================================================================== -- -- This package is the implementation of the demo package showing examples -- for the SH1107 OLED controller -- --=========================================================================== -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with HAL; with HAL.Bitmap; with HAL.Framebuffer; with RP.Timer; package body Demos is procedure Black_Background_White_Arrow (S : in out SH1107.SH1107_Screen); procedure White_Background_With_Black_Rectangle_Full_Screen (S : in out SH1107.SH1107_Screen); procedure Black_Background_With_White_Rectangle_Full_Screen (S : in out SH1107.SH1107_Screen); procedure White_Background_4_Black_Corners (S : in out SH1107.SH1107_Screen); procedure Black_Background_4_White_Corners (S : in out SH1107.SH1107_Screen); procedure Black_Background_White_Geometry (S : in out SH1107.SH1107_Screen); procedure White_Background_Black_Geometry (S : in out SH1107.SH1107_Screen); procedure White_Diagonal_Line_On_Black (S : in out SH1107.SH1107_Screen); procedure Black_Diagonal_Line_On_White (S : in out SH1107.SH1107_Screen); type Demo_Procedure is not null access procedure (S : in out SH1107.SH1107_Screen); Demos_Procedures : constant array (Demos_Available) of Demo_Procedure := (Demos.Black_Background_White_Arrow => (Black_Background_White_Arrow'Access), Demos.White_Background_With_Black_Rectangle_Full_Screen => ( White_Background_With_Black_Rectangle_Full_Screen'Access), Demos.Black_Background_With_White_Rectangle_Full_Screen => ( Black_Background_With_White_Rectangle_Full_Screen'Access), Demos.White_Background_4_Black_Corners => (White_Background_4_Black_Corners'Access), Demos.Black_Background_4_White_Corners => (Black_Background_4_White_Corners'Access), Demos.Black_Background_White_Geometry => (Black_Background_White_Geometry'Access), Demos.White_Background_Black_Geometry => (White_Background_Black_Geometry'Access), Demos.White_Diagonal_Line_On_Black => (White_Diagonal_Line_On_Black'Access), Demos.Black_Diagonal_Line_On_White => (Black_Diagonal_Line_On_White'Access) ); Another_Timer : RP.Timer.Delays; THE_LAYER : constant Positive := 1; Corner_0_0 : constant HAL.Bitmap.Point := (0, 0); Corner_1_1 : constant HAL.Bitmap.Point := (1, 1); Corner_0_127 : constant HAL.Bitmap.Point := (0, SH1107.THE_HEIGHT - 1); Corner_127_0 : constant HAL.Bitmap.Point := (SH1107.THE_WIDTH - 1, 0); Corner_127_127 : constant HAL.Bitmap.Point := (SH1107.THE_WIDTH - 1, SH1107.THE_HEIGHT - 1); My_Area : constant HAL.Bitmap.Rect := (Position => Corner_0_0, Width => SH1107.THE_WIDTH - 1, Height => SH1107.THE_HEIGHT - 1); My_Circle_Center : constant HAL.Bitmap.Point := (X => 64, Y => 38); My_Circle_Radius : constant Natural := 10; My_Rectangle : constant HAL.Bitmap.Rect := (Position => (X => 38, Y => 78), Width => 20, Height => 10); procedure Black_Background_White_Arrow (S : in out SH1107.SH1107_Screen) is Corners : constant HAL.Bitmap.Point_Array (1 .. 7) := ( 1 => (40, 118), 2 => (86, 118), 3 => (86, 60), 4 => (96, 60), 5 => (63, 10), 6 => (30, 60), 7 => (40, 60)); Start : HAL.Bitmap.Point; Stop : HAL.Bitmap.Point; My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 1); for N in Corners'First .. Corners'Last loop Start := Corners (N); if N = Corners'Last then Stop := Corners (1); else Stop := Corners (N + 1); end if; My_Hidden_Buffer.Draw_Line (Start, Stop); end loop; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end Black_Background_White_Arrow; procedure White_Background_With_Black_Rectangle_Full_Screen (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Draw_Rect (Area => My_Area); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end White_Background_With_Black_Rectangle_Full_Screen; procedure Black_Background_With_White_Rectangle_Full_Screen (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Draw_Rect (Area => My_Area); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end Black_Background_With_White_Rectangle_Full_Screen; procedure White_Background_4_Black_Corners (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Pixel (Pt => Corner_0_0, Native => 0); My_Hidden_Buffer.Set_Pixel (Pt => Corner_1_1, Native => 0); My_Hidden_Buffer.Set_Pixel (Pt => Corner_0_127, Native => 0); My_Hidden_Buffer.Set_Pixel (Pt => Corner_127_0, Native => 0); My_Hidden_Buffer.Set_Pixel (Pt => Corner_127_127, Native => 0); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end White_Background_4_Black_Corners; procedure Black_Background_4_White_Corners (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Pixel (Pt => Corner_0_0, Native => 1); My_Hidden_Buffer.Set_Pixel (Pt => Corner_0_127, Native => 1); My_Hidden_Buffer.Set_Pixel (Pt => Corner_127_0, Native => 1); My_Hidden_Buffer.Set_Pixel (Pt => Corner_127_127, Native => 1); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end Black_Background_4_White_Corners; procedure Black_Background_White_Geometry (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Draw_Circle (Center => My_Circle_Center, Radius => My_Circle_Radius); My_Hidden_Buffer.Draw_Rounded_Rect (Area => My_Rectangle, Radius => 4); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end Black_Background_White_Geometry; procedure White_Background_Black_Geometry (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Draw_Circle (Center => My_Circle_Center, Radius => My_Circle_Radius); My_Hidden_Buffer.Draw_Rounded_Rect (Area => My_Rectangle, Radius => 4); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end White_Background_Black_Geometry; procedure White_Diagonal_Line_On_Black (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Draw_Line (Start => Corner_0_0, Stop => Corner_127_127); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end White_Diagonal_Line_On_Black; procedure Black_Diagonal_Line_On_White (S : in out SH1107.SH1107_Screen) is My_Hidden_Buffer : HAL.Bitmap.Any_Bitmap_Buffer; begin My_Hidden_Buffer := SH1107.Hidden_Buffer (This => S, Layer => THE_LAYER); My_Hidden_Buffer.Set_Source (Native => 1); My_Hidden_Buffer.Fill; SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); My_Hidden_Buffer.Set_Source (Native => 0); My_Hidden_Buffer.Draw_Line (Start => Corner_0_0, Stop => Corner_127_127); SH1107.Update_Layer (This => S, Layer => THE_LAYER); RP.Timer.Delay_Seconds (This => Another_Timer, S => 1); end Black_Diagonal_Line_On_White; procedure Show_Multiple_Demos (S : in out SH1107.SH1107_Screen; O : SH1107.SH1107_Orientation; DA : Demo_Array) is begin for D in Demos_Available'First .. Demos_Available'Last loop if DA (D) then Show_1_Demo (S, O, D); end if; end loop; end Show_Multiple_Demos; procedure Show_1_Demo (S : in out SH1107.SH1107_Screen; O : SH1107.SH1107_Orientation; Demo : Demos_Available) is My_Color_Mode : HAL.Framebuffer.FB_Color_Mode; begin My_Color_Mode := SH1107.Color_Mode (This => S); SH1107.Initialize_Layer (This => S, Layer => THE_LAYER, Mode => My_Color_Mode); S.Set_Orientation (O); Demos_Procedures (Demo).all (S); end Show_1_Demo; end Demos;
------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2013, 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 2, 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 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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- ELF definitions (for loaders) with Interfaces; use Interfaces; package Elf32 is type Elf32_Ehdr is record E_Ident_Mag0 : Unsigned_8; E_Ident_Mag1 : Unsigned_8; E_Ident_Mag2 : Unsigned_8; E_Ident_Mag3 : Unsigned_8; E_Ident_Class : Unsigned_8; E_Ident_Data : Unsigned_8; E_Ident_Version : Unsigned_8; E_Ident_Pad7 : Unsigned_8; E_Ident_Pad8 : Unsigned_8; E_Ident_Pad9 : Unsigned_8; E_Ident_Pad10 : Unsigned_8; E_Ident_Pad11 : Unsigned_8; E_Ident_Pad12 : Unsigned_8; E_Ident_Pad13 : Unsigned_8; E_Ident_Pad14 : Unsigned_8; E_Ident_Pad15 : Unsigned_8; E_Type : Unsigned_16; E_Machine : Unsigned_16; E_Version : Unsigned_32; E_Entry : Unsigned_32; E_Phoff : Unsigned_32; E_Shoff : Unsigned_32; E_Flags : Unsigned_32; E_Ehsize : Unsigned_16; E_Phentsize : Unsigned_16; E_Phnum : Unsigned_16; E_Shentsize : Unsigned_16; E_Shnum : Unsigned_16; E_Shstrndx : Unsigned_16; end record; -- Values for e_ident Ei_Mag0 : constant := 16#7f#; Ei_Mag1 : constant := Character'Pos ('E'); Ei_Mag2 : constant := Character'Pos ('L'); Ei_Mag3 : constant := Character'Pos ('F'); Elfclass32 : constant := 1; Elfdata2lsb : constant := 1; Elfdata2msb : constant := 2; -- Values for e_type Et_Exec : constant := 2; -- Values for e_version Ev_Current : constant := 1; type Elf32_Phdr is record P_Type : Unsigned_32; P_Offset : Unsigned_32; P_Vaddr : Unsigned_32; P_Paddr : Unsigned_32; P_Filesz : Unsigned_32; P_Memsz : Unsigned_32; P_Flags : Unsigned_32; P_Align : Unsigned_32; end record; -- Values for p_type Pt_Null : constant := 0; Pt_Load : constant := 1; Pt_Dynamic : constant := 2; Pt_Interp : constant := 3; Pt_Note : constant := 4; Pt_Shlib : constant := 5; Pt_Phdr : constant := 6; -- Value for p_flags Pf_X : constant := 1; Pf_W : constant := 2; Pf_R : constant := 3; end Elf32;
-- { dg-do run } -- { dg-options "-O2" } procedure Opt4 is type Rec (D : Natural) is record S : String (1..D); end record; procedure Test (R : Rec) is begin if R.D /= 9 then raise Program_Error; end if; end; R : Rec(9); begin R := (9, "123456789"); Test (R); end;
package body power_station with SPARK_Mode is ------------------- -- Start_Reactor -- ------------------- procedure Start_Reactor is Pressure, Temperature : Integer; Pressure_Warning, Pressure_Danger : Boolean; Temperature_Warning, Temperature_Danger : Boolean; Shutdown : Boolean; begin Pressure := 0; Temperature := 0; loop pragma Loop_Invariant (Status (Standard_Output) = Success and Pressure >= 0 and Pressure <= 3 and Temperature >= 0 and Temperature <= 3); Update_Reading("Pressure", Pressure, Shutdown); if Shutdown = True then Emergency_Shutdown; exit; end if; Update_Reading("Temperature", Temperature, Shutdown); if Shutdown = True then Emergency_Shutdown; exit; end if; Check_Reading(Pressure, Pressure_Warning, Pressure_Danger); Check_Reading(Temperature, Temperature_Warning, Temperature_Danger); if Pressure_Danger then Put_Line("Pressure at dangerous level."); Emergency_Shutdown; exit; end if; if Temperature_Danger then Put_Line("Temperature at dangerous level."); Emergency_Shutdown; exit; end if; if Pressure_Warning and Temperature_Warning then Put_Line("Pressure and temperature at warning levels."); Emergency_Shutdown; exit; elsif not Pressure_Warning and Temperature_Warning then Increase_Pressure; elsif Pressure_Warning and not Temperature_Warning then Decrease_Pressure; end if; pragma Assert(Shutdown = False and Pressure_Danger = False and Temperature_Danger = False and not (Pressure_Warning = True and Temperature_Warning = True)); end loop; end Start_Reactor; ------------------- -- Check_Reading -- ------------------- procedure Check_Reading(Value : in Integer; Warning, Danger : out Boolean) is begin if Value >= 2 then Warning := True; if Value = 3 then Danger := True; else Danger := False; end if; else Warning := False; Danger := False; end if; end Check_Reading; ----------------------- -- Decrease_Pressure -- ----------------------- procedure Decrease_Pressure is begin Put_Line("Decreasing pressure."); end Decrease_Pressure; ------------------------ -- Emergency_Shutdown -- ------------------------ procedure Emergency_Shutdown is begin Put_Line("SCRAM initiated."); Put_Line("Opening relief valve."); end Emergency_Shutdown; ----------------------- -- Increase_Pressure -- ----------------------- procedure Increase_Pressure is begin Put_Line("Increasing pressure."); end Increase_Pressure; --------------------- -- Update_Reading -- --------------------- procedure Update_Reading(Name : in String; Value : in out Integer; Shutdown : out Boolean) is Input : String(1..2); Stop : Integer; begin Shutdown := False; Put("Current "); Put(Name); Put(": "); Put_Line(Integer'Image(Value)); Put(Name); Put(" change: "); loop pragma Loop_Invariant (Status (Standard_Output) = Success); Get_Line(Input,Stop); exit when not (Stop = 0); end loop; if Input(1) = '+' then if Value < 3 then Value := Value + 1; end if; elsif Input(1) = '-' then if Value > 0 then Value := Value - 1; end if; elsif Input(1) /= '=' then Put_Line("Invalid input. Requesting shutdown."); Shutdown := True; end if; end Update_Reading; end power_station;
-- PACKAGE Factorial -- -- Natural logarithm of Factorial for arguments 0 and greater. -- -- Uses Stieltjes' Continued Fraction method arg > 32, and -- table for 0 <= arg <= 32. -- -- Meant to be good to (much much) better than 30 digits (if you -- can instantiate with a 30+ digit Real). That's why the -- order of the Stieltjes' Continued Fraction is so high. -- But ordinarily you use a 15 or 18 digit Real. -- generic type Real is digits <>; package Factorial is pragma Pure (Factorial); function Log_Factorial (N : in Natural) return Real; -- For N >= 0. Natural logarithm of N! -- -- Uses Stieltjes' Continued Fraction method above N=20. -- Probably good to a lot better than 32 digits (if you can find -- that many digits). procedure Test_Stieltjes_Coefficients; procedure Test_Log_Factorial_Table; -- Should call these sometime. The test routine will do it for you. -- They raise Program_Error if the tables of constants have mutated. end Factorial;
with Ada.Containers.Vectors; package AdaM.program_Unit is type Item is interface; -- View -- type View is access all Item'Class; -- Vector -- package Vectors is new ada.Containers.Vectors (Positive, View); subtype Vector is Vectors.Vector; private procedure dummy; end AdaM.program_Unit;
package Primes with SPARK_Mode is function IsPrime (N : in Positive) return Boolean with SPARK_Mode, Pre => N >= 2, Post => (if IsPrime'Result then (for all I in 2 .. N - 1 => N rem I /= 0) else (for some I in 2 .. N - 1 => N rem I = 0)); end Primes;
with Ada.integer_text_IO; use Ada; procedure add_by_referance is procedure add(a, b: in Integer; c: out Integer) is begin c := a + b; end add; answer : Integer; begin add(3, 5, answer); integer_text_IO.put(answer); end add_by_referance;
-- { dg-do compile } with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package Controller is type Iface is interface; type Thing is tagged record Name : Unbounded_String; end record; type Object is abstract new Thing and Iface with private; private type Object is abstract new Thing and Iface with record Surname : Unbounded_String; end record; end Controller;
package Discr36_Pkg is generic type T is private; function Func return T; end Discr36_Pkg;
package body Plugin.Base is procedure Say (Message : IRC.Message) is Arguments : Vector := Words (Message.Content); Answer : IRC.Message := Message; begin Answer.Channel := Arguments (2); Delete (Arguments, 1); Delete (Arguments, 1); Answer.Content := Unwords (Arguments); IRC.Put_Message (Answer); end Say; procedure Join (Message : IRC.Message) is Channel : Unbounded_String := Words (Message.Content)(2); begin if Element (Channel, 1) /= '#' then Channel := "#" & Channel; end if; IRC.Join_Channel (To_String (Channel)); end Join; procedure Leave (Message : IRC.Message) is begin IRC.Put_Line (To_String ("PART " & Message.Channel)); end Leave; procedure Nick (Message : IRC.Message) is begin IRC.Set_Nick (To_String (Element (Words (Message.Content), 2))); end Nick; end Plugin.Base;
-- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 Lionel Draghi <lionel.draghi@free.fr> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- 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 Smk.Files; use Smk.Files; with Ada.Containers.Doubly_Linked_Lists; private package Smk.Assertions is -- -------------------------------------------------------------------------- type Trigger_Type is (No_Trigger, File_Update, File_Presence, File_Absence); function Trigger_Image (Trigger : Trigger_Type) return String is (case Trigger is when No_Trigger => "No trigger ", when File_Update => "If update ", when File_Presence => "If presence", when File_Absence => "If absence "); Override : constant array (Trigger_Type, Trigger_Type) of Boolean := (No_Trigger => (others => False), File_Update => (No_Trigger => True, others => False), File_Presence => (others => True), File_Absence => (others => True)); type Condition is record File : Files.File_Type; Name : Files.File_Name; Trigger : Trigger_Type; end record; -- -------------------------------------------------------------------------- function "=" (L, R : Condition) return Boolean is (L.Name = R.Name and Role (L.File) = Role (R.File)); -- Equality is based on Name, but we also discriminate Sources from Targets -- -------------------------------------------------------------------------- function Image (A : Condition; Prefix : String := "") return String; -- return an Image of that kind: -- Prefix & [Pre :file exists] -- -------------------------------------------------------------------------- package Condition_Lists is new Ada.Containers.Doubly_Linked_Lists (Condition); -- NB: "=" redefinition modify Contains (and other operations) -- -------------------------------------------------------------------------- function Name_Order (Left, Right : Condition) return Boolean is (Left.Name < Right.Name); package Name_Sorting is new Condition_Lists.Generic_Sorting (Name_Order); -- function Time_Order (Left, Right : Condition) return Boolean is -- (Time_Tag (Left.File) < Time_Tag (Right.File)); -- package Time_Sorting is new Condition_Lists.Generic_Sorting (Time_Order); -- -------------------------------------------------------------------------- type File_Count is new Natural; function Count_Image (Count : File_Count) return String; -- -------------------------------------------------------------------------- function Count (Cond_List : Condition_Lists.List; Count_Sources : Boolean := False; Count_Targets : Boolean := False; With_System_Files : Boolean := False) return File_Count; -- -------------------------------------------------------------------------- type Rule_Kind is (Pattern_Rule, Simple_Rule); -- type Rule (Kind : Rule_Kind) is record -- when Pattern_Rule => -- From : Unbounded_String; -- To : Unbounded_String; -- when Simple_Rule => -- null; -- end record; end Smk.Assertions;
-- 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. limited with Orka.Contexts; package Orka.Windows is pragma Preelaborate; type Window is limited interface; function Create_Window (Context : Contexts.Surface_Context'Class; Width, Height : Positive; Title : String := ""; Samples : Natural := 0; Visible, Resizable : Boolean := True; Transparent : Boolean := False) return Window is abstract; function Width (Object : Window) return Positive is abstract; function Height (Object : Window) return Positive is abstract; procedure Set_Title (Object : in out Window; Value : String) is abstract; -- Set the title of the window -- -- Task safety: Must only be called from the environment task. procedure Close (Object : in out Window) is abstract; function Should_Close (Object : Window) return Boolean is abstract; procedure Swap_Buffers (Object : in out Window) is abstract; -- Swap the front and back buffers of the window -- -- Task safety: Must only be called from the rendering task. procedure Set_Vertical_Sync (Object : in out Window; Enable : Boolean) is abstract; -- Request the vertical retrace synchronization or vsync to be enabled -- or disabled -- -- Vsync causes the video driver to wait for a screen update before -- swapping the buffers. The video driver may ignore the request. -- Enablng vsync avoids tearing. end Orka.Windows;
with Ada.Strings.Bounded; package Encodings.Encoding_Lists is Encoding_Name_Length_Maximum: constant := 16; package Encoding_Name_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length( Max => Encoding_Name_Length_Maximum ); end Encodings.Encoding_Lists;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Interfaces.COBOL; use Interfaces.COBOL; package body P_StructuralTypes is package T_Bit_IO is new Ada.Text_IO.Modular_IO(T_Bit); function O_plus (b1 : in T_BinaryUnit ; b2 : in T_BinaryUnit) return T_BinaryUnit is Operand_Error : exception; res : T_BinaryUnit(1..b1'Length); begin if (b1'Length /= b2'Length) then raise Operand_Error; else for i in 1..b1'Length loop res(i) := b1(b1'First + i - 1) + b2(b2'First + i - 1); end loop; end if; return res; end; function TextBlock_To_Binary (Block : String) return T_BinaryBlock is BinaryTextBlock : T_BinaryBlock; IntValue : Integer; BitRank : Integer; begin for i in Block'Range loop BitRank := 0; IntValue := Character'Pos(Block(i)); while BitRank /= 8 loop BinaryTextBlock(i * 8 - BitRank) := T_Bit(IntValue mod 2); IntValue := IntValue / 2; BitRank := BitRank + 1; end loop; end loop; return BinaryTextBlock; end; function Byte_To_CharacterCode (Byte : in T_Byte) return Integer is CharCode : Integer; begin CharCode := 0; for i in Byte'Range loop CharCode := CharCode + Integer((Byte(Byte'First + i - 1)))*(2**(Byte'Last - i)); end loop; return CharCode; end; function Integer_To_Binary (Number : Integer; NbBits : Integer) return T_BinaryUnit is BitRank : Integer; Unit : T_BinaryUnit (1..NbBits); Tmp : Integer := Number; begin if (2 ** (NbBits +1)) < Number then raise Conversion_Error; else BitRank := 0; while Tmp /= 0 loop Unit(NbBits - BitRank) := T_Bit(Tmp mod 2); Tmp := Tmp / 2; BitRank := BitRank + 1; end loop; return Unit; end if; end; procedure Replace_Block (Ptr_BinaryContainer : in BinaryContainer_Access; Index : in Integer; BinaryBlock : in T_BinaryBlock) is begin Ptr_BinaryContainer.all(Index) := BinaryBlock; end; procedure Put_BinaryUnit (Unit : T_BinaryUnit) is begin Put ("Print of Unit") ; New_Line ; for i in Unit'Range loop T_Bit_IO.Put (Unit(i)) ; end loop; New_Line; end; procedure Left_Shift (Unit : in out T_BinaryUnit ; Iteration : in Positive) is OverflowBit : T_Bit; begin for Round in 1..Iteration loop OverflowBit := Unit(1); for Index in 1..Unit'Last-1 loop Unit(Index) := Unit(Index+1); end loop; Unit(Unit'Last) := OverflowBit; end loop; end; function Left (Block : T_BinaryUnit) return T_BinaryUnit is begin return Block (1..Block'Last/2); end; function Right (Block : T_BinaryUnit) return T_BinaryUnit is begin return Block ((Block'Last/2)+1..Block'Last); end; end P_StructuralTypes;
with Ada.Text_IO; procedure Digits_Squaring is function Is_89 (Number : in Positive) return Boolean is Squares : constant array (0 .. 9) of Natural := (0, 1, 4, 9, 16, 25, 36, 49, 64, 81); Sum : Natural := Number; Acc : Natural; begin loop Acc := Sum; Sum := 0; while Acc > 0 loop Sum := Sum + Squares (Acc mod 10); Acc := Acc / 10; end loop; if Sum = 89 then return True; end if; if Sum = 1 then return False; end if; end loop; end Is_89; use Ada.Text_IO; Count : Natural := 0; begin for A in 1 .. 99_999_999 loop if Is_89 (A) then Count := Count + 1; end if; if A = 999_999 then Put_Line ("In range 1 .. 999_999: " & Count'Image); end if; end loop; Put_Line ("In range 1 .. 99_999_999: " & Count'Image); end Digits_Squaring;
-- FILE: oedipus-complex_text_io.ads LICENSE: MIT © 2021 Mae Morella with Oedipus, Ada.Text_IO; use Oedipus, Ada.Text_IO; package Oedipus.Complex_Text_IO is -- Overloads the Put function, for printing Complex numbers. Same argument -- scheme as Ada.Float_Text_IO. Default_Aft : Field := 1; Default_Exp : Field := 0; Default_Fore : Field := 0; procedure Put (Item : in Complex; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); procedure Get (Item : out Complex); end Oedipus.Complex_Text_IO;
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Text_IO_Demo -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2004,2006 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.16 $ -- $Date: 2006/06/25 14:30:22 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Numerics.Generic_Elementary_Functions; with Ada.Numerics.Complex_Types; use Ada.Numerics.Complex_Types; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Text_IO; use Terminal_Interface.Curses.Text_IO; with Terminal_Interface.Curses.Text_IO.Integer_IO; with Terminal_Interface.Curses.Text_IO.Float_IO; with Terminal_Interface.Curses.Text_IO.Enumeration_IO; with Terminal_Interface.Curses.Text_IO.Complex_IO; with Terminal_Interface.Curses.Text_IO.Fixed_IO; with Terminal_Interface.Curses.Text_IO.Decimal_IO; with Terminal_Interface.Curses.Text_IO.Modular_IO; with Sample.Manifest; use Sample.Manifest; with Sample.Function_Key_Setting; use Sample.Function_Key_Setting; with Sample.Keyboard_Handler; use Sample.Keyboard_Handler; with Sample.Explanation; use Sample.Explanation; package body Sample.Text_IO_Demo is type Weekday is (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday); type Fix is delta 0.1 range 0.0 .. 4.0; type Dec is delta 0.01 digits 5 range 0.0 .. 4.0; type Md is mod 5; package Math is new Ada.Numerics.Generic_Elementary_Functions (Float); package Int_IO is new Terminal_Interface.Curses.Text_IO.Integer_IO (Integer); use Int_IO; package Real_IO is new Terminal_Interface.Curses.Text_IO.Float_IO (Float); use Real_IO; package Enum_IO is new Terminal_Interface.Curses.Text_IO.Enumeration_IO (Weekday); use Enum_IO; package C_IO is new Terminal_Interface.Curses.Text_IO.Complex_IO (Ada.Numerics.Complex_Types); use C_IO; package F_IO is new Terminal_Interface.Curses.Text_IO.Fixed_IO (Fix); use F_IO; package D_IO is new Terminal_Interface.Curses.Text_IO.Decimal_IO (Dec); use D_IO; package M_IO is new Terminal_Interface.Curses.Text_IO.Modular_IO (Md); use M_IO; procedure Demo is W : Window; P : Panel := Create (Standard_Window); K : Real_Key_Code; Im : constant Complex := (0.0, 1.0); Fx : constant Dec := 3.14; Dc : constant Dec := 2.72; L : Md; begin Push_Environment ("TEXTIO"); Default_Labels; Notepad ("TEXTIO-PAD00"); Set_Echo_Mode (False); Set_Meta_Mode; Set_KeyPad_Mode; W := Sub_Window (Standard_Window, Lines - 2, Columns - 2, 1, 1); Box; Refresh_Without_Update; Set_Meta_Mode (W); Set_KeyPad_Mode (W); Immediate_Update_Mode (W, True); Set_Window (W); for I in 1 .. 10 loop Put ("Square root of "); Put (Item => I, Width => 5); Put (" is "); Put (Item => Math.Sqrt (Float (I)), Exp => 0, Aft => 7); New_Line; end loop; for W in Weekday loop Put (Item => W); Put (' '); end loop; New_Line; L := Md'First; for I in 1 .. 2 loop for J in Md'Range loop Put (L); Put (' '); L := L + 1; end loop; end loop; New_Line; Put (Im); New_Line; Put (Fx); New_Line; Put (Dc); New_Line; loop K := Get_Key; if K in Special_Key_Code'Range then case K is when QUIT_CODE => exit; when HELP_CODE => Explain_Context; when EXPLAIN_CODE => Explain ("TEXTIOKEYS"); when others => null; end case; end if; end loop; Set_Window (Null_Window); Erase; Refresh_Without_Update; Delete (P); Delete (W); Pop_Environment; end Demo; end Sample.Text_IO_Demo;
package body GNAT.Strings is procedure Raw_Free is new Ada.Unchecked_Deallocation (String_List, String_List_Access); procedure Free (Arg : in out String_List_Access) is begin if Arg /= null then for I in Arg'Range loop Free (Arg (I)); end loop; Raw_Free (Arg); end if; end Free; end GNAT.Strings;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S T Y L E S W -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the style switches used for setting style options. -- The only clients of this package are the body of Style and the body of -- Switches. All other style checking issues are handled using the public -- interfaces in the spec of Style. with Types; use Types; package Stylesw is -------------------------- -- Style Check Switches -- -------------------------- -- These flags are used to control the details of the style checking -- options. The default values shown here correspond to no style -- checking. If any of these values is set to a non-default value, -- then Opt.Style_Check is set True to active calls to this package. -- The actual mechanism for setting these switches to other than -- default values is via the Set_Style_Check_Option procedure or -- through a call to Set_Default_Style_Check_Options. They should -- not be set directly in any other manner. Style_Check_Attribute_Casing : Boolean := False; -- This can be set True by using the -gnatg or -gnatya switches. If -- it is True, then attribute names (including keywords such as -- digits used as attribute names) must be in mixed case. Style_Check_Blanks_At_End : Boolean := False; -- This can be set True by using the -gnatg or -gnatyb switches. If -- it is True, then spaces at the end of lines are not permitted. Style_Check_Comments : Boolean := False; -- This can be set True by using the -gnatg or -gnatyc switches. If -- it is True, then comments are style checked as follows: -- -- All comments must be at the start of the line, or the first -- minus must be preceded by at least one space. -- -- For a comment that is not at the start of a line, the only -- requirement is that a space follow the comment characters. -- -- For a coment that is at the start of the line, one of the -- following conditions must hold: -- -- The comment characters are the only non-blank characters on the line -- -- The comment characters are followed by an exclamation point (the -- sequence --! is used by gnatprep for marking deleted lines). -- -- The comment characters are followed by two space characters -- -- The line consists entirely of minus signs -- -- The comment characters are followed by a single space, and the -- last two characters on the line are also comment characters. -- -- Note: the reason for the last two conditions is to allow "boxed" -- comments where only a single space separates the comment characters. Style_Check_End_Labels : Boolean := False; -- This can be set True by using the -gnatg or -gnatye switches. If -- it is True, then optional END labels must always be present. Style_Check_Form_Feeds : Boolean := False; -- This can be set True by using the -gnatg or -gnatyf switches. If -- it is True, then form feeds and vertical tabs are not allowed in -- the source text. Style_Check_Horizontal_Tabs : Boolean := False; -- This can be set True by using the -gnatg or -gnatyh switches. If -- it is True, then horizontal tabs are not allowed in source text. Style_Check_If_Then_Layout : Boolean := False; -- This can be set True by using the -gnatg or -gnatyi switches. If -- it is True, then a THEN keyword may not appear on the line that -- immediately follows the line containing the corresponding IF. -- -- This permits one of two styles for IF-THEN layout. Either the -- IF and THEN keywords are on the same line, where the condition -- is short enough, or the conditions are continued over to the -- lines following the IF and the THEN stands on its own. For -- example: -- -- if X > Y then -- -- if X > Y -- and then Y < Z -- then -- -- are allowed, but -- -- if X > Y -- then -- -- is not allowed. Style_Check_Indentation : Column_Number range 0 .. 9 := 0; -- This can be set non-zero by using the -gnatg or -gnatyn (n a digit) -- switches. If it is non-zero it activates indentation checking with -- the indicated indentation value. A value of zero turns off checking. -- The requirement is that any new statement, line comment, declaration -- or keyword such as END, start on a column that is a multiple of the -- indentiation value. Style_Check_Keyword_Casing : Boolean := False; -- This can be set True by using the -gnatg or -gnatyk switches. If -- it is True, then keywords are required to be in all lower case. -- This rule does not apply to keywords such as digits appearing as -- an attribute name. Style_Check_Max_Line_Length : Boolean := False; -- This can be set True by using the -gnatg or -gnatym switches. If -- it is True, it activates checking for a maximum line length of 79 -- characters (chosen to fit in standard 80 column displays that don't -- handle the limiting case of 80 characters cleanly). Style_Check_Pragma_Casing : Boolean := False; -- This can be set True by using the -gnatg or -gnatyp switches. If -- it is True, then pragma names must use mixed case. Style_Check_Layout : Boolean := False; -- This can be set True by using the -gnatg or -gnatyl switches. If -- it is True, it activates checks that constructs are indented as -- suggested by the examples in the RM syntax, e.g. that the ELSE -- keyword must line up with the IF keyword. Style_Check_References : Boolean := False; -- This can be set True by using the -gnatg or -gnatyr switches. If -- it is True, then all references to declared identifiers are -- checked. The requirement is that casing of the reference be the -- same as the casing of the corresponding declaration. Style_Check_Specs : Boolean := False; -- This can be set True by using the -gnatg or -gnatys switches. If -- it is True, then separate specs are required to be present for -- all procedures except parameterless library level procedures. -- The exception means that typical main programs do not require -- separate specs. Style_Check_Standard : Boolean := False; -- This can be set True by using the -gnatg or -gnatyn switches. If -- it is True, then any references to names in Standard have to be -- in mixed case mode (e.g. Integer, Boolean). Style_Check_Tokens : Boolean := False; -- This can be set True by using the -gnatg or -gnatyt switches. If -- it is True, then the style check that requires canonical spacing -- between various punctuation tokens as follows: -- -- ABS and NOT must be followed by a space -- -- => must be surrounded by spaces -- -- <> must be preceded by a space or left paren -- -- Binary operators other than ** must be surrounded by spaces. -- There is no restriction on the layout of the ** binary operator. -- -- Colon must be surrounded by spaces -- -- Colon-equal (assignment) must be surrounded by spaces -- -- Comma must be the first non-blank character on the line, or be -- immediately preceded by a non-blank character, and must be followed -- by a blank. -- -- A space must precede a left paren following a digit or letter, -- and a right paren must not be followed by a space (it can be -- at the end of the line). -- -- A right paren must either be the first non-blank character on -- a line, or it must be preceded by a non-blank character. -- -- A semicolon must not be preceded by a blank, and must not be -- followed by a non-blank character. -- -- A unary plus or minus may not be followed by a space -- -- A vertical bar must be surrounded by spaces -- -- Note that a requirement that a token be preceded by a space is -- met by placing the token at the start of the line, and similarly -- a requirement that a token be followed by a space is met by -- placing the token at the end of the line. Note that in the case -- where horizontal tabs are permitted, a horizontal tab is acceptable -- for meeting the requirement for a space. Style_Check_Subprogram_Order : Boolean := False; -- This can be set True by using the -gnatg or -gnatyo switch. If it -- is True, then names of subprogram bodies must be in alphabetical -- order (not taking casing into account). Style_Max_Line_Length : Int := 79; -- Value used to check maximum line length. Can be reset by a call to -- Set_Max_Line_Length. The value here is the default if no such call. ----------------- -- Subprograms -- ----------------- procedure Set_Default_Style_Check_Options; -- This procedure is called to set the default style checking options -- in response to a -gnatg switch or -gnaty with no suboptions. procedure Set_Style_Check_Options (Options : String; OK : out Boolean; Err_Col : out Natural); -- This procedure is called to set the style check options that -- correspond to the characters in the given Options string. If -- all options are valid, they are set in an additive manner: -- any previous options are retained unless overridden. If any -- invalid character is found, then OK is False on exit, and -- Err_Col is the index in options of the bad character. If all -- options are valid, OK is True on return, and Err_Col is set -- to Options'Last + 1. procedure Set_Style_Check_Options (Options : String); -- Like the above procedure, except that the call is simply ignored if -- there are any error conditions, this is for example appopriate for -- calls where the string is known to be valid, e.g. because it was -- obtained by Save_Style_Check_Options. procedure Reset_Style_Check_Options; -- Sets all style check options to off subtype Style_Check_Options is String (1 .. 32); -- Long enough string to hold all options from Save call below procedure Save_Style_Check_Options (Options : out Style_Check_Options); -- Sets Options to represent current selection of options. This -- set can be restored by first calling Reset_Style_Check_Options, -- and then calling Set_Style_Check_Options with the Options string. end Stylesw;
package Encodings.Unicode is Code_Point_Last: constant Wide_Wide_Character := Wide_Wide_Character'Val(16#10FFFF#); end Encodings.Unicode;
-- C37008A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT SPECIFYING AN INVALID DEFAULT INITIALIZATION -- RAISES CONSTRAINT_ERROR WHEN AN OBJECT IS DECLARED. -- DAT 3/6/81 -- SPS 10/26/82 -- RJW 1/9/86 - REVISED COMMENTS. ADDED 'IDENT_INT'. -- EDS 7/22/98 AVOID OPTIMIZATION WITH REPORT; USE REPORT; PROCEDURE C37008A IS BEGIN TEST ("C37008A", "CHECK THAT INVALID DEFAULT RECORD" & " COMPONENT INITIALIZATIONS RAISE" & " CONSTRAINT_ERROR"); BEGIN DECLARE TYPE R1 IS RECORD C1 : INTEGER RANGE 1 .. 5 := IDENT_INT (0); END RECORD; REC1 : R1; BEGIN FAILED ("NO EXCEPTION RAISED 1 " & INTEGER'IMAGE(REC1.C1)); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 1"); END; BEGIN DECLARE TYPE R IS RECORD C : CHARACTER RANGE 'A' .. 'Y' := 'Z'; END RECORD; REC2 : R; BEGIN FAILED ("NO EXCEPTION RAISED 1A " & (REC2.C)); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 1A"); END; BEGIN DECLARE TYPE R2 IS RECORD C2 : BOOLEAN RANGE FALSE .. FALSE := TRUE; END RECORD; REC3 : R2; BEGIN FAILED ("NO EXCEPTION RAISED 2 " & BOOLEAN'IMAGE(REC3.C2)); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 2"); END; BEGIN DECLARE TYPE E IS (E1, E2, E3); TYPE R IS RECORD C : E RANGE E2 .. E3 := E1; END RECORD; REC4 : R; BEGIN FAILED ("NO EXCEPTION RAISED 2A " & E'IMAGE(REC4.C)); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 2A"); END; BEGIN DECLARE TYPE R3 IS RECORD C3 : INTEGER RANGE 1 .. 5; END RECORD; REC5 : R3; TYPE R3A IS RECORD C3A : R3 := (OTHERS => IDENT_INT (6)); END RECORD; REC6 : R3A; BEGIN FAILED ("NO EXCEPTION RAISED 3 " & INTEGER'IMAGE(REC6.C3A.C3)); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 3"); END; BEGIN DECLARE TYPE ARR IS ARRAY (1..3) OF INTEGER RANGE 8..9; TYPE R4 IS RECORD C4 : ARR := (1 => 8, 2 => 9, 3 => 10); END RECORD; REC7 : R4; BEGIN FAILED ("NO EXCEPTION RAISED 4 " & INTEGER'IMAGE(REC7.C4(1))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 4"); END; BEGIN DECLARE TYPE A IS ARRAY (NATURAL RANGE <> ) OF INTEGER RANGE 1 .. 5; TYPE AA IS ACCESS A; TYPE R5 IS RECORD C5 : AA := NEW A' (4, 5, 6); END RECORD; REC8 : R5; BEGIN FAILED ("NO EXCEPTION RAISED 5 " & INTEGER'IMAGE(REC8.C5(1))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 5"); END; BEGIN DECLARE TYPE A IS ARRAY (NATURAL RANGE <> ) OF INTEGER RANGE 1 .. 5; TYPE AA IS ACCESS A (1 .. 3); TYPE R6 IS RECORD C6 : AA := NEW A' (4, 4, 4, 4); END RECORD; REC9 : R6; BEGIN FAILED ("NO EXCEPTION RAISED 6 " & INTEGER'IMAGE(REC9.C6(1))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 6"); END; BEGIN DECLARE TYPE AI IS ACCESS INTEGER RANGE 6 .. 8; TYPE R7 IS RECORD C7 : AI := NEW INTEGER' (5); END RECORD; REC10 : R7; BEGIN FAILED ("NO EXCEPTION RAISED 7 " & INTEGER'IMAGE(REC10.C7.ALL)); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 7"); END; BEGIN DECLARE TYPE UA IS ARRAY (NATURAL RANGE <> ) OF INTEGER RANGE 3 .. 5; SUBTYPE CA IS UA (7 .. 8); TYPE R8 IS RECORD C8 : CA := (6 .. 8 => 4); END RECORD; REC11 : R8; BEGIN FAILED ("NO EXCEPTION RAISED 8 " & INTEGER'IMAGE(REC11.C8(7))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 8"); END; BEGIN DECLARE TYPE UA IS ARRAY (NATURAL RANGE <> ) OF INTEGER RANGE 3 .. IDENT_INT(5); TYPE R9 IS RECORD C9 : UA (11 .. 11) := (11 => 6); END RECORD; REC12 : R9; BEGIN FAILED ("NO EXCEPTION RAISED 9 " & INTEGER'IMAGE(REC12.C9(11))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 9"); END; BEGIN DECLARE TYPE A IS ARRAY (NATURAL RANGE <> ) OF INTEGER RANGE 1 .. IDENT_INT (5); TYPE AA IS ACCESS A; TYPE R10 IS RECORD C10 : AA := NEW A '(4, 5, 6); END RECORD; REC13 : R10; BEGIN FAILED ("NO EXCEPTION RAISED 10 " & INTEGER'IMAGE(REC13.C10(1))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 10"); END; BEGIN DECLARE TYPE A IS ARRAY (NATURAL RANGE <> ) OF INTEGER RANGE 1 .. 5; TYPE AA IS ACCESS A (IDENT_INT (1) .. IDENT_INT (3)); TYPE R11 IS RECORD C11 : AA := NEW A '(4, 4, 4, 4); END RECORD; REC14 : R11; BEGIN FAILED ("NO EXCEPTION RAISED 11 " & INTEGER'IMAGE(REC14.C11(1))); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 11"); END; RESULT; END C37008A;
-- Copyright 2017-2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "WhoisXMLAPI" type = "api" function start() setratelimit(2) end function check() local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local resp, err = request(ctx, { url=verturl(domain, c.key), headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return end local j = json.decode(resp) if (j == nil or j.result == nil or j.result.count == 0 or #(j.result.records) == 0) then return end for _, r in pairs(j.result.records) do newname(ctx, r.domain) end end function verturl(domain, key) return "https://subdomains.whoisxmlapi.com/api/v1?apiKey=" .. key .. "&domainName=" .. domain end function horizontal(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local body, err = json.encode({ apiKey=c.key, searchType="current", mode="purchase", basicSearchTerms={ include={domain}, }, }) if (err ~= nil and err ~= "") then return end resp, err = request(ctx, { method="POST", data=body, url="https://reverse-whois.whoisxmlapi.com/api/v2", headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return end local j = json.decode(resp) if (j == nil or j.domainsCount == 0) then return end for _, name in pairs(j.domainsList) do associated(ctx, domain, name) end end function asn(ctx, addr, asn) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local prefix if (asn == 0) then if (addr == "") then return end asn = getasn(ctx, addr, c.key) if (asn == 0) then return end end local a = asinfo(ctx, asn, c.key) if (a == nil) then return end newasn(ctx, { ['addr']=addr, ['asn']=asn, ['prefix']=a.netblocks[1], ['cc']=a.cc, ['registry']=a.registry, ['desc']=a.desc, ['netblocks']=a.netblocks, }) end function getasn(ctx, ip, key) local resp, err = request(ctx, { url="https://ip-netblocks.whoisxmlapi.com/api/v2?apiKey=" .. key .. "&ip=" .. ip, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return 0 end local j = json.decode(resp) if (j == nil or j.result == nil or j.result.count == 0 or #(j.result.inetnums) == 0) then return end local asn = 0 for _, r in pairs(j.result.inetnums) do if r.as ~= nil and r.as.asn > 0 then asn = r.as.asn break end end return asn end function asinfo(ctx, asn, key) local resp, err = request(ctx, { url="https://ip-netblocks.whoisxmlapi.com/api/v2?apiKey=" .. key .. "&asn=" .. tostring(asn), headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return nil end local j = json.decode(resp) if (j == nil or j.result == nil or j.result.count == 0 or #(j.result.inetnums) == 0) then return nil end local cc = "" local name = "" local registry = "" local netblocks = {} for i, r in pairs(j.result.inetnums) do if i == 1 then registry = r.source if r.org ~= nil then cc = r.org.country name = r.org.name end end if r.as ~= nil and r.as.asn == asn and r.as.route ~= nil and r.as.route ~= "" then table.insert(netblocks, r.as.route) end end return { ['asn']=asn, desc=name, ['cc']=cc, ['registry']=registry, ['netblocks']=netblocks, } end
with Ada.Iterator_Interfaces; with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Containers.Vectors; with Ada.Finalization; use Ada; with EU_Projects.Nodes.Partners; with EU_Projects.Nodes.Timed_Nodes.Milestones; with EU_Projects.Nodes.Timed_Nodes.Deliverables; with EU_Projects.Nodes.Action_Nodes.WPs; with EU_Projects.Nodes.Action_Nodes.Tasks; with EU_Projects.Nodes.Risks; with EU_Projects.Node_Tables; with EU_Projects.Times; use EU_Projects.Nodes.Action_Nodes; use EU_Projects.Nodes.Timed_Nodes; with EU_Projects.Nodes.Timed_Nodes.Project_Infos; -- with Ada.Containers.Ordered_Maps; -------------------------- -- EU_Projects.Projects -- -------------------------- package EU_Projects.Projects is type Project_Descriptor is new Finalization.Limited_Controlled with private; type Project_Access is access Project_Descriptor; function Node_Directory (Item : aliased in out Project_Descriptor) return Node_Tables.Table_Ref; function Is_Blessed (Project : Project_Descriptor) return Boolean; procedure Bless (Project : in out Project_Descriptor; Info : Nodes.Timed_Nodes.Project_Infos.Info_Access) with Pre => not Project.Is_Blessed, Post => Project.Is_Blessed; procedure Configure (Project : in out Project_Descriptor; Name : String; Value : String); procedure Add_Partner (Project : in out Project_Descriptor; Partner : in Nodes.Partners.Partner_Access); procedure Add_WP (Project : in out Project_Descriptor; WP : in WPs.Project_WP_Access); procedure Add_Milestone (Project : in out Project_Descriptor; Item : in Nodes.Timed_Nodes.Milestones.Milestone_Access); procedure Add_Risk (Project : in out Project_Descriptor; Item : in Nodes.Risks.Risk_Access); type Freezing_Options is private; Sort_Milestones : constant Freezing_Options; function "+" (X, Y : Freezing_Options) return Freezing_Options; procedure Freeze (Project : in out Project_Descriptor; Options : Freezing_Options := Sort_Milestones) with Pre => not Project.Is_Freezed and Project.Is_Blessed, Post => Project.Is_Freezed; -- Do final housekeeping such as checking for duplicate labels, resolving -- all the implicit time references in the project and so on. -- Raise exception Unsolvable if some references cannot be resolved -- (usually because of a circular reference) and Duplicate_Label if -- there is more than one node with the same label function Is_Freezed (Project : Project_Descriptor) return Boolean; Unsolvable : exception; Duplicated_Label : exception; function Find (Where : Project_Descriptor; Label : Nodes.Node_Label) return Nodes.Node_Access; -- Search for a child with the given name and return it -- Return null if the child does not exist function Exists (Where : Project_Descriptor; Label : Nodes.Node_Label) return Boolean; function Duration (Item : Project_Descriptor) return Times.Instant; type Month_Number is new Positive; subtype Extended_Month_Number is Month_Number'Base range Month_Number'First - 1 .. Month_Number'Last; No_Month : constant Extended_Month_Number := Extended_Month_Number'First; type Milestone_Table_Type is array (Month_Number range <>, Positive range <>) of Nodes.Timed_Nodes.Milestones.Milestone_Access; function Milestone_Table (Item : Project_Descriptor) return Milestone_Table_Type with Pre => Item.Is_Freezed; -- ========= -- -- ITERATORS -- -- ========= -- ------------------ -- WP Iterators -- ------------------ type WP_Cursor is private; function Has_Element (X : WP_Cursor) return Boolean; package WP_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => WP_Cursor, Has_Element => Has_Element); function All_WPs (Item : Project_Descriptor) return WP_Iterator_Interfaces.Forward_Iterator'Class; function Element (Index : WP_Cursor) return WPs.Project_WP_Access; function N_WPs (Item : Project_Descriptor) return Natural; ----------------------- -- Partner Iterators -- ----------------------- type Partner_Cursor is private; function Has_Element (X : Partner_Cursor) return Boolean; package Partner_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => Partner_Cursor, Has_Element => Has_Element); function All_Partners (Item : Project_Descriptor) return Partner_Iterator_Interfaces.Forward_Iterator'Class; function Element (Index : Partner_Cursor) return Nodes.Partners.Partner_Access; function N_Partners (Item : Project_Descriptor) return Natural; function Partner_Names (Item : Project_Descriptor) return Nodes.Partners.Partner_Name_Array; -------------------- -- Risk Iterators -- -------------------- type Risk_Cursor is private; function Has_Element (X : Risk_Cursor) return Boolean; package Risk_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => Risk_Cursor, Has_Element => Has_Element); function All_Risks (Item : Project_Descriptor) return Risk_Iterator_Interfaces.Forward_Iterator'Class; ------------------------- -- All Nodes Iterators -- ------------------------- type All_Node_Cursor is private; function Has_Element (X : All_Node_Cursor) return Boolean; package All_Node_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => All_Node_Cursor, Has_Element => Has_Element); function All_Nodes (Item : Project_Descriptor; Full : Boolean := False) return All_Node_Iterator_Interfaces.Forward_Iterator'Class; function Element (Index : All_Node_Cursor) return Nodes.Node_Access; ------------------------- -- Milestone Iterators -- ------------------------- type Milestone_Cursor is private; function Has_Element (X : Milestone_Cursor) return Boolean; package Milestone_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => Milestone_Cursor, Has_Element => Has_Element); function All_Milestones (Item : Project_Descriptor) return Milestone_Iterator_Interfaces.Forward_Iterator'Class; function Element (Index : Milestone_Cursor) return Nodes.Timed_Nodes.Milestones.Milestone_Access; ----------------------- -- All task iteration -- ------------------------ type All_Task_Cursor is private; function Element (Index : All_Task_Cursor) return Tasks.Project_Task_Access; function Has_Element (X : All_Task_Cursor) return Boolean; package All_Task_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => All_Task_Cursor, Has_Element => Has_Element); function All_Tasks (Item : Project_Descriptor) return All_Task_Iterator_Interfaces.Forward_Iterator'Class; type All_Deliverable_Cursor is private; function Element (Index : All_Deliverable_Cursor) return Deliverables.Deliverable_Access; function Has_Element (X : All_Deliverable_Cursor) return Boolean; package All_Deliverable_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor => All_Deliverable_Cursor, Has_Element => Has_Element); function All_Deliverables (Item : Project_Descriptor) return All_Deliverable_Iterator_Interfaces.Forward_Iterator'Class; private use WPs, Nodes.Partners, Nodes.Timed_Nodes.Milestones; use Nodes, Nodes.Risks; -- procedure Add_Node (Project : in out Project_Descriptor; -- Label : Nodes.Node_Label; -- Node : Nodes.Node_Access); type Cursor is null record; -- type Deliverable_Cursor is -- new Nodes.Node_Index'Base range Nodes.Node_Index'First - 1 .. Nodes.Node_Index'Last; -- -- type Milestone_Cursor is -- new Nodes.Node_Index'Base range Nodes.Node_Index'First - 1 .. Nodes.Node_Index'Last; -- -- package WP_Lists is new Ada.Containers.Vectors (Index_Type => WP_Index, Element_Type => Project_WP_Access); package Partner_Lists is new Ada.Containers.Vectors (Index_Type => Partner_Index, Element_Type => Partner_Access); package Risk_Vectors is new Ada.Containers.Vectors (Index_Type => Risks.Risk_Index, Element_Type => Risks.Risk_Access); package Milestone_Vectors is new Ada.Containers.Vectors (Index_Type => Milestones.Milestone_Index, Element_Type => Milestones.Milestone_Access); use type Times.Instant; function Is_Earlier (X, Y : Milestones.Milestone_Access) return Boolean is (Times.Instant'(X.Due_On) < Times.Instant'(Y.Due_On)); package Milestone_Sort is new Milestone_Vectors.Generic_Sorting ("<" => Is_Earlier); package Option_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String, Element_Type => String); -- package Node_Maps is -- new Ada.Containers.Ordered_Maps (Key_Type => Nodes.Node_Label, -- Element_Type => Nodes.Node_Access); use type Nodes.Timed_Nodes.Project_Infos.Info_Access; type Project_Descriptor is new Finalization.Limited_Controlled with record Options : Option_Maps.Map; WP_List : WP_Lists.Vector; Partner_List : Partner_Lists.Vector; Risk_List : Risk_Vectors.Vector; Milestones : Milestone_Vectors.Vector; Node_Directory : aliased Node_Tables.Node_Table; Freezed : Boolean := False; Last_Month : Times.Instant := Times.Earliest_Istant; Info : Project_Infos.Info_Access := null; end record; function Is_Blessed (Project : Project_Descriptor) return Boolean is (Project.Info /= null); function Duration (Item : Project_Descriptor) return Times.Instant is (Item.Last_Month); function N_Partners (Item : Project_Descriptor) return Natural is (Natural (Item.Partner_List.Length)); function N_WPs (Item : Project_Descriptor) return Natural is (Natural (Item.WP_List.Length)); function Node_Directory (Item : aliased in out Project_Descriptor) return Node_Tables.Table_Ref is (D => Item.Node_Directory'Access); ------------------------- -- Milestone iteration -- ------------------------- type Milestone_Cursor is new Milestone_Vectors.Cursor; type Milestone_Iterator is new Milestone_Iterator_Interfaces.Forward_Iterator with record Start : Milestone_Vectors.Cursor; end record; overriding function First (Object : Milestone_Iterator) return Milestone_Cursor is (Milestone_Cursor (Object.Start)); overriding function Next (Object : Milestone_Iterator; Position : Milestone_Cursor) return Milestone_Cursor is (Milestone_Cursor (Milestone_Vectors.Next (Milestone_Vectors.Cursor (Position)))); function Element (Index : Milestone_Cursor) return Nodes.Timed_Nodes.Milestones.Milestone_Access is (Milestone_Vectors.Element (Milestone_Vectors.Cursor (Index))); function Has_Element (X : Milestone_Cursor) return Boolean is (Milestone_Vectors.Has_Element (Milestone_Vectors.Cursor (X))); function All_Milestones (Item : Project_Descriptor) return Milestone_Iterator_Interfaces.Forward_Iterator'Class is (Milestone_Iterator'(Start => Item.Milestones.First)); ------------------ -- WP iteration -- ------------------ type WP_Cursor is new WP_Lists.Cursor; type Task_Cursor is record WP : WP_Cursor; Tsk : Nodes.Node_Index; end record; type WP_Iterator is new WP_Iterator_Interfaces.Forward_Iterator with record Start : WP_Cursor; end record; overriding function First (Object : WP_Iterator) return WP_Cursor is (Object.Start); overriding function Next (Object : WP_Iterator; Position : WP_Cursor) return WP_Cursor is (WP_Cursor (WP_Lists.Next (WP_Lists.Cursor (Position)))); function Element (Index : WP_Cursor) return Nodes.Action_Nodes.WPs.Project_WP_Access is (WP_Lists.Element (WP_Lists.Cursor (Index))); function Has_Element (X : WP_Cursor) return Boolean is (WP_Lists.Has_Element (WP_Lists.Cursor (X))); function All_WPs (Item : Project_Descriptor) return WP_Iterator_Interfaces.Forward_Iterator'Class is (WP_Iterator'(Start => WP_Cursor (Item.WP_List.First))); ----------------------- -- Partner iteration -- ----------------------- type Partner_Cursor is new Partner_Lists.Cursor; type Partner_Iterator is new Partner_Iterator_Interfaces.Forward_Iterator with record Start : Partner_Lists.Cursor; end record; overriding function First (Object : Partner_Iterator) return Partner_Cursor is (Partner_Cursor (Object.Start)); overriding function Next (Object : Partner_Iterator; Position : Partner_Cursor) return Partner_Cursor is (Partner_Cursor (Partner_Lists.Next (Partner_Lists.Cursor (Position)))); function Element (Index : Partner_Cursor) return Nodes.Partners.Partner_Access is (Partner_Lists.Element (Partner_Lists.Cursor (Index))); function Has_Element (X : Partner_Cursor) return Boolean is (Partner_Lists.Has_Element (Partner_Lists.Cursor (X))); function All_Partners (Item : Project_Descriptor) return Partner_Iterator_Interfaces.Forward_Iterator'Class is (Partner_Iterator'(Start => Item.Partner_List.First)); ------------------------ -- All task iteration -- ------------------------ type All_Task_Cursor is record WP_Pos : WP_Cursor; Task_Pos : WPs.Task_Cursor; Task_Iter : WPs.Task_Iterator; end record; function Element (Index : All_Task_Cursor) return Tasks.Project_Task_Access is (WPs.Element (Index.Task_Pos)); function Has_Element (X : All_Task_Cursor) return Boolean is (Has_Element (X.WP_Pos)); type All_Task_Iterator is new All_Task_Iterator_Interfaces.Forward_Iterator with record WP_Iter : WP_Iterator; end record; overriding function First (Object : All_Task_Iterator) return All_Task_Cursor; overriding function Next (Object : All_Task_Iterator; Position : All_Task_Cursor) return All_Task_Cursor; function All_Tasks (Item : Project_Descriptor) return All_Task_Iterator_Interfaces.Forward_Iterator'Class is (All_Task_Iterator'(WP_Iter => WP_Iterator (Item.All_WPs))); ------------------------------ -- All_Deliverable_Iterator -- ------------------------------ type All_Deliverable_Iterator is new All_Deliverable_Iterator_Interfaces.Forward_Iterator with record WP_Iter : WP_Iterator; end record; type All_Deliverable_Cursor is record WP_Pos : WP_Cursor; Deliv_Pos : WPs.Deliverable_Cursor; Deliv_Iter : WPs.Deliverable_Iterator; end record; function Element (Index : All_Deliverable_Cursor) return Deliverables.Deliverable_Access is (WPs.Element (Index.Deliv_Pos)); function Has_Element (X : All_Deliverable_Cursor) return Boolean is (Has_Element (X.Deliv_Pos)); overriding function First (Object : All_Deliverable_Iterator) return All_Deliverable_Cursor; overriding function Next (Object : All_Deliverable_Iterator; Position : All_Deliverable_Cursor) return All_Deliverable_Cursor; function All_Deliverables (Item : Project_Descriptor) return All_Deliverable_Iterator_Interfaces.Forward_Iterator'Class is (All_Deliverable_Iterator'(WP_Iter => WP_Iterator (Item.All_WPs))); -------------------- -- Risk iteration -- -------------------- type Risk_Cursor is new Risk_Vectors.Cursor; type Risk_Iterator is new Risk_Iterator_Interfaces.Forward_Iterator with record Start : Risk_Vectors.Cursor; end record; overriding function First (Object : Risk_Iterator) return Risk_Cursor is (Risk_Cursor (Object.Start)); overriding function Next (Object : Risk_Iterator; Position : Risk_Cursor) return Risk_Cursor is (Risk_Cursor (Risk_Vectors.Next (Risk_Vectors.Cursor (Position)))); function Element (Index : Risk_Cursor) return Risks.Risk_Access is (Risk_Vectors.Element (Risk_Vectors.Cursor (Index))); function Has_Element (X : Risk_Cursor) return Boolean is (Risk_Vectors.Has_Element (Risk_Vectors.Cursor (X))); function All_Risks (Item : Project_Descriptor) return Risk_Iterator_Interfaces.Forward_Iterator'Class is (Risk_Iterator'(Start => Item.Risk_List.First)); ------------------------- -- All Node iteration -- ------------------------- subtype Restricted_Node_Class is Nodes.Node_Class range Node_Class'Succ (Nodes.Info_Node) .. Node_Class'Last; type All_Node_Cursor is record Prj_Info_Access : Nodes.Timed_Nodes.Project_Infos.Info_Access; Current_Class : Restricted_Node_Class; Risk_Pos : Risk_Cursor; Deliverable_Pos : All_Deliverable_Cursor; WP_Pos : WP_Cursor; Task_Pos : All_Task_Cursor; Partner_Pos : Partner_Cursor; Milestone_Pos : Milestone_Cursor; end record; type All_Node_Iterator is new All_Node_Iterator_Interfaces.Forward_Iterator with record Prj_Info_Access : Project_Infos.Info_Access; Risk_Iter : Risk_Iterator; Deliverable_Iter : All_Deliverable_Iterator; WP_Iter : WP_Iterator; All_Task_Iter : All_Task_Iterator; Partner_Iter : Partner_Iterator; Milestone_Iter : Milestone_Iterator; end record; overriding function First (Object : All_Node_Iterator) return All_Node_Cursor is (All_Node_Cursor'(Current_Class => Node_Class'Succ (Info_Node), Prj_Info_Access => Object.Prj_Info_Access, Risk_Pos => First (Object.Risk_Iter), Deliverable_Pos => First (Object.Deliverable_Iter), WP_Pos => First (Object.WP_Iter), Task_Pos => First (Object.All_Task_Iter), Partner_Pos => First (Object.Partner_Iter), Milestone_Pos => First (Object.Milestone_Iter))); overriding function Next (Object : All_Node_Iterator; Position : All_Node_Cursor) return All_Node_Cursor; function Element (Index : All_Node_Cursor) return Node_Access is (if Index.Prj_Info_Access /= null then Node_Access (Index.Prj_Info_Access) else (case Index.Current_Class is when WP_Node => Node_Access (Element (Index.WP_Pos)), when Task_Node => Node_Access (Element (Index.Task_Pos)), when Deliverable_Node => Node_Access (Element (Index.Deliverable_Pos)), when Risk_Node => Node_Access (Element (Index.Risk_Pos)), when Partner_Node => Node_Access (Element (Index.Partner_Pos)), when Milestone_Node => Node_Access (Element (Index.Milestone_Pos)))); function Has_Element (X : All_Node_Cursor) return Boolean is (X.Prj_Info_Access /= null or else X.Current_Class /= Nodes.Node_Class'Last or else Has_Element (X.Partner_Pos)); pragma Compile_Time_Error (Node_Class'Last /= Partner_Node, "Wrong has_element"); function All_Nodes (Item : Project_Descriptor; Full : Boolean := False) return All_Node_Iterator_Interfaces.Forward_Iterator'Class is (All_Node_Iterator' (Prj_Info_Access => (if Full then Item.Info else null), Risk_Iter => Risk_Iterator (Item.All_Risks), Deliverable_Iter => All_Deliverable_Iterator (Item.All_Deliverables), WP_Iter => WP_Iterator (Item.All_WPs), All_Task_Iter => All_Task_Iterator (Item.All_Tasks), Partner_Iter => Partner_Iterator (Item.All_Partners), Milestone_Iter => Milestone_Iterator (Item.All_Milestones))); function Is_Freezed (Project : Project_Descriptor) return Boolean is (Project.Freezed); type Freezing_Basic_Option is (Milestone_Sorting); type Freezing_Options is array (Freezing_Basic_Option) of Boolean; pragma Warnings(Off, "there are no others"); Sort_Milestones : constant Freezing_Options := (Milestone_Sorting => True, others => False); function "+" (X, Y : Freezing_Options) return Freezing_Options is (X or Y); end EU_Projects.Projects; -- function Find (Resolver : Project_Descriptor; -- What : Identifiers.Full_Paths.Full_ID) -- return Boolean; -- function Get_Attribute (Project : Project_Descriptor; -- Name : Identifier) -- return String; -- -- function Get_Attribute (Project : Project_Descriptor; -- Name : Identifier) -- return Integer; -- function Get (Project : Project_Descriptor; -- Name : WPs.WP_Label) -- return WPs.Project_WP_Access; -- -- function Get (Project : Project_Descriptor; -- Name : Nodes.Partners.Partner_Label) -- return Nodes.Partners.Partner_Access;
package Derived_Record is type Tagged_Record is tagged record Component_1 : Integer; end record; type Derived_Record is new Tagged_Record with record Component_2 : Integer; end record; end Derived_Record;
--////////////////////////////////////////////////////////// -- SFML - Simple and Fast Multimedia Library -- Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) -- This software is provided 'as-is', without any express or implied warranty. -- In no event will the authors be held liable for any damages arising from the use of this software. -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it freely, -- subject to the following restrictions: -- 1. The origin of this software must not be misrepresented; -- you must not claim that you wrote the original software. -- If you use this software in a product, an acknowledgment -- in the product documentation would be appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, -- and must not be misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// with Sf.System.Vector2; package Sf.Window.Mouse is --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --/ @brief Mouse buttons --/ --////////////////////////////////////////////////////////// --/< The left mouse button --/< The right mouse button --/< The middle (wheel) mouse button --/< The first extra mouse button --/< The second extra mouse button --/< Keep last -- the total number of mouse buttons type sfMouseButton is (sfMouseLeft, sfMouseRight, sfMouseMiddle, sfMouseXButton1, sfMouseXButton2, sfMouseButtonCount); --////////////////////////////////////////////////////////// --/ @brief Mouse wheels --/ --////////////////////////////////////////////////////////// --/< The vertical mouse wheel --/< The horizontal mouse wheel type sfMouseWheel is (sfMouseVerticalWheel, sfMouseHorizontalWheel); --////////////////////////////////////////////////////////// --/ @brief Check if a mouse button is pressed --/ --/ @param button Button to check --/ --/ @return sfTrue if the button is pressed, sfFalse otherwise --/ --////////////////////////////////////////////////////////// function isButtonPressed (button : sfMouseButton) return sfBool; --////////////////////////////////////////////////////////// --/ @brief Get the current position of the mouse --/ --/ This function returns the current position of the mouse --/ cursor relative to the given window, or desktop if NULL is passed. --/ --/ @param relativeTo Reference window --/ --/ @return Position of the mouse cursor, relative to the given window --/ --////////////////////////////////////////////////////////// function getPosition (relativeTo : sfWindow_Ptr) return Sf.System.Vector2.sfVector2i; --////////////////////////////////////////////////////////// --/ @brief Set the current position of the mouse --/ --/ This function sets the current position of the mouse --/ cursor relative to the given window, or desktop if NULL is passed. --/ --/ @param position New position of the mouse --/ @param relativeTo Reference window --/ --////////////////////////////////////////////////////////// procedure setPosition (position : Sf.System.Vector2.sfVector2i; relativeTo : sfWindow_Ptr); private pragma Convention (C, sfMouseButton); pragma Convention (C, sfMouseWheel); pragma Import (C, isButtonPressed, "sfMouse_isButtonPressed"); pragma Import (C, getPosition, "sfMouse_getPosition"); pragma Import (C, setPosition, "sfMouse_setPosition"); end Sf.Window.Mouse;
--with Text_io; use Text_io; package body Sorted_Array is Empty_Slot : constant Item := Item'Last; -- make type Item bigger if possible than data *set*. -- eg Item = Parent_Random_Int; or Random_Int'Base. -- would prefer Empty_Slot is out of range of actual data. -- not necessary tho. type Table is array (Table_Index) of Item; T : Table := (others => Empty_Slot); Index_of_Next_Item_to_Read : Table_Index := Table_Index'First; No_More_Items_Remaining : Boolean := False; -- Routines for reading the array sequentially (from beginning to end): -------------------------------------- -- Start_Reading_Array_at_Beginning -- -------------------------------------- procedure Start_Reading_Array_at_Beginning is begin Index_of_Next_Item_to_Read := Table_Index'First; end Start_Reading_Array_at_Beginning; ------------------------------- -- Set_Index_to_Present_Item -- ------------------------------- -- procedure Set_Index_to_Present_Item leaves index alone if it points -- a readable item, or else goes to next item if it exists, or to end of array -- if there are no more items. So if after calling Set_Index_to_Next_Item we -- find that T(Index_of_Next_Item_to_Read) = Empty_Slot then that means we have -- read every item in array already: set No_More_Items_Remaining := True. procedure Set_Index_to_Present_Item is begin if T(Index_of_Next_Item_to_Read) /= Empty_Slot then return; -- Index is set to proper next Item. Leave it here. end if; for i in table_Index loop if Index_of_Next_Item_to_Read < Table_Index'Last then Index_of_Next_Item_to_Read := Index_of_Next_Item_to_Read + 1; else No_More_Items_Remaining := True; return; -- Index_of_Next_Item_to_Read = Table_Index'Last, and no Item found end if; if T(Index_of_Next_Item_to_Read) /= Empty_Slot then -- Index is set to proper next Item. Leave it here. return; end if; end loop; end Set_Index_to_Present_Item; procedure Get_Next_Item (X : out Item; Item_is_Invalid : out Boolean) is begin -- init out param: Item_is_Invalid := False; Set_Index_to_Present_Item; -- stay at present index unless empty slot; skip all possible empty slots if No_More_Items_Remaining then -- go home early. Item_is_Invalid := True; X := Empty_Slot; return; end if; X := T(Index_of_Next_Item_to_Read); -- if we got to Table_Index'Last then Item at Table_Index'Last was valid, -- but now there may be no Items left: if Index_of_Next_Item_to_Read = Table_Index'Last then No_More_Items_Remaining := True; -- the reason we need No_More_Items_Re.. else -- Set_Index so Next Item is found next time around: Index_of_Next_Item_to_Read := Index_of_Next_Item_to_Read + 1; end if; end Get_Next_Item; -- Overflow Stacks: subtype Stack_Index is Table_Index range 0 .. Size_of_Overflow_Stacks - 1; type Item_Array is array (Stack_Index) of Item; type Stack is record Storage : Item_Array := (others => Empty_Slot); Next_Free_Slot_id : Stack_Index := Stack_Index'First; end record; Collision_Stack : Stack; type Sorted_Stack is record Storage : Item_Array := (others => Empty_Slot); Next_Free_Slot_id : Stack_Index := Stack_Index'First; end record; Low_End_Stack, High_End_Stack : Sorted_Stack; function No_of_Items_in_Low_Stack return Table_Index is begin return Table_Index (Low_End_Stack.Next_Free_Slot_id); end No_of_Items_in_Low_Stack; ----------------------------------- -- Initialize_Table_for_Restart -- ----------------------------------- procedure Initialize_Table_for_Restart is begin T := (others => Empty_Slot); Collision_Stack.Storage := (others => Empty_Slot); Low_End_Stack.Storage := (others => Empty_Slot); High_End_Stack.Storage := (others => Empty_Slot); Collision_Stack.Next_Free_Slot_id := Stack_Index'First; Low_End_Stack.Next_Free_Slot_id := Stack_Index'First; High_End_Stack.Next_Free_Slot_id := Stack_Index'First; No_More_Items_Remaining := False; Index_of_Next_Item_to_Read := Table_Index'First; end Initialize_Table_for_Restart; ---------- -- Push -- ---------- procedure Push (X : in Item; Stack_id : in out Stack) is pragma Assert (Stack_Index'First = 0); -- So No of items in stack = Next_Free_Slot_id S : Item_Array renames Stack_id.Storage; Next_Free_Slot_id : Stack_Index renames Stack_id.Next_Free_Slot_id; begin S (Next_Free_Slot_id) := X; if Next_Free_Slot_id = Stack_Index'Last then raise Constraint_Error; end if; Next_Free_Slot_id := Next_Free_Slot_id + 1; end Push; ------------------- -- Push_and_Sort -- ------------------- -- only way to update a Sorted_Stack, or sort fails. procedure Push_and_Sort (X : in Item; Stack_id : in out Sorted_Stack) is pragma Assert (Stack_Index'First = 0); X_Item_Size : constant Item := X; tmp : Item; S : Item_Array renames Stack_id.Storage; Next_Free_Slot_id : Stack_Index renames Stack_id.Next_Free_Slot_id; begin S (Next_Free_Slot_id) := X; bubble_sort: for i in reverse Stack_Index'First+1 .. Next_Free_Slot_id loop if X_Item_Size < S (i-1) then -- X is now in S(Next_Free_Slot_id) tmp := S (i-1); S (i-1) := S (i); S (i) := tmp; elsif X_Item_Size = S (i-1) then Push (X, Collision_Stack); exit bubble_sort; else -- X_Item_Size > S (i-1) exit bubble_sort; end if; end loop bubble_sort; if Next_Free_Slot_id = Stack_Index'Last then raise Constraint_Error; end if; Next_Free_Slot_id := Next_Free_Slot_id + 1; end Push_and_Sort; --------------------- -- Insert_and_Sort -- --------------------- -- X is both the item to be inserted, and the Item_Size procedure Insert_and_Sort (X : in Item) is X_Item_Size : constant Item := X; X_index_0 : constant Table_Index := Table_Index (X_Item_Size / Items_per_Table_Entry); Empty_Slot_id : Table_Index; Empty_Slot_Detected : Boolean := False; begin if X = Empty_Slot then -- value Empty_Slot signifies empty space in array, so is reserved. Push_and_Sort (X, High_End_Stack); return; end if; if T (X_index_0) = Empty_Slot then T (X_index_0) := X; return; end if; if X_Item_Size = T(X_index_0) then Push (X, Collision_Stack); return; elsif X_Item_Size < T (X_index_0) then if X_index_0 = Table_Index'First then Push_and_Sort (X, Low_End_Stack); return; end if; Empty_Slot_Detected := False; Find_Empty_Slot_Lower_Down: for i in reverse Table_Index range Table_Index'First .. X_index_0-1 loop if T(i) = Empty_Slot then Empty_Slot_id := i; Empty_Slot_Detected := True; exit Find_Empty_Slot_Lower_Down; end if; end loop Find_Empty_Slot_Lower_Down; if Empty_Slot_Detected = False then Push_and_Sort (X, Low_End_Stack); return; end if; -- shift the empty slot back to the rt place, and fill it with X: -- common short cut: if Empty_Slot_id = X_index_0-1 then -- put X into the table T(Empty_Slot_id) := X; return; end if; Shift_Slot_Up: for i in Empty_Slot_id+1 .. X_index_0 loop -- i-1 is the empty slot. if X_Item_Size > T(i) then T(i-1) := T(i); -- shift T(i) into the Empty Slot (at i-1) --T(i) := Empty_Slot;-- will fill this below with X elsif X_Item_Size = T(i) then Push (X, Collision_Stack); T(i-1) := X; return; else T(i-1) := X; return; end if; end loop Shift_Slot_Up; elsif X_Item_Size > T (X_index_0) then if X_index_0 = Table_Index'Last then Push_and_Sort (X, High_End_Stack); return; end if; Empty_Slot_Detected := False; Find_Empty_Slot_Higher_Up: for i in Table_Index range X_index_0+1 .. Table_Index'Last loop if T(i) = Empty_Slot then Empty_Slot_id := i; Empty_Slot_Detected := True; exit Find_Empty_Slot_Higher_Up; end if; end loop Find_Empty_Slot_Higher_Up; if Empty_Slot_Detected = False then Push_and_Sort (X, High_End_Stack); return; end if; -- shift the empty slot back to the rt place, and fill it with X: -- common short cut: if Empty_Slot_id = X_index_0+1 then -- put X into the table T(Empty_Slot_id) := X; return; end if; Shift_Slot_Down: for i in reverse X_index_0 .. Empty_Slot_id-1 loop -- i+1 is the empty slot. if X_Item_Size < T(i) then T(i+1) := T(i); -- put T(i) into the Empty Slot (at i+1) --T(i) := Empty_Slot;-- will fill this below with X elsif X_Item_Size = T(i) then Push (X, Collision_Stack); T(i+1) := X; return; else T(i+1) := X; return; end if; end loop Shift_Slot_Down; end if; end Insert_and_Sort; --------------------------- -- Array_Sort_Successful -- --------------------------- function Array_Sort_Successful return Boolean is Hi, Lo : Item; Non_Empty_Slot_id : Table_Index; begin Find_Non_Empty_Slot_Higher_Up: for i in Table_Index loop if T(i) /= Empty_Slot then Non_Empty_Slot_id := i; Lo := T(i); exit Find_Non_Empty_Slot_Higher_Up; end if; end loop Find_Non_Empty_Slot_Higher_Up; for i in Non_Empty_Slot_id+1 .. Table_Index'Last loop if T(i) = Empty_Slot then null; else Hi := T(i); if Hi < Lo then return False; end if; Hi := Lo; end if; end loop; return True; end Array_Sort_Successful; ------------------------------- -- No_of_Collisions_Detected -- ------------------------------- function No_of_Collisions_Detected return Table_Index is begin return Collision_Stack.Next_Free_Slot_id - Stack_Index'First; -- subtype of Table_Index end No_of_Collisions_Detected; end Sorted_Array;
with Ada.Integer_Text_IO; with Ada.Text_IO; with PrimeInstances; package body Problem_27 is package IO renames Ada.Text_IO; package I_IO renames Ada.Integer_Text_IO; procedure Solve is subtype Parameter is Integer range -999 .. 999; subtype Output is Integer range -(Parameter'Last**2) .. Parameter'Last**2; package Integer_Primes renames PrimeInstances.Integer_Primes; primes : constant Integer_Primes.Sieve := Integer_Primes.Generate_Sieve(79*79 + 999*79 + 999); function Is_Prime(n : Integer) return Boolean is subtype Sieve_Index is Positive range primes'Range; lower : Sieve_Index := primes'First; upper : Sieve_Index := primes'Last; midPoint : Sieve_Index; begin if n <= 1 then return False; end if; -- Basic binary search while lower <= upper loop midPoint := (lower + upper) / 2; if n = primes(midPoint) then return True; elsif n < primes(midPoint) then upper := midPoint - 1; else lower := midPoint + 1; end if; end loop; return False; end Is_Prime; function doQuad(n : Natural; a,b : parameter) return Integer is begin return n*n + a*n + b; end doQuad; highest_count : Natural := 0; best_output : Output; begin for a in Parameter'Range loop for prime_index in primes'Range loop exit when primes(prime_index) > Parameter'Last; declare b : constant Parameter := Parameter(primes(prime_index)); n : Natural := 0; begin while Is_Prime(doQuad(n, a, b)) loop n := n + 1; end loop; if n > highest_count then highest_count := n; best_output := a * b; end if; end; end loop; end loop; I_IO.Put(best_output); IO.New_Line; end Solve; end Problem_27;
-- This package has been generated automatically by GNATtest. -- Do not edit any part of it, see GNATtest documentation for more details. -- begin read only with Gnattest_Generated; package Bases.Cargo.Test_Data.Tests is type Test is new GNATtest_Generated.GNATtest_Standard.Bases.Cargo.Test_Data .Test with null record; procedure Test_Generate_Cargo_bedd31_021eea(Gnattest_T: in out Test); -- bases-cargo.ads:29:4:Generate_Cargo:Test_GenerateCargo procedure Test_Update_Base_Cargo_0621ee_1e1787(Gnattest_T: in out Test); -- bases-cargo.ads:43:4:Update_Base_Cargo:Test_UpdateBaseCargo procedure Test_Find_Base_Cargo_7b1190_f9e132(Gnattest_T: in out Test); -- bases-cargo.ads:59:4:Find_Base_Cargo:Test_FindBaseCargo end Bases.Cargo.Test_Data.Tests; -- end read only
with Command_Line; use Command_Line; with SPARK.Text_IO; use SPARK.Text_IO; with Error_Reporter; with Scanners; with Tokens; procedure Lox with SPARK_Mode is procedure Run (Source : String) with Pre => Source'First >= 1 and then Source'Last < Integer'Last; procedure Run_File (Path : String); procedure Run_Prompt; procedure Run (Source : String) is Token_List : Tokens.Lists.List (100); Position : Tokens.Lists.Cursor; begin Scanners.Scan_Tokens (Source, Token_List); Position := Tokens.Lists.First (Token_List); while Tokens.Lists.Has_Element (Token_List, Position) and then Is_Writable (Standard_Output) and then Status (Standard_Output) = Success loop Put_Line (Tokens.To_String (Tokens.Lists.Element (Token_List, Position))); Tokens.Lists.Next (Token_List, Position); end loop; end Run; procedure Run_File (Path : String) is Source_File : File_Type; Source : String (1 .. 10_240) := (others => ' '); Source_Line : String (1 .. 1_024); Last : Natural; Position : Natural := 1; Line_No : Natural := 0; begin if Is_Open (Source_File) then Error_Reporter.Error (Line_No => 1, Message => "Source file already open"); return; end if; if not Is_Open (Source_File) then Error_Reporter.Error (Line_No => 1, Message => "Could not open source file"); return; end if; Open (The_File => Source_File, The_Mode => In_File, The_Name => Path); while not End_Of_File (Source_File) loop Get_Line (File => Source_File, Item => Source_Line, Last => Last); if Line_No < Integer'Last then Line_No := Line_No + 1; else Error_Reporter.Error (Line_No => Line_No, Message => "Too many lines of source code"); return; end if; if Position <= Source'Last - Last then Source (Position .. Position + Last - 1) := Source_Line (1 .. Last); Source (Position + Last) := Scanners.LF; Position := Position + Last + 1; else Error_Reporter.Error (Line_No => Line_No, Message => "Source code too large for buffer"); return; end if; end loop; Run (Source (Source'First .. Position - 1)); if Error_Reporter.Had_Error then Command_Line.Set_Exit_Status (65); end if; end Run_File; procedure Run_Prompt is Source_Line : String (1 .. 1024); Last : Natural; begin loop if Status (Standard_Output) /= Success then Error_Reporter.Error (Line_No => 1, Message => "Session ended"); return; end if; Put ("> "); Get_Line (Item => Source_Line, Last => Last); Run (Source_Line (Source_Line'First .. Last)); Error_Reporter.Clear_Error; end loop; end Run_Prompt; begin if Argument_Count > 1 then if Status (Standard_Output) = Success then Put_Line ("Usage: lox [script]"); end if; elsif Argument_Count = 1 then Run_File (Argument (1)); else Run_Prompt; end if; end Lox;
with Lib_Pack; with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin Put_Line ("=== Main start ==="); Lib_Pack.Test; Put_Line ("=== Main end ==="); end Main;
package body collada.Library.animations is ----------- --- Utility -- function "+" (From : in ada.Strings.unbounded.unbounded_String) return String renames ada.Strings.unbounded.to_String; ------------- --- Animation -- function Source_of (Self : in Animation; source_Name : in String) return Source is use ada.Strings.unbounded; begin for i in Self.Sources'Range loop if Self.Sources (i).Id = source_Name (source_Name'First+1 .. source_Name'Last) then return Self.Sources (i); end if; end loop; declare null_Source : Source; begin return null_Source; end; end Source_of; function find_Inputs_of (Self : in Animation; for_Semantic : in Semantic) return access float_Array is the_Input : constant Input_t := find_in (Self.Sampler.Inputs.all, for_Semantic); begin if the_Input = null_Input then return null; end if; declare the_Source : constant Source := Source_of (Self, +the_Input.Source); begin return the_Source.Floats; end; end find_Inputs_of; function Inputs_of (Self : in Animation) return access float_Array is begin return find_Inputs_of (Self, for_Semantic => Input); end Inputs_of; function Outputs_of (Self : in Animation) return access float_Array is begin return find_Inputs_of (Self, for_Semantic => Output); end Outputs_of; function Interpolations_of (Self : in Animation) return access float_Array is begin return find_Inputs_of (Self, for_Semantic => Interpolation); end Interpolations_of; end collada.Library.animations;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME 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) 1995-2020, 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/>. -- -- -- ------------------------------------------------------------------------------ -- The standard implementation of this spec contains only dummy interrupt -- names. These dummy entries permit checking out code for correctness of -- semantics, even if interrupts are not supported. -- For specific implementations that fully support interrupts, this package -- spec is replaced by an implementation dependent version that defines the -- interrupts available on the system. package Ada.Interrupts.Names is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; DUMMY_INTERRUPT_1 : constant Interrupt_ID := 1; DUMMY_INTERRUPT_2 : constant Interrupt_ID := 2; end Ada.Interrupts.Names;
package Opt29 is type Word is mod 2**16; type PID is record W1, W2: Word; end record; type Root1 is tagged record Id: PID; end record; type Root1_Ptr is access all Root1'Class; type Root2 is tagged null record; type Root2_Ptr is access all Root2'class; type Derived2 is new Root2 with record Id: PID; end record; type Rec is record F1: Root1_Ptr; F2: Root2_Ptr; end record; procedure Proc (T : Rec); end Opt29;
-- #include "impact.d3.collision.polyhedral_contact_Clipping.h" -- #include "BulletCollision/CollisionShapes/impact.d3.convex_Polyhedron.h" -- -- #include <float.h> //for FLT_MAX with Impact.d3.Vector; with Impact.d3.Transform; package body Impact.d3.Collision.polyhedral_contact_Clipping -- -- Separating axis rest based on work from Pierre Terdiman -- Contact clipping based on work from Simon Hobbs -- is ------------ --- Globals -- gExpectedNbTests : Integer := 0; gActualNbTests : Integer := 0; gUseInternalObject : Boolean := True; gActualSATPairTests : Integer := 0; ------------ --- Utility -- function TestSepAxis (hullA, hullB : in Impact.d3.convex_Polyhedron.Item'Class; transA, transB : in Transform_3d; sep_axis : in Math.Vector_3; depth : out Math.Real) return Boolean is Min0, Max0, Min1, Max1, d0, d1 : Math.Real; begin hullA.project (transA, sep_axis, Min0, Max0); hullB.project (transB, sep_axis, Min1, Max1); if Max0 < Min1 or else Max1 < Min0 then return False; end if; d0 := Max0 - Min1; pragma Assert (d0 >= 0.0); d1 := Max1 - Min0; pragma Assert (d1 >= 0.0); if d0 < d1 then depth := d0; else depth := d1; end if; return True; end TestSepAxis; function IsAlmostZero (v : in Math.Vector_3) return Boolean is begin if abs (v (1)) > 1.0e-6 or else abs (v (2)) > 1.0e-6 or else abs (v (3)) > 1.0e-6 then return False; end if; return True; end IsAlmostZero; --------------- --- Operations -- procedure clipHullAgainstHull (separatingNormal1 : in Math.Vector_3; hullA, hullB : in Impact.d3.convex_Polyhedron.Item'Class; transA, transB : in Transform_3d; minDist, maxDist : in Math.Real; resultOut : out Impact.d3.Collision.Detector.discrete.Result' Class) is use linear_Algebra_3d, Impact.d3.Vector, Math.Vectors, Impact.d3.Transform; separatingNormal : constant Math.Vector_3 := Normalized (separatingNormal1); c0 : constant Math.Vector_3 := transA * hullA.m_localCenter; c1 : constant Math.Vector_3 := transB * hullB.m_localCenter; DeltaC2 : constant Math.Vector_3 := c0 - c1; curMaxDist : Math.Real := maxDist; closestFaceB : Integer := -1; dmax : Math.Real := -Math.Real'Last; worldVertsB1 : btVertexArray; begin for face in 1 .. Integer (hullB.m_faces.Length) loop declare Normal : constant Math.Vector_3 := (hullB.m_faces.Element (face).m_plane (1), hullB.m_faces.Element (face).m_plane (2), hullB.m_faces.Element (face).m_plane (3)); WorldNormal : constant Math.Vector_3 := getBasis (transB) * Normal; d : constant Math.Real := dot (WorldNormal, separatingNormal); begin if d > dmax then dmax := d; closestFaceB := face; end if; end; end loop; declare polyB : Impact.d3.convex_Polyhedron.btFace renames hullB.m_faces.Element(closestFaceB); numVertices : constant Integer := Integer (polyB.m_indices.Length); begin for e0 in 1 .. numVertices loop declare b : constant Math.Vector_3 := hullB.m_vertices.Element (polyB.m_indices.Element (e0)); begin worldVertsB1.Append (transB * b); end; end loop; end; if closestFaceB >= 0 then clipFaceAgainstHull (separatingNormal, hullA, transA, worldVertsB1, minDist, maxDist, resultOut); end if; end clipHullAgainstHull; procedure clipFaceAgainstHull (separatingNormal : in Math.Vector_3; hullA : in Impact.d3.convex_Polyhedron.Item'Class; transA : in Transform_3d; worldVertsB1 : in out btVertexArray; minDist, maxDist : in Math.Real; resultOut : out Impact.d3.Collision.Detector.discrete.Result' Class) is use Impact.d3.Transform, Impact.d3.Vector, Math.Vectors; worldVertsB2 : aliased btVertexArray; pVtxIn : access btVertexArray := worldVertsB1'Access; pVtxOut : access btVertexArray := worldVertsB2'Access; closestFaceA : Integer := -1; dmin : Math.Real := Math.Real'Last; begin pVtxOut.Reserve_Capacity (pVtxIn.Length); for face in 1 .. Integer (hullA.m_faces.Length) loop declare Normal : constant Math.Vector_3 := (hullA.m_faces.Element (face).m_plane (1), hullA.m_faces.Element (face).m_plane (2), hullA.m_faces.Element (face).m_plane (3)); faceANormalWS : constant Math.Vector_3 := getBasis (transA) * Normal; d : constant Math.Real := dot (faceANormalWS, separatingNormal); begin if d < dmin then dmin := d; closestFaceA := face; end if; end; end loop; if closestFaceA < 0 then return; end if; -- clip polygon to back of planes of all faces of hull A that are --adjacent to witness face -- declare use Impact.d3.convex_Polyhedron.btFace_Vectors; polyA : constant Impact.d3.convex_Polyhedron.btFace := hullA.m_faces.Element (closestFaceA); numContacts : Integer := Integer (pVtxIn.Length); numVerticesA : constant Integer := Integer (polyA.m_indices.Length); begin for e0 in 1 .. numVerticesA loop declare use linear_Algebra_3d, Impact.d3.convex_Polyhedron.vector_3_Vectors, Impact.d3.Containers.integer_Vectors; a : constant Math.Vector_3 := hullA.m_vertices.Element (polyA.m_indices.Element (e0)); b : constant Math.Vector_3 := hullA.m_vertices.Element (polyA.m_indices.Element ((e0 + 1) mod numVerticesA)); edge0 : constant Math.Vector_3 := a - b; WorldEdge0 : constant Math.Vector_3 := getBasis (transA) * edge0; worldPlaneAnormal1 : constant Math.Vector_3 := getBasis (transA) * (polyA.m_plane (1), polyA.m_plane (2), polyA.m_plane (3)); planeNormalWS1 : constant Math.Vector_3 := -cross (WorldEdge0, worldPlaneAnormal1); -- .cross(WorldEdge --0); worldA1 : constant Math.Vector_3 := transA * a; planeEqWS1 : constant Math.Real := -dot (worldA1, planeNormalWS1); planeNormalWS : constant Math.Vector_3 := planeNormalWS1; planeEqWS : constant Math.Real := planeEqWS1; begin clipFace (pVtxIn.all, pVtxOut.all, planeNormalWS, planeEqWS); -- clip face declare Pad : constant access btVertexArray := pVtxIn; begin pVtxIn := pVtxOut; pVtxOut := Pad; end; -- btSwap (pVtxIn,pVtxOut); pVtxOut.Set_Length (0); end; end loop; -- only keep points that are behind the witness face -- declare point : Math.Vector_3; localPlaneNormal : constant Math.Vector_3 := (polyA.m_plane (1), polyA.m_plane (2), polyA.m_plane (3)); localPlaneEq : constant Math.Real := polyA.m_plane (4); planeNormalWS : constant Math.Vector_3 := getBasis (transA) * localPlaneNormal; planeEqWS : Math.Real := localPlaneEq - dot (planeNormalWS, getOrigin (transA)); depth : Math.Real; begin for i in 1 .. Integer (pVtxIn.Length) loop depth := dot (planeNormalWS, pVtxIn.Element (i)) + planeEqWS; if depth <= minDist then depth := minDist; end if; if depth <= maxDist then point := pVtxIn.Element (i); resultOut.addContactPoint (separatingNormal, point, depth); end if; end loop; end; end; end clipFaceAgainstHull; function findSeparatingAxis (hullA, hullB : in Impact.d3.convex_Polyhedron.Item'Class; transA, transB : in Transform_3d; sep : out Math.Vector_3) return Boolean is dmin : Math.Real := Math.Real'Last; curPlaneTests : Integer := 0; numFacesA : constant Integer := Integer (hullA.m_faces.Length); numFacesB : Integer; begin gActualSATPairTests := gActualSATPairTests + 1; -- //#ifdef TEST_INTERNAL_OBJECTS -- const impact.d3.Vector c0 = transA * hullA.m_localCenter; -- const impact.d3.Vector c1 = transB * hullB.m_localCenter; -- const impact.d3.Vector DeltaC2 = c0 - c1; -- //#endif -- Test normals from hullA -- for i in 1 .. numFacesA loop declare use Impact.d3.Transform, Math.Vectors, Impact.d3.Vector; Normal : constant Math.Vector_3 := (hullA.m_faces.Element (i).m_plane (1), hullA.m_faces.Element (i).m_plane (2), hullA.m_faces.Element (i).m_plane (3)); faceANormalWS : constant Math.Vector_3 := getBasis (transA) * Normal; d : Math.Real; begin -- if not dot (DeltaC2, faceANormalWS) < 0 then curPlaneTests := curPlaneTests + 1; -- #ifdef TEST_INTERNAL_OBJECTS -- gExpectedNbTests++; -- if(gUseInternalObject && --!TestInternalObjects(transA,transB, DeltaC2, faceANormalWS, --hullA, hullB, dmin)) -- continue; -- gActualNbTests++; -- #endif if not TestSepAxis (hullA, hullB, transA, transB, faceANormalWS, d) then return False; end if; if d < dmin then dmin := d; sep := faceANormalWS; end if; -- end if; end; end loop; numFacesB := Integer (hullB.m_faces.Length); -- Test normals from hullB -- for i in 1 .. numFacesB loop declare use Impact.d3.Transform, Math.Vectors, Impact.d3.Vector; Normal : constant Math.Vector_3 := (hullB.m_faces.Element (i).m_plane (1), hullB.m_faces.Element (i).m_plane (2), hullB.m_faces.Element (i).m_plane (3)); WorldNormal : constant Math.Vector_3 := getBasis (transB) * Normal; d : Math.Real; begin -- if not dot (DeltaC2, WorldNormal) < 0 then curPlaneTests := curPlaneTests + 1; -- #ifdef TEST_INTERNAL_OBJECTS -- gExpectedNbTests++; -- if(gUseInternalObject && --!TestInternalObjects(transA,transB,DeltaC2, WorldNormal, hullA, --hullB, dmin)) -- continue; -- gActualNbTests++; -- #endif if not TestSepAxis (hullA, hullB, transA, transB, WorldNormal, d) then return False; end if; if d < dmin then dmin := d; sep := WorldNormal; end if; -- end if; end; end loop; -- Test edges -- declare use Impact.d3.Transform, Math.Vectors, Impact.d3.Vector; -- edgeAstart, edgeAend, -- edgeBstart, edgeBend : math.Vector_3; curEdgeEdge : Integer := 0; begin for e0 in 1 .. Integer (hullA.m_uniqueEdges.Length) loop declare edge0 : constant Math.Vector_3 := hullA.m_uniqueEdges.Element (e0); WorldEdge0 : constant Math.Vector_3 := getBasis (transA) * edge0; begin for e1 in 1 .. Integer (hullB.m_uniqueEdges.Length) loop declare edge1 : constant Math.Vector_3 := hullB.m_uniqueEdges.Element (e1); WorldEdge1 : constant Math.Vector_3 := getBasis (transB) * edge1; the_Cross : Math.Vector_3 := cross (WorldEdge0, WorldEdge1); dist : Math.Real; begin curEdgeEdge := curEdgeEdge + 1; if not IsAlmostZero (the_Cross) then the_Cross := Normalized (the_Cross); -- if not dot (DeltaC2, --the_Cross) < 0 then -- #ifdef TEST_INTERNAL_OBJECTS -- gExpectedNbTests++; -- if(gUseInternalObje --ct && !TestInternalObjects(transA,transB,DeltaC2, --Cross, hullA, hullB, dmin)) -- continue; -- gActualNbTests++; -- #endif if not TestSepAxis (hullA, hullB, transA, transB, the_Cross, dist) then return False; end if; if dist < dmin then dmin := dist; sep := the_Cross; end if; -- end if; end if; end; end loop; end; end loop; end; declare use Impact.d3.Transform, Math.Vectors, Impact.d3.Vector; deltaC : constant Math.Vector_3 := getOrigin (transB) - getOrigin (transA); begin if dot (deltaC, sep) > 0.0 then sep := -sep; end if; end; return True; end findSeparatingAxis; -- Clips a face to the back of a plane. -- procedure clipFace (pVtxIn : in btVertexArray; ppVtxOut : out btVertexArray; planeNormalWS : in Math.Vector_3; planeEqWS : in Math.Real) is use Impact.d3.Vector; ds, de : Math.Real; numVerts : constant Integer := Integer (pVtxIn.Length); firstVertex, endVertex : Math.Vector_3; begin if numVerts < 2 then return; end if; firstVertex := pVtxIn.Element (Integer (pVtxIn.Length)); endVertex := pVtxIn.Element (1); ds := dot (planeNormalWS, firstVertex) + planeEqWS; for ve in 1 .. numVerts loop endVertex := pVtxIn.Element (ve); de := dot (planeNormalWS, endVertex) + planeEqWS; if ds < 0.0 then if de < 0.0 then -- Start < 0, end < 0, so output endVertex ppVtxOut.Append (endVertex); else -- Start < 0, end >= 0, so output intersection ppVtxOut.Append (lerp (firstVertex, endVertex, Math.Real (ds * 1.0 / (ds - de)))); end if; else if de < 0.0 then -- Start >= 0, end < 0 so output intersection --and end ppVtxOut.Append (lerp (firstVertex, endVertex, Math.Real (ds * 1.0 / (ds - de)))); ppVtxOut.Append (endVertex); end if; end if; firstVertex := endVertex; ds := de; end loop; end clipFace; end Impact.d3.Collision.polyhedral_contact_Clipping; -- #ifdef TEST_INTERNAL_OBJECTS -- -- inline void BoxSupport(const impact.d3.Scalar extents[3], const --impact.d3.Scalar sv[3], impact.d3.Scalar p[3]) -- { -- // This version is ~11.000 cycles (4%) faster overall in one of --the tests. -- // IR(p[0]) = IR(extents[0])|(IR(sv[0])&SIGN_BITMASK); -- // IR(p[1]) = IR(extents[1])|(IR(sv[1])&SIGN_BITMASK); -- // IR(p[2]) = IR(extents[2])|(IR(sv[2])&SIGN_BITMASK); -- p[0] = sv[0] < 0.0f ? -extents[0] : extents[0]; -- p[1] = sv[1] < 0.0f ? -extents[1] : extents[1]; -- p[2] = sv[2] < 0.0f ? -extents[2] : extents[2]; -- } -- void InverseTransformPoint3x3(impact.d3.Vector& out, const --impact.d3.Vector& in, const impact.d3.Transform& tr) -- { -- const impact.d3.Matrix& rot = tr.getBasis(); -- const impact.d3.Vector& r0 = rot[0]; -- const impact.d3.Vector& r1 = rot[1]; -- const impact.d3.Vector& r2 = rot[2]; -- -- const impact.d3.Scalar x = r0.x()*in.x() + r1.x()*in.y() + --r2.x()*in.z(); -- const impact.d3.Scalar y = r0.y()*in.x() + r1.y()*in.y() + --r2.y()*in.z(); -- const impact.d3.Scalar z = r0.z()*in.x() + r1.z()*in.y() + --r2.z()*in.z(); -- -- out.setValue(x, y, z); -- } -- bool TestInternalObjects( const impact.d3.Transform& trans0, const --impact.d3.Transform& trans1, const impact.d3.Vector& delta_c, const --impact.d3.Vector& axis, const impact.d3.convex_Polyhedron& convex0, const --impact.d3.convex_Polyhedron& convex1, impact.d3.Scalar dmin) -- { -- const impact.d3.Scalar dp = delta_c.dot(axis); -- -- impact.d3.Vector localAxis0; -- InverseTransformPoint3x3(localAxis0, axis,trans0); -- impact.d3.Vector localAxis1; -- InverseTransformPoint3x3(localAxis1, axis,trans1); -- -- impact.d3.Scalar p0[3]; -- BoxSupport(convex0.m_extents, localAxis0, p0); -- impact.d3.Scalar p1[3]; -- BoxSupport(convex1.m_extents, localAxis1, p1); -- -- const impact.d3.Scalar Radius0 = p0[0]*localAxis0.x() + --p0[1]*localAxis0.y() + p0[2]*localAxis0.z(); -- const impact.d3.Scalar Radius1 = p1[0]*localAxis1.x() + --p1[1]*localAxis1.y() + p1[2]*localAxis1.z(); -- -- const impact.d3.Scalar MinRadius = Radius0>convex0.m_radius ? --Radius0 : convex0.m_radius; -- const impact.d3.Scalar MaxRadius = Radius1>convex1.m_radius ? --Radius1 : convex1.m_radius; -- -- const impact.d3.Scalar MinMaxRadius = MaxRadius + MinRadius; -- const impact.d3.Scalar d0 = MinMaxRadius + dp; -- const impact.d3.Scalar d1 = MinMaxRadius - dp; -- -- const impact.d3.Scalar depth = d0<d1 ? d0:d1; -- if(depth>dmin) -- return false; -- return true; -- } -- #endif //TEST_INTERNAL_OBJECTS
with Ada.Containers.Functional_Vectors; with TLSF.Block.Types; use TLSF.Block.Types; with TLSF.Config; use TLSF.Config; package TLSF.Block.Proof with SPARK_Mode, Ghost is pragma Unevaluated_Use_Of_Old (Allow); package Formal_Model with SPARK_Mode, Ghost is use Ada.Containers; subtype Positive_Count_Type is Count_Type range 1 .. Count_Type'Last; -- each block is unique charecterized by its address package Va is new Ada.Containers.Functional_Vectors (Element_Type => Address, Index_Type => Positive_Count_Type); function "=" (Left : Va.Sequence; Right : Va.Sequence) return Boolean renames Va."="; function "<" (Left : Va.Sequence; Right : Va.Sequence) return Boolean renames Va."<"; function "<=" (Left : Va.Sequence; Right : Va.Sequence) return Boolean renames Va."<="; function Find_Address (V : Va.Sequence; Addr : Address) return Count_Type -- Search for Address with Global => null, Post => (if Find_Address'Result > 0 then Find_Address'Result <= Va.Length (V) and Addr = Va.Get (V, Find_Address'Result)); function Address_Present(V : Va.Sequence; Addr : Address) return Boolean is (Find_Address(V, Addr) > 0); end Formal_Model; function Hash (Addr : Address) return Ada.Containers.Hash_Type is (Ada.Containers.Hash_Type(Addr)); package Block_Map is new Ada.Containers.Formal_Hashed_Maps (Key_Type => Address, Element_Type => Block_Header, Hash => Hash); package Free_Blocks_Set is new Ada.Containers.Formal_Hashed_Sets (Element_Type => Address, Hash => Hash); use type Ada.Containers.Count_Type; use type Free_Blocks_Set.Set; subtype Map is Block_Map.Map(Capacity => 1024, Modulus => 0); subtype Set is Free_Blocks_Set.Set(Capacity => 1024, Modulus => 0); Empty_Set : Set renames Free_Blocks_Set.Empty_Set; type Free_Lists_Type is array (First_Level_Index, Second_Level_Index) of Set; type Proof_State_Type is record Blocks : Map; Free_Lists : Free_Lists_Type; end record; Proof_State : Proof_State_Type; function Block_Present_At_Address(Addr : Valid_Address) return Boolean with Global => Proof_State, Contract_Cases => ( (Block_Map.Contains(Proof_State.Blocks, Addr)) => Block_Present_At_Address'Result = True, others => Block_Present_At_Address'Result = False); function Block_At_Address (Addr : Valid_Address) return Block_Header with Global => Proof_State, Pre => Block_Present_At_Address(Addr), Post => Block_At_Address'Result = Block_Map.Element(Proof_State.Blocks, Addr); function Specific_Block_Present_At_Address(Addr : Valid_Address; Block : Block_Header) return Boolean with Global => Proof_State, Contract_Cases => ( Block_Present_At_Address(Addr) and then Block_At_Address(Addr) = Block => Specific_Block_Present_At_Address'Result = True, others => Specific_Block_Present_At_Address'Result = False); procedure Put_Block_At_Address (Addr : Valid_Address; Block : Block_Header) with Global => (In_Out => Proof_State), Pre => not Block_Present_At_Address(Addr) and then Block_Map.Length(Proof_State.Blocks) < Proof_State.Blocks.Capacity, Post => (Block_Present_At_Address(Addr) and then Block_At_Address(Addr) = Block); procedure Remove_Block_At_Address(Addr : Valid_Address) with Pre => Block_Present_At_Address(Addr), Post => not Block_Present_At_Address(Addr); -- working with free lists function Get_Free_List (FL_Idx : First_Level_Index; SL_Idx : Second_Level_Index) return Set is (Proof_State.Free_Lists (FL_Idx, SL_Idx)); function Get_Free_List (Index : Level_Index) return Set is (Get_Free_List(Index.First_Level, Index.Second_Level)); function Get_Free_List (Sz : Size) return Set is (Get_Free_List(Calculate_Levels_Indices(Size_Bits(Sz)))) with Pre => Sz >= Small_Block_Size; function Is_Block_Present_In_Free_Lists (Addr : Valid_Address) return Boolean with Global => Proof_State, Contract_Cases => ( not (for all FL_Idx in First_Level_Index'Range => ( for all SL_Idx in Second_Level_Index'Range => (if Free_Blocks_Set.Contains(Get_Free_List(FL_Idx, SL_Idx), Addr) then False))) => Is_Block_Present_In_Free_Lists'Result = True, others => Is_Block_Present_In_Free_Lists'Result = False); function Is_Block_In_Free_List_For_Size (Sz : Size; Addr : Valid_Address) return Boolean with Global => (Input => Proof_State), Pre => Sz >= Small_Block_Size, Contract_Cases => ( Free_Blocks_Set.Contains(Get_Free_List(Sz), Addr) => Is_Block_In_Free_List_For_Size'Result = True, others => Is_Block_In_Free_List_For_Size'Result = False); function Is_Block_Present_In_Exactly_One_Free_List_For_Size (Sz : Size; Addr : Valid_Address) return Boolean with Global => (Input => Proof_State), Pre => Sz >= Small_Block_Size; -- TODO: Add quantified postcondition procedure Remove_Block_From_Free_List_For_Size (Sz : Size; Addr : Valid_Address) with Global => (In_Out => Proof_State), Pre => Sz >= Small_Block_Size and then Is_Block_In_Free_List_For_Size(Sz, Addr), Post => not Is_Block_In_Free_List_For_Size(Sz, Addr); procedure Put_Block_In_Free_List_For_Size (Sz : Size; Addr : Valid_Address) with Global => (In_Out => Proof_State), Pre => Sz >= Small_Block_Size and then not Is_Block_In_Free_List_For_Size(Sz, Addr), Post => Is_Block_In_Free_List_For_Size(Sz, Addr); end TLSF.Block.Proof;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . C G I -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-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. -- -- -- ------------------------------------------------------------------------------ -- This is a package to interface a GNAT program with a Web server via the -- Common Gateway Interface (CGI). -- Other related packages are: -- GNAT.CGI.Cookie which deal with Web HTTP Cookies. -- GNAT.CGI.Debug which output complete CGI runtime environment -- Basically this package parse the CGI parameter which are a set of key/value -- pairs. It builds a table whose index is the key and provides some services -- to deal with this table. -- Example: -- Consider the following simple HTML form to capture a client name: -- <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN"> -- <html> -- <head> -- <title>My Web Page</title> -- </head> -- <body> -- <form action="/cgi-bin/new_client" method="POST"> -- <input type=text name=client_name> -- <input type=submit name="Enter"> -- </form> -- </body> -- </html> -- The following program will retrieve the client's name: -- with GNAT.CGI; -- procedure New_Client is -- use GNAT; -- procedure Add_Client_To_Database (Name : String) is -- begin -- ... -- end Add_Client_To_Database; -- begin -- -- Check that we have 2 arguments (there is two inputs tag in -- -- the HTML form) and that one of them is called "client_name". -- if CGI.Argument_Count = 2 -- and then CGI.Key_Exists ("client_name") -- then -- Add_Client_To_Database (CGI.Value ("client_name")); -- end if; -- ... -- CGI.Put_Header; -- Text_IO.Put_Line ("<html><body>< ... Ok ... >"); -- exception -- when CGI.Data_Error => -- CGI.Put_Header ("Location: /htdocs/error.html"); -- -- This returns the address of a Web page to be displayed -- -- using a "Location:" header style. -- end New_Client; -- Note that the names in this package interface have been designed so that -- they read nicely with the CGI prefix. The recommended style is to avoid -- a use clause for GNAT.CGI, but to include a use clause for GNAT. -- This package builds up a table of CGI parameters whose memory is not -- released. A CGI program is expected to be a short lived program and -- so it is adequate to have the underlying OS free the program on exit. package GNAT.CGI is Data_Error : exception; -- This is raised when there is a problem with the CGI protocol. Either -- the data could not be retrieved or the CGI environment is invalid. -- -- The package will initialize itself by parsing the runtime CGI -- environment during elaboration but we do not want to raise an -- exception at this time, so the exception Data_Error is deferred -- and will be raised when calling any services below (except for Ok). Parameter_Not_Found : exception; -- This exception is raised when a specific parameter is not found Default_Header : constant String := "Content-type: text/html"; -- This is the default header returned by Put_Header. If the CGI program -- returned data is not an HTML page, this header must be change to a -- valid MIME type. type Method_Type is (Get, Post); -- The method used to pass parameter from the Web client to the -- server. With the GET method parameters are passed via the command -- line, with the POST method parameters are passed via environment -- variables. Others methods are not supported by this implementation. type Metavariable_Name is (Auth_Type, Content_Length, Content_Type, Document_Root, -- Web server dependent Gateway_Interface, HTTP_Accept, HTTP_Accept_Encoding, HTTP_Accept_Language, HTTP_Connection, HTTP_Cookie, HTTP_Extension, HTTP_From, HTTP_Host, HTTP_Referer, HTTP_User_Agent, Path, Path_Info, Path_Translated, Query_String, Remote_Addr, Remote_Host, Remote_Port, -- Web server dependent Remote_Ident, Remote_User, Request_Method, Request_URI, -- Web server dependent Script_Filename, -- Web server dependent Script_Name, Server_Addr, -- Web server dependent Server_Admin, -- Web server dependent Server_Name, Server_Port, Server_Protocol, Server_Signature, -- Web server dependent Server_Software); -- CGI metavariables that are set by the Web server during program -- execution. All these variables are part of the restricted CGI runtime -- environment and can be read using Metavariable service. The detailed -- meanings of these metavariables are out of the scope of this -- description. Please refer to http://www.w3.org/CGI/ for a description -- of the CGI specification. Some metavariables are Web server dependent -- and are not described in the cited document. procedure Put_Header (Header : String := Default_Header; Force : Boolean := False); -- Output standard CGI header by default. The header string is followed by -- an empty line. This header must be the first answer sent back to the -- server. Do nothing if this function has already been called and Force -- is False. function Ok return Boolean; -- Returns True if the CGI environment is valid and False otherwise. -- Every service used when the CGI environment is not valid will raise -- the exception Data_Error. function Method return Method_Type; -- Returns the method used to call the CGI function Metavariable (Name : Metavariable_Name; Required : Boolean := False) return String; -- Returns parameter Name value. Returns the null string if Name -- environment variable is not defined or raises Data_Error if -- Required is set to True. function Metavariable_Exists (Name : Metavariable_Name) return Boolean; -- Returns True if the environment variable Name is defined in -- the CGI runtime environment and False otherwise. function URL return String; -- Returns the URL used to call this script without the parameters. -- The URL form is: http://<server_name>[:<server_port>]<script_name> function Argument_Count return Natural; -- Returns the number of parameters passed to the client. This is the -- number of input tags in a form or the number of parameters passed to -- the CGI via the command line. --------------------------------------------------- -- Services to retrieve key/value CGI parameters -- --------------------------------------------------- function Value (Key : String; Required : Boolean := False) return String; -- Returns the parameter value associated to the parameter named Key. -- If parameter does not exist, returns an empty string if Required -- is False and raises the exception Parameter_Not_Found otherwise. function Value (Position : Positive) return String; -- Returns the parameter value associated with the CGI parameter number -- Position. Raises Parameter_Not_Found if there is no such parameter -- (i.e. Position > Argument_Count) function Key_Exists (Key : String) return Boolean; -- Returns True if the parameter named Key exists and False otherwise function Key (Position : Positive) return String; -- Returns the parameter key associated with the CGI parameter number -- Position. Raises the exception Parameter_Not_Found if there is no -- such parameter (i.e. Position > Argument_Count) generic with procedure Action (Key : String; Value : String; Position : Positive; Quit : in out Boolean); procedure For_Every_Parameter; -- Iterate through all existing key/value pairs and call the Action -- supplied procedure. The Key and Value are set appropriately, Position -- is the parameter order in the list, Quit is set to True by default. -- Quit can be set to False to control the iterator termination. private function Decode (S : String) return String; -- Decode Web string S. A string when passed to a CGI is encoded, -- this function will decode the string to return the original -- string's content. Every triplet of the form %HH (where H is an -- hexadecimal number) is translated into the character such that: -- Hex (Character'Pos (C)) = HH. end GNAT.CGI;
with TEXT_IO; with INFLECTIONS_PACKAGE; use INFLECTIONS_PACKAGE; with DICTIONARY_PACKAGE; use DICTIONARY_PACKAGE; package ADDONS_PACKAGE is use TEXT_IO; subtype FIX_TYPE is STEM_TYPE; NULL_FIX_TYPE : constant FIX_TYPE := NULL_STEM_TYPE; MAX_FIX_SIZE : constant := MAX_STEM_SIZE; subtype TARGET_POFS_TYPE is PART_OF_SPEECH_TYPE range X..V; type TARGET_ENTRY(POFS: TARGET_POFS_TYPE := X) is record case POFS is when N => N : NOUN_ENTRY; --NOUN_KIND : NOUN_KIND_TYPE; when PRON => PRON : PRONOUN_ENTRY; --PRONOUN_KIND : PRONOUN_KIND_TYPE; when PACK => PACK : PROPACK_ENTRY; --PROPACK_KIND : PRONOUN_KIND_TYPE; when ADJ => ADJ : ADJECTIVE_ENTRY; when NUM => NUM : NUMERAL_ENTRY; --NUMERAL_VALUE : NUMERAL_VALUE_TYPE; when ADV => ADV : ADVERB_ENTRY; when V => V : VERB_ENTRY; --VERB_KIND : VERB_KIND_TYPE; when others => null; end case; end record; NULL_TARGET_ENTRY : TARGET_ENTRY; package TARGET_ENTRY_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; P : out TARGET_ENTRY); procedure GET(P : out TARGET_ENTRY); procedure PUT(F : in FILE_TYPE; P : in TARGET_ENTRY); procedure PUT(P : in TARGET_ENTRY); procedure GET(S : in STRING; P : out TARGET_ENTRY; LAST : out INTEGER); procedure PUT(S : out STRING; P : in TARGET_ENTRY); end TARGET_ENTRY_IO; type TACKON_ENTRY is record BASE : TARGET_ENTRY; end record; NULL_TACKON_ENTRY : TACKON_ENTRY; package TACKON_ENTRY_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; I : out TACKON_ENTRY); procedure GET(I : out TACKON_ENTRY); procedure PUT(F : in FILE_TYPE; I : in TACKON_ENTRY); procedure PUT(I : in TACKON_ENTRY); procedure GET(S : in STRING; I : out TACKON_ENTRY; LAST : out INTEGER); procedure PUT(S : out STRING; I : in TACKON_ENTRY); end TACKON_ENTRY_IO; type PREFIX_ENTRY is record ROOT : PART_OF_SPEECH_TYPE := X; TARGET : PART_OF_SPEECH_TYPE := X; end record; NULL_PREFIX_ENTRY : PREFIX_ENTRY; package PREFIX_ENTRY_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; P : out PREFIX_ENTRY); procedure GET(P : out PREFIX_ENTRY); procedure PUT(F : in FILE_TYPE; P : in PREFIX_ENTRY); procedure PUT(P : in PREFIX_ENTRY); procedure GET(S : in STRING; P : out PREFIX_ENTRY; LAST : out INTEGER); procedure PUT(S : out STRING; P : in PREFIX_ENTRY); end PREFIX_ENTRY_IO; type SUFFIX_ENTRY is record ROOT : PART_OF_SPEECH_TYPE := X; ROOT_KEY : STEM_KEY_TYPE := 0; TARGET : TARGET_ENTRY := NULL_TARGET_ENTRY; TARGET_KEY : STEM_KEY_TYPE := 0; end record; NULL_SUFFIX_ENTRY : SUFFIX_ENTRY; package SUFFIX_ENTRY_IO is DEFAULT_WIDTH : NATURAL; procedure GET(F : in FILE_TYPE; P : out SUFFIX_ENTRY); procedure GET(P : out SUFFIX_ENTRY); procedure PUT(F : in FILE_TYPE; P : in SUFFIX_ENTRY); procedure PUT(P : in SUFFIX_ENTRY); procedure GET(S : in STRING; P : out SUFFIX_ENTRY; LAST : out INTEGER); procedure PUT(S : out STRING; P : in SUFFIX_ENTRY); end SUFFIX_ENTRY_IO; type TACKON_ITEM is record POFS: PART_OF_SPEECH_TYPE := TACKON; TACK : STEM_TYPE := NULL_STEM_TYPE; ENTR : TACKON_ENTRY := NULL_TACKON_ENTRY; MNPC : INTEGER := 0; end record; NULL_TACKON_ITEM : TACKON_ITEM; type PREFIX_ITEM is record POFS: PART_OF_SPEECH_TYPE := PREFIX; FIX : FIX_TYPE := NULL_FIX_TYPE; CONNECT : CHARACTER := ' '; ENTR : PREFIX_ENTRY := NULL_PREFIX_ENTRY; MNPC : INTEGER := 0; end record; NULL_PREFIX_ITEM : PREFIX_ITEM; type SUFFIX_ITEM is record POFS: PART_OF_SPEECH_TYPE := SUFFIX; FIX : FIX_TYPE := NULL_FIX_TYPE; CONNECT : CHARACTER := ' '; ENTR : SUFFIX_ENTRY := NULL_SUFFIX_ENTRY; MNPC : INTEGER := 0; end record; NULL_SUFFIX_ITEM : SUFFIX_ITEM; type PREFIX_ARRAY is array (INTEGER range <>) of PREFIX_ITEM; type TICKON_ARRAY is array (INTEGER range <>) of PREFIX_ITEM; type SUFFIX_ARRAY is array (INTEGER range <>) of SUFFIX_ITEM; type TACKON_ARRAY is array (INTEGER range <>) of TACKON_ITEM; type MEANS_ARRAY is array (INTEGER range <>) of MEANING_TYPE; -- To simulate a DICT_IO file, as used previously TACKONS : TACKON_ARRAY(1..20); PACKONS : TACKON_ARRAY(1..25); TICKONS : PREFIX_ARRAY(1..10); PREFIXES : PREFIX_ARRAY(1..130); SUFFIXES : SUFFIX_ARRAY(1..185); MEANS : MEANS_ARRAY(1..370); NUMBER_OF_TICKONS : INTEGER := 0; NUMBER_OF_TACKONS : INTEGER := 0; NUMBER_OF_PACKONS : INTEGER := 0; NUMBER_OF_PREFIXES : INTEGER := 0; NUMBER_OF_SUFFIXES : INTEGER := 0; procedure LOAD_ADDONS (FILE_NAME : in STRING); function SUBTRACT_TACKON(W : STRING; X : TACKON_ITEM) return STRING; function SUBTRACT_PREFIX(W : STRING; X : PREFIX_ITEM) return STEM_TYPE; function SUBTRACT_TICKON(W : STRING; X : PREFIX_ITEM) return STEM_TYPE renames SUBTRACT_PREFIX; function SUBTRACT_SUFFIX(W : STRING; X : SUFFIX_ITEM) return STEM_TYPE; function ADD_PREFIX(STEM : STEM_TYPE; PREFIX : PREFIX_ITEM) return STEM_TYPE; function ADD_SUFFIX(STEM : STEM_TYPE; SUFFIX : SUFFIX_ITEM) return STEM_TYPE; end ADDONS_PACKAGE;
-- This package has been generated automatically by GNATtest. -- You are allowed to add your code to the bodies of test routines. -- Such changes will be kept during further regeneration of this file. -- All code placed outside of test routine bodies will be lost. The -- code intended to set up and tear down the test environment should be -- placed into Crew.Test_Data. with AUnit.Assertions; use AUnit.Assertions; with System.Assertions; -- begin read only -- id:2.2/00/ -- -- This section can be used to add with clauses if necessary. -- -- end read only with Config; use Config; with Ships; use Ships; -- begin read only -- end read only package body Crew.Test_Data.Tests is -- begin read only -- id:2.2/01/ -- -- This section can be used to add global variables and other elements. -- -- end read only -- begin read only -- end read only -- begin read only procedure Wrap_Test_GainExp_685058_5db064 (Amount: Natural; SkillNumber, CrewIndex: Positive) is begin begin pragma Assert(SkillNumber <= Skills_Amount); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(crew.ads:0):Test_GainExp test requirement violated"); end; GNATtest_Generated.GNATtest_Standard.Crew.GainExp (Amount, SkillNumber, CrewIndex); begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(crew.ads:0:):Test_GainExp test commitment violated"); end; end Wrap_Test_GainExp_685058_5db064; -- end read only -- begin read only procedure Test_GainExp_test_gainexp(Gnattest_T: in out Test); procedure Test_GainExp_685058_5db064(Gnattest_T: in out Test) renames Test_GainExp_test_gainexp; -- id:2.2/685058e06b47ff9b/GainExp/1/0/test_gainexp/ procedure Test_GainExp_test_gainexp(Gnattest_T: in out Test) is procedure GainExp (Amount: Natural; SkillNumber, CrewIndex: Positive) renames Wrap_Test_GainExp_685058_5db064; -- end read only pragma Unreferenced(Gnattest_T); begin GainExp(1, 4, 1); Assert (Player_Ship.Crew(1).Skills(1).Experience = 8, "Failed to gain experience in skill."); -- begin read only end Test_GainExp_test_gainexp; -- end read only -- begin read only function Wrap_Test_GenerateMemberName_b4591b_b29bd9 (Gender: Character; FactionIndex: Unbounded_String) return Unbounded_String is begin begin pragma Assert (Gender in 'M' | 'F' and FactionIndex /= Null_Unbounded_String); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(crew.ads:0):Test_GenerateMemberName test requirement violated"); end; declare Test_GenerateMemberName_b4591b_b29bd9_Result: constant Unbounded_String := GNATtest_Generated.GNATtest_Standard.Crew.GenerateMemberName (Gender, FactionIndex); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(crew.ads:0:):Test_GenerateMemberName test commitment violated"); end; return Test_GenerateMemberName_b4591b_b29bd9_Result; end; end Wrap_Test_GenerateMemberName_b4591b_b29bd9; -- end read only -- begin read only procedure Test_GenerateMemberName_test_generatemembername (Gnattest_T: in out Test); procedure Test_GenerateMemberName_b4591b_b29bd9 (Gnattest_T: in out Test) renames Test_GenerateMemberName_test_generatemembername; -- id:2.2/b4591b69c6a992ff/GenerateMemberName/1/0/test_generatemembername/ procedure Test_GenerateMemberName_test_generatemembername (Gnattest_T: in out Test) is function GenerateMemberName (Gender: Character; FactionIndex: Unbounded_String) return Unbounded_String renames Wrap_Test_GenerateMemberName_b4591b_b29bd9; -- end read only pragma Unreferenced(Gnattest_T); begin Assert (GenerateMemberName('M', To_Unbounded_String("POLEIS")) /= Null_Unbounded_String, "Failed to generate male name for poleis faction."); -- begin read only end Test_GenerateMemberName_test_generatemembername; -- end read only -- begin read only function Wrap_Test_FindCabin_c60907_006804 (MemberIndex: Positive) return Natural is begin declare Test_FindCabin_c60907_006804_Result: constant Natural := GNATtest_Generated.GNATtest_Standard.Crew.FindCabin(MemberIndex); begin return Test_FindCabin_c60907_006804_Result; end; end Wrap_Test_FindCabin_c60907_006804; -- end read only -- begin read only procedure Test_FindCabin_test_findcabin(Gnattest_T: in out Test); procedure Test_FindCabin_c60907_006804(Gnattest_T: in out Test) renames Test_FindCabin_test_findcabin; -- id:2.2/c60907de3ec73748/FindCabin/1/0/test_findcabin/ procedure Test_FindCabin_test_findcabin(Gnattest_T: in out Test) is function FindCabin(MemberIndex: Positive) return Natural renames Wrap_Test_FindCabin_c60907_006804; -- end read only pragma Unreferenced(Gnattest_T); begin Assert (FindCabin(1) > 0, "Failed to find cabin for existing crew member."); Assert (FindCabin(100) = 0, "Failed to not find cabin for non existing crew member."); -- begin read only end Test_FindCabin_test_findcabin; -- end read only -- begin read only procedure Wrap_Test_UpdateCrew_123b55_011eae (Minutes: Positive; TiredPoints: Natural; InCombat: Boolean := False) is begin GNATtest_Generated.GNATtest_Standard.Crew.UpdateCrew (Minutes, TiredPoints, InCombat); end Wrap_Test_UpdateCrew_123b55_011eae; -- end read only -- begin read only procedure Test_UpdateCrew_test_updatecrew(Gnattest_T: in out Test); procedure Test_UpdateCrew_123b55_011eae(Gnattest_T: in out Test) renames Test_UpdateCrew_test_updatecrew; -- id:2.2/123b55a332c8ae22/UpdateCrew/1/0/test_updatecrew/ procedure Test_UpdateCrew_test_updatecrew(Gnattest_T: in out Test) is procedure UpdateCrew (Minutes: Positive; TiredPoints: Natural; InCombat: Boolean := False) renames Wrap_Test_UpdateCrew_123b55_011eae; -- end read only pragma Unreferenced(Gnattest_T); begin UpdateCrew(1, 1); Player_Ship.Crew(1).Health := 0; UpdateCrew(1, 1); New_Game_Settings.Player_Faction := To_Unbounded_String("POLEIS"); New_Game_Settings.Player_Career := To_Unbounded_String("general"); New_Game_Settings.Starting_Base := To_Unbounded_String("1"); New_Game; Assert(True, "This tests can only crash."); -- begin read only end Test_UpdateCrew_test_updatecrew; -- end read only -- begin read only procedure Wrap_Test_WaitForRest_237f93_b046aa is begin GNATtest_Generated.GNATtest_Standard.Crew.WaitForRest; end Wrap_Test_WaitForRest_237f93_b046aa; -- end read only -- begin read only procedure Test_WaitForRest_test_waitforrest(Gnattest_T: in out Test); procedure Test_WaitForRest_237f93_b046aa(Gnattest_T: in out Test) renames Test_WaitForRest_test_waitforrest; -- id:2.2/237f93172c11704d/WaitForRest/1/0/test_waitforrest/ procedure Test_WaitForRest_test_waitforrest(Gnattest_T: in out Test) is procedure WaitForRest renames Wrap_Test_WaitForRest_237f93_b046aa; -- end read only pragma Unreferenced(Gnattest_T); begin WaitForRest; Assert(True, "This test can only crash."); -- begin read only end Test_WaitForRest_test_waitforrest; -- end read only -- begin read only function Wrap_Test_GetSkillLevelName_b5615e_35c4c0 (SkillLevel: Skill_Range) return String is begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(crew.ads:0):Test_GetSkillLevelName test requirement violated"); end; declare Test_GetSkillLevelName_b5615e_35c4c0_Result: constant String := GNATtest_Generated.GNATtest_Standard.Crew.GetSkillLevelName (SkillLevel); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(crew.ads:0:):Test_GetSkillLevelName test commitment violated"); end; return Test_GetSkillLevelName_b5615e_35c4c0_Result; end; end Wrap_Test_GetSkillLevelName_b5615e_35c4c0; -- end read only -- begin read only procedure Test_GetSkillLevelName_test_getskilllevelname (Gnattest_T: in out Test); procedure Test_GetSkillLevelName_b5615e_35c4c0 (Gnattest_T: in out Test) renames Test_GetSkillLevelName_test_getskilllevelname; -- id:2.2/b5615ec8a22d7d74/GetSkillLevelName/1/0/test_getskilllevelname/ procedure Test_GetSkillLevelName_test_getskilllevelname (Gnattest_T: in out Test) is function GetSkillLevelName(SkillLevel: Skill_Range) return String renames Wrap_Test_GetSkillLevelName_b5615e_35c4c0; -- end read only pragma Unreferenced(Gnattest_T); begin Game_Settings.Show_Numbers := False; Assert (GetSkillLevelName(9) = "Beginner", "Failed to get skill level name for level 9"); Assert (GetSkillLevelName(54) = "Respected", "Failed to get skill level name for level 54"); Assert (GetSkillLevelName(92) = "Legendary", "Failed to get skill level name for level 92"); Game_Settings.Show_Numbers := True; Assert (GetSkillLevelName(9) = " 9", "Failed to get skill level name for level 9 (numeric)"); Assert (GetSkillLevelName(54) = " 54", "Failed to get skill level name for level 54 (numeric)"); Assert (GetSkillLevelName(92) = " 92", "Failed to get skill level name for level 92 (numeric)"); -- begin read only end Test_GetSkillLevelName_test_getskilllevelname; -- end read only -- begin read only function Wrap_Test_GetAttributeLevelName_ac08df_7fd836 (AttributeLevel: Positive) return String is begin begin pragma Assert((AttributeLevel <= 50)); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(crew.ads:0):Test_GetAttributeLevelName test requirement violated"); end; declare Test_GetAttributeLevelName_ac08df_7fd836_Result: constant String := GNATtest_Generated.GNATtest_Standard.Crew.GetAttributeLevelName (AttributeLevel); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(crew.ads:0:):Test_GetAttributeLevelName test commitment violated"); end; return Test_GetAttributeLevelName_ac08df_7fd836_Result; end; end Wrap_Test_GetAttributeLevelName_ac08df_7fd836; -- end read only -- begin read only procedure Test_GetAttributeLevelName_test_getattributelevelname (Gnattest_T: in out Test); procedure Test_GetAttributeLevelName_ac08df_7fd836 (Gnattest_T: in out Test) renames Test_GetAttributeLevelName_test_getattributelevelname; -- id:2.2/ac08dfe313a43d73/GetAttributeLevelName/1/0/test_getattributelevelname/ procedure Test_GetAttributeLevelName_test_getattributelevelname (Gnattest_T: in out Test) is function GetAttributeLevelName (AttributeLevel: Positive) return String renames Wrap_Test_GetAttributeLevelName_ac08df_7fd836; -- end read only pragma Unreferenced(Gnattest_T); begin Game_Settings.Show_Numbers := False; Assert (GetAttributeLevelName(3) = "Very low", "Failed to get attribute level name for level 3"); Assert (GetAttributeLevelName(12) = "Below average", "Failed to get attribute level name for level 12"); Assert (GetAttributeLevelName(48) = "Very high", "Failed to get attribute level name for level 48"); Game_Settings.Show_Numbers := True; Assert (GetAttributeLevelName(3) = " 3", "Failed to get attribute level name for level 3 (numeric)"); Assert (GetAttributeLevelName(12) = " 12", "Failed to get attribute level name for level 12 (numeric)"); Assert (GetAttributeLevelName(48) = " 48", "Failed to get attribute level name for level 48 (numeric)"); -- begin read only end Test_GetAttributeLevelName_test_getattributelevelname; -- end read only -- begin read only procedure Wrap_Test_DailyPayment_62db86_0bfd06 is begin GNATtest_Generated.GNATtest_Standard.Crew.DailyPayment; end Wrap_Test_DailyPayment_62db86_0bfd06; -- end read only -- begin read only procedure Test_DailyPayment_test_dailypayment(Gnattest_T: in out Test); procedure Test_DailyPayment_62db86_0bfd06(Gnattest_T: in out Test) renames Test_DailyPayment_test_dailypayment; -- id:2.2/62db86393c55b47a/DailyPayment/1/0/test_dailypayment/ procedure Test_DailyPayment_test_dailypayment(Gnattest_T: in out Test) is procedure DailyPayment renames Wrap_Test_DailyPayment_62db86_0bfd06; -- end read only pragma Unreferenced(Gnattest_T); begin DailyPayment; Assert(True, "This test can only crash."); -- begin read only end Test_DailyPayment_test_dailypayment; -- end read only -- begin read only function Wrap_Test_GetTrainingToolQuality_32b7f3_512b79 (MemberIndex, SkillIndex: Positive) return Positive is begin begin pragma Assert(SkillIndex <= Skills_Amount); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(crew.ads:0):Test_GetTrainingToolQuality test requirement violated"); end; declare Test_GetTrainingToolQuality_32b7f3_512b79_Result: constant Positive := GNATtest_Generated.GNATtest_Standard.Crew.GetTrainingToolQuality (MemberIndex, SkillIndex); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(crew.ads:0:):Test_GetTrainingToolQuality test commitment violated"); end; return Test_GetTrainingToolQuality_32b7f3_512b79_Result; end; end Wrap_Test_GetTrainingToolQuality_32b7f3_512b79; -- end read only -- begin read only procedure Test_GetTrainingToolQuality_test_gettrainingtoolquality (Gnattest_T: in out Test); procedure Test_GetTrainingToolQuality_32b7f3_512b79 (Gnattest_T: in out Test) renames Test_GetTrainingToolQuality_test_gettrainingtoolquality; -- id:2.2/32b7f32221fae8a9/GetTrainingToolQuality/1/0/test_gettrainingtoolquality/ procedure Test_GetTrainingToolQuality_test_gettrainingtoolquality (Gnattest_T: in out Test) is function GetTrainingToolQuality (MemberIndex, SkillIndex: Positive) return Positive renames Wrap_Test_GetTrainingToolQuality_32b7f3_512b79; -- end read only pragma Unreferenced(Gnattest_T); begin AUnit.Assertions.Assert (GetTrainingToolQuality(1, 1) = 100, "Failed to get minimun quality of training tool."); -- begin read only end Test_GetTrainingToolQuality_test_gettrainingtoolquality; -- end read only -- begin read only -- id:2.2/02/ -- -- This section can be used to add elaboration code for the global state. -- begin -- end read only null; -- begin read only -- end read only end Crew.Test_Data.Tests;
with Hash; with Box; with Box7; with Box8; with Core1; with Core3; with Onetimeauth; with Onetimeauth2; with Onetimeauth7; with Scalarmult; with Scalarmult2; with Scalarmult5; with Scalarmult6; with Secretbox; with Secretbox2; with Secretbox3; with Secretbox7; with Secretbox8; with Secretbox9; with Sign; with Stream; with Stream2; with Stream3; with Stream4; with Ada.Text_IO; use Ada.Text_IO; with Ada.Exceptions; use Ada.Exceptions; with GNAT.Traceback.Symbolic; use GNAT.Traceback.Symbolic; procedure Testall is begin Put_Line ("Hash"); Hash; Put_Line ("Box"); Box; Put_Line ("Box7"); Box7; Put_Line ("Box8"); Box8; Put_Line ("Core1"); Core1; Put_Line ("Core3"); Core3; Put_Line ("Onetimeauth"); Onetimeauth; Put_Line ("Onetimeauth2"); Onetimeauth2; Put_Line ("Onetimeauth7"); Onetimeauth7; Put_Line ("Scalarmult"); Scalarmult; Put_Line ("Scalarmult2"); Scalarmult2; Put_Line ("Scalarmult5"); Scalarmult5; Put_Line ("Scalarmult6"); Scalarmult6; Put_Line ("Secretbox"); Secretbox; Put_Line ("Secretbox2"); Secretbox2; Put_Line ("Secretbox3"); Secretbox3; Put_Line ("Secretbox7"); Secretbox7; Put_Line ("Secretbox8"); Secretbox8; Put_Line ("Secretbox9"); Secretbox9; Put_Line ("Sign"); Sign; Put_Line ("Stream"); Stream; Put_Line ("Stream2"); Stream2; Put_Line ("Stream3"); Stream3; Put_Line ("Stream4"); Stream4; exception when E : others => Put_Line (Exception_Message (E)); Put_Line (Exception_Information (E)); Put_Line (Symbolic_Traceback (E)); end Testall;
with adam.a_Package, gtk.Widget; private with aIDE.Editor.of_context, gtk.Text_View, gtk.Alignment, gtk.gEntry, gtk.Label, gtk.Box; with Gtk.Scrolled_Window; with Gtk.Notebook; with Gtk.Table; package aIDE.Editor.of_package is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function to_package_Editor (the_Package : in adam.a_Package.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; function my_Package (Self : in Item) return adam.a_Package.view; procedure Package_is (Self : in out Item; Now : in adam.a_Package.view); overriding procedure freshen (Self : in out Item); private use gtk.Text_View, Gtk.scrolled_Window, gtk.Box, gtk.gEntry, gtk.Notebook, gtk.Table, gtk.Label, gtk.Alignment; type Item is new Editor.item with record my_Package : adam.a_Package.view; -- public_Part : Boolean; Notebook : gtk_Notebook; public_context_Editor : aIDE.Editor.of_context.view; public_context_Alignment : gtk_Alignment; private_context_Editor : aIDE.Editor.of_context.view; private_context_Alignment : gtk_Alignment; name_Entry : gtk_Entry; package_Label : gtk_Label; declarations_Label : gtk_Label; simple_attributes_Table : gtk_Table; top_Window : gtk_scrolled_Window; top_Box : gtk_Box; public_entities_Box : gtk_Box; private_entities_Box : gtk_Box; declare_Text, begin_Text, exception_Text : Gtk_Text_View; end record; end aIDE.Editor.of_package;
with Ada.Characters.Handling; use Ada.Characters; package body Solitaire_Operations.Text_Representation is ------------------------------------------------------------------------ function Card (Name : Short_Card) return Card_Value is -- -- Returns the card for the given 2-character name. -- Upper_Card : Short_Card := Handling.To_Upper (Name); begin -- Card Find_Card : for I in Short_Card_Name'Range loop if Upper_Card = Short_Card_Name (I) then return I; end if; end loop Find_Card; raise Card_Not_Found; end Card; ------------------------------------------------------------------------ procedure Set_Deck (Deck : in out Deck_List; To : in Short_Card_Deck_String) is -- -- Sets the deck contents to the values provided in the compact list -- of 2-character names. -- Card_Index : Positive; begin -- Set_Deck Copy: for I in Deck'Range loop Card_Index := To'First + 2 * (I - Deck'First); Deck (I) := Card (To (Card_Index .. Card_Index + 1)); end loop Copy; end Set_Deck; end Solitaire_Operations.Text_Representation;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. generic type Integer_Type is range <>; package Apsepp.Generic_Prot_Integer is -- Evaluate the pre-conditions in this package. pragma Assertion_Policy (Pre => Check); type O_P_I_Type is private with Type_Invariant => ( Val (O_P_I_Type) = Integer_Type'First or else Val (O_P_I_Type) = Integer_Type'Last or else not Sat (O_P_I_Type) ); function Create (V : Integer_Type; S : Boolean := False) return O_P_I_Type with Pre => not S or else (V = Integer_Type'First or else V = Integer_Type'Last), Post => Val (Create'Result) = V and then Sat (Create'Result) = S; function Val (X : O_P_I_Type) return Integer_Type; function Sat (X : O_P_I_Type) return Boolean; function "+" (X_1, X_2 : O_P_I_Type) return O_P_I_Type with Pre => Val (X_2) >= 0; procedure Inc (X : in out O_P_I_Type; By : Integer_Type'Base := 1) with Pre => By >= 0; private type O_P_I_Type is record Value : Integer_Type := Integer_Type'First; Saturated : Boolean := False; end record; end Apsepp.Generic_Prot_Integer;
-- AoC 2020, Day 24 with Ada.Text_IO; with Ada.Containers.Hashed_Sets; use Ada.Containers; package body Day is package TIO renames Ada.Text_IO; type Hex is record x, y, z : Integer; end record; function hex_hash(h : in Hex) return Hash_Type is v : constant Long_Integer := Long_Integer((h.x * 103) + (h.y * 29) + (h.z * 43)); begin return Hash_Type(v mod Long_Integer(Hash_Type'Last)); end hex_hash; package Hex_Sets is new Ada.Containers.Hashed_Sets (Element_Type => Hex, Hash => hex_hash, Equivalent_Elements => "="); use Hex_Sets; procedure move_east(h : in out Hex) is begin h.x := h.x + 1; h.y := h.y - 1; end move_east; procedure move_west(h : in out Hex) is begin h.x := h.x - 1; h.y := h.y + 1; end move_west; procedure move_north(h : in out Hex; dir : in Character) is begin h.z := h.z - 1; if dir = 'e' then h.x := h.x + 1; else h.y := h.y + 1; end if; end move_north; procedure move_south(h : in out Hex; dir : in Character) is begin h.z := h.z + 1; if dir = 'e' then h.y := h.y - 1; else h.x := h.x - 1; end if; end move_south; type Color_Type is (black, white); function color(c : in Hex; h : in Hex_Sets.set) return Color_Type is begin if h.contains(c) then return black; else return white; end if; end color; function neighbors(c : in Hex) return Hex_Sets.Set is n : Hex_Sets.Set := Empty_Set; begin n.include(Hex'(x => c.x+1, y => c.y, z => c.z-1)); n.include(Hex'(x => c.x+1, y => c.y-1, z => c.z)); n.include(Hex'(x => c.x, y => c.y-1, z => c.z+1)); n.include(Hex'(x => c.x-1, y => c.y, z => c.z+1)); n.include(Hex'(x => c.x-1, y => c.y+1, z => c.z)); n.include(Hex'(x => c.x, y => c.y+1, z => c.z-1)); return n; end neighbors; function all_neighbors(h : in Hex_Sets.set) return Hex_Sets.Set is n : Hex_Sets.Set := Empty_Set; begin n.reserve_capacity(10_000); for c of h loop n := n or neighbors(c); end loop; return n; end all_neighbors; -- procedure put(h : in Hex) is -- begin -- TIO.put("(" & h.x'IMAGE & "," & h.y'IMAGE & "," & h.z'IMAGE & ")"); -- end put; function black_neighbors(c : in Hex; h : in Hex_Sets.Set) return Natural is neighs : constant Hex_Sets.Set := neighbors(c); total : Natural := 0; begin for c of neighs loop if black = color(c, h) then total := total + 1; end if; end loop; return total; end black_neighbors; procedure step(h : in out Hex_Sets.set) is n : constant Hex_Sets.Set := all_neighbors(h); complete : constant Hex_Sets.Set := h or n; next : Hex_Sets.Set := Empty_Set; begin next.reserve_capacity(10_000); TIO.put_line("Count: " & complete.length'IMAGE); for c of complete loop declare black_count : constant Natural := black_neighbors(c, h); begin case color(c, h) is when white => if black_count = 2 then next.include(c); end if; when black => if not(black_count = 0 or black_count > 2) then next.include(c); end if; end case; end; end loop; h := next; end step; function eval_input(filename : in String) return Hex_Sets.Set is file : TIO.File_Type; h : Hex_Sets.Set := Empty_Set; start_hex : constant Hex := Hex'(x=>0, y=>0, z=>0); begin TIO.open(File => file, Mode => TIO.In_File, Name => filename); while not TIO.end_of_file(file) loop declare line : constant String := TIO.get_line(file); curr : Hex := start_hex; last_char : Character := ' '; begin for c of line loop if last_char = 's' then move_south(curr, c); last_char := ' '; elsif last_char = 'n' then move_north(curr, c); last_char := ' '; else case c is when 'e' => move_east(curr); when 'w' => move_west(curr); when others => last_char := c; end case; end if; end loop; if h.contains(curr) then h.delete(curr); else h.insert(curr); end if; end; end loop; TIO.close(file); return h; end eval_input; function count_tiles(filename : in String) return Natural is h : constant Hex_Sets.Set := eval_input(filename); begin return Natural(h.length); end count_tiles; function evolve_tiles(filename : in String; steps : in Natural) return Natural is h : Hex_Sets.Set := eval_input(filename); begin h.reserve_capacity(10_000); for s in 1..steps loop step(h); TIO.put_line("Day" & s'IMAGE & ":" & h.length'IMAGE); end loop; return Natural(h.length); end evolve_tiles; end Day;
with Ada.Text_IO; with Assemble_Functions; with Ada.Directories; with GNAT.Command_Line; with Ada.Strings.Bounded; use GNAT.Command_Line; use Ada.Text_IO; --main function controls reading and writing --assemble package handles each line procedure Compiler is package SB is new Ada.Strings.Bounded.Generic_Bounded_Length(Max => 50); Mode : Integer := 0; Source_File : File_Type; Output_File : File_Type; Error_Flag : Boolean := True; Output_File_Name : SB.Bounded_String; Input_File_Name : SB.Bounded_String; begin loop case Getopt ("a d o:") is when 'a' => if Mode = 0 then Mode:=2; else Put_Line("Conflicting agument : '-a'"); return; end if; when 'd' => if Mode = 0 then Mode:=1; else Put_Line("Conflicting agument : '-d'"); return; end if; when 'o' => Output_File_Name := SB.To_Bounded_String(Parameter); when others => exit; end case; end loop; Input_File_Name := SB.To_Bounded_String(Get_Argument); if SB.Length(Input_File_Name) = 0 then Put_Line("No file name given"); return; end if; --open files Open(Source_File, In_File, SB.To_String(Input_File_Name)); Create(File=>Output_File, Name=>"~Out.s"); if Mode = 0 or else Mode = 2 then Error_Flag := Assemble_Functions.Build(Source_File, Output_File); elsif Mode = 1 then Put_Line("Disassemble is not supported yet"); end if; Close(Source_File); Close(Output_File); if Error_Flag = False then if SB.Length(Output_File_Name) > 0 then if Ada.Directories.Exists(SB.To_String(Output_File_Name)) then Ada.Directories.Delete_File(SB.To_String(Output_File_Name)); end if; Ada.Directories.Rename("~Out.s", SB.To_String(Output_File_Name)); else if Ada.Directories.Exists("Out.s") then Ada.Directories.Delete_File("Out.s"); end if; Ada.Directories.Rename("~Out.s", "Out.s"); end if; else Ada.Directories.Delete_File("~Out.s"); end if; end Compiler;
separate (openGL) function Profile return profile_Kind is begin return Desk; end Profile;
with Ada.Containers.Indefinite_Vectors, Ada.Text_IO; procedure Lalefile is package Word_Vec is new Ada.Containers.Indefinite_Vectors (Index_Type => Positive, Element_Type => String); use type Word_Vec.Vector, Ada.Containers.Count_Type; type Words_Type is array (Character) of Word_Vec.Vector; procedure Read(Words: out Words_Type) is F: Ada.Text_IO.File_Type; begin Ada.Text_IO.Open(File => F, Name => "pokemon70.txt", Mode => Ada.Text_IO.In_File); loop declare Word: String := Ada.Text_IO.Get_Line(F); begin exit when Word = ""; Words(Word(Word'First)).Append(Word); end; end loop; exception when Ada.Text_IO.End_Error => null; end Read; procedure Write (List: Word_Vec.Vector; Prefix: String := " ") is Copy: Word_Vec.Vector := List; begin loop exit when Copy.Is_Empty; Ada.Text_IO.Put_Line(Prefix & Copy.First_Element); Copy.Delete_First; end loop; end Write; function Run(Start: Character; Words: Words_Type) return Word_Vec.Vector is Result: Word_Vec.Vector := Word_Vec.Empty_Vector; begin for I in Words(Start).First_Index .. Words(Start).Last_Index loop declare Word: String := Words(Start).Element(I); Dupl: Words_Type := Words; Alternative : Word_Vec.Vector; begin Dupl(Start).Delete(I); Alternative := Word & Run(Word(Word'Last), Dupl); if Alternative.Length > Result.Length then Result := Alternative; end if; end; end loop; return Result; end Run; W: Words_Type; A_Vector: Word_Vec.Vector; Best: Word_Vec.Vector := Word_Vec.Empty_Vector; begin Read(W); Ada.Text_IO.Put("Processing "); for Ch in Character range 'a' .. 'z' loop Ada.Text_IO.Put(Ch & ", "); A_Vector := Run(Ch, W); if A_Vector.Length > Best.Length then Best := A_Vector; end if; end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line("Length of longest Path:" & Integer'Image(Integer(Best.Length))); Ada.Text_IO.Put_Line("One such path:"); Write(Best); end Lalefile;
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2012, Stefan Berghofer -- Copyright (C) 2012, secunet Security Networks AG -- 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 author 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. ------------------------------------------------------------------------------- package body LSC.Internal.EC is procedure Point_Double (X1 : in Bignum.Big_Int; X1_First : in Natural; X1_Last : in Natural; Y1 : in Bignum.Big_Int; Y1_First : in Natural; Z1 : in Bignum.Big_Int; Z1_First : in Natural; X2 : out Bignum.Big_Int; X2_First : in Natural; Y2 : out Bignum.Big_Int; Y2_First : in Natural; Z2 : out Bignum.Big_Int; Z2_First : in Natural; A : in Bignum.Big_Int; A_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32) is L : Natural; H1, H2, H3, H4, H5, H6 : Coord; begin L := X1_Last - X1_First; if Bignum.Is_Zero (Z1, Z1_First, Z1_First + L) then Bignum.Initialize (X2, X2_First, X2_First + L); Bignum.Initialize (Y2, Y2_First, Y2_First + L); Bignum.Initialize (Z2, Z2_First, Z2_First + L); else Bignum.Mod_Add (H1, H1'First, H1'First + L, Y1, Y1_First, Y1, Y1_First, M, M_First); Bignum.Mont_Mult (H2, H2'First, H2'First + L, H1, H1'First, Z1, Z1_First, M, M_First, M_Inv); Bignum.Mod_Add (H3, H3'First, H3'First + L, X1, X1_First, X1, X1_First, M, M_First); Bignum.Mod_Add_Inplace (H3, H3'First, H3'First + L, X1, X1_First, M, M_First); Bignum.Mont_Mult (H1, H1'First, H1'First + L, H3, H3'First, X1, X1_First, M, M_First, M_Inv); Bignum.Mont_Mult (H4, H4'First, H4'First + L, A, A_First, Z1, Z1_First, M, M_First, M_Inv); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H4, H4'First, Z1, Z1_First, M, M_First, M_Inv); Bignum.Mod_Add_Inplace (H1, H1'First, H1'First + L, H3, H3'First, M, M_First); Bignum.Mod_Sub_Inplace (H1, H1'First, H1'First + L, M, M_First, M, M_First); Bignum.Mont_Mult (H4, H4'First, H4'First + L, Y1, Y1_First, H2, H2'First, M, M_First, M_Inv); Bignum.Mod_Add (H6, H6'First, H6'First + L, X1, X1_First, X1, X1_First, M, M_First); Bignum.Mont_Mult (H5, H5'First, H5'First + L, H6, H6'First, H4, H4'First, M, M_First, M_Inv); Bignum.Mont_Mult (H6, H6'First, H6'First + L, H1, H1'First, H1, H1'First, M, M_First, M_Inv); Bignum.Mod_Sub_Inplace (H6, H6'First, H6'First + L, H5, H5'First, M, M_First); Bignum.Mod_Sub_Inplace (H6, H6'First, H6'First + L, H5, H5'First, M, M_First); Bignum.Mont_Mult (X2, X2_First, X2_First + L, H6, H6'First, H2, H2'First, M, M_First, M_Inv); Bignum.Mod_Sub (H3, H3'First, H3'First + L, H5, H5'First, H6, H6'First, M, M_First); Bignum.Mont_Mult (Y2, Y2_First, Y2_First + L, H3, H3'First, H1, H1'First, M, M_First, M_Inv); Bignum.Mod_Add (H3, H3'First, H3'First + L, H4, H4'First, H4, H4'First, M, M_First); Bignum.Mont_Mult (H1, H1'First, H1'First + L, H3, H3'First, H4, H4'First, M, M_First, M_Inv); Bignum.Mod_Sub_Inplace (Y2, Y2_First, Y2_First + L, H1, H1'First, M, M_First); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H2, H2'First, H2, H2'First, M, M_First, M_Inv); Bignum.Mont_Mult (Z2, Z2_First, Z2_First + L, H3, H3'First, H2, H2'First, M, M_First, M_Inv); end if; end Point_Double; ---------------------------------------------------------------------------- procedure Point_Add (X1 : in Bignum.Big_Int; X1_First : in Natural; X1_Last : in Natural; Y1 : in Bignum.Big_Int; Y1_First : in Natural; Z1 : in Bignum.Big_Int; Z1_First : in Natural; X2 : in Bignum.Big_Int; X2_First : in Natural; Y2 : in Bignum.Big_Int; Y2_First : in Natural; Z2 : in Bignum.Big_Int; Z2_First : in Natural; X3 : out Bignum.Big_Int; X3_First : in Natural; Y3 : out Bignum.Big_Int; Y3_First : in Natural; Z3 : out Bignum.Big_Int; Z3_First : in Natural; A : in Bignum.Big_Int; A_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32) is L : Natural; H1, H2, H3, H4, H5, H6, H7, H8, H9 : Coord; begin L := X1_Last - X1_First; if Bignum.Is_Zero (Z1, Z1_First, Z1_First + L) then Bignum.Initialize (X3, X3_First, X3_First + L); Bignum.Initialize (Y3, Y3_First, Y3_First + L); Bignum.Initialize (Z3, Z3_First, Z3_First + L); Bignum.Copy (X2, X2_First, X2_First + L, X3, X3_First); Bignum.Copy (Y2, Y2_First, Y2_First + L, Y3, Y3_First); Bignum.Copy (Z2, Z2_First, Z2_First + L, Z3, Z3_First); elsif Bignum.Is_Zero (Z2, Z2_First, Z2_First + L) then Bignum.Initialize (X3, X3_First, X3_First + L); Bignum.Initialize (Y3, Y3_First, Y3_First + L); Bignum.Initialize (Z3, Z3_First, Z3_First + L); Bignum.Copy (X1, X1_First, X1_Last, X3, X3_First); Bignum.Copy (Y1, Y1_First, Y1_First + L, Y3, Y3_First); Bignum.Copy (Z1, Z1_First, Z1_First + L, Z3, Z3_First); else Bignum.Mont_Mult (H1, H1'First, H1'First + L, X2, X2_First, Z1, Z1_First, M, M_First, M_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, X1, X1_First, Z2, Z2_First, M, M_First, M_Inv); Bignum.Mont_Mult (H3, H3'First, H3'First + L, Y2, Y2_First, Z1, Z1_First, M, M_First, M_Inv); Bignum.Mont_Mult (H4, H4'First, H4'First + L, Y1, Y1_First, Z2, Z2_First, M, M_First, M_Inv); Bignum.Mod_Sub (H5, H5'First, H5'First + L, H1, H1'First, H2, H2'First, M, M_First); Bignum.Mod_Sub (H6, H6'First, H6'First + L, H3, H3'First, H4, H4'First, M, M_First); if Bignum.Is_Zero (H5, H5'First, H5'First + L) then if Bignum.Is_Zero (H6, H6'First, H6'First + L) then Point_Double (X1, X1_First, X1_Last, Y1, Y1_First, Z1, Z1_First, X3, X3_First, Y3, Y3_First, Z3, Z3_First, A, A_First, M, M_First, M_Inv); else Bignum.Initialize (X3, X3_First, X3_First + L); Bignum.Initialize (Y3, Y3_First, Y3_First + L); Bignum.Initialize (Z3, Z3_First, Z3_First + L); end if; else Bignum.Mont_Mult (H7, H7'First, H7'First + L, Z1, Z1_First, Z2, Z2_First, M, M_First, M_Inv); Bignum.Mod_Add (H8, H8'First, H8'First + L, H1, H1'First, H2, H2'First, M, M_First); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H5, H5'First, H5, H5'First, M, M_First, M_Inv); Bignum.Mont_Mult (H1, H1'First, H1'First + L, H2, H2'First, H3, H3'First, M, M_First, M_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, H8, H8'First, H3, H3'First, M, M_First, M_Inv); Bignum.Mont_Mult (H8, H8'First, H8'First + L, H3, H3'First, H5, H5'First, M, M_First, M_Inv); Bignum.Mont_Mult (H9, H9'First, H9'First + L, H6, H6'First, H6, H6'First, M, M_First, M_Inv); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H9, H9'First, H7, H7'First, M, M_First, M_Inv); Bignum.Mod_Sub_Inplace (H3, H3'First, H3'First + L, H2, H2'First, M, M_First); Bignum.Mont_Mult (X3, X3_First, X3_First + L, H5, H5'First, H3, H3'First, M, M_First, M_Inv); Bignum.Mod_Sub_Inplace (H1, H1'First, H1'First + L, H3, H3'First, M, M_First); Bignum.Mont_Mult (H2, H2'First, H2'First + L, H1, H1'First, H6, H6'First, M, M_First, M_Inv); Bignum.Mont_Mult (H1, H1'First, H1'First + L, H8, H8'First, H4, H4'First, M, M_First, M_Inv); Bignum.Mod_Sub (Y3, Y3_First, Y3_First + L, H2, H2'First, H1, H1'First, M, M_First); Bignum.Mont_Mult (Z3, Z3_First, Z3_First + L, H8, H8'First, H7, H7'First, M, M_First, M_Inv); end if; end if; end Point_Add; ---------------------------------------------------------------------------- procedure Point_Mult (X1 : in Bignum.Big_Int; X1_First : in Natural; X1_Last : in Natural; Y1 : in Bignum.Big_Int; Y1_First : in Natural; Z1 : in Bignum.Big_Int; Z1_First : in Natural; E : in Bignum.Big_Int; E_First : in Natural; E_Last : in Natural; X2 : out Bignum.Big_Int; X2_First : in Natural; Y2 : out Bignum.Big_Int; Y2_First : in Natural; Z2 : out Bignum.Big_Int; Z2_First : in Natural; A : in Bignum.Big_Int; A_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32) is L : Natural; X3, Y3, Z3 : Coord; begin L := X1_Last - X1_First; Bignum.Initialize (X2, X2_First, X2_First + L); Bignum.Initialize (Y2, Y2_First, Y2_First + L); Bignum.Initialize (Z2, Z2_First, Z2_First + L); for I in reverse Natural range E_First .. E_Last loop pragma Loop_Invariant (L = X1_Last - X1_First and Bignum.Num_Of_Big_Int (X2, X2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y2, Y2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z2, Z2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Point_Mult_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E, I + 1, E_Last - I), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1))); for J in reverse Natural range 0 .. 31 loop pragma Loop_Invariant (L = X1_Last - X1_First and Bignum.Num_Of_Big_Int (X2, X2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y2, Y2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z2, Z2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Point_Mult_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E, I + 1, E_Last - I) * Math_Int.From_Word32 (2) ** (31 - J) + Math_Int.From_Word32 (E (I)) / Math_Int.From_Word32 (2) ** (J + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1))); Point_Double (X2, X2_First, X2_First + L, Y2, Y2_First, Z2, Z2_First, X3, X3'First, Y3, Y3'First, Z3, Z3'First, A, A_First, M, M_First, M_Inv); if (E (I) and 2 ** J) /= 0 then Point_Add (X3, X3'First, X3'First + L, Y3, Y3'First, Z3, Z3'First, X1, X1_First, Y1, Y1_First, Z1, Z1_First, X2, X2_First, Y2, Y2_First, Z2, Z2_First, A, A_First, M, M_First, M_Inv); else Bignum.Copy (X3, X3'First, X3'First + L, X2, X2_First); Bignum.Copy (Y3, Y3'First, Y3'First + L, Y2, Y2_First); Bignum.Copy (Z3, Z3'First, Z3'First + L, Z2, Z2_First); end if; pragma Assert_And_Cut (L = X1_Last - X1_First and Bignum.Num_Of_Big_Int (X2, X2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y2, Y2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z2, Z2_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Point_Mult_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E, I + 1, E_Last - I) * Math_Int.From_Word32 (2) ** (31 - (J - 1)) + Math_Int.From_Word32 (E (I)) / Math_Int.From_Word32 (2) ** ((J - 1) + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1))); end loop; end loop; end Point_Mult; ---------------------------------------------------------------------------- procedure Two_Point_Mult (X1 : in Bignum.Big_Int; X1_First : in Natural; X1_Last : in Natural; Y1 : in Bignum.Big_Int; Y1_First : in Natural; Z1 : in Bignum.Big_Int; Z1_First : in Natural; E1 : in Bignum.Big_Int; E1_First : in Natural; E1_Last : in Natural; X2 : in Bignum.Big_Int; X2_First : in Natural; Y2 : in Bignum.Big_Int; Y2_First : in Natural; Z2 : in Bignum.Big_Int; Z2_First : in Natural; E2 : in Bignum.Big_Int; E2_First : in Natural; X3 : out Bignum.Big_Int; X3_First : in Natural; Y3 : out Bignum.Big_Int; Y3_First : in Natural; Z3 : out Bignum.Big_Int; Z3_First : in Natural; A : in Bignum.Big_Int; A_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32) is L : Natural; X4, Y4, Z4, X5, Y5, Z5 : Coord; begin L := X1_Last - X1_First; Point_Add (X1, X1_First, X1_Last, Y1, Y1_First, Z1, Z1_First, X2, X2_First, Y2, Y2_First, Z2, Z2_First, X5, X5'First, Y5, Y5'First, Z5, Z5'First, A, A_First, M, M_First, M_Inv); Bignum.Initialize (X3, X3_First, X3_First + L); Bignum.Initialize (Y3, Y3_First, Y3_First + L); Bignum.Initialize (Z3, Z3_First, Z3_First + L); for I in reverse Natural range E1_First .. E1_Last loop pragma Loop_Invariant (L = X1_Last - X1_First and Bignum.Num_Of_Big_Int (X3, X3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y3, Y3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z3, Z3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (X5, X5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y5, Y5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z5, Z5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Point_Add_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X5, X5'First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y5, Y5'First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z5, Z5'First, X1_Last - X1_First + 1)) and Two_Point_Mult_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E1, I + 1, E1_Last - I), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E2, E2_First + (I - E1_First) + 1, E1_Last - I), Bignum.Num_Of_Big_Int (X3, X3_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y3, Y3_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z3, Z3_First, X1_Last - X1_First + 1))); for J in reverse Natural range 0 .. 31 loop pragma Loop_Invariant (L = X1_Last - X1_First and Bignum.Num_Of_Big_Int (X3, X3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y3, Y3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z3, Z3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (X5, X5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y5, Y5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z5, Z5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Point_Add_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X5, X5'First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y5, Y5'First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z5, Z5'First, X1_Last - X1_First + 1)) and Two_Point_Mult_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E1, I + 1, E1_Last - I) * Math_Int.From_Word32 (2) ** (31 - J) + Math_Int.From_Word32 (E1 (I)) / Math_Int.From_Word32 (2) ** (J + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E2, E2_First + (I - E1_First) + 1, E1_Last - I) * Math_Int.From_Word32 (2) ** (31 - J) + Math_Int.From_Word32 (E2 (E2_First + (I - E1_First))) / Math_Int.From_Word32 (2) ** (J + 1), Bignum.Num_Of_Big_Int (X3, X3_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y3, Y3_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z3, Z3_First, X1_Last - X1_First + 1))); Point_Double (X3, X3_First, X3_First + L, Y3, Y3_First, Z3, Z3_First, X4, X4'First, Y4, Y4'First, Z4, Z4'First, A, A_First, M, M_First, M_Inv); if (E1 (I) and 2 ** J) /= 0 then if (E2 (E2_First + (I - E1_First)) and 2 ** J) /= 0 then Point_Add (X4, X4'First, X4'First + L, Y4, Y4'First, Z4, Z4'First, X5, X5'First, Y5, Y5'First, Z5, Z5'First, X3, X3_First, Y3, Y3_First, Z3, Z3_First, A, A_First, M, M_First, M_Inv); else Point_Add (X4, X4'First, X4'First + L, Y4, Y4'First, Z4, Z4'First, X1, X1_First, Y1, Y1_First, Z1, Z1_First, X3, X3_First, Y3, Y3_First, Z3, Z3_First, A, A_First, M, M_First, M_Inv); end if; elsif (E2 (E2_First + (I - E1_First)) and 2 ** J) /= 0 then Point_Add (X4, X4'First, X4'First + L, Y4, Y4'First, Z4, Z4'First, X2, X2_First, Y2, Y2_First, Z2, Z2_First, X3, X3_First, Y3, Y3_First, Z3, Z3_First, A, A_First, M, M_First, M_Inv); else Bignum.Copy (X4, X4'First, X4'First + L, X3, X3_First); Bignum.Copy (Y4, Y4'First, Y4'First + L, Y3, Y3_First); Bignum.Copy (Z4, Z4'First, Z4'First + L, Z3, Z3_First); end if; pragma Assert_And_Cut (L = X1_Last - X1_First and Bignum.Num_Of_Big_Int (X3, X3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y3, Y3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z3, Z3_First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (X5, X5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Y5, Y5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Bignum.Num_Of_Big_Int (Z5, Z5'First, L + 1) < Bignum.Num_Of_Big_Int (M, M_First, L + 1) and Point_Add_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X5, X5'First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y5, Y5'First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z5, Z5'First, X1_Last - X1_First + 1)) and Two_Point_Mult_Spec (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (A, A_First, X1_Last - X1_First + 1) * Bignum.Inverse (Bignum.Num_Of_Big_Int (M, M_First, X1_Last - X1_First + 1), Bignum.Base) ** (X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (X1, X1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y1, Y1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z1, Z1_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E1, I + 1, E1_Last - I) * Math_Int.From_Word32 (2) ** (31 - (J - 1)) + Math_Int.From_Word32 (E1 (I)) / Math_Int.From_Word32 (2) ** ((J - 1) + 1), Bignum.Num_Of_Big_Int (X2, X2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y2, Y2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z2, Z2_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (E2, E2_First + (I - E1_First) + 1, E1_Last - I) * Math_Int.From_Word32 (2) ** (31 - (J - 1)) + Math_Int.From_Word32 (E2 (E2_First + (I - E1_First))) / Math_Int.From_Word32 (2) ** ((J - 1) + 1), Bignum.Num_Of_Big_Int (X3, X3_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Y3, Y3_First, X1_Last - X1_First + 1), Bignum.Num_Of_Big_Int (Z3, Z3_First, X1_Last - X1_First + 1))); end loop; end loop; end Two_Point_Mult; ---------------------------------------------------------------------------- procedure Invert (A : in Bignum.Big_Int; A_First : in Natural; A_Last : in Natural; B : out Bignum.Big_Int; B_First : in Natural; R : in Bignum.Big_Int; R_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32) is L : Natural; Two : constant Coord := Coord'(2, others => 0); E, H1, H2, H3, H4 : Coord; Carry : Boolean; begin L := A_Last - A_First; pragma Warnings (Off, "unused assignment to ""Carry"""); Bignum.Sub (E, E'First, E'First + L, M, M_First, Two, Two'First, Carry); pragma Warnings (On, "unused assignment to ""Carry"""); pragma Warnings (Off, "unused assignment to ""H1"""); pragma Warnings (Off, "unused assignment to ""H2"""); pragma Warnings (Off, "unused assignment to ""H3"""); Bignum.Mont_Exp (A => H4, A_First => H4'First, A_Last => H4'First + L, X => A, X_First => A_First, E => E, E_First => E'First, E_Last => E'First + L, M => M, M_First => M_First, Aux1 => H1, Aux1_First => H1'First, Aux2 => H2, Aux2_First => H2'First, Aux3 => H3, Aux3_First => H3'First, R => R, R_First => R_First, M_Inv => M_Inv); pragma Warnings (On, "unused assignment to ""H1"""); pragma Warnings (On, "unused assignment to ""H2"""); pragma Warnings (On, "unused assignment to ""H3"""); Bignum.Mont_Mult (B, B_First, B_First + L, H4, H4'First, R, R_First, M, M_First, M_Inv); end Invert; ---------------------------------------------------------------------------- procedure Make_Affine (X1 : in Bignum.Big_Int; X1_First : in Natural; X1_Last : in Natural; Y1 : in Bignum.Big_Int; Y1_First : in Natural; Z1 : in Bignum.Big_Int; Z1_First : in Natural; X2 : out Bignum.Big_Int; X2_First : in Natural; Y2 : out Bignum.Big_Int; Y2_First : in Natural; R : in Bignum.Big_Int; R_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32) is L : Natural; H : Coord; begin L := X1_Last - X1_First; Invert (Z1, Z1_First, Z1_First + L, H, H'First, R, R_First, M, M_First, M_Inv); Bignum.Mont_Mult (X2, X2_First, X2_First + L, X1, X1_First, H, H'First, M, M_First, M_Inv); Bignum.Mont_Mult (Y2, Y2_First, Y2_First + L, Y1, Y1_First, H, H'First, M, M_First, M_Inv); end Make_Affine; ---------------------------------------------------------------------------- function On_Curve (X : Bignum.Big_Int; X_First : Natural; X_Last : Natural; Y : Bignum.Big_Int; Y_First : Natural; A : Bignum.Big_Int; A_First : Natural; B : Bignum.Big_Int; B_First : Natural; R : Bignum.Big_Int; R_First : Natural; M : Bignum.Big_Int; M_First : Natural; M_Inv : Types.Word32) return Boolean is L : Natural; H1, H2, H3, H4 : Coord; begin L := X_Last - X_First; Bignum.Mont_Mult (H3, H3'First, H3'First + L, Y, Y_First, R, R_First, M, M_First, M_Inv); Bignum.Mont_Mult (H1, H1'First, H1'First + L, H3, H3'First, H3, H3'First, M, M_First, M_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, X, X_First, R, R_First, M, M_First, M_Inv); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H2, H2'First, H2, H2'First, M, M_First, M_Inv); Bignum.Mod_Add_Inplace (H3, H3'First, H3'First + L, A, A_First, M, M_First); Bignum.Mont_Mult (H4, H4'First, H4'First + L, H3, H3'First, H2, H2'First, M, M_First, M_Inv); Bignum.Mod_Sub_Inplace (H1, H1'First, H1'First + L, H4, H4'First, M, M_First); Bignum.Mod_Sub_Inplace (H1, H1'First, H1'First + L, B, B_First, M, M_First); return Bignum.Is_Zero (H1, H1'First, H1'First + L); end On_Curve; ---------------------------------------------------------------------------- procedure Uncompress_Point (X : in Bignum.Big_Int; X_First : in Natural; X_Last : in Natural; Even : in Boolean; A : in Bignum.Big_Int; A_First : in Natural; B : in Bignum.Big_Int; B_First : in Natural; R : in Bignum.Big_Int; R_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32; Y : out Bignum.Big_Int; Y_First : in Natural; Success : out Boolean) is L : Natural; H1, H2, H3, H4, H5, H6 : Coord; Carry : Boolean; begin L := X_Last - X_First; Bignum.Mont_Mult (H1, H1'First, H1'First + L, X, X_First, R, R_First, M, M_First, M_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, H1, H1'First, H1, H1'First, M, M_First, M_Inv); Bignum.Mod_Add_Inplace (H2, H2'First, H2'First + L, A, A_First, M, M_First); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H2, H2'First, H1, H1'First, M, M_First, M_Inv); Bignum.Mod_Add_Inplace (H3, H3'First, H3'First + L, B, B_First, M, M_First); Bignum.Mont_Mult (H1, H1'First, H1'First + L, H3, H3'First, One, One'First, M, M_First, M_Inv); pragma Warnings (Off, "unused assignment to ""Carry"""); Bignum.Add (H2, H2'First, H2'First + L, M, M_First, One, One'First, Carry); pragma Warnings (On, "unused assignment to ""Carry"""); Bignum.SHR_Inplace (H2, H2'First, H2'First + L, 2); pragma Warnings (Off, "unused assignment to ""H4"""); pragma Warnings (Off, "unused assignment to ""H5"""); pragma Warnings (Off, "unused assignment to ""H6"""); Bignum.Mont_Exp (H3, H3'First, H3'First + L, H1, H1'First, H2, H2'First, H2'First + L, M, M_First, H4, H4'First, H5, H5'First, H6, H6'First, R, R_First, M_Inv); pragma Warnings (On, "unused assignment to ""H4"""); pragma Warnings (On, "unused assignment to ""H5"""); pragma Warnings (On, "unused assignment to ""H6"""); if Bignum.Is_Zero (H3, H3'First, H3'First + L) or else (H3 (H3'First) mod 2 = 0) = Even then Bignum.Initialize (Y, Y_First, Y_First + L); Bignum.Copy (H3, H3'First, H3'First + L, Y, Y_First); else pragma Warnings (Off, "unused assignment to ""Carry"""); Bignum.Sub (Y, Y_First, Y_First + L, M, M_First, H3, H3'First, Carry); pragma Warnings (On, "unused assignment to ""Carry"""); end if; Bignum.Mont_Mult (H2, H2'First, H2'First + L, Y, Y_First, R, R_First, M, M_First, M_Inv); Bignum.Mont_Mult (H3, H3'First, H3'First + L, Y, Y_First, H2, H2'First, M, M_First, M_Inv); Success := Bignum.Equal (H1, H1'First, H1'First + L, H3, H3'First); end Uncompress_Point; end LSC.Internal.EC;