content
stringlengths
23
1.05M
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . L I B M _ D O U B L E . S Q R T -- -- -- -- 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. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Ada Cert Math specific implementation of sqrt (powerpc) with Ada.Unchecked_Conversion; with System.Machine_Code; package body System.Libm_Double.Squareroot is function Rsqrt (X : Long_Float) return Long_Float; -- Compute the reciprocal square root. There are two reasons for computing -- the reciprocal square root instead of computing directly the square -- root: PowerPc provides an instruction (fsqrte) to compute an estimate of -- the reciprocal (with 5 bits of precision), and the Newton-Raphson method -- is more efficient on the reciprocal than on the direct root (because the -- direct root needs divisions, while the reciprocal does not). Note that -- PowerPc core e300 doesn't support the direct square root operation. ----------- -- Rsqrt -- ----------- function Rsqrt (X : Long_Float) return Long_Float is X_Half : constant Long_Float := X * 0.5; Y, Y1 : Long_Float; begin if Standard'Target_Name = "powerpc-elf" then -- On powerpc, the precision of fsqrte is at least 5 binary digits System.Machine_Code.Asm ("frsqrte %0,%1", Outputs => Long_Float'Asm_Output ("=f", Y), Inputs => Long_Float'Asm_Input ("f", X)); else -- Provide the exact result for 1.0 if X = 1.0 then return X; end if; -- Use the method described in Fast Inverse Square Root article by -- Chris Lomont (http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf), -- although the code was known before that article. declare type Unsigned_Long is mod 2**64; function To_Unsigned_Long is new Ada.Unchecked_Conversion (Long_Float, Unsigned_Long); function From_Unsigned_Long is new Ada.Unchecked_Conversion (Unsigned_Long, Long_Float); U : Unsigned_Long; begin U := To_Unsigned_Long (X); U := 16#5fe6ec85_e7de30da# - (U / 2); Y := From_Unsigned_Long (U); -- Precision is about 4 digits end; end if; -- Newton iterations: X <- X - F(X)/F'(X) -- Here F(X) = 1/X^2 - A, so F'(X) = -2/X^3 -- So: X <- X - (1/X^2 - A) / (-2/X^3) -- <- X + .5(X - A*X^3) -- <- X + .5*X*(1 - A*X^2) -- <- X (1 + .5 - .5*A*X^2) -- <- X(1.5 - .5*A*X^2) -- Precision is doubled at each iteration. -- Refine: 10 digits (PowerPc) or 8 digits (fast method) Y := Y * (1.5 - X_Half * Y * Y); -- Refine: 20 digits (PowerPc) or 16 digits (fast method) Y := Y * (1.5 - X_Half * Y * Y); -- Refine: 40 digits (PowerPc) or 32 digits (fast method) Y := Y * (1.5 - X_Half * Y * Y); -- Refine (beyond the precision of Long_Float) Y1 := Y * (1.5 - X_Half * Y * Y); if Y = Y1 then return Y1; else Y := Y1; end if; -- Empirical tests show the above iterations are inadequate in some -- cases and that two more iterations are needed to converge. Other -- algorithms may need to be explored. ??? Y1 := Y * (1.5 - X_Half * Y * Y); if Y = Y1 then return Y1; else Y := Y1; end if; Y := Y * (1.5 - X_Half * Y * Y); -- This algorithm doesn't always provide exact results. For example, -- Sqrt (25.0) /= 5.0 exactly (it's wrong in the last bit). return Y; end Rsqrt; ---------- -- Sqrt -- ---------- function Sqrt (X : Long_Float) return Long_Float is begin if X <= 0.0 then if X = 0.0 then return X; else return NaN; end if; elsif not Long_Float'Machine_Overflows and then X = Infinity then -- Note that if Machine_Overflow is True Infinity won't return. -- But in that case, we can assume that X is not infinity. return X; else return X * Rsqrt (X); end if; end Sqrt; end System.Libm_Double.Squareroot;
with Ada.Numerics; with Ada.Numerics.Generic_Elementary_Functions; with Hypot; with text_io; use text_io; -- Test estimates err in calculation of Sqrt(a^2 + b^2), a/Sqrt(a^2 + b^2), etc. -- -- Best accuracy uses -mfpmath=387 ! Runs about the same speed at -mfpmath=387 and -- -mfpmath=sse. procedure hypot_tst_1 is type Real is digits 15; package Hypotenuse is new Hypot (Real); --use Hypotenuse; type e is digits 18; package Hypotenuse_e is new Hypot (e); package mathr is new Ada.Numerics.Generic_Elementary_Functions (Real); use mathr; procedure Get_Hypotenuse_e (a, b : in e; Hypot : out e; sn_e, cn_m_1_e : out e) renames Hypotenuse_e.Get_Hypotenuse; procedure Get_Hypotenuse_r (a, b : in Real; Hypot_er : out e; sn_er : out e; cn_m_1_er : out e) is Hypot, cs_m_1, sn : Real; begin Hypotenuse.Get_Hypotenuse (a, b, Hypot, sn, cs_m_1); Hypot_er := e (Hypot); sn_er := e (sn); cn_m_1_er := e (cs_m_1); end Get_Hypotenuse_r; Zero : constant Real := +0.0; Two : constant Real := +2.0; Min_Real : constant e := e (Two ** (Real'Machine_Emin + 2)); a, b, hypot_0, sn_0, cn_m_1 : Real := Zero; Max_Err_0, Err_0, Max_Err_1, Err_1 : Real := Zero; Max_Err_2, Err_2, Max_Err_3, Err_3 : Real := Zero; Max_Err_4, Err_4, Max_Err_5, Err_5 : Real := Zero; Ave_Err_0, Ave_Err_1, Ave_Err_2, Ave_Err_3, Ave_Err_4, Ave_Err_5 : Real := Zero; sn_e, Hypot_e, cn_m_1_e : e; sn_er, Hypot_er, cn_m_1_er : e; Epsilon : constant Real := 1.00012345e-9 * 2.0; type int_64 is range 0 .. 2**63-1; No_Of_Bins : constant int_64 := 1024; No_Of_Test_Vectors : constant int_64 := 2 * 10**8 / 4; begin declare hypot_1, x_1, y_1 : Real := Zero; begin Hypotenuse.Get_Hypotenuse (0.0, 0.0, Hypot_1, x_1, y_1); put (Real'Image (Hypot_1)); Hypotenuse.Get_Hypotenuse (1.0E-307, 1.0E-307, Hypot_1, x_1, y_1); put (Real'Image (Hypot_1)); Hypotenuse.Get_Hypotenuse (1.0E-307, 1.0E+307, Hypot_1, x_1, y_1); put (Real'Image (Hypot_1)); Hypotenuse.Get_Hypotenuse (1.0E-306, 1.0E-300, Hypot_1, x_1, y_1); put (Real'Image (Hypot_1)); end; b := 0.000000000001 + 0.0; a := 0.881111111111; for j in 1 .. No_Of_Bins loop Max_Err_0 := Zero; Max_Err_1 := Zero; Max_Err_2 := Zero; Max_Err_3 := Zero; Max_Err_4 := Zero; Max_Err_5 := Zero; Ave_Err_0 := Zero; Ave_Err_1 := Zero; Ave_Err_2 := Zero; Ave_Err_3 := Zero; Ave_Err_4 := Zero; Ave_Err_5 := Zero; for i in int_64 range 1 .. No_Of_Test_Vectors loop Get_Hypotenuse_e (e(a), e(b), Hypot_e, sn_e, cn_m_1_e); -- uncorrected hypot: hypot_0 := Sqrt (a**2 + b**2); --hypot_e := Sqrt (e(a)**2 + e(b)**2); Err_0 := Real (Abs(e(Hypot_0) - Hypot_e) + Min_Real) / (Abs(Hypot_0) + 1.0e22 * Real(Min_Real)); if Err_0 > Max_Err_0 then Max_Err_0 := Err_0; end if; Ave_Err_0 := Ave_Err_0 + Err_0; -- Hypot_er is slightly corrected by Get_Hypotenuse_r: Get_Hypotenuse_r (a, b, Hypot_er, sn_er, cn_m_1_er); -- test func Hypotenuse(a,b) -- declare -- hypot_1, tst_1, x_1, y_1 : Real := Zero; -- begin -- Hypotenuse.Get_Hypotenuse -- (a, b, Hypot_1, x_1, y_1); -- tst_1 := Hypotenuse.Hypotenuse (a, b); -- --if Abs (tst_1 - Hypot_1) > 6.0E-17 then -- if Abs (tst_1 - Hypot_1) > 0.0 then -- put(real'image(tst_1 - Hypot_1)); -- end if; -- end; Err_1 := Real (Abs(Hypot_er - Hypot_e) + Min_Real) / (Abs(Hypot_0) + 1.0e22 * Real(Min_Real)); if Err_1 > Max_Err_1 then Max_Err_1 := Err_1; end if; Ave_Err_1 := Ave_Err_1 + Err_1; -- uncorrected sn: sn_0 := Real'Min(a, b) / (hypot_0 + 2.0 * Real (Min_Real)); Err_2 := Real (Abs(e(sn_0) - sn_e) + Min_Real) / Real (Abs(sn_e) + 1.0e22 * Min_Real); if Err_2 > Max_Err_2 then Max_Err_2 := Err_2; end if; Ave_Err_2 := Ave_Err_2 + Err_2; -- sn_er is slightly corrected by Get_Hypotenuse_r: Err_3 := Real (Abs(sn_er - sn_e) + Min_Real) / Real (Abs(sn_e) + 1.0e22 * Min_Real); if Err_3 > Max_Err_3 then Max_Err_3 := Err_3; end if; Ave_Err_3 := Ave_Err_3 + Err_3; -- uncorrected cn_m_1: cn_m_1 := - Real'Min(a, b)**2 / (hypot_0*(Real'Max(a, b) + hypot_0)); Err_4 := Real (Abs(e(cn_m_1) - cn_m_1_e) + Min_Real) / Real (Abs(cn_m_1_e) + 1.0e22 * Min_Real); if Err_4 > Max_Err_4 then Max_Err_4 := Err_4; end if; Ave_Err_4 := Ave_Err_4 + Err_4; -- cn_m_1_er is slightly corrected by Get_Hypotenuse_r: Err_5 := Real (Abs(cn_m_1_er - cn_m_1_e) + Min_Real) / Real (Abs(cn_m_1_e) + 1.0e22 * Min_Real); if Err_5 > Max_Err_5 then Max_Err_5 := Err_5; end if; Ave_Err_5 := Ave_Err_5 + Err_5; b := b + Epsilon; end loop; --Epsilon := Epsilon + 2.7777e-10; new_line; put ("b = "); put (Real'Image (b)); new_line(2); put("Max Err in uncorrected hypot: "); put (Real'Image (Max_Err_0)); new_line; put("Max Err in corrected hypot: "); put (Real'Image (Max_Err_1)); new_line(2); put("Max Err in uncorrected sin: "); put (Real'Image (Max_Err_2)); new_line; put("Max Err in sin: "); put (Real'Image (Max_Err_3)); new_line(2); put("Max Err in uncorrected cos-1: "); put (Real'Image (Max_Err_4)); new_line; put("Max Err in cos-1: "); put (Real'Image (Max_Err_5)); new_line(2); new_line; put("Average Err in uncorrected hypot: "); put (Real'Image (Ave_Err_0 / Real (No_Of_Test_Vectors))); new_line; put("Average Err in corrected hypot: "); put (Real'Image (Ave_Err_1 / Real (No_Of_Test_Vectors))); new_line(2); put("Average Err in uncorrected sin: "); put (Real'Image (Ave_Err_2 / Real (No_Of_Test_Vectors))); new_line; put("Average Err in sin: "); put (Real'Image (Ave_Err_3 / Real (No_Of_Test_Vectors))); new_line(2); put("Average Err in uncorrected cos-1: "); put (Real'Image (Ave_Err_4 / Real (No_Of_Test_Vectors))); new_line; put("Average Err in cos-1: "); put (Real'Image (Ave_Err_5 / Real (No_Of_Test_Vectors))); new_line(2); end loop; end hypot_tst_1;
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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 file provides Nested Vector interrupt Controller definitions for the -- STM32F4 (ARM Cortex M4F) microcontrollers from ST Microelectronics. with System; with Ada.Interrupts; use Ada.Interrupts; package STM32F4.NVIC is -- the Nested Vectored Interrupt Controller -- 0 bits for pre-emption priority; 4 bits for subpriority Priority_Group_0 : constant Word := 16#00000007#; -- 1 bits for pre-emption priority; 3 bits for subpriority Priority_Group_1 : constant Word := 16#00000006#; -- 2 bits for pre-emption priority; 2 bits for subpriority Priority_Group_2 : constant Word := 16#00000005#; -- 3 bits for pre-emption priority; 1 bits for subpriority Priority_Group_3 : constant Word := 16#00000004#; -- 4 bits for pre-emption priority; 0 bits for subpriority Priority_Group_4 : constant Word := 16#00000003#; procedure Set_Priority_Grouping (Priority_Group : Word) with Inline; function Priority_Grouping return Word with Inline; procedure Set_Priority (IRQn : Interrupt_Id; Priority : Word) with Inline; function Encoded_Priority (Priority_Group : Word; Preempt_Priority : Word; Subpriority : Word) return Word with Inline; procedure Set_Priority (IRQn : Interrupt_Id; Preempt_Priority : Word; Subpriority : Word) with Inline; -- A convenience routine that first encodes (Priority_Grouping(), -- Preempt_Priority, and Subpriority), and then calls the other -- Set_Priority with the resulting encoding for the Priority argument. procedure Enable_Interrupt (IRQn : Interrupt_Id) with Inline; procedure Disable_Interrupt (IRQn : Interrupt_Id) with Inline; function Active (IRQn : Interrupt_Id) return Boolean with Inline; function Pending (IRQn : Interrupt_Id) return Boolean with Inline; procedure Set_Pending (IRQn : Interrupt_Id) with Inline; procedure Clear_Pending (IRQn : Interrupt_Id) with Inline; procedure Reset_System; private type Words is array (Natural range <>) of Word; type Bytes is array (Natural range <>) of Byte; type Nested_Vectored_Interrupt_Controller is record ISER : Words (0 .. 7); -- Interrupt Set Enable Register Reserved0 : Words (0 .. 23); ICER : Words (0 .. 7); -- Interrupt Clear Enable Register Reserved1 : Words (0 .. 23); ISPR : Words (0 .. 7); -- Interrupt Set Pending Register Reserved2 : Words (0 .. 23); ICPR : Words (0 .. 7); -- Interrupt Clear Pending Register Reserved3 : Words (0 .. 23); IABR : Words (0 .. 7); -- Interrupt Active Bit Register Reserved4 : Words (0 .. 55); IP : Bytes (0 .. 239); -- Interrupt Priority Register Reserved5 : Words (0 .. 643); STIR : Word; -- Software Trigger Interrupt Register (write-only) end record with Volatile; for Nested_Vectored_Interrupt_Controller use record ISER at 0 range 0 .. 255; -- 32 bytes Reserved0 at 32 range 0 .. 767; -- 96 bytes ICER at 128 range 0 .. 255; -- 32 bytes Reserved1 at 160 range 0 .. 767; -- 96 bytes ISPR at 256 range 0 .. 255; -- 32 bytes Reserved2 at 288 range 0 .. 767; -- 96 bytes ICPR at 384 range 0 .. 255; -- 32 bytes Reserved3 at 416 range 0 .. 767; -- 96 bytes IABR at 512 range 0 .. 255; -- 32 bytes Reserved4 at 544 range 0 .. 1791; -- 220 bytes IP at 768 range 0 .. 1919; -- 240 bytes Reserved5 at 1008 range 0 .. 20607; -- 2576 bytes STIR at 3584 range 0 .. 31; -- 4 bytes end record; type System_Control_Block is record CPUID : Word; -- CPUID Base Register (read-only) ICSR : Word; -- Interrupt Control and State Register VTOR : Word; -- Vector Table Offset Register AIRCR : Word; -- Application Interrupt and Reset Control Register SCR : Word; -- System Control Register CCR : Word; -- Configuration Control Register SHP : Bytes (0 .. 11); -- System Handlers Priority Registers (4-7, 8-11, 12-15) SHCSR : Word; -- System Handler Control and State Register CFSR : Word; -- Configurable Fault Status Register HFSR : Word; -- HardFault Status Register DFSR : Word; -- Debug Fault Status Register MMFAR : Word; -- MemManage Fault Address Register BFAR : Word; -- BusFault Address Register AFSR : Word; -- Auxiliary Fault Status Register PFR : Words (0 .. 1); -- Processor Feature Register (read-only) DFR : Word; -- Debug Feature Register (read-only) ADR : Word; -- Auxiliary Feature Register (read-only) MMFR : Words (0 .. 3); -- Memory Model Feature Register (read-only) ISAR : Words (0 .. 4); -- Instruction Set Attributes Register (read-only) RESERVED0 : Words (0 .. 4); CPACR : Word; -- Coprocessor Access Control Register end record with Volatile; for System_Control_Block use record CPUID at 0 range 0 .. 31; -- Offset: 0x000 ICSR at 4 range 0 .. 31; -- Offset: 0x004 VTOR at 8 range 0 .. 31; -- Offset: 0x008 AIRCR at 12 range 0 .. 31; -- Offset: 0x00C SCR at 16 range 0 .. 31; -- Offset: 0x010 CCR at 20 range 0 .. 31; -- Offset: 0x014 SHP at 24 range 0 .. 95; -- Offset: 0x018 SHCSR at 36 range 0 .. 31; -- Offset: 0x024 CFSR at 40 range 0 .. 31; -- Offset: 0x028 HFSR at 44 range 0 .. 31; -- Offset: 0x02C DFSR at 48 range 0 .. 31; -- Offset: 0x030 MMFAR at 52 range 0 .. 31; -- Offset: 0x034 BFAR at 56 range 0 .. 31; -- Offset: 0x038 AFSR at 60 range 0 .. 31; -- Offset: 0x03C PFR at 64 range 0 .. 63; -- Offset: 0x040 DFR at 72 range 0 .. 31; -- Offset: 0x048 ADR at 76 range 0 .. 31; -- Offset: 0x04C MMFR at 80 range 0 .. 127; -- Offset: 0x050 ISAR at 96 range 0 .. 159; -- Offset: 0x060 RESERVED0 at 116 range 0 .. 159; CPACR at 136 range 0 .. 31; -- Offset: 0x088 end record; SCS_Base : constant := 16#E000_E000#; -- system control space base address NVIC_Base : constant := SCS_BASE + 16#0100#; SCB_Base : constant := SCS_BASE + 16#0D00#; -- System Control Block base address SCB : System_Control_Block with Volatile, Address => System'To_Address (SCB_Base); pragma Import (Ada, SCB); NVIC : Nested_Vectored_Interrupt_Controller with Volatile, Address => System'To_Address (NVIC_Base); pragma Import (Ada, NVIC); SCB_AIRCR_PRIGROUP_Pos : constant := 8; SCB_AIRCR_PRIGROUP_Mask : constant Word := Shift_Left (7, SCB_AIRCR_PRIGROUP_Pos); SCB_AIRCR_VECTKEY_Pos : constant := 16; SCB_AIRCR_VECTKEY_Mask : constant Word := Shift_Left (16#FFFF#, SCB_AIRCR_VECTKEY_Pos); SCB_AIRCR_SYSRESETREQ_Pos : constant := 2; SCB_AIRCR_SYSRESETREQ_Mask : constant Word := Shift_Left (1, SCB_AIRCR_SYSRESETREQ_Pos); NVIC_PRIO_BITS : constant := 4; -- STM32F4XX uses 4 bits for the priority levels end STM32F4.NVIC;
----------------------------------------------------------------------- -- Ada Labs -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- Labs is free software; you can redistribute it and/or modify it -- -- under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or -- -- (at your option) any later version. -- -- -- -- This program is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have received -- -- a copy of the GNU General Public License along with this program; -- -- if not, write to the Free Software Foundation, Inc., 59 Temple -- -- Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------- package Display is type Color_Component_T is mod 2**8; type RGBA_T is record R : Color_Component_T; G : Color_Component_T; B : Color_Component_T; A : Color_Component_T; end record with Pack, Size => 32; Transparent : RGBA_T := (R => 0, G => 0, B => 0, A => 0); Black : RGBA_T := (R => 0, G => 0, B => 0, A => 255); White : RGBA_T := (R => 255, G => 255, B => 255, A => 255); Blue : RGBA_T := (R => 0, G => 0, B => 255, A => 255); Green : RGBA_T := (R => 0, G => 255, B => 0, A => 255); Red : RGBA_T := (R => 255, G => 0, B => 0, A => 255); Cyan : RGBA_T := (R => 0, G => 255, B => 255, A => 255); Magenta : RGBA_T := (R => 255, G => 0, B => 255, A => 255); Yellow : RGBA_T := (R => 255, G => 255, B => 0, A => 255); Gray : RGBA_T := (R => 128, G => 128, B => 128, A => 255); Display_Error : exception; type Button_Type is (Left, Right); type Mouse_Position is record X, Y : Float; Button : Button_Type; end record; No_Mouse_Position : constant Mouse_Position := (-10_000.0, -10_000.0, Right); end Display;
pragma License (Unrestricted); -- generalized unit of Ada.Strings.UTF_Encoding.Strings generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; Expanding_From_8 : Positive; Expanding_From_16 : Positive; Expanding_From_32 : Positive; Expanding_To_8 : Positive; Expanding_To_16 : Positive; Expanding_To_32 : Positive; with procedure Get ( Item : String_Type; Last : out Natural; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean); with procedure Put ( Value : Wide_Wide_Character; Item : out String_Type; Last : out Natural); package Ada.Strings.UTF_Encoding.Generic_Strings is pragma Pure; -- Encoding / decoding between String_Type and various encoding schemes function Encode ( Item : String_Type; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String; function Encode (Item : String_Type; Output_BOM : Boolean := False) return UTF_8_String; function Encode (Item : String_Type; Output_BOM : Boolean := False) return UTF_16_Wide_String; -- extended function Encode (Item : String_Type; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String; function Decode (Item : UTF_String; Input_Scheme : Encoding_Scheme) return String_Type; function Decode (Item : UTF_8_String) return String_Type; function Decode (Item : UTF_16_Wide_String) return String_Type; -- extended function Decode (Item : UTF_32_Wide_Wide_String) return String_Type; end Ada.Strings.UTF_Encoding.Generic_Strings;
generic package any_Math.any_Arithmetic is pragma Pure; pragma Optimize (Time); end any_Math.any_Arithmetic;
with Device; with Memory.Split; use Memory.Split; with Memory.Join; use Memory.Join; with Memory.Transform; use Memory.Transform; package body Memory.Register is -- Locate the position at which to insert a register and insert it. function Insert_Register(mem : Memory_Pointer) return Boolean is max_path : constant Natural := Device.Get_Max_Path; begin if Get_Path_Length(mem.all) <= max_path then return False; end if; if mem.all in Split_Type'Class then declare sp : constant Split_Pointer := Split_Pointer(mem); np : constant Memory_Pointer := Get_Memory(sp.all); b0 : constant Memory_Pointer := Get_Bank(sp.all, 0); b1 : constant Memory_Pointer := Get_Bank(sp.all, 1); begin if Insert_Register(np) then return True; end if; if Insert_Register(b0) then return True; end if; if Insert_Register(b1) then return True; end if; -- Insert two registers: one for each bank. Set_Bank(sp.all, 0, Create_Register(b0)); Set_Bank(sp.all, 1, Create_Register(b1)); return True; end; elsif mem.all in Join_Type'Class then return False; elsif mem.all in Transform_Type'Class then declare tp : constant Transform_Pointer := Transform_Pointer(mem); np : constant Memory_Pointer := Get_Memory(tp.all); bp : constant Memory_Pointer := Get_Bank(tp.all); begin if Insert_Register(np) then return True; end if; if bp /= null and then Insert_Register(bp) then return True; end if; if bp /= null then Set_Bank(tp.all, Create_Register(bp)); else Set_Memory(tp.all, Create_Register(np)); end if; return True; end; else declare cp : constant Container_Pointer := Container_Pointer(mem); np : constant Memory_Pointer := Get_Memory(cp.all); begin if Insert_Register(np) then return True; end if; Set_Memory(cp.all, Create_Register(np)); return True; end; end if; end Insert_Register; procedure Insert_Registers(mem : access Memory_Type'Class) is begin -- Continue inserting registers until we either no longer exceed -- the max path length or we are unable to reduce the path length. loop exit when not Insert_Register(Memory_Pointer(mem)); end loop; end Insert_Registers; function Remove_Registers(mem : Memory_Pointer) return Memory_Pointer is begin if mem = null then return null; elsif mem.all in Register_Type'Class then declare rp : Register_Pointer := Register_Pointer(mem); np : constant Memory_Pointer := Get_Memory(rp.all); begin Set_Memory(rp.all, null); Destroy(Memory_Pointer(rp)); return Remove_Registers(np); end; elsif mem.all in Split_Type'Class then declare sp : constant Split_Pointer := Split_Pointer(mem); b0 : constant Memory_Pointer := Get_Bank(sp.all, 0); b1 : constant Memory_Pointer := Get_Bank(sp.all, 1); np : constant Memory_Pointer := Get_Memory(sp.all); begin Set_Bank(sp.all, 0, Remove_Registers(b0)); Set_Bank(sp.all, 1, Remove_Registers(b1)); Set_Memory(sp.all, Remove_Registers(np)); return mem; end; elsif mem.all in Transform_Type'Class then declare tp : constant Transform_Pointer := Transform_Pointer(mem); bp : constant Memory_Pointer := Get_Bank(tp.all); np : constant Memory_Pointer := Get_Memory(tp.all); begin Set_Bank(tp.all, Remove_Registers(bp)); Set_Memory(tp.all, Remove_Registers(np)); return mem; end; elsif mem.all in Container_Type'Class then declare cp : constant Container_Pointer := Container_Pointer(mem); np : constant Memory_Pointer := Get_Memory(cp.all); begin Set_Memory(cp.all, Remove_Registers(np)); return mem; end; else return mem; end if; end Remove_Registers; function Create_Register(mem : access Memory_Type'Class) return Register_Pointer is result : constant Register_Pointer := new Register_Type; begin Set_Memory(result.all, mem); return result; end Create_Register; function Clone(mem : Register_Type) return Memory_Pointer is begin return new Register_Type'(mem); end Clone; procedure Permute(mem : in out Register_Type; generator : in Distribution_Type; max_cost : in Cost_Type) is begin null; end Permute; procedure Read(mem : in out Register_Type; address : in Address_Type; size : in Positive) is begin Advance(mem, 1); Read(Container_Type(mem), address, size); end Read; procedure Write(mem : in out Register_Type; address : in Address_Type; size : in Positive) is begin Advance(mem, 1); Write(Container_Type(mem), address, size); end Write; function Get_Path_Length(mem : Register_Type) return Natural is begin return 0; end Get_Path_Length; function To_String(mem : Register_Type) return Unbounded_String is result : Unbounded_String; begin Append(result, "(register "); Append(result, "(memory "); Append(result, To_String(Container_Type(mem))); Append(result, ")"); Append(result, ")"); return result; end To_String; procedure Generate(mem : in Register_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is other : constant Memory_Pointer := Get_Memory(mem); wbits : constant Natural := 8 * Get_Word_Size(mem); name : constant String := "m" & To_String(Get_ID(mem)); oname : constant String := "m" & To_String(Get_ID(other.all)); begin Generate(other.all, sigs, code); Declare_Signals(sigs, name, wbits); Line(code, name & "_inst : entity work.reg"); Line(code, " generic map ("); Line(code, " ADDR_WIDTH => ADDR_WIDTH,"); Line(code, " WORD_WIDTH => " & To_String(wbits)); Line(code, " )"); Line(code, " port map ("); Line(code, " clk => clk,"); Line(code, " rst => rst,"); Line(code, " addr => " & name & "_addr,"); Line(code, " din => " & name & "_din,"); Line(code, " dout => " & name & "_dout,"); Line(code, " re => " & name & "_re,"); Line(code, " we => " & name & "_we,"); Line(code, " mask => " & name & "_mask,"); Line(code, " ready => " & name & "_ready,"); Line(code, " maddr => " & oname & "_addr,"); Line(code, " min => " & oname & "_dout,"); Line(code, " mout => " & oname & "_din,"); Line(code, " mre => " & oname & "_re,"); Line(code, " mwe => " & oname & "_we,"); Line(code, " mmask => " & oname & "_mask,"); Line(code, " mready => " & oname & "_ready"); Line(code, " );"); end Generate; end Memory.Register;
-- -- Copyright (C) 2022 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- with Server; with App; procedure Hello is S : Server.Socket_Server; begin S.On_Connect := App.On_Connect'Access; S.On_Readable := App.On_Readable'Access; S.On_Writable := App.On_Writable'Access; Server.Bind (S, "", "8000"); loop Server.Poll (S); end loop; exception when others => Server.Destroy (S); end Hello;
function Hide.Value (Data : String ) return Integer is Map : constant array (Character'('0') .. Character'('9')) of Integer := (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); begin return Ret : Integer := 0 do for Cursor in Data'Range loop Ret := Ret + Map (Data (Cursor)); if Cursor /= Data'Last then Ret := Ret * 10; end if; end loop; end return; end;
with System.Storage_Elements; package body System.Packed_Arrays is pragma Suppress (All_Checks); package body Ordering is function memcmp (s1, s2 : Address; n : Storage_Elements.Storage_Count) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_memcmp"; -- implementation function Compare ( Left : Address; Right : Address; Left_Len : Natural; Right_Len : Natural) return Integer is begin if Element_Type'Size = Standard'Storage_Unit and then Element_Type'Enum_Rep (Element_Type'First) = 0 then declare Result : constant Integer := memcmp ( Left, Right, Storage_Elements.Storage_Offset ( Integer'Min (Left_Len, Right_Len))); begin if Result /= 0 then return Result; end if; end; else declare pragma Compile_Time_Error ( Element_Type'Alignment /= 1, "misaligned"); Min_Length : constant Integer := Integer'Min (Left_Len, Right_Len); type Min_Array_Type is array (1 .. Min_Length) of Element_Type; pragma Pack (Min_Array_Type); pragma Suppress_Initialization (Min_Array_Type); Left_All : Min_Array_Type; for Left_All'Address use Left; Right_All : Min_Array_Type; for Right_All'Address use Right; begin for I in 1 .. Min_Length loop if Left_All (I) < Right_All (I) then return -1; elsif Left_All (I) > Right_All (I) then return 1; end if; end loop; end; end if; if Left_Len < Right_Len then return -1; elsif Left_Len > Right_Len then return 1; else return 0; end if; end Compare; end Ordering; package body Indexing is subtype Rem_8 is Natural range 0 .. 7; type Record_8_Units is record E0, E1, E2, E3, E4, E5, E6, E7 : Element_Type; end record; for Record_8_Units'Alignment use 1; pragma Pack (Record_8_Units); pragma Suppress_Initialization (Record_8_Units); function Get (Arr : Address; N : Natural) return Element_Type; pragma Machine_Attribute (Get, "pure"); function Get (Arr : Address; N : Natural) return Element_Type is Units : Record_8_Units; for Units'Address use Arr + Address (N / 8 * (Record_8_Units'Size / Standard'Storage_Unit)); begin case Rem_8 (N rem 8) is when 0 => return Units.E0; when 1 => return Units.E1; when 2 => return Units.E2; when 3 => return Units.E3; when 4 => return Units.E4; when 5 => return Units.E5; when 6 => return Units.E6; when 7 => return Units.E7; end case; end Get; procedure Set (Arr : Address; N : Natural; E : Element_Type); procedure Set (Arr : Address; N : Natural; E : Element_Type) is Units : Record_8_Units; for Units'Address use Arr + Address (N / 8 * (Record_8_Units'Size / Standard'Storage_Unit)); begin case Rem_8 (N rem 8) is when 0 => Units.E0 := E; when 1 => Units.E1 := E; when 2 => Units.E2 := E; when 3 => Units.E3 := E; when 4 => Units.E4 := E; when 5 => Units.E5 := E; when 6 => Units.E6 := E; when 7 => Units.E7 := E; end case; end Set; Reversed_Bit_Order : constant := 1 - Standard'Default_Bit_Order; type Reversed_Record_8_Units is new Record_8_Units; for Reversed_Record_8_Units'Bit_Order use Bit_Order'Val (Reversed_Bit_Order); for Reversed_Record_8_Units'Scalar_Storage_Order use Bit_Order'Val (Reversed_Bit_Order); pragma Suppress_Initialization (Reversed_Record_8_Units); function Get_Reversed (Arr : Address; N : Natural) return Element_Type; pragma Machine_Attribute (Get_Reversed, "pure"); function Get_Reversed (Arr : Address; N : Natural) return Element_Type is Units : Reversed_Record_8_Units; for Units'Address use Arr + Address (N / 8 * (Record_8_Units'Size / Standard'Storage_Unit)); begin case Rem_8 (N rem 8) is when 0 => return Units.E0; when 1 => return Units.E1; when 2 => return Units.E2; when 3 => return Units.E3; when 4 => return Units.E4; when 5 => return Units.E5; when 6 => return Units.E6; when 7 => return Units.E7; end case; end Get_Reversed; procedure Set_Reversed (Arr : Address; N : Natural; E : Element_Type); procedure Set_Reversed (Arr : Address; N : Natural; E : Element_Type) is Units : Reversed_Record_8_Units; for Units'Address use Arr + Address (N / 8 * (Record_8_Units'Size / Standard'Storage_Unit)); begin case Rem_8 (N rem 8) is when 0 => Units.E0 := E; when 1 => Units.E1 := E; when 2 => Units.E2 := E; when 3 => Units.E3 := E; when 4 => Units.E4 := E; when 5 => Units.E5 := E; when 6 => Units.E6 := E; when 7 => Units.E7 := E; end case; end Set_Reversed; -- implementation function Get ( Arr : Address; N : Natural; Rev_SSO : Boolean) return Element_Type is begin if Rev_SSO then return Get_Reversed (Arr, N); else return Get (Arr, N); end if; end Get; procedure Set ( Arr : Address; N : Natural; E : Element_Type; Rev_SSO : Boolean) is begin if Rev_SSO then Set_Reversed (Arr, N, E); else Set (Arr, N, E); end if; end Set; end Indexing; end System.Packed_Arrays;
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- 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. -- * The name of the copyright holder may not 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 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 Keccak.Generic_Duplex is ------------ -- Init -- ------------ procedure Init (Ctx : out Context; Capacity : in Positive) is begin Init_State (Ctx.State); Ctx.Rate := State_Size_Bits - Capacity; end Init; -------------- -- Duplex -- -------------- procedure Duplex (Ctx : in out Context; In_Data : in Keccak.Types.Byte_Array; In_Data_Bit_Length : in Natural; Out_Data : out Keccak.Types.Byte_Array; Out_Data_Bit_Length : in Natural) is use type Keccak.Types.Byte; Block : Keccak.Types.Byte_Array (0 .. (State_Size_Bits + 7) / 8 - 1) := (others => 0); Num_Bytes : constant Natural := (In_Data_Bit_Length + 7) / 8; begin if Num_Bytes > 0 then Block (0 .. Num_Bytes - 1) := In_Data (In_Data'First .. In_Data'First + (Num_Bytes - 1)); end if; Pad (Block (0 .. ((Rate_Of (Ctx) + 7) / 8) - 1), In_Data_Bit_Length, Rate_Of (Ctx)); XOR_Bits_Into_State (Ctx.State, Block (0 .. ((Ctx.Rate + 7) / 8) - 1), Rate_Of (Ctx)); Permute (Ctx.State); Extract_Bits (Ctx.State, Out_Data, Out_Data_Bit_Length); end Duplex; -------------------- -- Duplex_Blank -- -------------------- procedure Duplex_Blank (Ctx : in out Context; Out_Data : out Keccak.Types.Byte_Array; Out_Data_Bit_Length : in Natural) is use type Keccak.Types.Byte; Block : Keccak.Types.Byte_Array (0 .. (State_Size_Bits + 7) / 8 - 1) := (others => 0); begin Pad (Block (0 .. ((Rate_Of (Ctx) + 7) / 8) - 1), 0, Rate_Of (Ctx)); XOR_Bits_Into_State (Ctx.State, Block (0 .. ((Ctx.Rate + 7) / 8) - 1), Rate_Of (Ctx)); Permute (Ctx.State); Extract_Bits (Ctx.State, Out_Data, Out_Data_Bit_Length); end Duplex_Blank; ------------------- -- Duplex_Mute -- ------------------- procedure Duplex_Mute (Ctx : in out Context; In_Data : in Keccak.Types.Byte_Array; In_Data_Bit_Length : in Natural) is Block : Keccak.Types.Byte_Array (0 .. (State_Size_Bits + 7) / 8 - 1) := (others => 0); Nb_Bytes : constant Natural := (In_Data_Bit_Length + 7) / 8; begin Block (0 .. Nb_Bytes - 1) := In_Data (In_Data'First .. In_Data'First + Nb_Bytes - 1); Pad (Block (0 .. ((Rate_Of (Ctx) + 7) / 8) - 1), In_Data_Bit_Length, Rate_Of (Ctx)); XOR_Bits_Into_State (Ctx.State, Block (0 .. ((Ctx.Rate + 7) / 8) - 1), Rate_Of (Ctx)); Permute (Ctx.State); end Duplex_Mute; end Keccak.Generic_Duplex;
with Ada.Text_IO; package body CLIC_Ex.Commands.Switches_And_Args is ------------- -- Execute -- ------------- overriding procedure Execute (Cmd : in out Instance; Args : AAA.Strings.Vector) is begin Ada.Text_IO.Put_Line (Args.Flatten); end Execute; end CLIC_Ex.Commands.Switches_And_Args;
generic -- child of a generic package must be a generic unit package S_Expr.Parser is function Parse(Input: String) return List_Of_Data; -- the result of a parse process is always a list of expressions end S_Expr.Parser;
----------------------------------------------------------------------- -- awa-jobs-beans -- AWA Jobs Ada Beans -- Copyright (C) 2012, 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Beans.Objects; with Util.Beans.Basic; with Util.Beans.Methods; with AWA.Events; with AWA.Jobs.Services; with AWA.Jobs.Modules; package AWA.Jobs.Beans is -- The <tt>Process_Bean</tt> is the Ada bean that receives the job event and -- performs the job action associated with it. type Process_Bean is limited new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with private; type Process_Bean_Access is access all Process_Bean'Class; -- Get the value identified by the name. overriding function Get_Value (From : in Process_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. overriding procedure Set_Value (From : in out Process_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- This bean provides some methods that can be used in a Method_Expression overriding function Get_Method_Bindings (From : in Process_Bean) return Util.Beans.Methods.Method_Binding_Array_Access; -- Execute the job described by the event. procedure Execute (Bean : in out Process_Bean; Event : in AWA.Events.Module_Event'Class); -- Create the job process bean instance. function Create_Process_Bean (Module : in AWA.Jobs.Modules.Job_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; private type Process_Bean is limited new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record Module : AWA.Jobs.Modules.Job_Module_Access; Job : AWA.Jobs.Services.Job_Ref; end record; end AWA.Jobs.Beans;
-- Generated by gperfhash package Mysql.Perfect_Hash is pragma Preelaborate; function Hash (S : String) return Natural; -- Returns true if the string <b>S</b> is a keyword. function Is_Keyword (S : in String) return Boolean; type Name_Access is access constant String; type Keyword_Array is array (Natural range <>) of Name_Access; Keywords : constant Keyword_Array; private K_0 : aliased constant String := "ACCESSIBLE"; K_1 : aliased constant String := "ADD"; K_2 : aliased constant String := "ALL"; K_3 : aliased constant String := "ALTER"; K_4 : aliased constant String := "ANALYZE"; K_5 : aliased constant String := "AND"; K_6 : aliased constant String := "AS"; K_7 : aliased constant String := "ASC"; K_8 : aliased constant String := "ASENSITIVE"; K_9 : aliased constant String := "BEFORE"; K_10 : aliased constant String := "BETWEEN"; K_11 : aliased constant String := "BIGINT"; K_12 : aliased constant String := "BINARY"; K_13 : aliased constant String := "BLOB"; K_14 : aliased constant String := "BOTH"; K_15 : aliased constant String := "BY"; K_16 : aliased constant String := "CALL"; K_17 : aliased constant String := "CASCADE"; K_18 : aliased constant String := "CASE"; K_19 : aliased constant String := "CHANGE"; K_20 : aliased constant String := "CHAR"; K_21 : aliased constant String := "CHARACTER"; K_22 : aliased constant String := "CHECK"; K_23 : aliased constant String := "COLLATE"; K_24 : aliased constant String := "COLUMN"; K_25 : aliased constant String := "CONDITION"; K_26 : aliased constant String := "CONSTRAINT"; K_27 : aliased constant String := "CONTINUE"; K_28 : aliased constant String := "CONVERT"; K_29 : aliased constant String := "CREATE"; K_30 : aliased constant String := "CROSS"; K_31 : aliased constant String := "CURRENT_DATE"; K_32 : aliased constant String := "CURRENT_TIME"; K_33 : aliased constant String := "CURRENT_TIMESTAMP"; K_34 : aliased constant String := "CURRENT_USER"; K_35 : aliased constant String := "CURSOR"; K_36 : aliased constant String := "DATABASE"; K_37 : aliased constant String := "DATABASES"; K_38 : aliased constant String := "DAY_HOUR"; K_39 : aliased constant String := "DAY_MICROSECOND"; K_40 : aliased constant String := "DAY_MINUTE"; K_41 : aliased constant String := "DAY_SECOND"; K_42 : aliased constant String := "DEC"; K_43 : aliased constant String := "DECIMAL"; K_44 : aliased constant String := "DECLARE"; K_45 : aliased constant String := "DEFAULT"; K_46 : aliased constant String := "DELAYED"; K_47 : aliased constant String := "DELETE"; K_48 : aliased constant String := "DESC"; K_49 : aliased constant String := "DESCRIBE"; K_50 : aliased constant String := "DETERMINISTIC"; K_51 : aliased constant String := "DISTINCT"; K_52 : aliased constant String := "DISTINCTROW"; K_53 : aliased constant String := "DIV"; K_54 : aliased constant String := "DOUBLE"; K_55 : aliased constant String := "DROP"; K_56 : aliased constant String := "DUAL"; K_57 : aliased constant String := "EACH"; K_58 : aliased constant String := "ELSE"; K_59 : aliased constant String := "ELSEIF"; K_60 : aliased constant String := "ENCLOSED"; K_61 : aliased constant String := "ESCAPED"; K_62 : aliased constant String := "EXISTS"; K_63 : aliased constant String := "EXIT"; K_64 : aliased constant String := "EXPLAIN"; K_65 : aliased constant String := "FALSE"; K_66 : aliased constant String := "FETCH"; K_67 : aliased constant String := "FLOAT"; K_68 : aliased constant String := "FLOAT4"; K_69 : aliased constant String := "FLOAT8"; K_70 : aliased constant String := "FOR"; K_71 : aliased constant String := "FORCE"; K_72 : aliased constant String := "FOREIGN"; K_73 : aliased constant String := "FROM"; K_74 : aliased constant String := "FULLTEXT"; K_75 : aliased constant String := "GRANT"; K_76 : aliased constant String := "GROUP"; K_77 : aliased constant String := "HAVING"; K_78 : aliased constant String := "HIGH_PRIORITY"; K_79 : aliased constant String := "HOUR_MICROSECOND"; K_80 : aliased constant String := "HOUR_MINUTE"; K_81 : aliased constant String := "HOUR_SECOND"; K_82 : aliased constant String := "IF"; K_83 : aliased constant String := "IGNORE"; K_84 : aliased constant String := "IN"; K_85 : aliased constant String := "INDEX"; K_86 : aliased constant String := "INFILE"; K_87 : aliased constant String := "INNER"; K_88 : aliased constant String := "INOUT"; K_89 : aliased constant String := "INSENSITIVE"; K_90 : aliased constant String := "INSERT"; K_91 : aliased constant String := "INT"; K_92 : aliased constant String := "INT1"; K_93 : aliased constant String := "INT2"; K_94 : aliased constant String := "INT3"; K_95 : aliased constant String := "INT4"; K_96 : aliased constant String := "INT8"; K_97 : aliased constant String := "INTEGER"; K_98 : aliased constant String := "INTERVAL"; K_99 : aliased constant String := "INTO"; K_100 : aliased constant String := "IS"; K_101 : aliased constant String := "ITERATE"; K_102 : aliased constant String := "JOIN"; K_103 : aliased constant String := "KEY"; K_104 : aliased constant String := "KEYS"; K_105 : aliased constant String := "KILL"; K_106 : aliased constant String := "LEADING"; K_107 : aliased constant String := "LEAVE"; K_108 : aliased constant String := "LEFT"; K_109 : aliased constant String := "LIKE"; K_110 : aliased constant String := "LIMIT"; K_111 : aliased constant String := "LINEAR"; K_112 : aliased constant String := "LINES"; K_113 : aliased constant String := "LOAD"; K_114 : aliased constant String := "LOCALTIME"; K_115 : aliased constant String := "LOCALTIMESTAMP"; K_116 : aliased constant String := "LOCK"; K_117 : aliased constant String := "LONG"; K_118 : aliased constant String := "LONGBLOB"; K_119 : aliased constant String := "LONGTEXT"; K_120 : aliased constant String := "LOOP"; K_121 : aliased constant String := "LOW_PRIORITY"; K_122 : aliased constant String := "MASTER_SSL_VERIFY_SERVER_CERT"; K_123 : aliased constant String := "MATCH"; K_124 : aliased constant String := "MAXVALUE"; K_125 : aliased constant String := "MEDIUMBLOB"; K_126 : aliased constant String := "MEDIUMINT"; K_127 : aliased constant String := "MEDIUMTEXT"; K_128 : aliased constant String := "MIDDLEINT"; K_129 : aliased constant String := "MINUTE_MICROSECOND"; K_130 : aliased constant String := "MINUTE_SECOND"; K_131 : aliased constant String := "MOD"; K_132 : aliased constant String := "MODIFIES"; K_133 : aliased constant String := "NATURAL"; K_134 : aliased constant String := "NOT"; K_135 : aliased constant String := "NO_WRITE_TO_BINLOG"; K_136 : aliased constant String := "NULL"; K_137 : aliased constant String := "NUMERIC"; K_138 : aliased constant String := "ON"; K_139 : aliased constant String := "OPTIMIZE"; K_140 : aliased constant String := "OPTION"; K_141 : aliased constant String := "OPTIONALLY"; K_142 : aliased constant String := "OR"; K_143 : aliased constant String := "ORDER"; K_144 : aliased constant String := "OUT"; K_145 : aliased constant String := "OUTER"; K_146 : aliased constant String := "OUTFILE"; K_147 : aliased constant String := "PRECISION"; K_148 : aliased constant String := "PRIMARY"; K_149 : aliased constant String := "PROCEDURE"; K_150 : aliased constant String := "PURGE"; K_151 : aliased constant String := "RANGE"; K_152 : aliased constant String := "READ"; K_153 : aliased constant String := "READS"; K_154 : aliased constant String := "READ_WRITE"; K_155 : aliased constant String := "REAL"; K_156 : aliased constant String := "REFERENCES"; K_157 : aliased constant String := "REGEXP"; K_158 : aliased constant String := "RELEASE"; K_159 : aliased constant String := "RENAME"; K_160 : aliased constant String := "REPEAT"; K_161 : aliased constant String := "REPLACE"; K_162 : aliased constant String := "REQUIRE"; K_163 : aliased constant String := "RESIGNAL"; K_164 : aliased constant String := "RESTRICT"; K_165 : aliased constant String := "RETURN"; K_166 : aliased constant String := "REVOKE"; K_167 : aliased constant String := "RIGHT"; K_168 : aliased constant String := "RLIKE"; K_169 : aliased constant String := "SCHEMA"; K_170 : aliased constant String := "SCHEMAS"; K_171 : aliased constant String := "SECOND_MICROSECOND"; K_172 : aliased constant String := "SELECT"; K_173 : aliased constant String := "SENSITIVE"; K_174 : aliased constant String := "SEPARATOR"; K_175 : aliased constant String := "SET"; K_176 : aliased constant String := "SHOW"; K_177 : aliased constant String := "SIGNAL"; K_178 : aliased constant String := "SMALLINT"; K_179 : aliased constant String := "SPATIAL"; K_180 : aliased constant String := "SPECIFIC"; K_181 : aliased constant String := "SQL"; K_182 : aliased constant String := "SQLEXCEPTION"; K_183 : aliased constant String := "SQLSTATE"; K_184 : aliased constant String := "SQLWARNING"; K_185 : aliased constant String := "SQL_BIG_RESULT"; K_186 : aliased constant String := "SQL_CALC_FOUND_ROWS"; K_187 : aliased constant String := "SQL_SMALL_RESULT"; K_188 : aliased constant String := "SSL"; K_189 : aliased constant String := "STARTING"; K_190 : aliased constant String := "STRAIGHT_JOIN"; K_191 : aliased constant String := "TABLE"; K_192 : aliased constant String := "TERMINATED"; K_193 : aliased constant String := "THEN"; K_194 : aliased constant String := "TINYBLOB"; K_195 : aliased constant String := "TINYINT"; K_196 : aliased constant String := "TINYTEXT"; K_197 : aliased constant String := "TO"; K_198 : aliased constant String := "TRAILING"; K_199 : aliased constant String := "TRIGGER"; K_200 : aliased constant String := "TRUE"; K_201 : aliased constant String := "UNDO"; K_202 : aliased constant String := "UNION"; K_203 : aliased constant String := "UNIQUE"; K_204 : aliased constant String := "UNLOCK"; K_205 : aliased constant String := "UNSIGNED"; K_206 : aliased constant String := "UPDATE"; K_207 : aliased constant String := "USAGE"; K_208 : aliased constant String := "USE"; K_209 : aliased constant String := "USING"; K_210 : aliased constant String := "UTC_DATE"; K_211 : aliased constant String := "UTC_TIME"; K_212 : aliased constant String := "UTC_TIMESTAMP"; K_213 : aliased constant String := "VALUES"; K_214 : aliased constant String := "VARBINARY"; K_215 : aliased constant String := "VARCHAR"; K_216 : aliased constant String := "VARCHARACTER"; K_217 : aliased constant String := "VARYING"; K_218 : aliased constant String := "WHEN"; K_219 : aliased constant String := "WHERE"; K_220 : aliased constant String := "WHILE"; K_221 : aliased constant String := "WITH"; K_222 : aliased constant String := "WRITE"; K_223 : aliased constant String := "XOR"; K_224 : aliased constant String := "YEAR_MONTH"; K_225 : aliased constant String := "ZEROFILL"; Keywords : constant Keyword_Array := ( K_0'Access, K_1'Access, K_2'Access, K_3'Access, K_4'Access, K_5'Access, K_6'Access, K_7'Access, K_8'Access, K_9'Access, K_10'Access, K_11'Access, K_12'Access, K_13'Access, K_14'Access, K_15'Access, K_16'Access, K_17'Access, K_18'Access, K_19'Access, K_20'Access, K_21'Access, K_22'Access, K_23'Access, K_24'Access, K_25'Access, K_26'Access, K_27'Access, K_28'Access, K_29'Access, K_30'Access, K_31'Access, K_32'Access, K_33'Access, K_34'Access, K_35'Access, K_36'Access, K_37'Access, K_38'Access, K_39'Access, K_40'Access, K_41'Access, K_42'Access, K_43'Access, K_44'Access, K_45'Access, K_46'Access, K_47'Access, K_48'Access, K_49'Access, K_50'Access, K_51'Access, K_52'Access, K_53'Access, K_54'Access, K_55'Access, K_56'Access, K_57'Access, K_58'Access, K_59'Access, K_60'Access, K_61'Access, K_62'Access, K_63'Access, K_64'Access, K_65'Access, K_66'Access, K_67'Access, K_68'Access, K_69'Access, K_70'Access, K_71'Access, K_72'Access, K_73'Access, K_74'Access, K_75'Access, K_76'Access, K_77'Access, K_78'Access, K_79'Access, K_80'Access, K_81'Access, K_82'Access, K_83'Access, K_84'Access, K_85'Access, K_86'Access, K_87'Access, K_88'Access, K_89'Access, K_90'Access, K_91'Access, K_92'Access, K_93'Access, K_94'Access, K_95'Access, K_96'Access, K_97'Access, K_98'Access, K_99'Access, K_100'Access, K_101'Access, K_102'Access, K_103'Access, K_104'Access, K_105'Access, K_106'Access, K_107'Access, K_108'Access, K_109'Access, K_110'Access, K_111'Access, K_112'Access, K_113'Access, K_114'Access, K_115'Access, K_116'Access, K_117'Access, K_118'Access, K_119'Access, K_120'Access, K_121'Access, K_122'Access, K_123'Access, K_124'Access, K_125'Access, K_126'Access, K_127'Access, K_128'Access, K_129'Access, K_130'Access, K_131'Access, K_132'Access, K_133'Access, K_134'Access, K_135'Access, K_136'Access, K_137'Access, K_138'Access, K_139'Access, K_140'Access, K_141'Access, K_142'Access, K_143'Access, K_144'Access, K_145'Access, K_146'Access, K_147'Access, K_148'Access, K_149'Access, K_150'Access, K_151'Access, K_152'Access, K_153'Access, K_154'Access, K_155'Access, K_156'Access, K_157'Access, K_158'Access, K_159'Access, K_160'Access, K_161'Access, K_162'Access, K_163'Access, K_164'Access, K_165'Access, K_166'Access, K_167'Access, K_168'Access, K_169'Access, K_170'Access, K_171'Access, K_172'Access, K_173'Access, K_174'Access, K_175'Access, K_176'Access, K_177'Access, K_178'Access, K_179'Access, K_180'Access, K_181'Access, K_182'Access, K_183'Access, K_184'Access, K_185'Access, K_186'Access, K_187'Access, K_188'Access, K_189'Access, K_190'Access, K_191'Access, K_192'Access, K_193'Access, K_194'Access, K_195'Access, K_196'Access, K_197'Access, K_198'Access, K_199'Access, K_200'Access, K_201'Access, K_202'Access, K_203'Access, K_204'Access, K_205'Access, K_206'Access, K_207'Access, K_208'Access, K_209'Access, K_210'Access, K_211'Access, K_212'Access, K_213'Access, K_214'Access, K_215'Access, K_216'Access, K_217'Access, K_218'Access, K_219'Access, K_220'Access, K_221'Access, K_222'Access, K_223'Access, K_224'Access, K_225'Access); end Mysql.Perfect_Hash;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 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.Task_Primitives.Operations; with System.Storage_Elements; package body System.Tasking is package STPO renames System.Task_Primitives.Operations; --------------------- -- Detect_Blocking -- --------------------- function Detect_Blocking return Boolean is GL_Detect_Blocking : Integer; pragma Import (C, GL_Detect_Blocking, "__gl_detect_blocking"); -- Global variable exported by the binder generated file. A value equal -- to 1 indicates that pragma Detect_Blocking is active, while 0 is used -- for the pragma not being present. begin return GL_Detect_Blocking = 1; end Detect_Blocking; ----------------------- -- Number_Of_Entries -- ----------------------- function Number_Of_Entries (Self_Id : Task_Id) return Entry_Index is begin return Entry_Index (Self_Id.Entry_Num); end Number_Of_Entries; ---------- -- Self -- ---------- function Self return Task_Id renames STPO.Self; ------------------ -- Storage_Size -- ------------------ function Storage_Size (T : Task_Id) return System.Parameters.Size_Type is begin return System.Parameters.Size_Type (T.Common.Compiler_Data.Pri_Stack_Info.Size); end Storage_Size; --------------------- -- Initialize_ATCB -- --------------------- procedure Initialize_ATCB (Self_ID : Task_Id; Task_Entry_Point : Task_Procedure_Access; Task_Arg : System.Address; Parent : Task_Id; Elaborated : Access_Boolean; Base_Priority : System.Any_Priority; Base_CPU : System.Multiprocessors.CPU_Range; Domain : Dispatching_Domain_Access; Task_Info : System.Task_Info.Task_Info_Type; Stack_Size : System.Parameters.Size_Type; T : Task_Id; Success : out Boolean) is begin T.Common.State := Unactivated; -- Initialize T.Common.LL STPO.Initialize_TCB (T, Success); if not Success then return; end if; -- Note that use of an aggregate here for this assignment -- would be illegal, because Common_ATCB is limited because -- Task_Primitives.Private_Data is limited. T.Common.Parent := Parent; T.Common.Base_Priority := Base_Priority; T.Common.Base_CPU := Base_CPU; -- The Domain defaults to that of the activator. But that can be null in -- the case of foreign threads (see Register_Foreign_Thread), in which -- case we default to the System_Domain. if Domain /= null then T.Common.Domain := Domain; elsif Self_ID.Common.Domain /= null then T.Common.Domain := Self_ID.Common.Domain; else T.Common.Domain := System_Domain; end if; pragma Assert (T.Common.Domain /= null); T.Common.Current_Priority := 0; T.Common.Protected_Action_Nesting := 0; T.Common.Call := null; T.Common.Task_Arg := Task_Arg; T.Common.Task_Entry_Point := Task_Entry_Point; T.Common.Activator := Self_ID; T.Common.Wait_Count := 0; T.Common.Elaborated := Elaborated; T.Common.Activation_Failed := False; T.Common.Task_Info := Task_Info; T.Common.Global_Task_Lock_Nesting := 0; T.Common.Fall_Back_Handler := null; T.Common.Specific_Handler := null; T.Common.Debug_Events := (others => False); T.Common.Task_Image_Len := 0; if T.Common.Parent = null then -- For the environment task, the adjusted stack size is meaningless. -- For example, an unspecified Stack_Size means that the stack size -- is determined by the environment, or can grow dynamically. The -- Stack_Checking algorithm therefore needs to use the requested -- size, or 0 in case of an unknown size. T.Common.Compiler_Data.Pri_Stack_Info.Size := Storage_Elements.Storage_Offset (Stack_Size); else T.Common.Compiler_Data.Pri_Stack_Info.Size := Storage_Elements.Storage_Offset (Parameters.Adjust_Storage_Size (Stack_Size)); end if; -- Link the task into the list of all tasks T.Common.All_Tasks_Link := All_Tasks_List; All_Tasks_List := T; end Initialize_ATCB; ---------------- -- Initialize -- ---------------- Main_Task_Image : constant String := "main_task"; -- Image of environment task Main_Priority : Integer; pragma Import (C, Main_Priority, "__gl_main_priority"); -- Priority for main task. Note that this is of type Integer, not Priority, -- because we use the value -1 to indicate the default main priority, and -- that is of course not in Priority'range. Main_CPU : Integer; pragma Import (C, Main_CPU, "__gl_main_cpu"); -- Affinity for main task. Note that this is of type Integer, not -- CPU_Range, because we use the value -1 to indicate the unassigned -- affinity, and that is of course not in CPU_Range'Range. Initialized : Boolean := False; -- Used to prevent multiple calls to Initialize procedure Initialize is T : Task_Id; Base_Priority : Any_Priority; Base_CPU : System.Multiprocessors.CPU_Range; Success : Boolean; use type System.Multiprocessors.CPU_Range; begin if Initialized then return; end if; Initialized := True; -- Initialize Environment Task Base_Priority := (if Main_Priority = Unspecified_Priority then Default_Priority else Priority (Main_Priority)); Base_CPU := (if Main_CPU = Unspecified_CPU then System.Multiprocessors.Not_A_Specific_CPU else System.Multiprocessors.CPU_Range (Main_CPU)); -- At program start-up the environment task is allocated to the default -- system dispatching domain. -- Make sure that the processors which are not available are not taken -- into account. Use Number_Of_CPUs to know the exact number of -- processors in the system at execution time. System_Domain := new Dispatching_Domain' (Multiprocessors.CPU'First .. Multiprocessors.Number_Of_CPUs => True); T := STPO.New_ATCB (0); Initialize_ATCB (Self_ID => null, Task_Entry_Point => null, Task_Arg => Null_Address, Parent => Null_Task, Elaborated => null, Base_Priority => Base_Priority, Base_CPU => Base_CPU, Domain => System_Domain, Task_Info => Task_Info.Unspecified_Task_Info, Stack_Size => 0, T => T, Success => Success); pragma Assert (Success); STPO.Initialize (T); STPO.Set_Priority (T, T.Common.Base_Priority); T.Common.State := Runnable; T.Common.Task_Image_Len := Main_Task_Image'Length; T.Common.Task_Image (Main_Task_Image'Range) := Main_Task_Image; Dispatching_Domain_Tasks := new Array_Allocated_Tasks' (Multiprocessors.CPU'First .. Multiprocessors.Number_Of_CPUs => 0); -- Signal that this task is being allocated to a processor if Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU then -- Increase the number of tasks attached to the CPU to which this -- task is allocated. Dispatching_Domain_Tasks (Base_CPU) := Dispatching_Domain_Tasks (Base_CPU) + 1; end if; -- The full initialization of the environment task's Entry_Calls array -- is deferred to Init_RTS because only the first element of the array -- is used by the restricted Ravenscar runtime. T.Entry_Calls (T.Entry_Calls'First).Self := T; T.Entry_Calls (T.Entry_Calls'First).Level := T.Entry_Calls'First; end Initialize; end System.Tasking;
pragma License (Unrestricted); -- implementation unit with Ada.Strings.Naked_Maps; package Ada.Strings.Maps.Naked is pragma Preelaborate; generic with function Source return not null Naked_Maps.Character_Set_Access; function To_Set return Character_Set; pragma Inline (To_Set); generic with function Source return not null Naked_Maps.Character_Mapping_Access; function To_Mapping return Character_Mapping; pragma Inline (To_Mapping); end Ada.Strings.Maps.Naked;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- I N T E R F A C E S . O S 2 L I B . S Y N C H R O N I Z A T I O N -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1993-1998 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. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Interfaces.OS2Lib.Threads; package Interfaces.OS2Lib.Synchronization is pragma Preelaborate (Synchronization); package IC renames Interfaces.C; package IOT renames Interfaces.OS2Lib.Threads; package S renames System; -- Semaphore Attributes DC_SEM_SHARED : constant := 16#01#; -- DosCreateMutex, DosCreateEvent, and DosCreateMuxWait use it to indicate -- whether the semaphore is shared or private when the PSZ is null SEM_INDEFINITE_WAIT : constant ULONG := -1; SEM_IMMEDIATE_RETURN : constant ULONG := 0; type HSEM is new LHANDLE; type PHSEM is access all HSEM; type SEMRECORD is record hsemCur : HSEM; ulUser : ULONG; end record; type PSEMRECORD is access all SEMRECORD; -- Quad word structure -- Originally QWORD is defined as a record containing two ULONGS, -- the first containing low word and the second for the high word, -- but it is cleaner to define it as follows: type QWORD is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0; type PQWORD is access all QWORD; type HEV is new HSEM; type PHEV is access all HEV; type HMTX is new HSEM; type PHMTX is access all HMTX; type HMUX is new HSEM; type PHMUX is access all HMUX; type HTIMER is new LHANDLE; type PHTIMER is access all HTIMER; ----------------------- -- Critical sections -- ----------------------- function DosEnterCritSec return APIRET; pragma Import (C, DosEnterCritSec, "DosEnterCritSec"); function DosExitCritSec return APIRET; pragma Import (C, DosExitCritSec, "DosExitCritSec"); -------------- -- EventSem -- -------------- function DosCreateEventSem (pszName : PSZ; f_phev : PHEV; flAttr : ULONG; fState : BOOL32) return APIRET; pragma Import (C, DosCreateEventSem, "DosCreateEventSem"); function DosOpenEventSem (pszName : PSZ; F_phev : PHEV) return APIRET; pragma Import (C, DosOpenEventSem, "DosOpenEventSem"); function DosCloseEventSem (F_hev : HEV) return APIRET; pragma Import (C, DosCloseEventSem, "DosCloseEventSem"); function DosResetEventSem (F_hev : HEV; pulPostCt : PULONG) return APIRET; pragma Import (C, DosResetEventSem, "DosResetEventSem"); function DosPostEventSem (F_hev : HEV) return APIRET; pragma Import (C, DosPostEventSem, "DosPostEventSem"); function DosWaitEventSem (F_hev : HEV; ulTimeout : ULONG) return APIRET; pragma Import (C, DosWaitEventSem, "DosWaitEventSem"); function DosQueryEventSem (F_hev : HEV; pulPostCt : PULONG) return APIRET; pragma Import (C, DosQueryEventSem, "DosQueryEventSem"); -------------- -- MutexSem -- -------------- function DosCreateMutexSem (pszName : PSZ; F_phmtx : PHMTX; flAttr : ULONG; fState : BOOL32) return APIRET; pragma Import (C, DosCreateMutexSem, "DosCreateMutexSem"); function DosOpenMutexSem (pszName : PSZ; F_phmtx : PHMTX) return APIRET; pragma Import (C, DosOpenMutexSem, "DosOpenMutexSem"); function DosCloseMutexSem (F_hmtx : HMTX) return APIRET; pragma Import (C, DosCloseMutexSem, "DosCloseMutexSem"); function DosRequestMutexSem (F_hmtx : HMTX; ulTimeout : ULONG) return APIRET; pragma Import (C, DosRequestMutexSem, "DosRequestMutexSem"); function DosReleaseMutexSem (F_hmtx : HMTX) return APIRET; pragma Import (C, DosReleaseMutexSem, "DosReleaseMutexSem"); function DosQueryMutexSem (F_hmtx : HMTX; F_ppid : IOT.PPID; F_ptid : IOT.PTID; pulCount : PULONG) return APIRET; pragma Import (C, DosQueryMutexSem, "DosQueryMutexSem"); ---------------- -- MuxWaitSem -- ---------------- function DosCreateMuxWaitSem (pszName : PSZ; F_phmux : PHMUX; cSemRec : ULONG; pSemRec : PSEMRECORD; flAttr : ULONG) return APIRET; pragma Import (C, DosCreateMuxWaitSem, "DosCreateMuxWaitSem"); DCMW_WAIT_ANY : constant := 16#02#; -- wait on any event/mutex to occur DCMW_WAIT_ALL : constant := 16#04#; -- wait on all events/mutexes to occur -- Values for "flAttr" parameter in DosCreateMuxWaitSem call function DosOpenMuxWaitSem (pszName : PSZ; F_phmux : PHMUX) return APIRET; pragma Import (C, DosOpenMuxWaitSem, "DosOpenMuxWaitSem"); function DosCloseMuxWaitSem (F_hmux : HMUX) return APIRET; pragma Import (C, DosCloseMuxWaitSem, "DosCloseMuxWaitSem"); function DosWaitMuxWaitSem (F_hmux : HMUX; ulTimeout : ULONG; pulUser : PULONG) return APIRET; pragma Import (C, DosWaitMuxWaitSem, "DosWaitMuxWaitSem"); function DosAddMuxWaitSem (F_hmux : HMUX; pSemRec : PSEMRECORD) return APIRET; pragma Import (C, DosAddMuxWaitSem, "DosAddMuxWaitSem"); function DosDeleteMuxWaitSem (F_hmux : HMUX; F_hsem : HSEM) return APIRET; pragma Import (C, DosDeleteMuxWaitSem, "DosDeleteMuxWaitSem"); function DosQueryMuxWaitSem (F_hmux : HMUX; pcSemRec : PULONG; pSemRec : PSEMRECORD; pflAttr : PULONG) return APIRET; pragma Import (C, DosQueryMuxWaitSem, "DosQueryMuxWaitSem"); ----------- -- Timer -- ----------- function DosAsyncTimer (msec : ULONG; F_hsem : HSEM; F_phtimer : PHTIMER) return APIRET; pragma Import (C, DosAsyncTimer, "DosAsyncTimer"); function DosStartTimer (msec : ULONG; F_hsem : HSEM; F_phtimer : PHTIMER) return APIRET; pragma Import (C, DosStartTimer, "DosStartTimer"); function DosStopTimer (F_htimer : HTIMER) return APIRET; pragma Import (C, DosStopTimer, "DosStopTimer"); -- DosTmrQueryTime provides a snapshot of the time -- from the IRQ0 high resolution timer (Intel 8254) function DosTmrQueryTime (pqwTmrTime : access QWORD) -- Time in 8254 ticks (1_192_755.2 Hz) return APIRET; pragma Import (C, DosTmrQueryTime, "DosTmrQueryTime"); end Interfaces.OS2Lib.Synchronization;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Compilation_Units; with Program.Elements.Defining_Names; with Program.Elements.Expressions; with Program.Elements; with Program.Symbol_Lists; with Program.Symbols; package Program.Node_Symbols is pragma Preelaborate; function Get_Symbol (Name : access Program.Elements.Element'Class) return Program.Symbols.Symbol; -- Return a symbol for given direct name or defining name. Return symbol of -- the selector for expanded [defining] name. procedure Unit_Full_Name (Self : in out Program.Symbol_Lists.Symbol_List_Table'Class; Unit : not null Program.Compilation_Units.Compilation_Unit_Access; Name : out Program.Symbol_Lists.Symbol_List); -- Return unit full name as a symbol list procedure Defining_Name_Symbol (Self : in out Program.Symbol_Lists.Symbol_List_Table'Class; Element : not null Program.Elements.Defining_Names.Defining_Name_Access; Result : out Program.Symbol_Lists.Symbol_List); procedure Name_Symbol (Self : in out Program.Symbol_Lists.Symbol_List_Table'Class; Element : not null Program.Elements.Expressions.Expression_Access; Result : out Program.Symbol_Lists.Symbol_List); end Program.Node_Symbols;
-- Task ventilator -- Binds PUSH socket to tcp://localhost:5557 -- Sends batch of tasks to workers via that socket with Ada.Command_Line; with Ada.Text_IO; with Ada.Numerics.Discrete_Random; with GNAT.Formatted_String; with ZMQ; procedure TaskVent is use type GNAT.Formatted_String.Formatted_String; type Workload_T is range 1 .. 100; package Random_Workload is new Ada.Numerics.Discrete_Random (Workload_T); function Main return Ada.Command_Line.Exit_Status is Random_Workload_Seed : Random_Workload.Generator; begin declare Context : ZMQ.Context_Type := ZMQ.New_Context; -- Socket to send messages on Sender : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUSH); -- Socket to send start of batch message on Sink : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUSH); begin Sender.Bind ("tcp://*:5557"); Sink.Connect ("tcp://localhost:5558"); Ada.Text_IO.Put ("Press Enter when the workers are ready: "); declare Dummy : String := Ada.Text_IO.Get_Line; begin null; end; Ada.Text_IO.Put_Line ("Sending tasks to workers..."); -- The first message is "0" and signals start of batch Sink.Send ("0"); -- -- Initialize random number generator Random_Workload.Reset (Random_Workload_Seed); -- Send 100 tasks declare total_msec : Integer := 0; -- Total expected cost in msecs begin for Task_Nbr in 1 .. 100 loop declare -- Random workload from 1 to 100msecs Workload : constant Workload_T := Random_Workload.Random (Random_Workload_Seed); begin total_msec := total_msec + Integer (Workload); Sender.Send (-(+"%d"&Integer (Workload))); end; end loop; Ada.Text_IO.Put_Line (-(+"Total expected cost: %d msec"&Integer (total_msec))); end; Sink.Close; Sender.Close; Context.Term; end; return 0; end Main; begin Ada.Command_Line.Set_Exit_Status (Main); end TaskVent;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with System; use System; with Interfaces.C; use Interfaces; with GBA.BIOS.Arm; use GBA.BIOS.Arm; with Ada.Unchecked_Conversion; use type Interfaces.C.size_t; function GBA.BIOS.Memset ( Dest : in Address; Value : Integer; Num_Bytes : C.size_t ) return Address is function Conv is new Ada.Unchecked_Conversion (Integer, Unsigned_32); function Conv is new Ada.Unchecked_Conversion (C.size_t, Cpu_Set_Unit_Count); function Conv is new Ada.Unchecked_Conversion (C.size_t, Address); Value_U32 : Unsigned_32 := Conv (Value); Num_Bytes_32 : C.size_t := Num_Bytes and not 2#1111#; Num_Bytes_2 : C.size_t := Num_Bytes and 2#1110#; Num_Bytes_1 : C.size_t := Num_Bytes and 2#0001#; Copy_Dest : Address := Dest; begin Value_U32 := @ and 16#FF#; Value_U32 := @ or Shift_Left (Value_U32, 8); Value_U32 := @ or Shift_Left (Value_U32, 16); if Num_Bytes_32 /= 0 then Cpu_Fast_Set ( Value_U32'Address , Copy_Dest , Conv (Num_Bytes_32 / 4) , Mode => Fill ); Copy_Dest := @ + Conv (Num_Bytes_32); end if; if Num_Bytes_2 /= 0 then Cpu_Set ( Value_U32'Address , Copy_Dest , Conv (Num_Bytes_2 / 2) , Mode => Fill , Unit_Size => Half_Word ); Copy_Dest := @ + Conv (Num_Bytes_2); end if; if Num_Bytes_1 /= 0 then Unsigned_8'Deref (Copy_Dest) := Unsigned_8'Mod (Value_U32); end if; return Dest; end;
with Program.Parsers.Nodes; use Program.Parsers.Nodes; pragma Style_Checks ("N"); procedure Program.Parsers.On_Reduce_2001 (Self : access Parse_Context; Prod : Anagram.Grammars.Production_Index; Nodes : in out Program.Parsers.Nodes.Node_Array) is begin case Prod is when 2001 => null; when 2002 => null; when 2003 => null; when 2004 => null; when 2005 => null; when 2006 => declare List : Node := Nodes (1); begin Self.Factory.Append_Protected_Operation_Item (List, Nodes (2)); Nodes (1) := List; end; when 2007 => declare List : Node := Self. Factory.Protected_Operation_Item_Sequence; begin Self.Factory.Append_Protected_Operation_Item (List, Nodes (1)); Nodes (1) := List; end; when 2008 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11)); when 2009 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (7), Nodes (8)); when 2010 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), (Self.Factory.Aspect_Specification_Sequence), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10)); when 2011 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), (Self.Factory.Aspect_Specification_Sequence), Nodes (5), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (6), Nodes (7)); when 2012 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10)); when 2013 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, Nodes (4), Nodes (5), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (6), Nodes (7)); when 2014 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, (Self.Factory.Aspect_Specification_Sequence), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9)); when 2015 => Nodes (1) := Self.Factory.Protected_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, (Self.Factory.Aspect_Specification_Sequence), Nodes (4), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (5), Nodes (6)); when 2016 => Nodes (1) := Self.Factory.Qualified_Expression (Nodes (1), Nodes (2), No_Token, Nodes (3), No_Token); when 2017 => Nodes (1) := Self.Factory.Quantified_Expression (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); when 2018 => Nodes (1) := Self.Factory.Quantified_Expression (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); when 2019 => null; when 2020 => null; when 2021 => Nodes (1) := Self.Factory.Raise_Statement (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); when 2022 => Nodes (1) := Self.Factory.Raise_Statement (Nodes (1), Nodes (2), No_Token, None, Nodes (3)); when 2023 => Nodes (1) := Self.Factory.Raise_Statement (Nodes (1), None, No_Token, None, Nodes (2)); when 2024 => Nodes (1) := Self.Factory.Range_Attribute_Reference (Nodes (1)); when 2025 => Nodes (1) := Self.Factory.Simple_Expression_Range (Nodes (1), Nodes (2), Nodes (3)); when 2026 => Nodes (1) := Self.Factory.Attribute_Reference (Nodes (1), Nodes (2), Self.Factory.Identifier (Nodes (3)), Nodes (5)); when 2027 => Nodes (1) := Self.Factory.Attribute_Reference (Nodes (1), Nodes (2), Self.Factory.Identifier (Nodes (3)), None); when 2028 => Nodes (1) := Nodes (2); when 2029 => Nodes (1) := Self.Factory.Real_Range_Specification (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2030 => Nodes (1) := Self.Factory.To_Aggregate_Or_Expression (Nodes (1)); when 2031 => Nodes (1) := Self.Factory.Association (Nodes (1), Nodes (2), Nodes (3)); when 2032 => Nodes (1) := Self.Factory.Association ((Self.Factory.Discrete_Choice_Sequence), No_Token, Nodes (1)); when 2033 => declare Box : constant Node := Self.Factory.Box (Nodes (3)); begin Nodes (1) := Self.Factory.Association (Nodes (1), Nodes (2), Box); end; when 2034 => declare List : Node := Self.Factory.Discrete_Choice_Sequence; begin Self.Factory.Prepend_Discrete_Choice (List, Nodes (1)); Nodes (1) := Self.Factory.Association (List, No_Token, None); end; when 2035 => declare List : Node := Nodes (2); begin Self.Factory.Prepend_Association (List, Nodes (1)); Nodes (1) := List; end; when 2036 => declare List : Node := Self.Factory.Association_Sequence; begin Self.Factory.Prepend_Association (List, Nodes (1)); Nodes (1) := List; end; when 2037 => declare List : constant Node := Self.Factory.Association_Sequence; begin Nodes (1) := List; end; when 2038 => Nodes (1) := Self.Factory. Record_Definition (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2039 => Nodes (1) := Self.Factory. Null_Record_Definition (Nodes (1), Nodes (2)); when 2040 => Nodes (1) := Self.Factory. Record_Representation_Clause (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11), Nodes (12)); when 2041 => Nodes (1) := Self.Factory. Record_Representation_Clause (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), (Self.Factory.Clause_Or_Pragma_Sequence), Nodes (9), Nodes (10), Nodes (11)); when 2042 => Nodes (1) := Self.Factory. Record_Representation_Clause (Nodes (1), Nodes (2), Nodes (3), Nodes (4), No_Token, No_Token, None, No_Token, Nodes (5), Nodes (6), Nodes (7), Nodes (8)); when 2043 => Nodes (1) := Self.Factory. Record_Representation_Clause (Nodes (1), Nodes (2), Nodes (3), Nodes (4), No_Token, No_Token, None, No_Token, (Self.Factory.Clause_Or_Pragma_Sequence), Nodes (5), Nodes (6), Nodes (7)); when 2044 => Nodes (1) := Self.Factory.Record_Type_Definition (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2045 => Nodes (1) := Self.Factory.Record_Type_Definition (Nodes (1), Nodes (2), No_Token, Nodes (3)); when 2046 => Nodes (1) := Self.Factory.Record_Type_Definition (No_Token, Nodes (1), Nodes (2), Nodes (3)); when 2047 => Nodes (1) := Self.Factory.Record_Type_Definition (No_Token, Nodes (1), No_Token, Nodes (2)); when 2048 => Nodes (1) := Self.Factory.Record_Type_Definition (No_Token, No_Token, Nodes (1), Nodes (2)); when 2049 => Nodes (1) := Self.Factory.Record_Type_Definition (No_Token, No_Token, No_Token, Nodes (1)); when 2050 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2051 => null; when 2052 => Nodes (1) := Self.Factory.Membership_Test (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2053 => Nodes (1) := Self.Factory.Membership_Test (Nodes (1), No_Token, Nodes (2), Nodes (3)); when 2054 => null; when 2055 => null; when 2056 => null; when 2057 => null; when 2058 => null; when 2059 => null; when 2060 => Nodes (1) := Self.Factory.Requeue_Statement (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); when 2061 => Nodes (1) := Self.Factory.Requeue_Statement (Nodes (1), Nodes (2), No_Token, No_Token, Nodes (3)); when 2062 => null; when 2063 => null; when 2064 => null; when 2065 => null; when 2066 => null; when 2067 => null; when 2068 => null; when 2069 => declare Item : constant Node := Self.Factory.Select_Or_Path (Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6)); List : Node := Nodes (1); begin Self.Factory.Append_Select_Or_Else_Path (List, Item); Nodes (1) := List; end; when 2070 => declare Item : constant Node := Self.Factory.Select_Or_Path (Nodes (2), No_Token, None, No_Token, Nodes (3)); List : Node := Nodes (1); begin Self.Factory.Append_Select_Or_Else_Path (List, Item); Nodes (1) := List; end; when 2071 => declare Item : constant Node := Self.Factory.Select_Or_Path (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); List : Node := Self.Factory.Select_Or_Else_Path_Sequence; begin Self.Factory.Append_Select_Or_Else_Path (List, Item); Nodes (1) := List; end; when 2072 => declare Item : constant Node := Self.Factory.Select_Or_Path (Nodes (1), No_Token, None, No_Token, Nodes (2)); List : Node := Self.Factory.Select_Or_Else_Path_Sequence; begin Self.Factory.Append_Select_Or_Else_Path (List, Item); Nodes (1) := List; end; when 2073 => Nodes (1) := Self.Factory.Selected_Component (Nodes (1), Nodes (2), Nodes (3)); when 2074 => Nodes (1) := Self.Factory.Selected_Identifier (Nodes (1), Nodes (2), Nodes (3)); when 2075 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token Nodes (2), Nodes (3), Nodes (4), Nodes (5)); Else_Item : constant Node := Self.Factory.Else_Path (Nodes (7), Nodes (8)); List : Node := Nodes (6); begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Self.Factory.Append_Select_Or_Else_Path (List, Else_Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (9), Nodes (10), Nodes (11)); end; when 2076 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token Nodes (2), Nodes (3), Nodes (4), Nodes (5)); List : Node := Nodes (6); begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (7), Nodes (8), Nodes (9)); end; when 2077 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token Nodes (2), Nodes (3), Nodes (4), Nodes (5)); Else_Item : constant Node := Self.Factory.Else_Path (Nodes (6), Nodes (7)); List : Node := Self.Factory.Select_Or_Else_Path_Sequence; begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Self.Factory.Append_Select_Or_Else_Path (List, Else_Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (8), Nodes (9), Nodes (10)); end; when 2078 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token Nodes (2), Nodes (3), Nodes (4), Nodes (5)); List : Node := Self.Factory.Select_Or_Else_Path_Sequence; begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (6), Nodes (7), Nodes (8)); end; when 2079 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token No_Token, None, No_Token, Nodes (2)); Else_Item : constant Node := Self.Factory.Else_Path (Nodes (4), Nodes (5)); List : Node := Nodes (3); begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Self.Factory.Append_Select_Or_Else_Path (List, Else_Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (6), Nodes (7), Nodes (8)); end; when 2080 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token No_Token, None, No_Token, Nodes (2)); List : Node := Nodes (3); begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (4), Nodes (5), Nodes (6)); end; when 2081 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token No_Token, None, No_Token, Nodes (2)); Else_Item : constant Node := Self.Factory.Else_Path (Nodes (3), Nodes (4)); List : Node := Self.Factory.Select_Or_Else_Path_Sequence; begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Self.Factory.Append_Select_Or_Else_Path (List, Else_Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (5), Nodes (6), Nodes (7)); end; when 2082 => declare Item : constant Node := Self.Factory.Select_Or_Path (No_Token, -- Or_Token No_Token, None, No_Token, Nodes (2)); List : Node := Self.Factory.Select_Or_Else_Path_Sequence; begin Self.Factory.Prepend_Select_Or_Else_Path (List, Item); Nodes (1) := Self.Factory.Selective_Accept (Nodes (1), List, Nodes (3), Nodes (4), Nodes (5)); end; when 2083 => null; when 2084 => Nodes (1) := Self.Factory.Character_Literal (Nodes (1)); when 2085 => null; when 2086 => declare List : Node := Nodes (2); begin Self.Factory.Prepend_Exception_Handler (List, Nodes (1)); Nodes (1) := List; end; when 2087 => declare List : Node := Self.Factory. Exception_Handler_Sequence; begin Self.Factory.Prepend_Exception_Handler (List, Nodes (1)); Nodes (1) := List; end; when 2088 => declare List : Node := Nodes (2); Dummy : constant Node := Self.Factory.Label_Decorator (Nodes (3), None); begin Self.Factory.Prepend_Statement (List, Nodes (1)); Self.Factory.Append_Statement (List, Dummy); Nodes (1) := List; end; when 2089 => declare List : Node := Nodes (2); begin Self.Factory.Prepend_Statement (List, Nodes (1)); Nodes (1) := List; end; when 2090 => declare List : Node := Self.Factory. Statement_Sequence; Dummy : constant Node := Self.Factory.Label_Decorator (Nodes (2), None); begin Self.Factory.Prepend_Statement (List, Nodes (1)); Self.Factory.Append_Statement (List, Dummy); Nodes (1) := List; end; when 2091 => declare List : Node := Self.Factory. Statement_Sequence; begin Self.Factory.Prepend_Statement (List, Nodes (1)); Nodes (1) := List; end; when 2092 => Nodes (1) := Self.Factory.Signed_Integer_Type_Definition (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2093 => Nodes (1) := Self.Factory.Numeric_Literal (Nodes (1)); when 2094 => Nodes (1) := Self.Factory.Null_Literal (Nodes (1)); when 2095 => null; when 2096 => null; when 2097 => null; when 2098 => Nodes (1) := Nodes (2); when 2099 => Nodes (1) := Nodes (2); when 2100 => Nodes (1) := Self.Factory.Infix_Call (Nodes (1), None, Nodes (2)); when 2101 => Nodes (1) := Self.Factory.Infix_Call (Nodes (1), None, Nodes (2)); when 2102 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2103 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2104 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2105 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2106 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2107 => Nodes (1) := Self.Factory.Infix_Call (Nodes (1), None, Nodes (2)); when 2108 => Nodes (1) := Self.Factory.Infix_Call (Nodes (1), None, Nodes (2)); when 2109 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2110 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2111 => Nodes (1) := Self.Factory.Infix_Call (Nodes (2), Nodes (1), Nodes (3)); when 2112 => Nodes (1) := Self.Factory.Simple_Return_Statement (Nodes (1), Nodes (2), Nodes (3)); when 2113 => Nodes (1) := Self.Factory.Simple_Return_Statement (Nodes (1), None, Nodes (2)); when 2114 => Nodes (1) := Self.Factory.Single_Protected_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9)); when 2115 => Nodes (1) := Self.Factory.Single_Protected_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (5), Nodes (6)); when 2116 => Nodes (1) := Self.Factory.Single_Protected_Declaration (Nodes (1), Nodes (2), (Self.Factory.Aspect_Specification_Sequence), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8)); when 2117 => Nodes (1) := Self.Factory.Single_Protected_Declaration (Nodes (1), Nodes (2), (Self.Factory.Aspect_Specification_Sequence), Nodes (3), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (4), Nodes (5)); when 2118 => Nodes (1) := Self.Factory.Single_Task_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9)); when 2119 => Nodes (1) := Self.Factory.Single_Task_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (5), Nodes (6)); when 2120 => Nodes (1) := Self.Factory.Single_Task_Declaration (Nodes (1), Nodes (2), Nodes (3), No_Token, No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, None, Nodes (4)); when 2121 => Nodes (1) := Self.Factory.Single_Task_Declaration (Nodes (1), Nodes (2), (Self.Factory.Aspect_Specification_Sequence), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8)); when 2122 => Nodes (1) := Self.Factory.Single_Task_Declaration (Nodes (1), Nodes (2), (Self.Factory.Aspect_Specification_Sequence), Nodes (3), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (4), Nodes (5)); when 2123 => Nodes (1) := Self.Factory.Single_Task_Declaration (Nodes (1), Nodes (2), (Self.Factory.Aspect_Specification_Sequence), No_Token, No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, None, Nodes (3)); when 2124 => Nodes (1) := Self.Factory.Label_Decorator (Nodes (1), Nodes (2)); when 2125 => null; when 2126 => declare List : Node := Nodes (1); begin Self.Factory.Append_Statement (List, Nodes (2)); Nodes (1) := List; end; when 2127 => declare List : Node := Self. Factory.Statement_Sequence; begin Self.Factory.Append_Statement (List, Nodes (1)); Nodes (1) := List; end; when 2128 => Nodes (1) := Self.Factory.Subtype_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6)); when 2129 => Nodes (1) := Self.Factory.Subtype_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), (Self.Factory.Aspect_Specification_Sequence), Nodes (5)); when 2130 => Nodes (1) := Self.Factory.To_Subtype_Indication (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2131 => Nodes (1) := Self.Factory.To_Subtype_Indication (Nodes (1), Nodes (2), Nodes (3), None); when 2132 => Nodes (1) := Self.Factory.To_Subtype_Indication (No_Token, No_Token, Nodes (1), Nodes (2)); when 2133 => Nodes (1) := Self.Factory.To_Subtype_Indication (No_Token, No_Token, Nodes (1), None); when 2134 => null; when 2135 => declare List : Node := Nodes (1); begin Self.Factory.Append_Subtype_Mark (List, Nodes (3)); Nodes (1) := List; end; when 2136 => declare List : Node := Self. Factory.Subtype_Mark_Sequence; begin Self.Factory.Append_Subtype_Mark (List, Nodes (2)); Nodes (1) := List; end; when 2137 => Nodes (1) := Self.Factory.Subunit (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6)); when 2138 => Nodes (1) := Self.Factory.Subunit ((Self.Factory.Context_Item_Sequence), Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); when 2139 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11), Nodes (12), Nodes (13)); when 2140 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11), No_Token, Nodes (12)); when 2141 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (9), Nodes (10), Nodes (11)); when 2142 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (9), No_Token, Nodes (10)); when 2143 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), (Self.Factory.Declarative_Item_Sequence), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11), Nodes (12)); when 2144 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), (Self.Factory.Declarative_Item_Sequence), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), No_Token, Nodes (11)); when 2145 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), (Self.Factory.Declarative_Item_Sequence), Nodes (6), Nodes (7), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (8), Nodes (9), Nodes (10)); when 2146 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), (Self.Factory.Declarative_Item_Sequence), Nodes (6), Nodes (7), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (8), No_Token, Nodes (9)); when 2147 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11), Nodes (12)); when 2148 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), No_Token, Nodes (11)); when 2149 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), Nodes (5), Nodes (6), Nodes (7), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (8), Nodes (9), Nodes (10)); when 2150 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), Nodes (5), Nodes (6), Nodes (7), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (8), No_Token, Nodes (9)); when 2151 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), (Self.Factory.Declarative_Item_Sequence), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11)); when 2152 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), (Self.Factory.Declarative_Item_Sequence), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), No_Token, Nodes (10)); when 2153 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), (Self.Factory.Declarative_Item_Sequence), Nodes (5), Nodes (6), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (7), Nodes (8), Nodes (9)); when 2154 => Nodes (1) := Self.Factory.Task_Body (Nodes (1), Nodes (2), Nodes (3), (Self.Factory.Aspect_Specification_Sequence), Nodes (4), (Self.Factory.Declarative_Item_Sequence), Nodes (5), Nodes (6), No_Token, (Self.Factory.Exception_Handler_Sequence), Nodes (7), No_Token, Nodes (8)); when 2155 => Nodes (1) := Self.Factory.Task_Body_Stub (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7)); when 2156 => Nodes (1) := Self.Factory.Task_Body_Stub (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), (Self.Factory.Aspect_Specification_Sequence), Nodes (6)); when 2157 => Nodes (1) := Self.Factory.Task_Definition (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5)); when 2158 => Nodes (1) := Self.Factory.Task_Definition (Nodes (1), Nodes (2), Nodes (3), Nodes (4), No_Token); when 2159 => Nodes (1) := Self.Factory.Task_Definition (Nodes (1), Nodes (2), (Self.Factory.Task_Item_Sequence), Nodes (3), Nodes (4)); when 2160 => Nodes (1) := Self.Factory.Task_Definition (Nodes (1), Nodes (2), (Self.Factory.Task_Item_Sequence), Nodes (3), No_Token); when 2161 => Nodes (1) := Self.Factory.Task_Definition (Nodes (1), No_Token, (Self.Factory.Task_Item_Sequence), Nodes (2), Nodes (3)); when 2162 => Nodes (1) := Self.Factory.Task_Definition (Nodes (1), No_Token, (Self.Factory.Task_Item_Sequence), Nodes (2), No_Token); when 2163 => Nodes (1) := Self.Factory.Task_Definition ((Self.Factory.Task_Item_Sequence), Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2164 => Nodes (1) := Self.Factory.Task_Definition ((Self.Factory.Task_Item_Sequence), Nodes (1), Nodes (2), Nodes (3), No_Token); when 2165 => Nodes (1) := Self.Factory.Task_Definition ((Self.Factory.Task_Item_Sequence), Nodes (1), (Self.Factory.Task_Item_Sequence), Nodes (2), Nodes (3)); when 2166 => Nodes (1) := Self.Factory.Task_Definition ((Self.Factory.Task_Item_Sequence), Nodes (1), (Self.Factory.Task_Item_Sequence), Nodes (2), No_Token); when 2167 => Nodes (1) := Self.Factory.Task_Definition ((Self.Factory.Task_Item_Sequence), No_Token, (Self.Factory.Task_Item_Sequence), Nodes (1), Nodes (2)); when 2168 => Nodes (1) := Self.Factory.Task_Definition ((Self.Factory.Task_Item_Sequence), No_Token, (Self.Factory.Task_Item_Sequence), Nodes (1), No_Token); when 2169 => null; when 2170 => null; when 2171 => declare List : Node := Nodes (1); begin Self.Factory.Prepend_Task_Item (List, Nodes (2)); Nodes (1) := List; end; when 2172 => declare List : Node := Self. Factory.Task_Item_Sequence; begin Self.Factory.Prepend_Task_Item (List, Nodes (1)); Nodes (1) := List; end; when 2173 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10), Nodes (11)); when 2174 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), Nodes (6), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (7), Nodes (8)); when 2175 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), Nodes (5), No_Token, No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, None, Nodes (6)); when 2176 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), (Self.Factory.Aspect_Specification_Sequence), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10)); when 2177 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), (Self.Factory.Aspect_Specification_Sequence), Nodes (5), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (6), Nodes (7)); when 2178 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), Nodes (4), (Self.Factory.Aspect_Specification_Sequence), No_Token, No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, None, Nodes (5)); when 2179 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9), Nodes (10)); when 2180 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, Nodes (4), Nodes (5), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (6), Nodes (7)); when 2181 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, Nodes (4), No_Token, No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, None, Nodes (5)); when 2182 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, (Self.Factory.Aspect_Specification_Sequence), Nodes (4), Nodes (5), Nodes (6), Nodes (7), Nodes (8), Nodes (9)); when 2183 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, (Self.Factory.Aspect_Specification_Sequence), Nodes (4), No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, Nodes (5), Nodes (6)); when 2184 => Nodes (1) := Self.Factory.Task_Type_Declaration (Nodes (1), Nodes (2), Nodes (3), None, (Self.Factory.Aspect_Specification_Sequence), No_Token, No_Token, (Self.Factory.Subtype_Mark_Sequence), No_Token, None, Nodes (4)); when 2185 => declare Item : constant Node := Self.Factory.Terminate_Alternative_Statement (Nodes (1), Nodes (2)); List : Node := Self.Factory.Statement_Sequence; begin Self.Factory.Append_Statement (List, Item); Nodes (1) := List; end; when 2186 => null; when 2187 => null; when 2188 => null; when 2189 => null; when 2190 => null; when 2191 => null; when 2192 => null; when 2193 => null; when 2194 => null; when 2195 => null; when 2196 => null; when 2197 => declare List : Node := Nodes (4); begin Self.Factory.Prepend_Subtype_Mark (List, Nodes (3)); Nodes (1) := Self.Factory. Unconstrained_Array_Definition (Nodes (1), Nodes (2), List, Nodes (5), Nodes (6), Nodes (7)); end; when 2198 => declare List : Node := Self.Factory. Subtype_Mark_Sequence; begin Self.Factory.Prepend_Subtype_Mark (List, Nodes (3)); Nodes (1) := Self.Factory. Unconstrained_Array_Definition (Nodes (1), Nodes (2), List, Nodes (4), Nodes (5), Nodes (6)); end; when 2199 => Nodes (1) := Self.Factory.Unknown_Discriminant_Part (Nodes (1), Nodes (2), Nodes (3)); when 2200 => null; when 2201 => null; when 2202 => null; when 2203 => null; when 2204 => null; when 2205 => null; when 2206 => null; when 2207 => null; when 2208 => null; when 2209 => null; when 2210 => null; when 2211 => null; when 2212 => null; when 2213 => null; when 2214 => null; when 2215 => null; when 2216 => null; when 2217 => null; when 2218 => null; when 2219 => null; when 2220 => null; when 2221 => declare List : Node := Nodes (3); begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (2)); Nodes (1) := Self.Factory.Use_Package_Clause (Nodes (1), List, Nodes (4)); end; when 2222 => declare List : Node := Self. Factory.Program_Unit_Name_Sequence; begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (2)); Nodes (1) := Self.Factory.Use_Package_Clause (Nodes (1), List, Nodes (3)); end; when 2223 => declare List : Node := Nodes (5); begin Self.Factory.Prepend_Subtype_Mark (List, Nodes (4)); Nodes (1) := Self.Factory.Use_Type_Clause (Nodes (1), Nodes (2), Nodes (3), List, Nodes (6)); end; when 2224 => declare List : Node := Self. Factory.Subtype_Mark_Sequence; begin Self.Factory.Prepend_Subtype_Mark (List, Nodes (4)); Nodes (1) := Self.Factory.Use_Type_Clause (Nodes (1), Nodes (2), Nodes (3), List, Nodes (5)); end; when 2225 => declare List : Node := Nodes (4); begin Self.Factory.Prepend_Subtype_Mark (List, Nodes (3)); Nodes (1) := Self.Factory.Use_Type_Clause (Nodes (1), No_Token, Nodes (2), List, Nodes (5)); end; when 2226 => declare List : Node := Self. Factory.Subtype_Mark_Sequence; begin Self.Factory.Prepend_Subtype_Mark (List, Nodes (3)); Nodes (1) := Self.Factory.Use_Type_Clause (Nodes (1), No_Token, Nodes (2), List, Nodes (4)); end; when 2227 => Nodes (1) := Self.Factory.Variant (Nodes (1), Nodes (2), Nodes (3), Nodes (4)); when 2228 => declare List : Node := Nodes (1); begin Self.Factory.Append_Variant (List, Nodes (2)); Nodes (1) := List; end; when 2229 => declare List : Node := Self. Factory.Variant_Sequence; begin Self.Factory.Append_Variant (List, Nodes (1)); Nodes (1) := List; end; when 2230 => declare List : Node := Nodes (5); begin Self.Factory.Prepend_Variant (List, Nodes (4)); Nodes (1) := Self.Factory.Variant_Part (Nodes (1), Nodes (2), Nodes (3), List, Nodes (6), Nodes (7), Nodes (8)); end; when 2231 => declare List : Node := Self.Factory.Variant_Sequence; begin Self.Factory.Prepend_Variant (List, Nodes (4)); Nodes (1) := Self.Factory.Variant_Part (Nodes (1), Nodes (2), Nodes (3), List, Nodes (5), Nodes (6), Nodes (7)); end; when 2232 => declare List : Node := Nodes (5); begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (4)); Nodes (1) := Self.Factory.With_Clause (Nodes (1), Nodes (2), Nodes (3), List, Nodes (6)); end; when 2233 => declare List : Node := Self. Factory.Program_Unit_Name_Sequence; begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (4)); Nodes (1) := Self.Factory.With_Clause (Nodes (1), Nodes (2), Nodes (3), List, Nodes (5)); end; when 2234 => declare List : Node := Nodes (4); begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (3)); Nodes (1) := Self.Factory.With_Clause (Nodes (1), No_Token, Nodes (2), List, Nodes (5)); end; when 2235 => declare List : Node := Self. Factory.Program_Unit_Name_Sequence; begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (3)); Nodes (1) := Self.Factory.With_Clause (Nodes (1), No_Token, Nodes (2), List, Nodes (4)); end; when 2236 => declare List : Node := Nodes (4); begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (3)); Nodes (1) := Self.Factory.With_Clause (No_Token, Nodes (1), Nodes (2), List, Nodes (5)); end; when 2237 => declare List : Node := Self. Factory.Program_Unit_Name_Sequence; begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (3)); Nodes (1) := Self.Factory.With_Clause (No_Token, Nodes (1), Nodes (2), List, Nodes (4)); end; when 2238 => declare List : Node := Nodes (3); begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (2)); Nodes (1) := Self.Factory.With_Clause (No_Token, No_Token, Nodes (1), List, Nodes (4)); end; when 2239 => declare List : Node := Self. Factory.Program_Unit_Name_Sequence; begin Self.Factory.Prepend_Program_Unit_Name (List, Nodes (2)); Nodes (1) := Self.Factory.With_Clause (No_Token, No_Token, Nodes (1), List, Nodes (3)); end; when others => raise Constraint_Error; end case; end Program.Parsers.On_Reduce_2001;
with System; with GDNative.Thin; use GDNative.Thin; package Minimal is procedure GDNative_Intialize (p_options : access godot_gdnative_init_options) with Export => True, Convention => C, External_Name => "minimal_gdnative_init"; procedure GDNative_Finalize (p_options : access godot_gdnative_terminate_options) with Export => True, Convention => C, External_Name => "minimal_gdnative_terminate"; procedure Nativescript_Initialize (p_handle : Nativescript_Handle) with Export => True, Convention => C, External_Name => "minimal_nativescript_init"; end;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2015 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. with Ada.Unchecked_Conversion; with GL.API; with GL.Enums; package body GL.Objects.Pipelines is procedure Use_Program_Stages (Object : Pipeline; Stages : Stage_Bits; Program : Programs.Program) is use type Low_Level.Bitfield; function Convert is new Ada.Unchecked_Conversion (Source => Stage_Bits, Target => Low_Level.Bitfield); Raw_Bits : constant Low_Level.Bitfield := Convert (Stages) and 2#0000000000111111#; begin API.Use_Program_Stages.Ref (Object.Reference.GL_Id, Raw_Bits, Program.Raw_Id); end Use_Program_Stages; procedure Bind (Object : Pipeline) is begin API.Use_Program.Ref (0); API.Bind_Program_Pipeline.Ref (Object.Reference.GL_Id); end Bind; function Validate (Object : Pipeline) return Boolean is Status_Value : Int := 0; begin API.Validate_Program_Pipeline.Ref (Object.Reference.GL_Id); API.Get_Program_Pipeline_Param.Ref (Object.Reference.GL_Id, Enums.Validate_Status, Status_Value); return Status_Value /= 0; end Validate; function Info_Log (Object : Pipeline) return String is Log_Length : Size := 0; begin API.Get_Program_Pipeline_Param.Ref (Object.Reference.GL_Id, Enums.Info_Log_Length, Log_Length); if Log_Length = 0 then return ""; end if; declare Info_Log : String (1 .. Integer (Log_Length)); begin API.Get_Program_Pipeline_Info_Log.Ref (Object.Reference.GL_Id, Log_Length, Log_Length, Info_Log); return Info_Log (1 .. Integer (Log_Length)); end; end Info_Log; overriding procedure Initialize_Id (Object : in out Pipeline) is New_Id : UInt := 0; begin API.Create_Program_Pipelines.Ref (1, New_Id); Object.Reference.GL_Id := New_Id; end Initialize_Id; overriding procedure Delete_Id (Object : in out Pipeline) is begin API.Delete_Program_Pipelines.Ref (1, (1 => Object.Reference.GL_Id)); Object.Reference.GL_Id := 0; end Delete_Id; end GL.Objects.Pipelines;
pragma License (Unrestricted); -- extended unit, not in RM package Ada.Wide_Wide_Characters.Latin_1 is -- Wide_Wide_Character version of Ada.Characters.Latin_1. pragma Pure; -- Control characters: NUL : constant Wide_Wide_Character := Wide_Wide_Character'Val (0); SOH : constant Wide_Wide_Character := Wide_Wide_Character'Val (1); STX : constant Wide_Wide_Character := Wide_Wide_Character'Val (2); ETX : constant Wide_Wide_Character := Wide_Wide_Character'Val (3); EOT : constant Wide_Wide_Character := Wide_Wide_Character'Val (4); ENQ : constant Wide_Wide_Character := Wide_Wide_Character'Val (5); ACK : constant Wide_Wide_Character := Wide_Wide_Character'Val (6); BEL : constant Wide_Wide_Character := Wide_Wide_Character'Val (7); BS : constant Wide_Wide_Character := Wide_Wide_Character'Val (8); HT : constant Wide_Wide_Character := Wide_Wide_Character'Val (9); LF : constant Wide_Wide_Character := Wide_Wide_Character'Val (10); VT : constant Wide_Wide_Character := Wide_Wide_Character'Val (11); FF : constant Wide_Wide_Character := Wide_Wide_Character'Val (12); CR : constant Wide_Wide_Character := Wide_Wide_Character'Val (13); SO : constant Wide_Wide_Character := Wide_Wide_Character'Val (14); SI : constant Wide_Wide_Character := Wide_Wide_Character'Val (15); DLE : constant Wide_Wide_Character := Wide_Wide_Character'Val (16); DC1 : constant Wide_Wide_Character := Wide_Wide_Character'Val (17); DC2 : constant Wide_Wide_Character := Wide_Wide_Character'Val (18); DC3 : constant Wide_Wide_Character := Wide_Wide_Character'Val (19); DC4 : constant Wide_Wide_Character := Wide_Wide_Character'Val (20); NAK : constant Wide_Wide_Character := Wide_Wide_Character'Val (21); SYN : constant Wide_Wide_Character := Wide_Wide_Character'Val (22); ETB : constant Wide_Wide_Character := Wide_Wide_Character'Val (23); CAN : constant Wide_Wide_Character := Wide_Wide_Character'Val (24); EM : constant Wide_Wide_Character := Wide_Wide_Character'Val (25); SUB : constant Wide_Wide_Character := Wide_Wide_Character'Val (26); ESC : constant Wide_Wide_Character := Wide_Wide_Character'Val (27); FS : constant Wide_Wide_Character := Wide_Wide_Character'Val (28); GS : constant Wide_Wide_Character := Wide_Wide_Character'Val (29); RS : constant Wide_Wide_Character := Wide_Wide_Character'Val (30); US : constant Wide_Wide_Character := Wide_Wide_Character'Val (31); -- ISO 646 graphic characters: Space : constant Wide_Wide_Character := Wide_Wide_Character'Val (32); -- ' ' Exclamation : constant Wide_Wide_Character := Wide_Wide_Character'Val (33); -- '!' Quotation : constant Wide_Wide_Character := Wide_Wide_Character'Val (34); -- '"' Number_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (35); -- '#' Dollar_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (36); -- '$' Percent_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (37); -- '%' Ampersand : constant Wide_Wide_Character := Wide_Wide_Character'Val (38); -- '&' Apostrophe : constant Wide_Wide_Character := Wide_Wide_Character'Val (39); -- ''' Left_Parenthesis : constant Wide_Wide_Character := Wide_Wide_Character'Val (40); -- '(' Right_Parenthesis : constant Wide_Wide_Character := Wide_Wide_Character'Val (41); -- ')' Asterisk : constant Wide_Wide_Character := Wide_Wide_Character'Val (42); -- '*' Plus_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (43); -- '+' Comma : constant Wide_Wide_Character := Wide_Wide_Character'Val (44); -- ',' Hyphen : constant Wide_Wide_Character := Wide_Wide_Character'Val (45); -- '-' Minus_Sign : Wide_Wide_Character renames Hyphen; Full_Stop : constant Wide_Wide_Character := Wide_Wide_Character'Val (46); -- '.' Solidus : constant Wide_Wide_Character := Wide_Wide_Character'Val (47); -- '/' -- Decimal digits '0' though '9' are at positions 48 through 57 Colon : constant Wide_Wide_Character := Wide_Wide_Character'Val (58); -- ':' Semicolon : constant Wide_Wide_Character := Wide_Wide_Character'Val (59); -- ';' Less_Than_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (60); -- '<' Equals_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (61); -- '=' Greater_Than_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (62); -- '>' Question : constant Wide_Wide_Character := Wide_Wide_Character'Val (63); -- '?' Commercial_At : constant Wide_Wide_Character := Wide_Wide_Character'Val (64); -- '@' -- Letters 'A' through 'Z' are at positions 65 through 90 Left_Square_Bracket : constant Wide_Wide_Character := Wide_Wide_Character'Val (91); -- '[' Reverse_Solidus : constant Wide_Wide_Character := Wide_Wide_Character'Val (92); -- '\' Right_Square_Bracket : constant Wide_Wide_Character := Wide_Wide_Character'Val (93); -- ']' Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (94); -- '^' Low_Line : constant Wide_Wide_Character := Wide_Wide_Character'Val (95); -- '_' Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (96); -- '`' LC_A : constant Wide_Wide_Character := Wide_Wide_Character'Val (97); -- 'a' LC_B : constant Wide_Wide_Character := Wide_Wide_Character'Val (98); -- 'b' LC_C : constant Wide_Wide_Character := Wide_Wide_Character'Val (99); -- 'c' LC_D : constant Wide_Wide_Character := Wide_Wide_Character'Val (100); -- 'd' LC_E : constant Wide_Wide_Character := Wide_Wide_Character'Val (101); -- 'e' LC_F : constant Wide_Wide_Character := Wide_Wide_Character'Val (102); -- 'f' LC_G : constant Wide_Wide_Character := Wide_Wide_Character'Val (103); -- 'g' LC_H : constant Wide_Wide_Character := Wide_Wide_Character'Val (104); -- 'h' LC_I : constant Wide_Wide_Character := Wide_Wide_Character'Val (105); -- 'i' LC_J : constant Wide_Wide_Character := Wide_Wide_Character'Val (106); -- 'j' LC_K : constant Wide_Wide_Character := Wide_Wide_Character'Val (107); -- 'k' LC_L : constant Wide_Wide_Character := Wide_Wide_Character'Val (108); -- 'l' LC_M : constant Wide_Wide_Character := Wide_Wide_Character'Val (109); -- 'm' LC_N : constant Wide_Wide_Character := Wide_Wide_Character'Val (110); -- 'n' LC_O : constant Wide_Wide_Character := Wide_Wide_Character'Val (111); -- 'o' LC_P : constant Wide_Wide_Character := Wide_Wide_Character'Val (112); -- 'p' LC_Q : constant Wide_Wide_Character := Wide_Wide_Character'Val (113); -- 'q' LC_R : constant Wide_Wide_Character := Wide_Wide_Character'Val (114); -- 'r' LC_S : constant Wide_Wide_Character := Wide_Wide_Character'Val (115); -- 's' LC_T : constant Wide_Wide_Character := Wide_Wide_Character'Val (116); -- 't' LC_U : constant Wide_Wide_Character := Wide_Wide_Character'Val (117); -- 'u' LC_V : constant Wide_Wide_Character := Wide_Wide_Character'Val (118); -- 'v' LC_W : constant Wide_Wide_Character := Wide_Wide_Character'Val (119); -- 'w' LC_X : constant Wide_Wide_Character := Wide_Wide_Character'Val (120); -- 'x' LC_Y : constant Wide_Wide_Character := Wide_Wide_Character'Val (121); -- 'y' LC_Z : constant Wide_Wide_Character := Wide_Wide_Character'Val (122); -- 'z' Left_Curly_Bracket : constant Wide_Wide_Character := Wide_Wide_Character'Val (123); -- '{' Vertical_Line : constant Wide_Wide_Character := Wide_Wide_Character'Val (124); -- '|' Right_Curly_Bracket : constant Wide_Wide_Character := Wide_Wide_Character'Val (125); -- '}' Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (126); -- '~' DEL : constant Wide_Wide_Character := Wide_Wide_Character'Val (127); -- ISO 6429 control characters: IS4 : Wide_Wide_Character renames FS; IS3 : Wide_Wide_Character renames GS; IS2 : Wide_Wide_Character renames RS; IS1 : Wide_Wide_Character renames US; Reserved_128 : constant Wide_Wide_Character := Wide_Wide_Character'Val (128); Reserved_129 : constant Wide_Wide_Character := Wide_Wide_Character'Val (129); BPH : constant Wide_Wide_Character := Wide_Wide_Character'Val (130); NBH : constant Wide_Wide_Character := Wide_Wide_Character'Val (131); Reserved_132 : constant Wide_Wide_Character := Wide_Wide_Character'Val (132); NEL : constant Wide_Wide_Character := Wide_Wide_Character'Val (133); SSA : constant Wide_Wide_Character := Wide_Wide_Character'Val (134); ESA : constant Wide_Wide_Character := Wide_Wide_Character'Val (135); HTS : constant Wide_Wide_Character := Wide_Wide_Character'Val (136); HTJ : constant Wide_Wide_Character := Wide_Wide_Character'Val (137); VTS : constant Wide_Wide_Character := Wide_Wide_Character'Val (138); PLD : constant Wide_Wide_Character := Wide_Wide_Character'Val (139); PLU : constant Wide_Wide_Character := Wide_Wide_Character'Val (140); RI : constant Wide_Wide_Character := Wide_Wide_Character'Val (141); SS2 : constant Wide_Wide_Character := Wide_Wide_Character'Val (142); SS3 : constant Wide_Wide_Character := Wide_Wide_Character'Val (143); DCS : constant Wide_Wide_Character := Wide_Wide_Character'Val (144); PU1 : constant Wide_Wide_Character := Wide_Wide_Character'Val (145); PU2 : constant Wide_Wide_Character := Wide_Wide_Character'Val (146); STS : constant Wide_Wide_Character := Wide_Wide_Character'Val (147); CCH : constant Wide_Wide_Character := Wide_Wide_Character'Val (148); MW : constant Wide_Wide_Character := Wide_Wide_Character'Val (149); SPA : constant Wide_Wide_Character := Wide_Wide_Character'Val (150); EPA : constant Wide_Wide_Character := Wide_Wide_Character'Val (151); SOS : constant Wide_Wide_Character := Wide_Wide_Character'Val (152); Reserved_153 : constant Wide_Wide_Character := Wide_Wide_Character'Val (153); SCI : constant Wide_Wide_Character := Wide_Wide_Character'Val (154); CSI : constant Wide_Wide_Character := Wide_Wide_Character'Val (155); ST : constant Wide_Wide_Character := Wide_Wide_Character'Val (156); OSC : constant Wide_Wide_Character := Wide_Wide_Character'Val (157); PM : constant Wide_Wide_Character := Wide_Wide_Character'Val (158); APC : constant Wide_Wide_Character := Wide_Wide_Character'Val (159); -- Other graphic characters: -- Character positions 160 (16#A0#) .. 175 (16#AF#): No_Break_Space : constant Wide_Wide_Character := Wide_Wide_Character'Val (160); -- ' ' NBSP : Wide_Wide_Character renames No_Break_Space; Inverted_Exclamation : constant Wide_Wide_Character := Wide_Wide_Character'Val (161); -- '¡' Cent_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (162); -- '¢' Pound_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (163); -- '£' Currency_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (164); -- '¤' Yen_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (165); -- '¥' Broken_Bar : constant Wide_Wide_Character := Wide_Wide_Character'Val (166); -- '¦' Section_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (167); -- '§' Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (168); -- '¨' Copyright_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (169); -- '©' Feminine_Ordinal_Indicator : constant Wide_Wide_Character := Wide_Wide_Character'Val (170); -- 'ª' Left_Angle_Quotation : constant Wide_Wide_Character := Wide_Wide_Character'Val (171); -- '«' Not_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (172); -- '¬' Soft_Hyphen : constant Wide_Wide_Character := Wide_Wide_Character'Val (173); -- ' ' Registered_Trade_Mark_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (174); -- '®' Macron : constant Wide_Wide_Character := Wide_Wide_Character'Val (175); -- '¯' -- Character positions 176 (16#B0#) .. 191 (16#BF#): Degree_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (176); -- '°' Ring_Above : Wide_Wide_Character renames Degree_Sign; Plus_Minus_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (177); -- '±' Superscript_Two : constant Wide_Wide_Character := Wide_Wide_Character'Val (178); -- '²' Superscript_Three : constant Wide_Wide_Character := Wide_Wide_Character'Val (179); -- '³' Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (180); -- '´' Micro_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (181); -- 'µ' Pilcrow_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (182); -- '¶' Paragraph_Sign : Wide_Wide_Character renames Pilcrow_Sign; Middle_Dot : constant Wide_Wide_Character := Wide_Wide_Character'Val (183); -- '·' Cedilla : constant Wide_Wide_Character := Wide_Wide_Character'Val (184); -- '¸' Superscript_One : constant Wide_Wide_Character := Wide_Wide_Character'Val (185); -- '¹' Masculine_Ordinal_Indicator : constant Wide_Wide_Character := Wide_Wide_Character'Val (186); -- 'º' Right_Angle_Quotation : constant Wide_Wide_Character := Wide_Wide_Character'Val (187); -- '»' Fraction_One_Quarter : constant Wide_Wide_Character := Wide_Wide_Character'Val (188); -- '¼' Fraction_One_Half : constant Wide_Wide_Character := Wide_Wide_Character'Val (189); -- '½' Fraction_Three_Quarters : constant Wide_Wide_Character := Wide_Wide_Character'Val (190); -- '¾' Inverted_Question : constant Wide_Wide_Character := Wide_Wide_Character'Val (191); -- '¿' -- Character positions 192 (16#C0#) .. 207 (16#CF#): UC_A_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (192); -- 'À' UC_A_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (193); -- 'Á' UC_A_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (194); -- 'Â' UC_A_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (195); -- 'Ã' UC_A_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (196); -- 'Ä' UC_A_Ring : constant Wide_Wide_Character := Wide_Wide_Character'Val (197); -- 'Å' UC_AE_Diphthong : constant Wide_Wide_Character := Wide_Wide_Character'Val (198); -- 'Æ' UC_C_Cedilla : constant Wide_Wide_Character := Wide_Wide_Character'Val (199); -- 'Ç' UC_E_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (200); -- 'È' UC_E_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (201); -- 'É' UC_E_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (202); -- 'Ê' UC_E_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (203); -- 'Ë' UC_I_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (204); -- 'Ì' UC_I_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (205); -- 'Í' UC_I_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (206); -- 'Î' UC_I_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (207); -- 'Ï' -- Character positions 208 (16#D0#) .. 223 (16#DF#): UC_Icelandic_Eth : constant Wide_Wide_Character := Wide_Wide_Character'Val (208); -- 'Ð' UC_N_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (209); -- 'Ñ' UC_O_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (210); -- 'Ò' UC_O_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (211); -- 'Ó' UC_O_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (212); -- 'Ô' UC_O_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (213); -- 'Õ' UC_O_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (214); -- 'Ö' Multiplication_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (215); -- '×' UC_O_Oblique_Stroke : constant Wide_Wide_Character := Wide_Wide_Character'Val (216); -- 'Ø' UC_U_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (217); -- 'Ù' UC_U_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (218); -- 'Ú' UC_U_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (219); -- 'Û' UC_U_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (220); -- 'Ü' UC_Y_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (221); -- 'Ý' UC_Icelandic_Thorn : constant Wide_Wide_Character := Wide_Wide_Character'Val (222); -- 'Þ' LC_German_Sharp_S : constant Wide_Wide_Character := Wide_Wide_Character'Val (223); -- 'ß' -- Character positions 224 (16#E0#) .. 239 (16#EF#): LC_A_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (224); -- 'à' LC_A_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (225); -- 'á' LC_A_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (226); -- 'â' LC_A_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (227); -- 'ã' LC_A_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (228); -- 'ä' LC_A_Ring : constant Wide_Wide_Character := Wide_Wide_Character'Val (229); -- 'å' LC_AE_Diphthong : constant Wide_Wide_Character := Wide_Wide_Character'Val (230); -- 'æ' LC_C_Cedilla : constant Wide_Wide_Character := Wide_Wide_Character'Val (231); -- 'ç' LC_E_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (232); -- 'è' LC_E_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (233); -- 'é' LC_E_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (234); -- 'ê' LC_E_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (235); -- 'ë' LC_I_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (236); -- 'ì' LC_I_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (237); -- 'í' LC_I_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (238); -- 'î' LC_I_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (239); -- 'ï' -- Character positions 240 (16#F0#) .. 255 (16#FF#): LC_Icelandic_Eth : constant Wide_Wide_Character := Wide_Wide_Character'Val (240); -- 'ð' LC_N_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (241); -- 'ñ' LC_O_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (242); -- 'ò' LC_O_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (243); -- 'ó' LC_O_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (244); -- 'ô' LC_O_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (245); -- 'õ' LC_O_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (246); -- 'ö' Division_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (247); -- '÷'; LC_O_Oblique_Stroke : constant Wide_Wide_Character := Wide_Wide_Character'Val (248); -- 'ø' LC_U_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (249); -- 'ù' LC_U_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (250); -- 'ú' LC_U_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (251); -- 'û'; LC_U_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (252); -- 'ü' LC_Y_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (253); -- 'ý' LC_Icelandic_Thorn : constant Wide_Wide_Character := Wide_Wide_Character'Val (254); -- 'þ' LC_Y_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (255); -- 'ÿ' end Ada.Wide_Wide_Characters.Latin_1;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Compilation_Units; with Program.Compilation_Unit_Vectors; with Program.Library_Items; limited with Program.Library_Unit_Declarations; package Program.Library_Unit_Bodies is pragma Pure; type Library_Unit_Body is limited interface and Program.Library_Items.Library_Item; -- A library_unit_body is a compilation unit that is the subprogram or -- package body. -- -- A unit interpreted only as the completion of a subprogram, or a unit -- interpreted as both the declaration and body of a library subprogram. -- Reference Manual 10.1.4(4) type Library_Unit_Body_Access is access all Library_Unit_Body'Class with Storage_Size => 0; not overriding function Corresponding_Declaration (Self : access Library_Unit_Body) return Program.Library_Unit_Declarations.Library_Unit_Declaration_Access is abstract; -- Returns the corresponding library_unit_declaration, if any, for the -- library_unit_body. The corresponding library unit is the unit upon -- which the library_unit_body depends semantically. -- -- Returns null for library_unit_body arguments that do not have a -- corresponding library unit contained in the Context. not overriding function Subunits (Self : access Library_Unit_Body) return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access is abstract; -- with Post'Class => -- (Subunits'Result.Is_Empty -- or else (for all X in Subunits'Result.Each_Unit => X.Unit.Is_Subunit)); -- Returns a complete list of subunit values, with one value for each body -- stub that appears in the given Library_Unit_Body. Returns an empty list -- if the parent unit does not contain any body stubs. end Program.Library_Unit_Bodies;
with Hello, Add; procedure Test is begin Hello; Add; end Test;
generic UB1 : Natural; UB2 : Natural; package Array25_Pkg is type Arr1 is array (1 .. UB1) of Integer; type Rec is record Data : Arr1; end record; type Arr2 is array (1 .. UB2) of Rec; procedure Get (A : out Arr2); end Array25_Pkg;
----------------------------------------------------------------------- -- applications -- Ada Web Application -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2018, 2020, 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Fixed; with ASF.Contexts.Facelets; with ASF.Applications.Main; with ASF.Components.Base; with ASF.Components.Core; with ASF.Components.Core.Views; with ASF.Converters; with ASF.Validators; with EL.Objects; package body ASF.Applications.Views is use ASF.Components; type Facelet_Context is new ASF.Contexts.Facelets.Facelet_Context with record Facelets : access ASF.Views.Facelets.Facelet_Factory; Application : access ASF.Applications.Main.Application'Class; end record; -- Include the definition having the given name. overriding procedure Include_Facelet (Context : in out Facelet_Context; Source : in String; Parent : in Base.UIComponent_Access); overriding function Get_Converter (Context : in Facelet_Context; Name : in EL.Objects.Object) return ASF.Converters.Converter_Access; overriding function Get_Validator (Context : in Facelet_Context; Name : in EL.Objects.Object) return ASF.Validators.Validator_Access; -- Compose a URI path with two components. Unlike the Ada.Directories.Compose, -- and Util.Files.Compose the path separator must be a URL path separator (ie, '/'). -- ------------------------------ function Compose (Directory : in String; Name : in String) return String; -- ------------------------------ -- Include the definition having the given name. -- ------------------------------ overriding procedure Include_Facelet (Context : in out Facelet_Context; Source : in String; Parent : in Base.UIComponent_Access) is use ASF.Views; Path : constant String := Context.Resolve_Path (Source); Tree : Facelets.Facelet; begin Facelets.Find_Facelet (Factory => Context.Facelets.all, Name => Path, Context => Context, Result => Tree); Facelets.Build_View (View => Tree, Context => Context, Root => Parent); end Include_Facelet; -- ------------------------------ -- Get a converter from a name. -- Returns the converter object or null if there is no converter. -- ------------------------------ function Get_Converter (Context : in Facelet_Context; Name : in EL.Objects.Object) return ASF.Converters.Converter_Access is begin return Context.Application.Find (Name); end Get_Converter; -- ------------------------------ -- Get a validator from a name. -- Returns the validator object or null if there is no validator. -- ------------------------------ function Get_Validator (Context : in Facelet_Context; Name : in EL.Objects.Object) return ASF.Validators.Validator_Access is begin return Context.Application.Find_Validator (Name); end Get_Validator; -- ------------------------------ -- Get the facelet name from the view name. -- ------------------------------ function Get_Facelet_Name (Handler : in View_Handler; Name : in String) return String is use Ada.Strings.Fixed; use Ada.Strings.Unbounded; Pos : constant Natural := Index (Name, ".", Ada.Strings.Backward); begin if Pos > 0 and then Handler.View_Ext = Name (Pos .. Name'Last) then return Name (Name'First .. Pos - 1) & To_String (Handler.File_Ext); elsif Pos > 0 and then Handler.File_Ext = Name (Pos .. Name'Last) then return Name; end if; return Name & To_String (Handler.File_Ext); end Get_Facelet_Name; -- ------------------------------ -- Restore the view identified by the given name in the faces context -- and create the component tree representing that view. -- ------------------------------ procedure Restore_View (Handler : in out View_Handler; Name : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class; View : out ASF.Components.Root.UIViewRoot; Ignore : in Boolean := False) is use ASF.Views; use Util.Locales; use type ASF.Components.Base.UIComponent_Access; Ctx : Facelet_Context; Tree : Facelets.Facelet; View_Name : constant String := Handler.Get_Facelet_Name (Name); begin Ctx.Facelets := Handler.Facelets'Unchecked_Access; Ctx.Application := Context.Get_Application; Ctx.Set_ELContext (Context.Get_ELContext); Facelets.Find_Facelet (Factory => Handler.Facelets, Name => View_Name, Context => Ctx, Result => Tree, Ignore => Ignore); -- If the view could not be found, do not report any error yet. -- The SC_NOT_FOUND response will be returned when rendering the response. if Facelets.Is_Null (Tree) then return; end if; -- Build the component tree for this request. declare Root : aliased Core.UIComponentBase; Node : Base.UIComponent_Access; begin Facelets.Build_View (View => Tree, Context => Ctx, Root => Root'Unchecked_Access); ASF.Components.Base.Steal_Root_Component (Root, Node); -- If there was some error while building the view, return now. -- The SC_NOT_FOUND response will also be returned when rendering the response. if Node = null then return; end if; ASF.Components.Root.Set_Root (View, Node, View_Name); if Context.Get_Locale = NULL_LOCALE then if Node.all in Core.Views.UIView'Class then Context.Set_Locale (Core.Views.UIView'Class (Node.all).Get_Locale (Context)); else Context.Set_Locale (Handler.Calculate_Locale (Context)); end if; end if; end; end Restore_View; -- ------------------------------ -- Create a new UIViewRoot instance initialized from the context and with -- the view identifier. If the view is a valid view, create the component tree -- representing that view. -- ------------------------------ procedure Create_View (Handler : in out View_Handler; Name : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class; View : out ASF.Components.Root.UIViewRoot; Ignore : in Boolean := False) is Pos : constant Natural := Util.Strings.Rindex (Name, '.'); begin if Pos > 0 then Handler.Restore_View (Name (Name'First .. Pos - 1), Context, View, Ignore); else Handler.Restore_View (Name, Context, View, Ignore); end if; end Create_View; -- ------------------------------ -- Render the view represented by the component tree. The view is -- rendered using the context. -- ------------------------------ procedure Render_View (Handler : in out View_Handler; Context : in out ASF.Contexts.Faces.Faces_Context'Class; View : in ASF.Components.Root.UIViewRoot) is pragma Unreferenced (Handler); Root : constant access ASF.Components.Base.UIComponent'Class := ASF.Components.Root.Get_Root (View); begin if Root /= null then Root.Encode_All (Context); end if; end Render_View; -- ------------------------------ -- Compute the locale that must be used according to the <b>Accept-Language</b> request -- header and the application supported locales. -- ------------------------------ function Calculate_Locale (Handler : in View_Handler; Context : in ASF.Contexts.Faces.Faces_Context'Class) return Util.Locales.Locale is pragma Unreferenced (Handler); App : constant ASF.Contexts.Faces.Application_Access := Context.Get_Application; begin return App.Calculate_Locale (Context); end Calculate_Locale; -- ------------------------------ -- Compose a URI path with two components. Unlike the Ada.Directories.Compose, -- and Util.Files.Compose the path separator must be a URL path separator (ie, '/'). -- ------------------------------ function Compose (Directory : in String; Name : in String) return String is begin if Directory'Length = 0 then return Name; elsif Directory (Directory'Last) = '/' and Name (Name'First) = '/' then return Directory & Name (Name'First + 1 .. Name'Last); elsif Directory (Directory'Last) = '/' or Name (Name'First) = '/' then return Directory & Name; else return Directory & "/" & Name; end if; end Compose; -- ------------------------------ -- Get the URL suitable for encoding and rendering the view specified by the <b>View</b> -- identifier. -- ------------------------------ function Get_Action_URL (Handler : in View_Handler; Context : in ASF.Contexts.Faces.Faces_Context'Class; View : in String) return String is use Ada.Strings.Unbounded; Pos : constant Natural := Util.Strings.Rindex (View, '.'); Context_Path : constant String := Context.Get_Request.Get_Context_Path; begin if Pos > 0 and then View (Pos .. View'Last) = Handler.File_Ext then return Compose (Context_Path, View (View'First .. Pos - 1) & To_String (Handler.View_Ext)); end if; if Pos > 0 and then View (Pos .. View'Last) = Handler.View_Ext then return Compose (Context_Path, View); end if; return Compose (Context_Path, View); end Get_Action_URL; -- ------------------------------ -- Get the URL for redirecting the user to the specified view. -- ------------------------------ function Get_Redirect_URL (Handler : in View_Handler; Context : in ASF.Contexts.Faces.Faces_Context'Class; View : in String) return String is Pos : constant Natural := Util.Strings.Rindex (View, '?'); begin if Pos > 0 then return Handler.Get_Action_URL (Context, View (View'First .. Pos - 1)) & View (Pos .. View'Last); else return Handler.Get_Action_URL (Context, View); end if; end Get_Redirect_URL; -- ------------------------------ -- Initialize the view handler. -- ------------------------------ procedure Initialize (Handler : out View_Handler; Components : access ASF.Factory.Component_Factory; Conf : in Config) is use ASF.Views; use Ada.Strings.Unbounded; begin Handler.Paths := Conf.Get (VIEW_DIR_PARAM); Handler.View_Ext := Conf.Get (VIEW_EXT_PARAM); Handler.File_Ext := Conf.Get (VIEW_FILE_EXT_PARAM); Facelets.Initialize (Factory => Handler.Facelets, Components => Components, Paths => To_String (Handler.Paths), Ignore_White_Spaces => Conf.Get (VIEW_IGNORE_WHITE_SPACES_PARAM), Ignore_Empty_Lines => Conf.Get (VIEW_IGNORE_EMPTY_LINES_PARAM), Escape_Unknown_Tags => Conf.Get (VIEW_ESCAPE_UNKNOWN_TAGS_PARAM)); end Initialize; -- ------------------------------ -- Closes the view handler -- ------------------------------ procedure Close (Handler : in out View_Handler) is use ASF.Views; begin Facelets.Clear_Cache (Handler.Facelets); end Close; -- ------------------------------ -- Set the extension mapping rule to find the facelet file from -- the name. -- ------------------------------ procedure Set_Extension_Mapping (Handler : in out View_Handler; From : in String; Into : in String) is use Ada.Strings.Unbounded; begin Handler.View_Ext := To_Unbounded_String (From); Handler.File_Ext := To_Unbounded_String (Into); end Set_Extension_Mapping; end ASF.Applications.Views;
-- -- Main routines testing/illustrating the mixins. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with Ada.Text_IO; use Ada.Text_IO; with base_iface; use base_iface; with base_type; use base_type; with generic_mixin; with generic_mixin_compositor; with oop_mixin_compositor; procedure run_mixins is begin Put_Line("Starting methods mixin demo,"); Put_Line("generic_mixin"); declare -- this adds the methods but the "direct inheritance" is not as visually evident -- that can be shown via public/private parts as shown in .. package P_base1 is new generic_mixin(Base=>The_Type); type Mixin is new P_base1.Derived with null record; -- type Stub is tagged null record; package P_stub is new generic_mixin(Base=>Stub); type Extension is new P_stub.Derived with null record; -- M : Mixin; E : Extension; begin Put_Line(" direct declaration:"); Put_Line(" mixin:"); M.method; M.simple; M.compound; M.redispatching; -- Put_Line(" extension:"); E.simple; E.compound; E.redispatching; end; declare -- this uses the compositor, hiding generic instantiation but exposing -- (logic of) type inheritance (see the corresponding module). use generic_mixin_compositor; M : Mixin; E : Extension; MC : Mixin_Child; begin Put_Line(" compositor:"); Put_Line(" extension:"); E.simple; E.compound; E.redispatching; -- Put_Line(" mixin:"); M.method; M.simple; M.compound; M.redispatching; M.class_wide; -- Put_Line(" Mixin_Child:"); MC.method; MC.simple; MC.compound; -- this should output gm:simple MC.redispatching; -- this should output MC:simple MC.class_wide; end; -- Put_Line("non-generic (OOP) mixin"); declare -- Only one version is provided in this case. -- Explicit declaration directly here would be impractical and messy. -- The composition is much more clearly illustrated by keeping all the relevant code -- in the separate (compositor) module. use oop_mixin_compositor; M : Mixin; E : Extension; MC : Mixin_Child; begin Put_Line(" compositor (only):"); Put_Line(" extension:"); E.simple; E.compound; E.redispatching; -- Put_Line(" mixin:"); M.method; M.simple; M.compound; M.redispatching; M.class_wide; -- Put_Line(" Mixin_Child:"); MC.method; MC.simple; MC.compound; -- this should output gm:simple MC.redispatching; -- this outputs gm:simple MC.class_wide; -- this outputs MC:simple end; end run_mixins;
-- -- Copyright (c) 2007, 2008, 2010 Tero Koskinen <tero.koskinen@iki.fi> -- -- Permission to use, copy, modify, and distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- with Ahven.AStrings; with Ada.Text_IO; package Ahven.Temporary_Output is Temporary_File_Error : exception; type Temporary_File is limited private; procedure Create_Temp (File : out Temporary_File); -- Create a new temporary file. Exception Temporary_File_Error -- is raised if the procedure cannot create a new temp file. function Get_Name (File : Temporary_File) return String; -- Return the name of the file. procedure Redirect_Output (To_File : in out Temporary_File); -- Redirect the standard output to the file. -- To_File must be opened using Create_Temp. procedure Restore_Output; -- Restore the standard output to its default settings. procedure Remove_Temp (File : in out Temporary_File); -- Remove the temporary file. File can be either open or closed. procedure Close_Temp (File : in out Temporary_File); -- Close the temporary file. private type Temporary_File is limited record Name : AStrings.Bounded_String; Handle : Ada.Text_IO.File_Type; end record; end Ahven.Temporary_Output;
----------------------------------------------------------------------- -- package body Crout_LU, LU decomposition, with equation solving -- Copyright (C) 2008-2018 Jonathan S. Parker -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --------------------------------------------------------------------------------- package body Crout_LU is Zero : constant Real := +0.0; One : constant Real := +1.0; Two : constant Real := +2.0; Min_Allowed_Real : constant Real := Two ** (Real'Machine_Emin - Real'Machine_Emin / 8); --------- -- "-" -- --------- function "-" (A, B : in Col_Vector) return Col_Vector is Result : Col_Vector; begin for J in Index loop Result(J) := A(J) - B(J); end loop; return Result; end "-"; ------------- -- Product -- ------------- function Product (A : Matrix; V : Row_Vector; Final_Index : Index := Index'Last; Starting_Index : Index := Index'First) return Row_Vector is Result : Col_Vector := (others => Zero); Sum : Real; begin for i in Starting_Index .. Final_Index loop Sum := Zero; for j in Starting_Index .. Final_Index loop Sum := Sum + A(i, j) * V(j); end loop; Result (i) := Sum; end loop; return Result; end Product; -------------------------- -- Scale_Cols_Then_Rows -- -------------------------- procedure Scale_Cols_Then_Rows (A : in out Matrix; Scalings : out Scale_Vectors; Final_Index : in Index := Index'Last; Starting_Index : in Index := Index'First) is Sum, Scale_Factor : Real; Power_of_Two : Integer; begin -- Scale each column to near unity: Scalings (For_Cols) := (others => One); for Col in Starting_Index .. Final_Index loop Sum := Zero; for j in Starting_Index .. Final_Index loop Sum := Sum + Abs A(j, Col); end loop; Power_of_Two := Real'Exponent (Sum + Min_Allowed_Real); Scale_Factor := Two ** (-Power_of_Two); for j in Starting_Index .. Final_Index loop A(j, Col) := Scale_Factor * A(j, Col); end loop; Scalings (For_Cols)(Col) := Scale_Factor; end loop; -- Scale each row to near unity: Scalings (For_Rows) := (others => One); for Row in Starting_Index .. Final_Index loop Sum := Zero; for j in Starting_Index .. Final_Index loop Sum := Sum + Abs A(Row, j); end loop; Power_of_Two := Real'Exponent (Sum + Min_Allowed_Real); Scale_Factor := Two ** (-Power_of_Two); for j in Starting_Index .. Final_Index loop A(Row, j) := Scale_Factor * A(Row, j); end loop; Scalings (For_Rows)(Row) := Scale_Factor; end loop; end Scale_Cols_Then_Rows; ------------------ -- LU_Decompose -- ------------------ -- The upper matrix is U, the lower L. -- We assume that the diagonal elements of L are One. Thus -- the diagonal elements of U but not L appear on the -- the diagonal of the output matrix A. procedure LU_Decompose (A : in out Matrix; Scalings : out Scale_Vectors; Row_Permutation : out Rearrangement; Final_Index : in Index := Index'Last; Starting_Index : in Index := Index'First; Scaling_Desired : in Boolean := False) is Stage : Index; tmp_Index, The_Pivotal_Row : Index; Sum, tmp : Real; Min_Allowed_Pivot_Val, Reciprocal_Pivot_Val : Real; Pivot_Val, Abs_Pivot_Val : Real; Min_Pivot_Ratio : constant Real := Two**(-Real'Machine_Mantissa-24); Max_Pivot_Val : Real := Min_Allowed_Real; ----------------------------- -- Find_Max_Element_Of_Col -- ----------------------------- procedure Find_Max_Element_Of_Col (Col_ID : in Index; Starting_Index : in Index; Index_of_Max_Element : out Index; Val_of_Max_Element : out Real; Abs_Val_of_Max_Element : out Real) is Pivot_Val, Abs_Pivot_Val : Real; begin Val_of_Max_Element := A (Starting_Index, Col_ID); Abs_Val_of_Max_Element := Abs (Val_of_Max_Element); Index_of_Max_Element := Starting_Index; if Final_Index > Starting_Index then for k in Starting_Index+1..Final_Index loop Pivot_Val := A (k, Col_ID); Abs_Pivot_Val := Abs (Pivot_Val); if Abs_Pivot_Val > Abs_Val_of_Max_Element then Val_of_Max_Element := Pivot_Val; Abs_Val_of_Max_Element := Abs_Pivot_Val; Index_of_Max_Element := k; end if; end loop; end if; end Find_Max_Element_Of_Col; begin for I in Index loop Row_Permutation(I) := I; end loop; Scalings(Diag_Inverse) := (others => Zero); Scalings(For_Cols) := (others => One); Scalings(For_Rows) := (others => One); if Scaling_Desired then Scale_Cols_Then_Rows (A, Scalings, Final_Index, Starting_Index); end if; -- Step 0: 1 X 1 matrices: if Final_Index = Starting_Index then Pivot_Val := A(Starting_Index, Starting_Index); if Abs (Pivot_Val) < Min_Allowed_Real then A(Starting_Index, Starting_Index) := Zero; else A(Starting_Index, Starting_Index) := Pivot_Val; Scalings(Diag_Inverse)(Starting_Index) := One / Pivot_Val; end if; return; end if; -- Process goes through stages Starting_Index..Final_Index. -- The last stage is a special case. -- -- At each stage calculate row "stage" of the Upper -- matrix U and Col "Stage" of the Lower matrix L. -- The matrix A is overwritten with these, because the elements -- of A in those places are never needed in future stages. -- However, the elements of U and L ARE needed in those places, -- so to get those elements we access A (which stores them). for Stage in Starting_Index .. Final_Index-1 loop if Stage > Starting_Index then for Row in Stage .. Final_Index loop Sum := Zero; for K in Starting_Index .. Stage-1 loop --Sum := Sum + L(Row, K)*U(K, Stage); Sum := Sum + A(Row, K)*A(K, Stage); end loop; A(Row, Stage) := A(Row, Stage) - Sum; end loop; end if; -- Step 2. Swap rows of L and A if necessary. -- Do it by swapping rows of A. -- Notice that the Rows of U that have already been calculated and -- stored in A, namely (1..Stage-1), are untouched by the swap. Find_Max_Element_Of_Col (Col_ID => Stage, Starting_Index => Stage, Index_of_Max_Element => The_Pivotal_Row, Val_of_Max_Element => Pivot_Val, Abs_Val_of_Max_Element => Abs_Pivot_Val); if The_Pivotal_Row /= Stage then for j in Starting_Index .. Final_Index loop tmp := A(The_Pivotal_Row, j); A(The_Pivotal_Row, j) := A(Stage, j); A(Stage, j) := tmp; end loop; tmp_Index := Row_Permutation(The_Pivotal_Row); Row_Permutation(The_Pivotal_Row) := Row_Permutation(Stage); Row_Permutation(Stage) := tmp_Index; end if; -- Step 3: -- Update Ith_row = Stage of the upper triangular matrix U. -- Update Ith_col = Stage of the lower triangular matrix L. -- The rules are that the diagonal elements of L are 1 even -- though Pivot_Val * Reciprocal_Pivot_Val /= 1. -- Constraint is that L*U = A when possible. if Abs_Pivot_Val > Max_Pivot_Val then Max_Pivot_Val := Abs_Pivot_Val; end if; Min_Allowed_Pivot_Val := Max_Pivot_Val * Min_Pivot_Ratio + Min_Allowed_Real; if (Abs_Pivot_Val < Abs Min_Allowed_Pivot_Val) then Reciprocal_Pivot_Val := Zero; else Reciprocal_Pivot_Val := One / Pivot_Val; end if; Scalings(Diag_Inverse)(Stage) := Reciprocal_Pivot_Val; A(Stage, Stage) := Pivot_Val; for Row in Stage+1 .. Final_Index loop A(Row, Stage) := A(Row, Stage) * Reciprocal_Pivot_Val; end loop; if Stage > Starting_Index then for Col in Stage+1 .. Final_Index loop Sum := Zero; for K in Starting_Index .. Stage-1 loop --Sum := Sum + L(Stage, K)*U(K, Col); Sum := Sum + A(Stage, K)*A(K, Col); end loop; --U(Stage, Col) := A(Stage, Col) - Sum; A(Stage, Col) := A(Stage, Col) - Sum; end loop; end if; end loop; -- Stage -- Step 4: Get final row and column. Stage := Final_Index; Sum := Zero; for K in Starting_Index .. Stage-1 loop --Sum := Sum + L(Stage, K)*U(K, Stage); Sum := Sum + A(Stage, K)*A(K, Stage); end loop; Pivot_Val := A(Stage, Stage) - Sum; Abs_Pivot_Val := Abs Pivot_Val; Min_Allowed_Pivot_Val := Max_Pivot_Val * Min_Pivot_Ratio + Min_Allowed_Real; if (Abs_Pivot_Val < Abs Min_Allowed_Pivot_Val) then Reciprocal_Pivot_Val := Zero; else Reciprocal_Pivot_Val := One / Pivot_Val; end if; Scalings(Diag_Inverse)(Stage) := Reciprocal_Pivot_Val; A(Stage, Stage) := Pivot_Val; end LU_Decompose; -------------- -- LU_Solve -- -------------- procedure LU_Solve (X : out Row_Vector; B : in Row_Vector; A_LU : in Matrix; Scalings : in Scale_Vectors; Row_Permutation : in Rearrangement; Final_Index : in Index := Index'Last; Starting_Index : in Index := Index'First) is Z, B2, B_s : Row_Vector; Sum : Real; begin X := (others => Zero); -- A*X = B was changed to (S_r*A*S_c) * (S_c^(-1)*X) = (S_r*B). -- The matrix LU'd was (S_r*A*S_c). Let B_s = (S_r*B). Solve for -- X_s = (S_c^(-1)*X). -- -- The matrix equation is now P*L*U*X_s = B_s (the scaled B). -- -- First assume L*U*X_s is B2, and solve for B2 in the equation P*B2 = B_s. -- Permute the elements of the vector B_s according to "Permutation": -- Get B_s = S_r*B: for i in Starting_Index .. Final_Index loop B_s(i) := Scalings(For_Rows)(i) * B(i); end loop; -- Get B2 by solving P*B2 = B_s = B: for i in Starting_Index .. Final_Index loop B2(i) := B_s(Row_Permutation(i)); end loop; -- The matrix equation is now L*U*X = B2. -- Assume U*X is Z, and solve for Z in the equation L*Z = B2. -- Remember that by assumption L(I, I) = One, U(I, I) /= One. Z(Starting_Index) := B2(Starting_Index); if Starting_Index < Final_Index then for Row in Starting_Index+1 .. Final_Index loop Sum := Zero; for Col in Starting_Index .. Row-1 loop Sum := Sum + A_LU(Row, Col) * Z(Col); end loop; Z(Row) := B2(Row) - Sum; end loop; end if; -- Solve for X_s in the equation U X_s = Z. X(Final_Index) := Z(Final_Index) * Scalings(Diag_Inverse)(Final_Index); if Final_Index > Starting_Index then for Row in reverse Starting_Index .. Final_Index-1 loop Sum := Zero; for Col in Row+1 .. Final_Index loop Sum := Sum + A_LU(Row, Col) * X(Col); end loop; X(Row) := (Z(Row) - Sum) * Scalings(Diag_Inverse)(Row); end loop; end if; -- Solved for the scaled X_s (but called it X); now get the real X: for i in Starting_Index .. Final_Index loop X(i) := Scalings(For_Cols)(i) * X(i); end loop; end LU_Solve; end Crout_LU;
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; -- Troodon: renamed this to X11 to deconflict with the use of 'x' as coordinate package X11 is X_PROTOCOL : constant := 11; -- /usr/include/X11/X.h:53 X_PROTOCOL_REVISION : constant := 0; -- /usr/include/X11/X.h:54 None : constant := 0; -- /usr/include/X11/X.h:115 ParentRelative : constant := 1; -- /usr/include/X11/X.h:118 CopyFromParent : constant := 0; -- /usr/include/X11/X.h:121 PointerWindow : constant := 0; -- /usr/include/X11/X.h:126 InputFocus : constant := 1; -- /usr/include/X11/X.h:127 PointerRoot : constant := 1; -- /usr/include/X11/X.h:129 AnyPropertyType : constant := 0; -- /usr/include/X11/X.h:131 AnyKey : constant := 0; -- /usr/include/X11/X.h:133 AnyButton : constant := 0; -- /usr/include/X11/X.h:135 AllTemporary : constant := 0; -- /usr/include/X11/X.h:137 CurrentTime : constant := 0; -- /usr/include/X11/X.h:139 NoSymbol : constant := 0; -- /usr/include/X11/X.h:141 NoEventMask : constant := 0; -- /usr/include/X11/X.h:150 KeyPressMask : constant := (2**0); -- /usr/include/X11/X.h:151 KeyReleaseMask : constant := (2**1); -- /usr/include/X11/X.h:152 ButtonPressMask : constant := (2**2); -- /usr/include/X11/X.h:153 ButtonReleaseMask : constant := (2**3); -- /usr/include/X11/X.h:154 EnterWindowMask : constant := (2**4); -- /usr/include/X11/X.h:155 LeaveWindowMask : constant := (2**5); -- /usr/include/X11/X.h:156 PointerMotionMask : constant := (2**6); -- /usr/include/X11/X.h:157 PointerMotionHintMask : constant := (2**7); -- /usr/include/X11/X.h:158 Button1MotionMask : constant := (2**8); -- /usr/include/X11/X.h:159 Button2MotionMask : constant := (2**9); -- /usr/include/X11/X.h:160 Button3MotionMask : constant := (2**10); -- /usr/include/X11/X.h:161 Button4MotionMask : constant := (2**11); -- /usr/include/X11/X.h:162 Button5MotionMask : constant := (2**12); -- /usr/include/X11/X.h:163 ButtonMotionMask : constant := (2**13); -- /usr/include/X11/X.h:164 KeymapStateMask : constant := (2**14); -- /usr/include/X11/X.h:165 ExposureMask : constant := (2**15); -- /usr/include/X11/X.h:166 VisibilityChangeMask : constant := (2**16); -- /usr/include/X11/X.h:167 StructureNotifyMask : constant := (2**17); -- /usr/include/X11/X.h:168 ResizeRedirectMask : constant := (2**18); -- /usr/include/X11/X.h:169 SubstructureNotifyMask : constant := (2**19); -- /usr/include/X11/X.h:170 SubstructureRedirectMask : constant := (2**20); -- /usr/include/X11/X.h:171 FocusChangeMask : constant := (2**21); -- /usr/include/X11/X.h:172 PropertyChangeMask : constant := (2**22); -- /usr/include/X11/X.h:173 ColormapChangeMask : constant := (2**23); -- /usr/include/X11/X.h:174 OwnerGrabButtonMask : constant := (2**24); -- /usr/include/X11/X.h:175 KeyPress : constant := 2; -- /usr/include/X11/X.h:181 KeyRelease : constant := 3; -- /usr/include/X11/X.h:182 ButtonPress : constant := 4; -- /usr/include/X11/X.h:183 ButtonRelease : constant := 5; -- /usr/include/X11/X.h:184 MotionNotify : constant := 6; -- /usr/include/X11/X.h:185 EnterNotify : constant := 7; -- /usr/include/X11/X.h:186 LeaveNotify : constant := 8; -- /usr/include/X11/X.h:187 FocusIn : constant := 9; -- /usr/include/X11/X.h:188 FocusOut : constant := 10; -- /usr/include/X11/X.h:189 KeymapNotify : constant := 11; -- /usr/include/X11/X.h:190 Expose : constant := 12; -- /usr/include/X11/X.h:191 GraphicsExpose : constant := 13; -- /usr/include/X11/X.h:192 NoExpose : constant := 14; -- /usr/include/X11/X.h:193 VisibilityNotify : constant := 15; -- /usr/include/X11/X.h:194 CreateNotify : constant := 16; -- /usr/include/X11/X.h:195 DestroyNotify : constant := 17; -- /usr/include/X11/X.h:196 UnmapNotify : constant := 18; -- /usr/include/X11/X.h:197 MapNotify : constant := 19; -- /usr/include/X11/X.h:198 MapRequest : constant := 20; -- /usr/include/X11/X.h:199 ReparentNotify : constant := 21; -- /usr/include/X11/X.h:200 ConfigureNotify : constant := 22; -- /usr/include/X11/X.h:201 ConfigureRequest : constant := 23; -- /usr/include/X11/X.h:202 GravityNotify : constant := 24; -- /usr/include/X11/X.h:203 ResizeRequest : constant := 25; -- /usr/include/X11/X.h:204 CirculateNotify : constant := 26; -- /usr/include/X11/X.h:205 CirculateRequest : constant := 27; -- /usr/include/X11/X.h:206 PropertyNotify : constant := 28; -- /usr/include/X11/X.h:207 SelectionClear : constant := 29; -- /usr/include/X11/X.h:208 SelectionRequest : constant := 30; -- /usr/include/X11/X.h:209 SelectionNotify : constant := 31; -- /usr/include/X11/X.h:210 ColormapNotify : constant := 32; -- /usr/include/X11/X.h:211 ClientMessage : constant := 33; -- /usr/include/X11/X.h:212 MappingNotify : constant := 34; -- /usr/include/X11/X.h:213 GenericEvent : constant := 35; -- /usr/include/X11/X.h:214 LASTEvent : constant := 36; -- /usr/include/X11/X.h:215 ShiftMask : constant := (2**0); -- /usr/include/X11/X.h:221 LockMask : constant := (2**1); -- /usr/include/X11/X.h:222 ControlMask : constant := (2**2); -- /usr/include/X11/X.h:223 Mod1Mask : constant := (2**3); -- /usr/include/X11/X.h:224 Mod2Mask : constant := (2**4); -- /usr/include/X11/X.h:225 Mod3Mask : constant := (2**5); -- /usr/include/X11/X.h:226 Mod4Mask : constant := (2**6); -- /usr/include/X11/X.h:227 Mod5Mask : constant := (2**7); -- /usr/include/X11/X.h:228 ShiftMapIndex : constant := 0; -- /usr/include/X11/X.h:233 LockMapIndex : constant := 1; -- /usr/include/X11/X.h:234 ControlMapIndex : constant := 2; -- /usr/include/X11/X.h:235 Mod1MapIndex : constant := 3; -- /usr/include/X11/X.h:236 Mod2MapIndex : constant := 4; -- /usr/include/X11/X.h:237 Mod3MapIndex : constant := 5; -- /usr/include/X11/X.h:238 Mod4MapIndex : constant := 6; -- /usr/include/X11/X.h:239 Mod5MapIndex : constant := 7; -- /usr/include/X11/X.h:240 Button1Mask : constant := (2**8); -- /usr/include/X11/X.h:246 Button2Mask : constant := (2**9); -- /usr/include/X11/X.h:247 Button3Mask : constant := (2**10); -- /usr/include/X11/X.h:248 Button4Mask : constant := (2**11); -- /usr/include/X11/X.h:249 Button5Mask : constant := (2**12); -- /usr/include/X11/X.h:250 AnyModifier : constant := (2**15); -- /usr/include/X11/X.h:252 Button1 : constant := 1; -- /usr/include/X11/X.h:259 Button2 : constant := 2; -- /usr/include/X11/X.h:260 Button3 : constant := 3; -- /usr/include/X11/X.h:261 Button4 : constant := 4; -- /usr/include/X11/X.h:262 Button5 : constant := 5; -- /usr/include/X11/X.h:263 NotifyNormal : constant := 0; -- /usr/include/X11/X.h:267 NotifyGrab : constant := 1; -- /usr/include/X11/X.h:268 NotifyUngrab : constant := 2; -- /usr/include/X11/X.h:269 NotifyWhileGrabbed : constant := 3; -- /usr/include/X11/X.h:270 NotifyHint : constant := 1; -- /usr/include/X11/X.h:272 NotifyAncestor : constant := 0; -- /usr/include/X11/X.h:276 NotifyVirtual : constant := 1; -- /usr/include/X11/X.h:277 NotifyInferior : constant := 2; -- /usr/include/X11/X.h:278 NotifyNonlinear : constant := 3; -- /usr/include/X11/X.h:279 NotifyNonlinearVirtual : constant := 4; -- /usr/include/X11/X.h:280 NotifyPointer : constant := 5; -- /usr/include/X11/X.h:281 NotifyPointerRoot : constant := 6; -- /usr/include/X11/X.h:282 NotifyDetailNone : constant := 7; -- /usr/include/X11/X.h:283 VisibilityUnobscured : constant := 0; -- /usr/include/X11/X.h:287 VisibilityPartiallyObscured : constant := 1; -- /usr/include/X11/X.h:288 VisibilityFullyObscured : constant := 2; -- /usr/include/X11/X.h:289 PlaceOnTop : constant := 0; -- /usr/include/X11/X.h:293 PlaceOnBottom : constant := 1; -- /usr/include/X11/X.h:294 FamilyInternet : constant := 0; -- /usr/include/X11/X.h:298 FamilyDECnet : constant := 1; -- /usr/include/X11/X.h:299 FamilyChaos : constant := 2; -- /usr/include/X11/X.h:300 FamilyInternet6 : constant := 6; -- /usr/include/X11/X.h:301 FamilyServerInterpreted : constant := 5; -- /usr/include/X11/X.h:304 PropertyNewValue : constant := 0; -- /usr/include/X11/X.h:308 PropertyDelete : constant := 1; -- /usr/include/X11/X.h:309 ColormapUninstalled : constant := 0; -- /usr/include/X11/X.h:313 ColormapInstalled : constant := 1; -- /usr/include/X11/X.h:314 GrabModeSync : constant := 0; -- /usr/include/X11/X.h:318 GrabModeAsync : constant := 1; -- /usr/include/X11/X.h:319 GrabSuccess : constant := 0; -- /usr/include/X11/X.h:323 AlreadyGrabbed : constant := 1; -- /usr/include/X11/X.h:324 GrabInvalidTime : constant := 2; -- /usr/include/X11/X.h:325 GrabNotViewable : constant := 3; -- /usr/include/X11/X.h:326 GrabFrozen : constant := 4; -- /usr/include/X11/X.h:327 AsyncPointer : constant := 0; -- /usr/include/X11/X.h:331 SyncPointer : constant := 1; -- /usr/include/X11/X.h:332 ReplayPointer : constant := 2; -- /usr/include/X11/X.h:333 AsyncKeyboard : constant := 3; -- /usr/include/X11/X.h:334 SyncKeyboard : constant := 4; -- /usr/include/X11/X.h:335 ReplayKeyboard : constant := 5; -- /usr/include/X11/X.h:336 AsyncBoth : constant := 6; -- /usr/include/X11/X.h:337 SyncBoth : constant := 7; -- /usr/include/X11/X.h:338 -- unsupported macro: RevertToNone (int)None -- unsupported macro: RevertToPointerRoot (int)PointerRoot RevertToParent : constant := 2; -- /usr/include/X11/X.h:344 Success : constant := 0; -- /usr/include/X11/X.h:350 BadRequest : constant := 1; -- /usr/include/X11/X.h:351 BadValue : constant := 2; -- /usr/include/X11/X.h:352 BadWindow : constant := 3; -- /usr/include/X11/X.h:353 BadPixmap : constant := 4; -- /usr/include/X11/X.h:354 BadAtom : constant := 5; -- /usr/include/X11/X.h:355 BadCursor : constant := 6; -- /usr/include/X11/X.h:356 BadFont : constant := 7; -- /usr/include/X11/X.h:357 BadMatch : constant := 8; -- /usr/include/X11/X.h:358 BadDrawable : constant := 9; -- /usr/include/X11/X.h:359 BadAccess : constant := 10; -- /usr/include/X11/X.h:360 BadAlloc : constant := 11; -- /usr/include/X11/X.h:369 BadColor : constant := 12; -- /usr/include/X11/X.h:370 BadGC : constant := 13; -- /usr/include/X11/X.h:371 BadIDChoice : constant := 14; -- /usr/include/X11/X.h:372 BadName : constant := 15; -- /usr/include/X11/X.h:373 BadLength : constant := 16; -- /usr/include/X11/X.h:374 BadImplementation : constant := 17; -- /usr/include/X11/X.h:375 FirstExtensionError : constant := 128; -- /usr/include/X11/X.h:377 LastExtensionError : constant := 255; -- /usr/include/X11/X.h:378 InputOutput : constant := 1; -- /usr/include/X11/X.h:387 InputOnly : constant := 2; -- /usr/include/X11/X.h:388 CWBackPixmap : constant := (2**0); -- /usr/include/X11/X.h:392 CWBackPixel : constant := (2**1); -- /usr/include/X11/X.h:393 CWBorderPixmap : constant := (2**2); -- /usr/include/X11/X.h:394 CWBorderPixel : constant := (2**3); -- /usr/include/X11/X.h:395 CWBitGravity : constant := (2**4); -- /usr/include/X11/X.h:396 CWWinGravity : constant := (2**5); -- /usr/include/X11/X.h:397 CWBackingStore : constant := (2**6); -- /usr/include/X11/X.h:398 CWBackingPlanes : constant := (2**7); -- /usr/include/X11/X.h:399 CWBackingPixel : constant := (2**8); -- /usr/include/X11/X.h:400 CWOverrideRedirect : constant := (2**9); -- /usr/include/X11/X.h:401 CWSaveUnder : constant := (2**10); -- /usr/include/X11/X.h:402 CWEventMask : constant := (2**11); -- /usr/include/X11/X.h:403 CWDontPropagate : constant := (2**12); -- /usr/include/X11/X.h:404 CWColormap : constant := (2**13); -- /usr/include/X11/X.h:405 CWCursor : constant := (2**14); -- /usr/include/X11/X.h:406 CWX : constant := (2**0); -- /usr/include/X11/X.h:410 CWY : constant := (2**1); -- /usr/include/X11/X.h:411 CWWidth : constant := (2**2); -- /usr/include/X11/X.h:412 CWHeight : constant := (2**3); -- /usr/include/X11/X.h:413 CWBorderWidth : constant := (2**4); -- /usr/include/X11/X.h:414 CWSibling : constant := (2**5); -- /usr/include/X11/X.h:415 CWStackMode : constant := (2**6); -- /usr/include/X11/X.h:416 ForgetGravity : constant := 0; -- /usr/include/X11/X.h:421 NorthWestGravity : constant := 1; -- /usr/include/X11/X.h:422 NorthGravity : constant := 2; -- /usr/include/X11/X.h:423 NorthEastGravity : constant := 3; -- /usr/include/X11/X.h:424 WestGravity : constant := 4; -- /usr/include/X11/X.h:425 CenterGravity : constant := 5; -- /usr/include/X11/X.h:426 EastGravity : constant := 6; -- /usr/include/X11/X.h:427 SouthWestGravity : constant := 7; -- /usr/include/X11/X.h:428 SouthGravity : constant := 8; -- /usr/include/X11/X.h:429 SouthEastGravity : constant := 9; -- /usr/include/X11/X.h:430 StaticGravity : constant := 10; -- /usr/include/X11/X.h:431 UnmapGravity : constant := 0; -- /usr/include/X11/X.h:435 NotUseful : constant := 0; -- /usr/include/X11/X.h:439 WhenMapped : constant := 1; -- /usr/include/X11/X.h:440 Always : constant := 2; -- /usr/include/X11/X.h:441 IsUnmapped : constant := 0; -- /usr/include/X11/X.h:445 IsUnviewable : constant := 1; -- /usr/include/X11/X.h:446 IsViewable : constant := 2; -- /usr/include/X11/X.h:447 SetModeInsert : constant := 0; -- /usr/include/X11/X.h:451 SetModeDelete : constant := 1; -- /usr/include/X11/X.h:452 DestroyAll : constant := 0; -- /usr/include/X11/X.h:456 RetainPermanent : constant := 1; -- /usr/include/X11/X.h:457 RetainTemporary : constant := 2; -- /usr/include/X11/X.h:458 Above : constant := 0; -- /usr/include/X11/X.h:462 Below : constant := 1; -- /usr/include/X11/X.h:463 TopIf : constant := 2; -- /usr/include/X11/X.h:464 BottomIf : constant := 3; -- /usr/include/X11/X.h:465 Opposite : constant := 4; -- /usr/include/X11/X.h:466 RaiseLowest : constant := 0; -- /usr/include/X11/X.h:470 LowerHighest : constant := 1; -- /usr/include/X11/X.h:471 PropModeReplace : constant := 0; -- /usr/include/X11/X.h:475 PropModePrepend : constant := 1; -- /usr/include/X11/X.h:476 PropModeAppend : constant := 2; -- /usr/include/X11/X.h:477 GXclear : constant := 16#0#; -- /usr/include/X11/X.h:485 GXand : constant := 16#1#; -- /usr/include/X11/X.h:486 GXandReverse : constant := 16#2#; -- /usr/include/X11/X.h:487 GXcopy : constant := 16#3#; -- /usr/include/X11/X.h:488 GXandInverted : constant := 16#4#; -- /usr/include/X11/X.h:489 GXnoop : constant := 16#5#; -- /usr/include/X11/X.h:490 GXxor : constant := 16#6#; -- /usr/include/X11/X.h:491 GXor : constant := 16#7#; -- /usr/include/X11/X.h:492 GXnor : constant := 16#8#; -- /usr/include/X11/X.h:493 GXequiv : constant := 16#9#; -- /usr/include/X11/X.h:494 GXinvert : constant := 16#a#; -- /usr/include/X11/X.h:495 GXorReverse : constant := 16#b#; -- /usr/include/X11/X.h:496 GXcopyInverted : constant := 16#c#; -- /usr/include/X11/X.h:497 GXorInverted : constant := 16#d#; -- /usr/include/X11/X.h:498 GXnand : constant := 16#e#; -- /usr/include/X11/X.h:499 GXset : constant := 16#f#; -- /usr/include/X11/X.h:500 LineSolid : constant := 0; -- /usr/include/X11/X.h:504 LineOnOffDash : constant := 1; -- /usr/include/X11/X.h:505 LineDoubleDash : constant := 2; -- /usr/include/X11/X.h:506 CapNotLast : constant := 0; -- /usr/include/X11/X.h:510 CapButt : constant := 1; -- /usr/include/X11/X.h:511 CapRound : constant := 2; -- /usr/include/X11/X.h:512 CapProjecting : constant := 3; -- /usr/include/X11/X.h:513 JoinMiter : constant := 0; -- /usr/include/X11/X.h:517 JoinRound : constant := 1; -- /usr/include/X11/X.h:518 JoinBevel : constant := 2; -- /usr/include/X11/X.h:519 FillSolid : constant := 0; -- /usr/include/X11/X.h:523 FillTiled : constant := 1; -- /usr/include/X11/X.h:524 FillStippled : constant := 2; -- /usr/include/X11/X.h:525 FillOpaqueStippled : constant := 3; -- /usr/include/X11/X.h:526 EvenOddRule : constant := 0; -- /usr/include/X11/X.h:530 WindingRule : constant := 1; -- /usr/include/X11/X.h:531 ClipByChildren : constant := 0; -- /usr/include/X11/X.h:535 IncludeInferiors : constant := 1; -- /usr/include/X11/X.h:536 Unsorted : constant := 0; -- /usr/include/X11/X.h:540 YSorted : constant := 1; -- /usr/include/X11/X.h:541 YXSorted : constant := 2; -- /usr/include/X11/X.h:542 YXBanded : constant := 3; -- /usr/include/X11/X.h:543 CoordModeOrigin : constant := 0; -- /usr/include/X11/X.h:547 CoordModePrevious : constant := 1; -- /usr/include/X11/X.h:548 Complex : constant := 0; -- /usr/include/X11/X.h:552 Nonconvex : constant := 1; -- /usr/include/X11/X.h:553 Convex : constant := 2; -- /usr/include/X11/X.h:554 ArcChord : constant := 0; -- /usr/include/X11/X.h:558 ArcPieSlice : constant := 1; -- /usr/include/X11/X.h:559 GCFunction : constant := (2**0); -- /usr/include/X11/X.h:564 GCPlaneMask : constant := (2**1); -- /usr/include/X11/X.h:565 GCForeground : constant := (2**2); -- /usr/include/X11/X.h:566 GCBackground : constant := (2**3); -- /usr/include/X11/X.h:567 GCLineWidth : constant := (2**4); -- /usr/include/X11/X.h:568 GCLineStyle : constant := (2**5); -- /usr/include/X11/X.h:569 GCCapStyle : constant := (2**6); -- /usr/include/X11/X.h:570 GCJoinStyle : constant := (2**7); -- /usr/include/X11/X.h:571 GCFillStyle : constant := (2**8); -- /usr/include/X11/X.h:572 GCFillRule : constant := (2**9); -- /usr/include/X11/X.h:573 GCTile : constant := (2**10); -- /usr/include/X11/X.h:574 GCStipple : constant := (2**11); -- /usr/include/X11/X.h:575 GCTileStipXOrigin : constant := (2**12); -- /usr/include/X11/X.h:576 GCTileStipYOrigin : constant := (2**13); -- /usr/include/X11/X.h:577 GCFont : constant := (2**14); -- /usr/include/X11/X.h:578 GCSubwindowMode : constant := (2**15); -- /usr/include/X11/X.h:579 GCGraphicsExposures : constant := (2**16); -- /usr/include/X11/X.h:580 GCClipXOrigin : constant := (2**17); -- /usr/include/X11/X.h:581 GCClipYOrigin : constant := (2**18); -- /usr/include/X11/X.h:582 GCClipMask : constant := (2**19); -- /usr/include/X11/X.h:583 GCDashOffset : constant := (2**20); -- /usr/include/X11/X.h:584 GCDashList : constant := (2**21); -- /usr/include/X11/X.h:585 GCArcMode : constant := (2**22); -- /usr/include/X11/X.h:586 GCLastBit : constant := 22; -- /usr/include/X11/X.h:588 FontLeftToRight : constant := 0; -- /usr/include/X11/X.h:595 FontRightToLeft : constant := 1; -- /usr/include/X11/X.h:596 FontChange : constant := 255; -- /usr/include/X11/X.h:598 XYBitmap : constant := 0; -- /usr/include/X11/X.h:606 XYPixmap : constant := 1; -- /usr/include/X11/X.h:607 ZPixmap : constant := 2; -- /usr/include/X11/X.h:608 AllocNone : constant := 0; -- /usr/include/X11/X.h:616 AllocAll : constant := 1; -- /usr/include/X11/X.h:617 DoRed : constant := (2**0); -- /usr/include/X11/X.h:622 DoGreen : constant := (2**1); -- /usr/include/X11/X.h:623 DoBlue : constant := (2**2); -- /usr/include/X11/X.h:624 CursorShape : constant := 0; -- /usr/include/X11/X.h:632 TileShape : constant := 1; -- /usr/include/X11/X.h:633 StippleShape : constant := 2; -- /usr/include/X11/X.h:634 AutoRepeatModeOff : constant := 0; -- /usr/include/X11/X.h:640 AutoRepeatModeOn : constant := 1; -- /usr/include/X11/X.h:641 AutoRepeatModeDefault : constant := 2; -- /usr/include/X11/X.h:642 LedModeOff : constant := 0; -- /usr/include/X11/X.h:644 LedModeOn : constant := 1; -- /usr/include/X11/X.h:645 KBKeyClickPercent : constant := (2**0); -- /usr/include/X11/X.h:649 KBBellPercent : constant := (2**1); -- /usr/include/X11/X.h:650 KBBellPitch : constant := (2**2); -- /usr/include/X11/X.h:651 KBBellDuration : constant := (2**3); -- /usr/include/X11/X.h:652 KBLed : constant := (2**4); -- /usr/include/X11/X.h:653 KBLedMode : constant := (2**5); -- /usr/include/X11/X.h:654 KBKey : constant := (2**6); -- /usr/include/X11/X.h:655 KBAutoRepeatMode : constant := (2**7); -- /usr/include/X11/X.h:656 MappingSuccess : constant := 0; -- /usr/include/X11/X.h:658 MappingBusy : constant := 1; -- /usr/include/X11/X.h:659 MappingFailed : constant := 2; -- /usr/include/X11/X.h:660 MappingModifier : constant := 0; -- /usr/include/X11/X.h:662 MappingKeyboard : constant := 1; -- /usr/include/X11/X.h:663 MappingPointer : constant := 2; -- /usr/include/X11/X.h:664 DontPreferBlanking : constant := 0; -- /usr/include/X11/X.h:670 PreferBlanking : constant := 1; -- /usr/include/X11/X.h:671 DefaultBlanking : constant := 2; -- /usr/include/X11/X.h:672 DisableScreenSaver : constant := 0; -- /usr/include/X11/X.h:674 DisableScreenInterval : constant := 0; -- /usr/include/X11/X.h:675 DontAllowExposures : constant := 0; -- /usr/include/X11/X.h:677 AllowExposures : constant := 1; -- /usr/include/X11/X.h:678 DefaultExposures : constant := 2; -- /usr/include/X11/X.h:679 ScreenSaverReset : constant := 0; -- /usr/include/X11/X.h:683 ScreenSaverActive : constant := 1; -- /usr/include/X11/X.h:684 HostInsert : constant := 0; -- /usr/include/X11/X.h:692 HostDelete : constant := 1; -- /usr/include/X11/X.h:693 EnableAccess : constant := 1; -- /usr/include/X11/X.h:697 DisableAccess : constant := 0; -- /usr/include/X11/X.h:698 StaticGray : constant := 0; -- /usr/include/X11/X.h:704 GrayScale : constant := 1; -- /usr/include/X11/X.h:705 StaticColor : constant := 2; -- /usr/include/X11/X.h:706 PseudoColor : constant := 3; -- /usr/include/X11/X.h:707 TrueColor : constant := 4; -- /usr/include/X11/X.h:708 DirectColor : constant := 5; -- /usr/include/X11/X.h:709 LSBFirst : constant := 0; -- /usr/include/X11/X.h:714 MSBFirst : constant := 1; -- /usr/include/X11/X.h:715 -- Definitions for the X window system likely to be used by applications --********************************************************** --Copyright 1987, 1998 The Open Group --Permission to use, copy, modify, distribute, and sell this software and its --documentation for any purpose is hereby granted without fee, provided that --the above copyright notice appear in all copies and that both that --copyright notice and this permission notice appear in supporting --documentation. --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 --OPEN GROUP 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 of The Open Group shall not be --used in advertising or otherwise to promote the sale, use or other dealings --in this Software without prior written authorization from The Open Group. --Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. -- All Rights Reserved --Permission to use, copy, modify, and distribute this software and its --documentation for any purpose and without fee is hereby granted, --provided that the above copyright notice appear in all copies and that --both that copyright notice and this permission notice appear in --supporting documentation, and that the name of Digital not be --used in advertising or publicity pertaining to distribution of the --software without specific, written prior permission. --DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING --ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL --DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR --ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, --WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, --ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS --SOFTWARE. --***************************************************************** -- Resources -- * _XSERVER64 must ONLY be defined when compiling X server sources on -- * systems where unsigned long is not 32 bits, must NOT be used in -- * client or library code. -- subtype XID is unsigned_long; -- /usr/include/X11/X.h:66 subtype Mask is unsigned_long; -- /usr/include/X11/X.h:70 -- Also in Xdefs.h subtype Atom is unsigned_long; -- /usr/include/X11/X.h:74 subtype VisualID is unsigned_long; -- /usr/include/X11/X.h:76 subtype Time is unsigned_long; -- /usr/include/X11/X.h:77 subtype Window is XID; -- /usr/include/X11/X.h:96 subtype Drawable is XID; -- /usr/include/X11/X.h:97 subtype Font is XID; -- /usr/include/X11/X.h:100 subtype Pixmap is XID; -- /usr/include/X11/X.h:102 subtype Cursor is XID; -- /usr/include/X11/X.h:103 subtype Colormap is XID; -- /usr/include/X11/X.h:104 subtype GContext is XID; -- /usr/include/X11/X.h:105 subtype KeySym is XID; -- /usr/include/X11/X.h:106 subtype KeyCode is unsigned_char; -- /usr/include/X11/X.h:108 --**************************************************************** -- * RESERVED RESOURCE AND CONSTANT DEFINITIONS -- **************************************************************** --**************************************************************** -- * EVENT DEFINITIONS -- **************************************************************** -- Input Event Masks. Used as event-mask window attribute and as arguments -- to Grab requests. Not to be confused with event names. -- Event names. Used in "type" field in XEvent structures. Not to be --confused with event masks above. They start from 2 because 0 and 1 --are reserved in the protocol for errors and replies. -- Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer, -- state in various key-, mouse-, and button-related events. -- modifier names. Used to build a SetModifierMapping request or -- to read a GetModifierMapping request. These correspond to the -- masks defined above. -- button masks. Used in same manner as Key masks above. Not to be confused -- with button names below. -- button names. Used as arguments to GrabButton and as detail in ButtonPress -- and ButtonRelease events. Not to be confused with button masks above. -- Note that 0 is already defined above as "AnyButton". -- Notify modes -- Notify detail -- Visibility notify -- Circulation request -- protocol families -- authentication families not tied to a specific protocol -- Property notification -- Color Map notification -- GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes -- GrabPointer, GrabKeyboard reply status -- AllowEvents modes -- Used in SetInputFocus, GetInputFocus --**************************************************************** -- * ERROR CODES -- **************************************************************** --**************************************************************** -- * WINDOW DEFINITIONS -- **************************************************************** -- Window classes used by CreateWindow -- Note that CopyFromParent is already defined as 0 above -- Window attributes for CreateWindow and ChangeWindowAttributes -- ConfigureWindow structure -- Bit Gravity -- Window gravity + bit gravity above -- Used in CreateWindow for backing-store hint -- Used in GetWindowAttributes reply -- Used in ChangeSaveSet -- Used in ChangeCloseDownMode -- Window stacking method (in configureWindow) -- Circulation direction -- Property modes --**************************************************************** -- * GRAPHICS DEFINITIONS -- **************************************************************** -- graphics functions, as in GC.alu -- LineStyle -- capStyle -- joinStyle -- fillStyle -- fillRule -- subwindow mode -- SetClipRectangles ordering -- CoordinateMode for drawing routines -- Polygon shapes -- Arc modes for PolyFillArc -- GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into -- GC.stateChanges --**************************************************************** -- * FONTS -- **************************************************************** -- used in QueryFont -- draw direction --**************************************************************** -- * IMAGING -- **************************************************************** -- ImageFormat -- PutImage, GetImage --**************************************************************** -- * COLOR MAP STUFF -- **************************************************************** -- For CreateColormap -- Flags used in StoreNamedColor, StoreColors --**************************************************************** -- * CURSOR STUFF -- **************************************************************** -- QueryBestSize Class --**************************************************************** -- * KEYBOARD/POINTER STUFF -- **************************************************************** -- masks for ChangeKeyboardControl --**************************************************************** -- * SCREEN SAVER STUFF -- **************************************************************** -- for ForceScreenSaver --**************************************************************** -- * HOSTS AND CONNECTIONS -- **************************************************************** -- for ChangeHosts -- for ChangeAccessControl -- Display classes used in opening the connection -- * Note that the statically allocated ones are even numbered and the -- * dynamically changeable ones are odd numbered -- Byte order used in imageByteOrder and bitmapBitOrder end X11;
----------------------------------------------------------------------- -- ADO Sessions -- Sessions Management -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with ADO.Configs; with ADO.Schemas; with ADO.Statements; with ADO.Objects; with ADO.Objects.Cache; with ADO.Connections; with ADO.Queries; with ADO.SQL; with ADO.Caches; with Util.Concurrent.Counters; limited with ADO.Sequences; limited with ADO.Schemas.Entities; limited with ADO.Audits; -- = Session = -- The `ADO.Sessions` package defines the control and management of database sessions. -- The database session is represented by the `Session` or `Master_Session` types. -- It provides operation to create a database statement that can be executed. -- The `Session` type is used to represent read-only database sessions. It provides -- operations to query the database but it does not allow to update or delete content. -- The `Master_Session` type extends the `Session` type to provide write -- access and it provides operations to get update or delete statements. The differentiation -- between the two sessions is provided for the support of database replications with -- databases such as MySQL. -- -- @include ado-drivers.ads -- @include ado-sessions-sources.ads -- @include ado-sessions-factory.ads -- @include ado-caches.ads package ADO.Sessions is use ADO.Statements; -- Raised if the database connection is not open. Session_Error : exception; -- Raised when the connection URI is invalid. Connection_Error : exception renames ADO.Configs.Connection_Error; -- The database connection status type Connection_Status is (OPEN, CLOSED); type Object_Factory is tagged private; -- --------- -- Session -- --------- -- Read-only database connection (or slave connection). -- type Session is tagged private; -- Get the session status. function Get_Status (Database : in Session) return Connection_Status; -- Get the database driver which manages this connection. function Get_Driver (Database : in Session) return ADO.Connections.Driver_Access; -- Close the session. procedure Close (Database : in out Session); -- Insert a new cache in the manager. The cache is identified by the given name. procedure Add_Cache (Database : in out Session; Name : in String; Cache : in ADO.Caches.Cache_Type_Access); -- Attach the object to the session. procedure Attach (Database : in out Session; Object : in ADO.Objects.Object_Ref'Class); -- Check if the session contains the object identified by the given key. function Contains (Database : in Session; Item : in ADO.Objects.Object_Key) return Boolean; -- Remove the object from the session cache. procedure Evict (Database : in out Session; Item : in ADO.Objects.Object_Key); -- Create a query statement. The statement is not prepared function Create_Statement (Database : in Session; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement; -- Create a query statement. The statement is not prepared function Create_Statement (Database : in Session; Query : in String) return Query_Statement; -- Create a query statement. The statement is not prepared function Create_Statement (Database : in Session; Query : in ADO.Queries.Context'Class) return Query_Statement; -- Create a query statement and initialize the SQL statement with the query definition. function Create_Statement (Database : in Session; Query : in ADO.Queries.Query_Definition_Access) return Query_Statement; -- Create a query statement. The statement is not prepared function Create_Statement (Database : in Session; Query : in ADO.SQL.Query'Class; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement; -- Load the database schema definition for the current database. procedure Load_Schema (Database : in Session; Schema : out ADO.Schemas.Schema_Definition); -- Internal method to get the session proxy associated with the given database session. -- The session proxy is associated with some ADO objects to be able to retrieve the database -- session for the implementation of lazy loading. The session proxy is kept until the -- session exist and at least one ADO object is refering to it. function Get_Session_Proxy (Database : in Session) return ADO.Objects.Session_Proxy_Access; -- --------- -- Master Session -- --------- -- Read-write session. -- type Master_Session is new Session with private; -- Start a transaction. procedure Begin_Transaction (Database : in out Master_Session); -- Commit the current transaction. procedure Commit (Database : in out Master_Session); -- Rollback the current transaction. procedure Rollback (Database : in out Master_Session); -- Allocate an identifier for the table. procedure Allocate (Database : in out Master_Session; Id : in out ADO.Objects.Object_Record'Class); -- Flush the objects that were modified. procedure Flush (Database : in out Master_Session); -- Create a delete statement function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement; -- Create an update statement function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement; -- Create an insert statement function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement; -- Get the audit manager. function Get_Audit_Manager (Database : in Master_Session) return access Audits.Audit_Manager'Class; subtype Database_Connection is Connections.Database_Connection; -- Internal operation to get access to the database connection. procedure Access_Connection (Database : in out Master_Session; Process : not null access procedure (Connection : in out Database_Connection'Class)); type Session_Record is limited private; type Session_Record_Access is access all Session_Record; private type Entity_Cache_Access is access ADO.Schemas.Entities.Entity_Cache; type Object_Factory is tagged record A : Integer; end record; type Object_Factory_Access is access all Object_Factory'Class; -- The <b>Session_Record</b> maintains the connection information to the database for -- the duration of the session. It also maintains a cache of application objects -- which is used when session objects are fetched (either through Load or a Find). -- The connection is released and the session record is deleted when the session -- is closed with <b>Close</b>. -- -- For the lazy loading support, each object is associated with a shared <b>Session_Proxy</b> -- object that allows to give access to the session record associated with the object. -- When a session is closed, the <b>Session_Proxy</b> is not deleted but it is simply -- unlinked from the session record. type Session_Record is limited record Counter : Util.Concurrent.Counters.Counter := Util.Concurrent.Counters.ONE; Database : ADO.Connections.Ref.Ref; Proxy : ADO.Objects.Session_Proxy_Access; Cache : ADO.Objects.Cache.Object_Cache; Entities : Entity_Cache_Access; Values : ADO.Caches.Cache_Manager_Access; Queries : ADO.Queries.Query_Manager_Access; end record; type Session is new Ada.Finalization.Controlled with record Impl : Session_Record_Access := null; end record; overriding procedure Adjust (Object : in out Session); overriding procedure Finalize (Object : in out Session); type Factory_Access is access all ADO.Sequences.Factory; type Master_Session is new Session with record Sequences : Factory_Access; Audit : access ADO.Audits.Audit_Manager'Class; end record; procedure Check_Session (Database : in Session'Class; Message : in String := ""); pragma Inline (Check_Session); end ADO.Sessions;
function Factorial (N : Positive) return Positive is Result : Positive := N; Counter : Natural := N - 1; begin for I in reverse 1..Counter loop Result := Result * I; end loop; return Result; end Factorial;
-- This spec has been automatically generated from STM32F7x9.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.MDIOS is pragma Preelaborate; --------------- -- Registers -- --------------- subtype MDIOS_CR_PORT_ADDRESS_Field is HAL.UInt5; -- MDIOS configuration register type MDIOS_CR_Register is record -- Peripheral enable EN : Boolean := False; -- Register write interrupt enable WRIE : Boolean := False; -- Register Read Interrupt Enable RDIE : Boolean := False; -- Error interrupt enable EIE : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Disable Preamble Check DPC : Boolean := False; -- Slaves's address PORT_ADDRESS : MDIOS_CR_PORT_ADDRESS_Field := 16#0#; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_CR_Register use record EN at 0 range 0 .. 0; WRIE at 0 range 1 .. 1; RDIE at 0 range 2 .. 2; EIE at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; DPC at 0 range 7 .. 7; PORT_ADDRESS at 0 range 8 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- MDIOS status register type MDIOS_SR_Register is record -- Read-only. Preamble error flag PERF : Boolean; -- Read-only. Start error flag SERF : Boolean; -- Read-only. Turnaround error flag TERF : Boolean; -- unspecified Reserved_3_31 : HAL.UInt29; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_SR_Register use record PERF at 0 range 0 .. 0; SERF at 0 range 1 .. 1; TERF at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- MDIOS clear flag register type MDIOS_CLRFR_Register is record -- Clear the preamble error flag CPERF : Boolean := False; -- Clear the start error flag CSERF : Boolean := False; -- Clear the turnaround error flag CTERF : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_CLRFR_Register use record CPERF at 0 range 0 .. 0; CSERF at 0 range 1 .. 1; CTERF at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype MDIOS_DINR0_DIN0_Field is HAL.UInt16; -- MDIOS input data register 0 type MDIOS_DINR0_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN0 : MDIOS_DINR0_DIN0_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR0_Register use record DIN0 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR1_DIN1_Field is HAL.UInt16; -- MDIOS input data register 1 type MDIOS_DINR1_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN1 : MDIOS_DINR1_DIN1_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR1_Register use record DIN1 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR2_DIN2_Field is HAL.UInt16; -- MDIOS input data register 2 type MDIOS_DINR2_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN2 : MDIOS_DINR2_DIN2_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR2_Register use record DIN2 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR3_DIN3_Field is HAL.UInt16; -- MDIOS input data register 3 type MDIOS_DINR3_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN3 : MDIOS_DINR3_DIN3_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR3_Register use record DIN3 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR4_DIN4_Field is HAL.UInt16; -- MDIOS input data register 4 type MDIOS_DINR4_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN4 : MDIOS_DINR4_DIN4_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR4_Register use record DIN4 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR5_DIN5_Field is HAL.UInt16; -- MDIOS input data register 5 type MDIOS_DINR5_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN5 : MDIOS_DINR5_DIN5_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR5_Register use record DIN5 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR6_DIN6_Field is HAL.UInt16; -- MDIOS input data register 6 type MDIOS_DINR6_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN6 : MDIOS_DINR6_DIN6_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR6_Register use record DIN6 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR7_DIN7_Field is HAL.UInt16; -- MDIOS input data register 7 type MDIOS_DINR7_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN7 : MDIOS_DINR7_DIN7_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR7_Register use record DIN7 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR8_DIN8_Field is HAL.UInt16; -- MDIOS input data register 8 type MDIOS_DINR8_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN8 : MDIOS_DINR8_DIN8_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR8_Register use record DIN8 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR9_DIN9_Field is HAL.UInt16; -- MDIOS input data register 9 type MDIOS_DINR9_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN9 : MDIOS_DINR9_DIN9_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR9_Register use record DIN9 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR10_DIN10_Field is HAL.UInt16; -- MDIOS input data register 10 type MDIOS_DINR10_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN10 : MDIOS_DINR10_DIN10_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR10_Register use record DIN10 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR11_DIN11_Field is HAL.UInt16; -- MDIOS input data register 11 type MDIOS_DINR11_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN11 : MDIOS_DINR11_DIN11_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR11_Register use record DIN11 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR12_DIN12_Field is HAL.UInt16; -- MDIOS input data register 12 type MDIOS_DINR12_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN12 : MDIOS_DINR12_DIN12_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR12_Register use record DIN12 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR13_DIN13_Field is HAL.UInt16; -- MDIOS input data register 13 type MDIOS_DINR13_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN13 : MDIOS_DINR13_DIN13_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR13_Register use record DIN13 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR14_DIN14_Field is HAL.UInt16; -- MDIOS input data register 14 type MDIOS_DINR14_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN14 : MDIOS_DINR14_DIN14_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR14_Register use record DIN14 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR15_DIN15_Field is HAL.UInt16; -- MDIOS input data register 15 type MDIOS_DINR15_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN15 : MDIOS_DINR15_DIN15_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR15_Register use record DIN15 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR16_DIN16_Field is HAL.UInt16; -- MDIOS input data register 16 type MDIOS_DINR16_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN16 : MDIOS_DINR16_DIN16_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR16_Register use record DIN16 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR17_DIN17_Field is HAL.UInt16; -- MDIOS input data register 17 type MDIOS_DINR17_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN17 : MDIOS_DINR17_DIN17_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR17_Register use record DIN17 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR18_DIN18_Field is HAL.UInt16; -- MDIOS input data register 18 type MDIOS_DINR18_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN18 : MDIOS_DINR18_DIN18_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR18_Register use record DIN18 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR19_DIN19_Field is HAL.UInt16; -- MDIOS input data register 19 type MDIOS_DINR19_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN19 : MDIOS_DINR19_DIN19_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR19_Register use record DIN19 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR20_DIN20_Field is HAL.UInt16; -- MDIOS input data register 20 type MDIOS_DINR20_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN20 : MDIOS_DINR20_DIN20_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR20_Register use record DIN20 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR21_DIN21_Field is HAL.UInt16; -- MDIOS input data register 21 type MDIOS_DINR21_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN21 : MDIOS_DINR21_DIN21_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR21_Register use record DIN21 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR22_DIN22_Field is HAL.UInt16; -- MDIOS input data register 22 type MDIOS_DINR22_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN22 : MDIOS_DINR22_DIN22_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR22_Register use record DIN22 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR23_DIN23_Field is HAL.UInt16; -- MDIOS input data register 23 type MDIOS_DINR23_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN23 : MDIOS_DINR23_DIN23_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR23_Register use record DIN23 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR24_DIN24_Field is HAL.UInt16; -- MDIOS input data register 24 type MDIOS_DINR24_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN24 : MDIOS_DINR24_DIN24_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR24_Register use record DIN24 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR25_DIN25_Field is HAL.UInt16; -- MDIOS input data register 25 type MDIOS_DINR25_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN25 : MDIOS_DINR25_DIN25_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR25_Register use record DIN25 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR26_DIN26_Field is HAL.UInt16; -- MDIOS input data register 26 type MDIOS_DINR26_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN26 : MDIOS_DINR26_DIN26_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR26_Register use record DIN26 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR27_DIN27_Field is HAL.UInt16; -- MDIOS input data register 27 type MDIOS_DINR27_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN27 : MDIOS_DINR27_DIN27_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR27_Register use record DIN27 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR28_DIN28_Field is HAL.UInt16; -- MDIOS input data register 28 type MDIOS_DINR28_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN28 : MDIOS_DINR28_DIN28_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR28_Register use record DIN28 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR29_DIN29_Field is HAL.UInt16; -- MDIOS input data register 29 type MDIOS_DINR29_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN29 : MDIOS_DINR29_DIN29_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR29_Register use record DIN29 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR30_DIN30_Field is HAL.UInt16; -- MDIOS input data register 30 type MDIOS_DINR30_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN30 : MDIOS_DINR30_DIN30_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR30_Register use record DIN30 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DINR31_DIN31_Field is HAL.UInt16; -- MDIOS input data register 31 type MDIOS_DINR31_Register is record -- Read-only. Input data received from MDIO Master during write frames DIN31 : MDIOS_DINR31_DIN31_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DINR31_Register use record DIN31 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR0_DOUT0_Field is HAL.UInt16; -- MDIOS output data register 0 type MDIOS_DOUTR0_Register is record -- Output data sent to MDIO Master during read frames DOUT0 : MDIOS_DOUTR0_DOUT0_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR0_Register use record DOUT0 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR1_DOUT1_Field is HAL.UInt16; -- MDIOS output data register 1 type MDIOS_DOUTR1_Register is record -- Output data sent to MDIO Master during read frames DOUT1 : MDIOS_DOUTR1_DOUT1_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR1_Register use record DOUT1 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR2_DOUT2_Field is HAL.UInt16; -- MDIOS output data register 2 type MDIOS_DOUTR2_Register is record -- Output data sent to MDIO Master during read frames DOUT2 : MDIOS_DOUTR2_DOUT2_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR2_Register use record DOUT2 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR3_DOUT3_Field is HAL.UInt16; -- MDIOS output data register 3 type MDIOS_DOUTR3_Register is record -- Output data sent to MDIO Master during read frames DOUT3 : MDIOS_DOUTR3_DOUT3_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR3_Register use record DOUT3 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR4_DOUT4_Field is HAL.UInt16; -- MDIOS output data register 4 type MDIOS_DOUTR4_Register is record -- Output data sent to MDIO Master during read frames DOUT4 : MDIOS_DOUTR4_DOUT4_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR4_Register use record DOUT4 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR5_DOUT5_Field is HAL.UInt16; -- MDIOS output data register 5 type MDIOS_DOUTR5_Register is record -- Output data sent to MDIO Master during read frames DOUT5 : MDIOS_DOUTR5_DOUT5_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR5_Register use record DOUT5 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR6_DOUT6_Field is HAL.UInt16; -- MDIOS output data register 6 type MDIOS_DOUTR6_Register is record -- Output data sent to MDIO Master during read frames DOUT6 : MDIOS_DOUTR6_DOUT6_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR6_Register use record DOUT6 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR7_DOUT7_Field is HAL.UInt16; -- MDIOS output data register 7 type MDIOS_DOUTR7_Register is record -- Output data sent to MDIO Master during read frames DOUT7 : MDIOS_DOUTR7_DOUT7_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR7_Register use record DOUT7 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR8_DOUT8_Field is HAL.UInt16; -- MDIOS output data register 8 type MDIOS_DOUTR8_Register is record -- Output data sent to MDIO Master during read frames DOUT8 : MDIOS_DOUTR8_DOUT8_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR8_Register use record DOUT8 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR9_DOUT9_Field is HAL.UInt16; -- MDIOS output data register 9 type MDIOS_DOUTR9_Register is record -- Output data sent to MDIO Master during read frames DOUT9 : MDIOS_DOUTR9_DOUT9_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR9_Register use record DOUT9 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR10_DOUT10_Field is HAL.UInt16; -- MDIOS output data register 10 type MDIOS_DOUTR10_Register is record -- Output data sent to MDIO Master during read frames DOUT10 : MDIOS_DOUTR10_DOUT10_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR10_Register use record DOUT10 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR11_DOUT11_Field is HAL.UInt16; -- MDIOS output data register 11 type MDIOS_DOUTR11_Register is record -- Output data sent to MDIO Master during read frames DOUT11 : MDIOS_DOUTR11_DOUT11_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR11_Register use record DOUT11 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR12_DOUT12_Field is HAL.UInt16; -- MDIOS output data register 12 type MDIOS_DOUTR12_Register is record -- Output data sent to MDIO Master during read frames DOUT12 : MDIOS_DOUTR12_DOUT12_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR12_Register use record DOUT12 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR13_DOUT13_Field is HAL.UInt16; -- MDIOS output data register 13 type MDIOS_DOUTR13_Register is record -- Output data sent to MDIO Master during read frames DOUT13 : MDIOS_DOUTR13_DOUT13_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR13_Register use record DOUT13 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR14_DOUT14_Field is HAL.UInt16; -- MDIOS output data register 14 type MDIOS_DOUTR14_Register is record -- Output data sent to MDIO Master during read frames DOUT14 : MDIOS_DOUTR14_DOUT14_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR14_Register use record DOUT14 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR15_DOUT15_Field is HAL.UInt16; -- MDIOS output data register 15 type MDIOS_DOUTR15_Register is record -- Output data sent to MDIO Master during read frames DOUT15 : MDIOS_DOUTR15_DOUT15_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR15_Register use record DOUT15 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR16_DOUT16_Field is HAL.UInt16; -- MDIOS output data register 16 type MDIOS_DOUTR16_Register is record -- Output data sent to MDIO Master during read frames DOUT16 : MDIOS_DOUTR16_DOUT16_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR16_Register use record DOUT16 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR17_DOUT17_Field is HAL.UInt16; -- MDIOS output data register 17 type MDIOS_DOUTR17_Register is record -- Output data sent to MDIO Master during read frames DOUT17 : MDIOS_DOUTR17_DOUT17_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR17_Register use record DOUT17 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR18_DOUT18_Field is HAL.UInt16; -- MDIOS output data register 18 type MDIOS_DOUTR18_Register is record -- Output data sent to MDIO Master during read frames DOUT18 : MDIOS_DOUTR18_DOUT18_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR18_Register use record DOUT18 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR19_DOUT19_Field is HAL.UInt16; -- MDIOS output data register 19 type MDIOS_DOUTR19_Register is record -- Output data sent to MDIO Master during read frames DOUT19 : MDIOS_DOUTR19_DOUT19_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR19_Register use record DOUT19 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR20_DOUT20_Field is HAL.UInt16; -- MDIOS output data register 20 type MDIOS_DOUTR20_Register is record -- Output data sent to MDIO Master during read frames DOUT20 : MDIOS_DOUTR20_DOUT20_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR20_Register use record DOUT20 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR21_DOUT21_Field is HAL.UInt16; -- MDIOS output data register 21 type MDIOS_DOUTR21_Register is record -- Output data sent to MDIO Master during read frames DOUT21 : MDIOS_DOUTR21_DOUT21_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR21_Register use record DOUT21 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR22_DOUT22_Field is HAL.UInt16; -- MDIOS output data register 22 type MDIOS_DOUTR22_Register is record -- Output data sent to MDIO Master during read frames DOUT22 : MDIOS_DOUTR22_DOUT22_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR22_Register use record DOUT22 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR23_DOUT23_Field is HAL.UInt16; -- MDIOS output data register 23 type MDIOS_DOUTR23_Register is record -- Output data sent to MDIO Master during read frames DOUT23 : MDIOS_DOUTR23_DOUT23_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR23_Register use record DOUT23 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR24_DOUT24_Field is HAL.UInt16; -- MDIOS output data register 24 type MDIOS_DOUTR24_Register is record -- Output data sent to MDIO Master during read frames DOUT24 : MDIOS_DOUTR24_DOUT24_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR24_Register use record DOUT24 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR25_DOUT25_Field is HAL.UInt16; -- MDIOS output data register 25 type MDIOS_DOUTR25_Register is record -- Output data sent to MDIO Master during read frames DOUT25 : MDIOS_DOUTR25_DOUT25_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR25_Register use record DOUT25 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR26_DOUT26_Field is HAL.UInt16; -- MDIOS output data register 26 type MDIOS_DOUTR26_Register is record -- Output data sent to MDIO Master during read frames DOUT26 : MDIOS_DOUTR26_DOUT26_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR26_Register use record DOUT26 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR27_DOUT27_Field is HAL.UInt16; -- MDIOS output data register 27 type MDIOS_DOUTR27_Register is record -- Output data sent to MDIO Master during read frames DOUT27 : MDIOS_DOUTR27_DOUT27_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR27_Register use record DOUT27 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR28_DOUT28_Field is HAL.UInt16; -- MDIOS output data register 28 type MDIOS_DOUTR28_Register is record -- Output data sent to MDIO Master during read frames DOUT28 : MDIOS_DOUTR28_DOUT28_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR28_Register use record DOUT28 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR29_DOUT29_Field is HAL.UInt16; -- MDIOS output data register 29 type MDIOS_DOUTR29_Register is record -- Output data sent to MDIO Master during read frames DOUT29 : MDIOS_DOUTR29_DOUT29_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR29_Register use record DOUT29 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR30_DOUT30_Field is HAL.UInt16; -- MDIOS output data register 30 type MDIOS_DOUTR30_Register is record -- Output data sent to MDIO Master during read frames DOUT30 : MDIOS_DOUTR30_DOUT30_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR30_Register use record DOUT30 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MDIOS_DOUTR31_DOUT31_Field is HAL.UInt16; -- MDIOS output data register 31 type MDIOS_DOUTR31_Register is record -- Output data sent to MDIO Master during read frames DOUT31 : MDIOS_DOUTR31_DOUT31_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MDIOS_DOUTR31_Register use record DOUT31 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Management data input/output slave type MDIOS_Peripheral is record -- MDIOS configuration register MDIOS_CR : aliased MDIOS_CR_Register; -- MDIOS write flag register MDIOS_WRFR : aliased HAL.UInt32; -- MDIOS clear write flag register MDIOS_CWRFR : aliased HAL.UInt32; -- MDIOS read flag register MDIOS_RDFR : aliased HAL.UInt32; -- MDIOS clear read flag register MDIOS_CRDFR : aliased HAL.UInt32; -- MDIOS status register MDIOS_SR : aliased MDIOS_SR_Register; -- MDIOS clear flag register MDIOS_CLRFR : aliased MDIOS_CLRFR_Register; -- MDIOS input data register 0 MDIOS_DINR0 : aliased MDIOS_DINR0_Register; -- MDIOS input data register 1 MDIOS_DINR1 : aliased MDIOS_DINR1_Register; -- MDIOS input data register 2 MDIOS_DINR2 : aliased MDIOS_DINR2_Register; -- MDIOS input data register 3 MDIOS_DINR3 : aliased MDIOS_DINR3_Register; -- MDIOS input data register 4 MDIOS_DINR4 : aliased MDIOS_DINR4_Register; -- MDIOS input data register 5 MDIOS_DINR5 : aliased MDIOS_DINR5_Register; -- MDIOS input data register 6 MDIOS_DINR6 : aliased MDIOS_DINR6_Register; -- MDIOS input data register 7 MDIOS_DINR7 : aliased MDIOS_DINR7_Register; -- MDIOS input data register 8 MDIOS_DINR8 : aliased MDIOS_DINR8_Register; -- MDIOS input data register 9 MDIOS_DINR9 : aliased MDIOS_DINR9_Register; -- MDIOS input data register 10 MDIOS_DINR10 : aliased MDIOS_DINR10_Register; -- MDIOS input data register 11 MDIOS_DINR11 : aliased MDIOS_DINR11_Register; -- MDIOS input data register 12 MDIOS_DINR12 : aliased MDIOS_DINR12_Register; -- MDIOS input data register 13 MDIOS_DINR13 : aliased MDIOS_DINR13_Register; -- MDIOS input data register 14 MDIOS_DINR14 : aliased MDIOS_DINR14_Register; -- MDIOS input data register 15 MDIOS_DINR15 : aliased MDIOS_DINR15_Register; -- MDIOS input data register 16 MDIOS_DINR16 : aliased MDIOS_DINR16_Register; -- MDIOS input data register 17 MDIOS_DINR17 : aliased MDIOS_DINR17_Register; -- MDIOS input data register 18 MDIOS_DINR18 : aliased MDIOS_DINR18_Register; -- MDIOS input data register 19 MDIOS_DINR19 : aliased MDIOS_DINR19_Register; -- MDIOS input data register 20 MDIOS_DINR20 : aliased MDIOS_DINR20_Register; -- MDIOS input data register 21 MDIOS_DINR21 : aliased MDIOS_DINR21_Register; -- MDIOS input data register 22 MDIOS_DINR22 : aliased MDIOS_DINR22_Register; -- MDIOS input data register 23 MDIOS_DINR23 : aliased MDIOS_DINR23_Register; -- MDIOS input data register 24 MDIOS_DINR24 : aliased MDIOS_DINR24_Register; -- MDIOS input data register 25 MDIOS_DINR25 : aliased MDIOS_DINR25_Register; -- MDIOS input data register 26 MDIOS_DINR26 : aliased MDIOS_DINR26_Register; -- MDIOS input data register 27 MDIOS_DINR27 : aliased MDIOS_DINR27_Register; -- MDIOS input data register 28 MDIOS_DINR28 : aliased MDIOS_DINR28_Register; -- MDIOS input data register 29 MDIOS_DINR29 : aliased MDIOS_DINR29_Register; -- MDIOS input data register 30 MDIOS_DINR30 : aliased MDIOS_DINR30_Register; -- MDIOS input data register 31 MDIOS_DINR31 : aliased MDIOS_DINR31_Register; -- MDIOS output data register 0 MDIOS_DOUTR0 : aliased MDIOS_DOUTR0_Register; -- MDIOS output data register 1 MDIOS_DOUTR1 : aliased MDIOS_DOUTR1_Register; -- MDIOS output data register 2 MDIOS_DOUTR2 : aliased MDIOS_DOUTR2_Register; -- MDIOS output data register 3 MDIOS_DOUTR3 : aliased MDIOS_DOUTR3_Register; -- MDIOS output data register 4 MDIOS_DOUTR4 : aliased MDIOS_DOUTR4_Register; -- MDIOS output data register 5 MDIOS_DOUTR5 : aliased MDIOS_DOUTR5_Register; -- MDIOS output data register 6 MDIOS_DOUTR6 : aliased MDIOS_DOUTR6_Register; -- MDIOS output data register 7 MDIOS_DOUTR7 : aliased MDIOS_DOUTR7_Register; -- MDIOS output data register 8 MDIOS_DOUTR8 : aliased MDIOS_DOUTR8_Register; -- MDIOS output data register 9 MDIOS_DOUTR9 : aliased MDIOS_DOUTR9_Register; -- MDIOS output data register 10 MDIOS_DOUTR10 : aliased MDIOS_DOUTR10_Register; -- MDIOS output data register 11 MDIOS_DOUTR11 : aliased MDIOS_DOUTR11_Register; -- MDIOS output data register 12 MDIOS_DOUTR12 : aliased MDIOS_DOUTR12_Register; -- MDIOS output data register 13 MDIOS_DOUTR13 : aliased MDIOS_DOUTR13_Register; -- MDIOS output data register 14 MDIOS_DOUTR14 : aliased MDIOS_DOUTR14_Register; -- MDIOS output data register 15 MDIOS_DOUTR15 : aliased MDIOS_DOUTR15_Register; -- MDIOS output data register 16 MDIOS_DOUTR16 : aliased MDIOS_DOUTR16_Register; -- MDIOS output data register 17 MDIOS_DOUTR17 : aliased MDIOS_DOUTR17_Register; -- MDIOS output data register 18 MDIOS_DOUTR18 : aliased MDIOS_DOUTR18_Register; -- MDIOS output data register 19 MDIOS_DOUTR19 : aliased MDIOS_DOUTR19_Register; -- MDIOS output data register 20 MDIOS_DOUTR20 : aliased MDIOS_DOUTR20_Register; -- MDIOS output data register 21 MDIOS_DOUTR21 : aliased MDIOS_DOUTR21_Register; -- MDIOS output data register 22 MDIOS_DOUTR22 : aliased MDIOS_DOUTR22_Register; -- MDIOS output data register 23 MDIOS_DOUTR23 : aliased MDIOS_DOUTR23_Register; -- MDIOS output data register 24 MDIOS_DOUTR24 : aliased MDIOS_DOUTR24_Register; -- MDIOS output data register 25 MDIOS_DOUTR25 : aliased MDIOS_DOUTR25_Register; -- MDIOS output data register 26 MDIOS_DOUTR26 : aliased MDIOS_DOUTR26_Register; -- MDIOS output data register 27 MDIOS_DOUTR27 : aliased MDIOS_DOUTR27_Register; -- MDIOS output data register 28 MDIOS_DOUTR28 : aliased MDIOS_DOUTR28_Register; -- MDIOS output data register 29 MDIOS_DOUTR29 : aliased MDIOS_DOUTR29_Register; -- MDIOS output data register 30 MDIOS_DOUTR30 : aliased MDIOS_DOUTR30_Register; -- MDIOS output data register 31 MDIOS_DOUTR31 : aliased MDIOS_DOUTR31_Register; end record with Volatile; for MDIOS_Peripheral use record MDIOS_CR at 16#0# range 0 .. 31; MDIOS_WRFR at 16#4# range 0 .. 31; MDIOS_CWRFR at 16#8# range 0 .. 31; MDIOS_RDFR at 16#C# range 0 .. 31; MDIOS_CRDFR at 16#10# range 0 .. 31; MDIOS_SR at 16#14# range 0 .. 31; MDIOS_CLRFR at 16#18# range 0 .. 31; MDIOS_DINR0 at 16#1C# range 0 .. 31; MDIOS_DINR1 at 16#20# range 0 .. 31; MDIOS_DINR2 at 16#24# range 0 .. 31; MDIOS_DINR3 at 16#28# range 0 .. 31; MDIOS_DINR4 at 16#2C# range 0 .. 31; MDIOS_DINR5 at 16#30# range 0 .. 31; MDIOS_DINR6 at 16#34# range 0 .. 31; MDIOS_DINR7 at 16#38# range 0 .. 31; MDIOS_DINR8 at 16#3C# range 0 .. 31; MDIOS_DINR9 at 16#40# range 0 .. 31; MDIOS_DINR10 at 16#44# range 0 .. 31; MDIOS_DINR11 at 16#48# range 0 .. 31; MDIOS_DINR12 at 16#4C# range 0 .. 31; MDIOS_DINR13 at 16#50# range 0 .. 31; MDIOS_DINR14 at 16#54# range 0 .. 31; MDIOS_DINR15 at 16#58# range 0 .. 31; MDIOS_DINR16 at 16#5C# range 0 .. 31; MDIOS_DINR17 at 16#60# range 0 .. 31; MDIOS_DINR18 at 16#64# range 0 .. 31; MDIOS_DINR19 at 16#68# range 0 .. 31; MDIOS_DINR20 at 16#6C# range 0 .. 31; MDIOS_DINR21 at 16#70# range 0 .. 31; MDIOS_DINR22 at 16#74# range 0 .. 31; MDIOS_DINR23 at 16#78# range 0 .. 31; MDIOS_DINR24 at 16#7C# range 0 .. 31; MDIOS_DINR25 at 16#80# range 0 .. 31; MDIOS_DINR26 at 16#84# range 0 .. 31; MDIOS_DINR27 at 16#88# range 0 .. 31; MDIOS_DINR28 at 16#8C# range 0 .. 31; MDIOS_DINR29 at 16#90# range 0 .. 31; MDIOS_DINR30 at 16#94# range 0 .. 31; MDIOS_DINR31 at 16#98# range 0 .. 31; MDIOS_DOUTR0 at 16#9C# range 0 .. 31; MDIOS_DOUTR1 at 16#A0# range 0 .. 31; MDIOS_DOUTR2 at 16#A4# range 0 .. 31; MDIOS_DOUTR3 at 16#A8# range 0 .. 31; MDIOS_DOUTR4 at 16#AC# range 0 .. 31; MDIOS_DOUTR5 at 16#B0# range 0 .. 31; MDIOS_DOUTR6 at 16#B4# range 0 .. 31; MDIOS_DOUTR7 at 16#B8# range 0 .. 31; MDIOS_DOUTR8 at 16#BC# range 0 .. 31; MDIOS_DOUTR9 at 16#C0# range 0 .. 31; MDIOS_DOUTR10 at 16#C4# range 0 .. 31; MDIOS_DOUTR11 at 16#C8# range 0 .. 31; MDIOS_DOUTR12 at 16#CC# range 0 .. 31; MDIOS_DOUTR13 at 16#D0# range 0 .. 31; MDIOS_DOUTR14 at 16#D4# range 0 .. 31; MDIOS_DOUTR15 at 16#D8# range 0 .. 31; MDIOS_DOUTR16 at 16#DC# range 0 .. 31; MDIOS_DOUTR17 at 16#E0# range 0 .. 31; MDIOS_DOUTR18 at 16#E4# range 0 .. 31; MDIOS_DOUTR19 at 16#E8# range 0 .. 31; MDIOS_DOUTR20 at 16#EC# range 0 .. 31; MDIOS_DOUTR21 at 16#F0# range 0 .. 31; MDIOS_DOUTR22 at 16#F4# range 0 .. 31; MDIOS_DOUTR23 at 16#F8# range 0 .. 31; MDIOS_DOUTR24 at 16#FC# range 0 .. 31; MDIOS_DOUTR25 at 16#100# range 0 .. 31; MDIOS_DOUTR26 at 16#104# range 0 .. 31; MDIOS_DOUTR27 at 16#108# range 0 .. 31; MDIOS_DOUTR28 at 16#10C# range 0 .. 31; MDIOS_DOUTR29 at 16#110# range 0 .. 31; MDIOS_DOUTR30 at 16#114# range 0 .. 31; MDIOS_DOUTR31 at 16#118# range 0 .. 31; end record; -- Management data input/output slave MDIOS_Periph : aliased MDIOS_Peripheral with Import, Address => System'To_Address (16#40017800#); end STM32_SVD.MDIOS;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . T E X T _ I O -- -- -- -- B o d y -- -- -- -- 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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Xilinx XPS UART16550 version of this package -- The UART interface is configured for 115200 baud rate, 8-bits, no parity -- and 1 stop bit. The baud rate is set by the constant below. This package -- uses a simple polling interface. with Interfaces; with System; with System.BB.Board_Parameters; package body System.Text_IO is use Interfaces; Baud_Rate : constant := 115_200; -- XPS UART16550 Registers pragma Warnings (Off, "*is not referenced*"); -- Disable warnings on unused interface entities UART16550_Base_Address : constant := 16#83E0_0000#; Receiver_Buffer_Offset : constant := 16#1000#; Transmitter_Holding_Offset : constant := 16#1000#; Interrupt_Enable_Offset : constant := 16#1004#; Interrupt_Identification_Offset : constant := 16#1008#; FIFO_Control_Offset : constant := 16#1008#; Line_Control_Offset : constant := 16#100C#; Modem_Control_Offset : constant := 16#1010#; Line_Status_Offset : constant := 16#1014#; Modem_Status_Offset : constant := 16#1018#; Scratch_Offset : constant := 16#101C#; Divisor_Latch_Low_Offset : constant := 16#1000#; Divisor_Latch_High_Offset : constant := 16#1004#; type Interrupt_Enable is record Enable_Modem_Status_Interrupt : Boolean; Enable_Receiver_Line_Status_Interrupt : Boolean; Enable_Transmitter_Holding_Register_Empty_Interrupt : Boolean; Enable_Received_Data_Available_Interrupt : Boolean; end record with Size => 32; for Interrupt_Enable use record Enable_Modem_Status_Interrupt at 0 range 28 .. 28; Enable_Receiver_Line_Status_Interrupt at 0 range 29 .. 29; Enable_Transmitter_Holding_Register_Empty_Interrupt at 0 range 30 .. 30; Enable_Received_Data_Available_Interrupt at 0 range 31 .. 31; end record; type UART16550_Interrupt_ID is (Modem_Status, Transmitter_Holding_Register_Empty, Received_Data_Available, Receiver_Line_Status, Character_Timeout); type Interrupt_Identification is record FIFOs_Enabled : Boolean; Interrupt_ID : UART16550_Interrupt_ID; Interrupt_Not_Pending : Boolean; end record with Size => 32; for Interrupt_Identification use record FIFOs_Enabled at 0 range 24 .. 25; Interrupt_ID at 0 range 28 .. 30; Interrupt_Not_Pending at 0 range 31 .. 31; end record; type Stop_Bits_Type is (One, Two); type Word_Length_Type is (Five, Six, Seven, Eight); type Line_Control is record Divisor_Latch_Access : Boolean; Set_Break : Boolean; Stick_Parity : Boolean; Even_Parity : Boolean; Parity_Enable : Boolean; Stop_Bits : Stop_Bits_Type; Word_Length : Word_Length_Type; end record with Size => 32; for Line_Control use record Divisor_Latch_Access at 0 range 24 .. 24; Set_Break at 0 range 25 .. 25; Stick_Parity at 0 range 26 .. 26; Even_Parity at 0 range 27 .. 27; Parity_Enable at 0 range 28 .. 28; Stop_Bits at 0 range 29 .. 29; Word_Length at 0 range 30 .. 31; end record; type Line_Status is record Error_in_RCVR_FIFO : Boolean; Transmitter_Empty : Boolean; Transmitter_Holding_Register_Empty : Boolean; Break_Interrupt : Boolean; Framing_Error : Boolean; Parity_Error : Boolean; Overrun_Error : Boolean; Data_Ready : Boolean; end record with Size => 32; for Line_Status use record Error_in_RCVR_FIFO at 0 range 24 .. 24; Transmitter_Empty at 0 range 25 .. 25; Transmitter_Holding_Register_Empty at 0 range 26 .. 26; Break_Interrupt at 0 range 27 .. 27; Framing_Error at 0 range 28 .. 28; Parity_Error at 0 range 29 .. 29; Overrun_Error at 0 range 30 .. 30; Data_Ready at 0 range 31 .. 31; end record; Receiver_Buffer_Register : Character with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Receiver_Buffer_Offset + 3); Transmitter_Holding_Register : Character with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Transmitter_Holding_Offset + 3); Interrupt_Enable_Register : Interrupt_Enable with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Interrupt_Enable_Offset); Interrupt_Identification_Register : Interrupt_Identification with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Interrupt_Identification_Offset); Line_Control_Register : Line_Control with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Line_Control_Offset); Line_Status_Register : Line_Status with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Line_Status_Offset); Divisor_Latch_Low : Unsigned_32 with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Divisor_Latch_Low_Offset); Divisor_Latch_High : Unsigned_32 with Volatile_Full_Access, Address => System'To_Address (UART16550_Base_Address + Divisor_Latch_High_Offset); pragma Warnings (On, "*is not referenced*"); -- Restore warnings --------- -- Get -- --------- function Get return Character is begin -- Retrive character from receiver buffer return Receiver_Buffer_Register; end Get; ---------------- -- Initialize -- ---------------- procedure Initialize is Divisor : constant Unsigned_32 := System.BB.Board_Parameters.PLB_Clock_Frequency / (Baud_Rate * 16); begin -- Configured the UART for 115200 baud rate, 8-bits, no parity -- and 1 stop bit. -- Set divisor latch Line_Control_Register.Divisor_Latch_Access := True; Divisor_Latch_Low := Divisor; Divisor_Latch_High := Shift_Right (Divisor, 8); -- Setup Line Control Register Line_Control_Register := (Divisor_Latch_Access => False, Set_Break => False, Stick_Parity => False, Even_Parity => True, Parity_Enable => False, Stop_Bits => One, Word_Length => Eight); Initialized := True; end Initialize; ----------------- -- Is_Rx_Ready -- ----------------- function Is_Rx_Ready return Boolean is begin return Line_Status_Register.Data_Ready; end Is_Rx_Ready; ----------------- -- Is_Tx_Ready -- ----------------- function Is_Tx_Ready return Boolean is begin return Line_Status_Register.Transmitter_Holding_Register_Empty; end Is_Tx_Ready; --------- -- Put -- --------- procedure Put (C : Character) is begin -- Send the character Transmitter_Holding_Register := C; end Put; ---------------------------- -- Use_Cr_Lf_For_New_Line -- ---------------------------- function Use_Cr_Lf_For_New_Line return Boolean is begin return True; end Use_Cr_Lf_For_New_Line; end System.Text_IO;
with Ada.Exception_Identification.From_Here; with Ada.Exceptions.Finally; with System.Formatting; with System.Long_Long_Integer_Types; with C.signal; with C.sys.ioctl; with C.unistd; package body System.Native_Text_IO is use Ada.Exception_Identification.From_Here; use type Ada.Streams.Stream_Element_Offset; use type C.signed_int; use type C.unsigned_char; -- cc_t use type C.unsigned_int; -- tcflag_t in Linux or FreeBSD use type C.unsigned_long; -- tcflag_t in Darwin subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; procedure tcgetsetattr ( Handle : Handle_Type; Action : C.signed_int; Mask : C.termios.tcflag_t; Min : C.termios.cc_t; Saved_Settings : not null access C.termios.struct_termios); procedure tcgetsetattr ( Handle : Handle_Type; Action : C.signed_int; Mask : C.termios.tcflag_t; Min : C.termios.cc_t; Saved_Settings : not null access C.termios.struct_termios) is Settings : aliased C.termios.struct_termios; begin -- get current terminal mode if C.termios.tcgetattr (Handle, Saved_Settings) < 0 then Raise_Exception (Device_Error'Identity); end if; -- set non-canonical mode Settings := Saved_Settings.all; Settings.c_lflag := Settings.c_lflag and Mask; Settings.c_cc (C.termios.VTIME) := 0; -- wait 0.0 sec Settings.c_cc (C.termios.VMIN) := Min; -- wait Min bytes if C.termios.tcsetattr (Handle, Action, Settings'Access) < 0 then Raise_Exception (Device_Error'Identity); end if; end tcgetsetattr; procedure Read_Escape_Sequence ( Handle : Handle_Type; Item : out String; Last : out Natural; Read_Until : Character); procedure Read_Escape_Sequence ( Handle : Handle_Type; Item : out String; Last : out Natural; Read_Until : Character) is Read_Length : Ada.Streams.Stream_Element_Offset; begin Last := Item'First - 1; loop Native_IO.Read ( Handle, Item (Last + 1)'Address, 1, Read_Length); if Read_Length < 0 then Raise_Exception (Device_Error'Identity); end if; exit when Read_Length = 0; if Last < Item'First then -- skip until 16#1b# if Item (Last + 1) = Character'Val (16#1b#) then Last := Last + 1; end if; else Last := Last + 1; exit when Item (Last) = Read_Until or else Last >= Item'Last; end if; end loop; end Read_Escape_Sequence; procedure Parse_Escape_Sequence ( Item : String; Prefix : String; Postfix : Character; X1, X2 : out Word_Unsigned); procedure Parse_Escape_Sequence ( Item : String; Prefix : String; Postfix : Character; X1, X2 : out Word_Unsigned) is P : Natural; Error : Boolean; L : constant Natural := Item'First + (Prefix'Length - 1); begin if L > Item'Last or else Item (Item'First .. L) /= Prefix then Error := True; else Formatting.Value ( Item (L + 1 .. Item'Last), P, X1, Error => Error); if not Error then if P >= Item'Last or else Item (P + 1) /= ';' then Error := True; else Formatting.Value ( Item (P + 2 .. Item'Last), P, X2, Error => Error); if not Error and then (P + 1 /= Item'Last or else Item (P + 1) /= Postfix) then Error := True; end if; end if; end if; end if; if Error then Raise_Exception (Data_Error'Identity); end if; end Parse_Escape_Sequence; State_Stack_Count : Natural := 0; -- implementation procedure Write_Just ( Handle : Handle_Type; Item : String) is Written_Length : Ada.Streams.Stream_Element_Offset; begin Native_IO.Write ( Handle, Item'Address, Item'Length, Written_Length); if Written_Length < 0 then Raise_Exception (Device_Error'Identity); end if; end Write_Just; procedure Terminal_Size ( Handle : Handle_Type; Line_Length, Page_Length : out Natural) is WS : aliased C.sys.ioctl.struct_winsize; begin if C.sys.ioctl.ioctl (Handle, C.sys.ioctl.TIOCGWINSZ, WS'Access) < 0 then Raise_Exception (Device_Error'Identity); else Line_Length := Natural (WS.ws_col); Page_Length := Natural (WS.ws_row); end if; end Terminal_Size; procedure Set_Terminal_Size ( Handle : Handle_Type; Line_Length, Page_Length : Natural) is Seq : String (1 .. 256); Last : Natural := 0; Error : Boolean; begin Seq (1) := Character'Val (16#1b#); Seq (2) := '['; Seq (3) := '8'; Seq (4) := ';'; Last := 4; Formatting.Image ( Word_Unsigned (Page_Length), Seq (Last + 1 .. Seq'Last), Last, Error => Error); Last := Last + 1; Seq (Last) := ';'; Formatting.Image ( Word_Unsigned (Line_Length), Seq (Last + 1 .. Seq'Last), Last, Error => Error); Last := Last + 1; Seq (Last) := 't'; Write_Just (Handle, Seq (1 .. Last)); end Set_Terminal_Size; procedure Terminal_View ( Handle : Handle_Type; Left, Top : out Positive; Right, Bottom : out Natural) is begin Terminal_Size (Handle, Right, Bottom); Left := 1; Top := 1; end Terminal_View; function Use_Terminal_Position (Handle : Handle_Type) return Boolean is begin -- It's a workaround for that in some kinds of combinations of -- commands like timeout(1), the process may be run as background, -- so it may receive SIGTTOU by tcsetattr and be stopped. return C.unistd.tcgetpgrp (Handle) = C.unistd.getpgrp; end Use_Terminal_Position; procedure Terminal_Position ( Handle : Handle_Type; Col, Line : out Positive) is Seq : constant String (1 .. 4) := (Character'Val (16#1b#), '[', '6', 'n'); type Signal_Setting is record Old_Mask : aliased C.signal.sigset_t; Error : Boolean; end record; pragma Suppress_Initialization (Signal_Setting); SS : aliased Signal_Setting; type Terminal_Setting is record Old_Settings : aliased C.termios.struct_termios; Handle : Handle_Type; Error : Boolean; end record; pragma Suppress_Initialization (Terminal_Setting); TS : aliased Terminal_Setting; Buffer : String (1 .. 256); Last : Natural; begin -- block SIGINT declare Mask : aliased C.signal.sigset_t; Dummy_R : C.signed_int; begin Dummy_R := C.signal.sigemptyset (Mask'Access); Dummy_R := C.signal.sigaddset (Mask'Access, C.signal.SIGINT); if C.signal.sigprocmask ( C.signal.SIG_BLOCK, Mask'Access, SS.Old_Mask'Access) < 0 then raise Program_Error; -- sigprocmask failed end if; end; declare procedure Finally (X : in out Signal_Setting); procedure Finally (X : in out Signal_Setting) is begin -- unblock SIGINT X.Error := C.signal.sigprocmask ( C.signal.SIG_SETMASK, X.Old_Mask'Access, null) < 0; end Finally; package Holder is new Ada.Exceptions.Finally.Scoped_Holder ( Signal_Setting, Finally); begin Holder.Assign (SS); TS.Handle := Handle; -- non-canonical mode and disable echo tcgetsetattr ( Handle, C.termios.TCSAFLUSH, not (C.termios.ECHO or C.termios.ICANON), 1, TS.Old_Settings'Access); declare procedure Finally (X : in out Terminal_Setting); procedure Finally (X : in out Terminal_Setting) is begin -- restore terminal mode X.Error := C.termios.tcsetattr ( X.Handle, C.termios.TCSANOW, X.Old_Settings'Access) < 0; end Finally; package Holder is new Ada.Exceptions.Finally.Scoped_Holder ( Terminal_Setting, Finally); begin Holder.Assign (TS); -- output Write_Just (Handle, Seq); -- input Read_Escape_Sequence (Handle, Buffer, Last, 'R'); end; if TS.Error then Raise_Exception (Device_Error'Identity); end if; end; if SS.Error then raise Program_Error; -- sigprocmask failed end if; -- parse Parse_Escape_Sequence ( Buffer (1 .. Last), Character'Val (16#1b#) & "[", 'R', Word_Unsigned (Line), Word_Unsigned (Col)); end Terminal_Position; procedure Set_Terminal_Position ( Handle : Handle_Type; Col, Line : Positive) is Seq : String (1 .. 256); Last : Natural := 0; Error : Boolean; begin Seq (1) := Character'Val (16#1b#); Seq (2) := '['; Last := 2; Formatting.Image ( Word_Unsigned (Line), Seq (Last + 1 .. Seq'Last), Last, Error => Error); Last := Last + 1; Seq (Last) := ';'; Formatting.Image ( Word_Unsigned (Col), Seq (Last + 1 .. Seq'Last), Last, Error => Error); Last := Last + 1; Seq (Last) := 'H'; Write_Just (Handle, Seq (1 .. Last)); end Set_Terminal_Position; procedure Set_Terminal_Col ( Handle : Handle_Type; To : Positive) is Seq : String (1 .. 256); Last : Natural := 0; Error : Boolean; begin Seq (1) := Character'Val (16#1b#); Seq (2) := '['; Last := 2; Formatting.Image ( Word_Unsigned (To), Seq (Last + 1 .. Seq'Last), Last, Error => Error); Last := Last + 1; Seq (Last) := 'G'; Write_Just (Handle, Seq (1 .. Last)); end Set_Terminal_Col; procedure Terminal_Clear ( Handle : Handle_Type) is Code : constant String (1 .. 10) := ( Character'Val (16#1b#), '[', '2', 'J', Character'Val (16#1b#), '[', '0', ';', '0', 'H'); begin Write_Just (Handle, Code); end Terminal_Clear; procedure Set_Non_Canonical_Mode ( Handle : Handle_Type; Wait : Boolean; Saved_Settings : aliased out Setting) is begin tcgetsetattr ( Handle, C.termios.TCSADRAIN, not C.termios.ICANON, C.termios.cc_t (Boolean'Pos (Wait)), -- minimum waiting size Saved_Settings'Access); end Set_Non_Canonical_Mode; procedure Restore ( Handle : Handle_Type; Settings : aliased Setting) is begin if C.termios.tcsetattr ( Handle, C.termios.TCSANOW, Settings'Access) < 0 then Raise_Exception (Device_Error'Identity); end if; end Restore; procedure Save_State (Handle : Handle_Type; To_State : out Output_State) is Seq : constant String (1 .. 2) := (Character'Val (16#1b#), '7'); begin State_Stack_Count := State_Stack_Count + 1; To_State := State_Stack_Count; Write_Just (Handle, Seq); end Save_State; procedure Reset_State (Handle : Handle_Type; From_State : Output_State) is pragma Check (Pre, Check => From_State = State_Stack_Count or else raise Status_Error); Seq : constant String (1 .. 2) := (Character'Val (16#1b#), '8'); begin State_Stack_Count := State_Stack_Count - 1; Write_Just (Handle, Seq); end Reset_State; end System.Native_Text_IO;
with Qt; use Qt; package CovidSimForm is type Simulation_Engine is (Lancet, XPH_Pharmaceutical); covidsim_form : QWidgetH; procedure covidsim_form_init (parent : QWidgetH := null); procedure slot_change_simulation_engine (simulation_engine_beautiful_name : QStringH); pragma Convention (C, slot_change_simulation_engine); procedure slot_change_scenario (scenario_beautiful_name : QStringH); pragma Convention (C, slot_change_scenario); procedure slot_change_iterations (iterations: Integer); pragma Convention (C, slot_change_iterations); procedure slot_change_population (population: Integer); pragma Convention (C, slot_change_population); procedure slot_export_to_csv; pragma Convention (C, slot_export_to_csv); end;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt package Definitions is pragma Pure; raven_version_major : constant String := "1"; raven_version_minor : constant String := "71"; copyright_years : constant String := "2015-2021"; raven_tool : constant String := "ravenadm"; variant_standard : constant String := "standard"; contact_nobody : constant String := "nobody"; contact_automaton : constant String := "automaton"; dlgroup_main : constant String := "main"; dlgroup_none : constant String := "none"; options_none : constant String := "none"; options_all : constant String := "all"; broken_all : constant String := "all"; boolean_yes : constant String := "yes"; homepage_none : constant String := "none"; spkg_complete : constant String := "complete"; spkg_docs : constant String := "docs"; spkg_examples : constant String := "examples"; spkg_nls : constant String := "nls"; ports_default : constant String := "floating"; default_ssl : constant String := "libressl"; default_mysql : constant String := "oracle-8.0"; default_lua : constant String := "5.3"; default_perl : constant String := "5.30"; default_pgsql : constant String := "12"; default_php : constant String := "7.4"; default_python3 : constant String := "3.8"; default_ruby : constant String := "2.7"; default_tcltk : constant String := "8.6"; default_firebird : constant String := "2.5"; default_binutils : constant String := "binutils:ravensys"; default_compiler : constant String := "gcc9"; previous_default : constant String := "gcc9"; compiler_version : constant String := "9.3.0"; previous_compiler : constant String := "9.2.0"; binutils_version : constant String := "2.35.1"; previous_binutils : constant String := "2.34"; arc_ext : constant String := ".tzst"; jobs_per_cpu : constant := 2; task_stack_limit : constant := 10_000_000; type supported_opsys is (dragonfly, freebsd, netbsd, openbsd, sunos, linux, macos); type supported_arch is (x86_64, i386, aarch64); type cpu_range is range 1 .. 64; type scanners is range cpu_range'First .. cpu_range'Last; type builders is range cpu_range'First .. cpu_range'Last * jobs_per_cpu; type count_type is (total, success, failure, ignored, skipped); -- Modify following with post-patch sed accordingly platform_type : constant supported_opsys := dragonfly; host_localbase : constant String := "/raven"; raven_var : constant String := "/var/ravenports"; host_pkg8 : constant String := host_localbase & "/sbin/ravensw"; ravenexec : constant String := host_localbase & "/libexec/ravenexec"; end Definitions;
----------------------------------------------------------------------- -- babel-streams-tests - Unit tests for babel streams -- Copyright (C) 2015, 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. ----------------------------------------------------------------------- with Util.Test_Caller; with Babel.Files.Buffers; with Babel.Streams.Cached; with Babel.Streams.Files; with Babel.Streams.XZ; package body Babel.Streams.Tests is package Caller is new Util.Test_Caller (Test, "Streams"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Babel.Streams.Read", Test_Stream_Composition'Access); end Add_Tests; -- ------------------------------ -- Stream copy, compression and decompression test. -- Create a compressed version of the source file and then decompress the result. -- The source file is then compared to the decompressed result and must match. -- ------------------------------ procedure Do_Copy (T : in out Test; Pool : in out Babel.Files.Buffers.Buffer_Pool; Src : in String) is use type Babel.Files.Buffers.Buffer_Access; Src_Path : constant String := Util.Tests.Get_Path (Src); Dst_Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/" & Src & ".xz"); Tst_Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/" & Src); Buffer : Babel.Files.Buffers.Buffer_Access; begin -- Compress the 'configure' file into 'configure.xz' through the file+cache+xz+file streams. declare In_File : aliased Babel.Streams.Files.Stream_Type; Out_File : aliased Babel.Streams.Files.Stream_Type; Cache : aliased Babel.Streams.Cached.Stream_Type; Lz : aliased Babel.Streams.XZ.Stream_Type; begin Pool.Get_Buffer (Buffer); In_File.Open (Src_Path, Buffer); Cache.Load (In_File, Pool); Pool.Get_Buffer (Buffer); Out_File.Create (Dst_Path, 8#644#); Lz.Set_Buffer (Buffer); Lz.Set_Output (Out_File'Unchecked_Access); loop Cache.Read (Buffer); exit when Buffer = null; Lz.Write (Buffer); end loop; Lz.Flush; Lz.Close; lz.Finalize; Cache.Finalize; In_File.Finalize; Out_File.Finalize; end; -- Decompress through file+cache+xz+file declare In_File : aliased Babel.Streams.Files.Stream_Type; Out_File : aliased Babel.Streams.Files.Stream_Type; Cache : aliased Babel.Streams.Cached.Stream_Type; Lz : aliased Babel.Streams.XZ.Stream_Type; begin Pool.Get_Buffer (Buffer); In_File.Open (Dst_Path, Buffer); Cache.Load (In_File, Pool); -- Setup decompression. Pool.Get_Buffer (Buffer); Lz.Set_Input (Cache'Unchecked_Access); Lz.Set_Buffer (Buffer); Out_File.Create (Tst_Path, 8#644#); loop Lz.Read (Buffer); exit when Buffer = null; Out_File.Write (Buffer); end loop; Out_File.Close; lz.Finalize; Cache.Finalize; In_File.Finalize; Out_File.Finalize; end; Util.Tests.Assert_Equal_Files (T, Src_Path, Tst_Path, "Composition stream failed for: " & Src); end Do_Copy; -- ------------------------------ -- Test the Find function resolving some existing user. -- ------------------------------ procedure Test_Stream_Composition (T : in out Test) is Pool : aliased Babel.Files.Buffers.Buffer_Pool; begin Pool.Create_Pool (Size => 1_000, Count => 1000); Do_Copy (T, Pool, "configure"); Do_Copy (T, Pool, "babel.gpr"); Do_Copy (T, Pool, "configure.in"); Do_Copy (T, Pool, "config.guess"); Do_Copy (T, Pool, "Makefile.in"); end Test_Stream_Composition; end Babel.Streams.Tests;
with Ada.Text_IO; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A047 is use Ada.Text_IO; use Ada.Integer_Text_IO; -- File Reference: http://www.naturalnumbers.org/primes.html Max_N : constant Integer := 5E5; Array_Range : constant Integer := Integer (Float'Floor ( Float (Max_N) / 10.0)); FT : File_Type; Last_Index : Natural; Prime_Num : String (1 .. 10); File_Name : constant String := "problems/003/PrimeNumbers_Upto_1000000"; I : Integer := 1; Main_Count : Integer := 0; Primes_List : array (Integer range 1 .. Array_Range) of Integer := (others => 0); J, Temp_I, I_By_5, Sub_Count : Integer; begin Open (FT, In_File, File_Name); while not End_Of_File (FT) loop Get_Line (FT, Prime_Num, Last_Index); if (Integer'Value (Prime_Num (1 .. Last_Index)) > Max_N) then exit; end if; Primes_List (I) := Integer'Value (Prime_Num (1 .. Last_Index)); I := I + 1; end loop; Close (FT); I := 1000; while I <= Max_N loop J := 1; Temp_I := I; I_By_5 := Integer (Float'Floor (Float (I) / 5.0)); Sub_Count := 0; while Primes_List (J) < I_By_5 loop if (Temp_I mod Primes_List (J)) = 0 then while (Temp_I mod Primes_List (J)) = 0 loop Temp_I := Temp_I / Primes_List (J); end loop; Sub_Count := Sub_Count + 1; if Sub_Count = 4 then exit; end if; end if; J := J + 1; end loop; if Sub_Count /= 4 then Main_Count := 0; else Main_Count := Main_Count + 1; if Main_Count = 4 then exit; end if; end if; I := I + 1; end loop; Put (I - 3, Width => 0); end A047;
-- { dg-do compile } with Ada.Finalization; package preelab is type T is limited private; pragma Preelaborable_Initialization (T); private type T is new Ada.Finalization.Limited_Controlled with null record; end preelab;
pragma Style_Checks ("NM32766"); pragma Wide_Character_Encoding (Brackets); --------------------------------------------------- -- This file has been generated automatically from -- cbsg.idl -- by IAC (IDL to Ada Compiler) 20.0w (rev. 90136cd4). --------------------------------------------------- -- NOTE: If you modify this file by hand, your -- changes will be lost when you re-run the -- IDL to Ada compiler. --------------------------------------------------- with CORBA; pragma Elaborate_All (CORBA); with CORBA.Object; package CorbaCBSG.CBSG.Helper is TC_CBSG : CORBA.TypeCode.Object; function From_Any (Item : CORBA.Any) return CorbaCBSG.CBSG.Ref; function To_Any (Item : CorbaCBSG.CBSG.Ref) return CORBA.Any; function Unchecked_To_Ref (The_Ref : CORBA.Object.Ref'Class) return CorbaCBSG.CBSG.Ref; function To_Ref (The_Ref : CORBA.Object.Ref'Class) return CorbaCBSG.CBSG.Ref; package Internals is procedure Initialize_CBSG; end Internals; end CorbaCBSG.CBSG.Helper;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C A L E N D A R -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 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. -- -- -- -- -- -- -- -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package Ada.Calendar is type Time is private; -- Declarations representing limits of allowed local time values. Note that -- these do NOT constrain the possible stored values of time which may well -- permit a larger range of times (this is explicitly allowed in Ada 95). subtype Year_Number is Integer range 1901 .. 2099; subtype Month_Number is Integer range 1 .. 12; subtype Day_Number is Integer range 1 .. 31; subtype Day_Duration is Duration range 0.0 .. 86_400.0; function Clock return Time; function Year (Date : Time) return Year_Number; function Month (Date : Time) return Month_Number; function Day (Date : Time) return Day_Number; function Seconds (Date : Time) return Day_Duration; procedure Split (Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Seconds : out Day_Duration); function Time_Of (Year : Year_Number; Month : Month_Number; Day : Day_Number; Seconds : Day_Duration := 0.0) return Time; -- GNAT Note: Normally when procedure Split is called on a Time value -- result of a call to function Time_Of, the out parameters of procedure -- Split are identical to the in parameters of function Time_Of. However, -- when a non-existent time of day is specified, the values for Seconds -- may or may not be different. This may happen when Daylight Saving Time -- (DST) is in effect, on the day when switching to DST, if Seconds -- specifies a time of day in the hour that does not exist. For example, -- in New York: -- -- Time_Of (Year => 1998, Month => 4, Day => 5, Seconds => 10740.0) -- -- will return a Time value T. If Split is called on T, the resulting -- Seconds may be 14340.0 (3:59:00) instead of 10740.0 (2:59:00 being -- a time that not exist). function "+" (Left : Time; Right : Duration) return Time; function "+" (Left : Duration; Right : Time) return Time; function "-" (Left : Time; Right : Duration) return Time; function "-" (Left : Time; Right : Time) return Duration; function "<" (Left, Right : Time) return Boolean; function "<=" (Left, Right : Time) return Boolean; function ">" (Left, Right : Time) return Boolean; function ">=" (Left, Right : Time) return Boolean; Time_Error : exception; private pragma Inline (Clock); pragma Inline (Year); pragma Inline (Month); pragma Inline (Day); pragma Inline ("+"); pragma Inline ("-"); pragma Inline ("<"); pragma Inline ("<="); pragma Inline (">"); pragma Inline (">="); -- Time is represented as a signed duration from the base point which is -- what Unix calls the EPOCH (i.e. 12 midnight (24:00:00), Dec 31st, 1969, -- or if you prefer 0:00:00 on Jan 1st, 1970). Since Ada allows dates -- before this EPOCH value, the stored duration value may be negative. -- The time value stored is typically a GMT value, as provided in standard -- Unix environments. If this is the case then Split and Time_Of perform -- required conversions to and from local times. The range of times that -- can be stored in Time values depends on the declaration of the type -- Duration, which must at least cover the required Ada range represented -- by the declaration of Year_Number, but may be larger (we take full -- advantage of the new permission in Ada 95 to store time values outside -- the range that would be acceptable to Split). The Duration type is a -- real value representing a time interval in seconds. type Time is new Duration; -- The following package provides handling of leap seconds. It is -- used by Ada.Calendar.Arithmetic and Ada.Calendar.Formatting, both -- Ada 2005 children of Ada.Calendar. package Leap_Sec_Ops is After_Last_Leap : constant Time := Time'Last; -- Bigger by far than any leap second value. Not within range of -- Ada.Calendar specified dates. procedure Cumulative_Leap_Secs (Start_Date : Time; End_Date : Time; Leaps_Between : out Duration; Next_Leap_Sec : out Time); -- Leaps_Between is the sum of the leap seconds that have occured -- on or after Start_Date and before (strictly before) End_Date. -- Next_Leap_Sec represents the next leap second occurence on or -- after End_Date. If there are no leaps seconds after End_Date, -- After_Last_Leap is returned. This does not provide info about -- the next leap second (pos/neg or ?). After_Last_Leap can be used -- as End_Date to count all the leap seconds that have occured on -- or after Start_Date. -- Important Notes: any fractional parts of Start_Date and End_Date -- are discarded before the calculations are done. For instance: if -- 113 seconds is a leap second (it isn't) and 113.5 is input as an -- End_Date, the leap second at 113 will not be counted in -- Leaps_Between, but it will be returned as Next_Leap_Sec. Thus, if -- the caller wants to know if the End_Date is a leap second, the -- comparison should be: -- End_Date >= Next_Leap_Sec; -- After_Last_Leap is designed so that this comparison works without -- having to first check if Next_Leap_Sec is a valid leap second. function All_Leap_Seconds return Duration; -- Returns the sum off all of the leap seoncds. end Leap_Sec_Ops; procedure Split_W_Offset (Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Seconds : out Day_Duration; Offset : out Long_Integer); -- Split_W_Offset has the same spec as Split with the addition of an -- offset value which give the offset of the local time zone from UTC -- at the input Date. This value comes for free during the implementation -- of Split and is needed by UTC_Time_Offset. The returned Offset time -- is straight from the C tm struct and is in seconds. end Ada.Calendar;
-- Institution: Technische Universitaet Muenchen -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: Emanuel Regnath (emanuel.regnath@tum.de) with HAL; with Interfaces; use Interfaces; with Ada.Unchecked_Conversion; -- @summary -- target-independent functions of HIL. package HIL with SPARK_Mode is pragma Preelaborate; --procedure configure_Hardware; subtype Byte is HAL.Byte; -- Unsigned_8 -- Integer_8 type Bit is mod 2**1 with Size => 1; -- Architecture Independent type Unsigned_8_Mask is new Unsigned_8; subtype Unsigned_8_Bit_Index is Natural range 0 .. 7; type Unsigned_16_Mask is new Unsigned_16; type Unsigned_16_Bit_Index is new Natural range 0 .. 15; type Unsigned_32_Mask is new Unsigned_32; type Unsigned_32_Bit_Index is new Natural range 0 .. 31; -- Arrays type Byte_Array is array(Natural range <>) of Byte; type Short_Array is array(Natural range <>) of Unsigned_16; type Word_Array is array(Natural range <>) of Unsigned_32; subtype Byte_Array_2 is Byte_Array(1..2); -- not working (explicit raise in flow_utility.adb) -- type Byte_Array_2 is Byte_Array(1..2); type Byte_Array_4 is array(1..4) of Byte; type Unsigned_8_Array is array(Natural range <>) of Unsigned_8; type Unsigned_16_Array is array(Natural range <>) of Unsigned_16; type Unsigned_32_Array is array(Natural range <>) of Unsigned_32; type Integer_8_Array is array(Natural range <>) of Integer_8; type Integer_16_Array is array(Natural range <>) of Integer_16; type Integer_32_Array is array(Natural range <>) of Integer_32; type Float_Array is array(Natural range <>) of Float; function From_Byte_Array_To_Float is new Ada.Unchecked_Conversion (Source => Byte_Array_4, Target => Float); function From_Float_To_Byte_Array is new Ada.Unchecked_Conversion (Source => Float, Target => Byte_Array_4); -- little endian (lowest byte first) function toBytes(uint : in Unsigned_16) return Byte_Array is (1 => Unsigned_8( uint mod 2**8 ), 2 => Unsigned_8 ( uint / 2**8 ) ); function toBytes( source : in Float) return Byte_Array_4 is (From_Float_To_Byte_Array( source ) ) with Pre => source'Size = 32; -- FAILS (unsigned arg, constrained return) function toBytes_uc(uint : Unsigned_16) return Byte_Array_2 is (1 => Unsigned_8( uint mod 2**8 ), 2 => Unsigned_8 ( uint / 2**8 ) ); function toUnsigned_16( bytes : Byte_Array) return Unsigned_16 is ( Unsigned_16 (bytes (bytes'First )) + Unsigned_16 (bytes (bytes'First + 1)) * 2**8) with Pre => bytes'Length = 2; function toUnsigned_32( bytes : Byte_Array) return Unsigned_32 is ( Unsigned_32 (bytes (bytes'First )) + Unsigned_32 (bytes (bytes'First + 1)) * 2**8 + Unsigned_32 (bytes (bytes'First + 2)) * 2**16 + Unsigned_32 (bytes (bytes'First + 3)) * 2**24) with Pre => bytes'Length = 4; function Bytes_To_Unsigned32 is new Ada.Unchecked_Conversion (Source => Byte_Array_4, Target => Unsigned_32); function Unsigned32_To_Bytes is new Ada.Unchecked_Conversion (Source => Unsigned_32, Target => Byte_Array_4); function From_Byte_To_Integer_8 is new Ada.Unchecked_Conversion (Source => Byte, Target => Integer_8); function From_Byte_Array_To_Integer_32 is new Ada.Unchecked_Conversion (Source => Byte_Array_4, Target => Integer_32); function toInteger_8( value : Byte ) return Integer_8 is ( From_Byte_To_Integer_8( value ) ); function toInteger_32( bytes : Byte_Array) return Integer_32 is (From_Byte_Array_To_Integer_32( Byte_Array_4( bytes ) ) ) with Pre => bytes'Length = 4; function toCharacter( source : Byte ) return Character is ( Character'Val ( source ) ); function toFloat( source : Byte_Array_4 ) return Float is ( From_Byte_Array_To_Float( source ) ); procedure write_Bits( register : in out Unsigned_8; start_index : Unsigned_8_Bit_Index; length : Positive; value : Integer) with Pre => length <= Natural (Unsigned_8_Bit_Index'Last) + 1 - Natural (start_index) and then value < 2**(length-1) + 2**(length-1) - 1; -- e.g. 2^8 = 256, but range is only up to 2^8-1 function read_Bits( register : in Unsigned_8; start_index : Unsigned_8_Bit_Index; length : Positive) return Unsigned_8 with Pre => length <= Natural (Unsigned_8_Bit_Index'Last) + 1 - Natural (start_index), Post => read_Bits'Result < 2**length; -- procedure set_Bit( reg : in out Unsigned_16, bit : Unsigned_16_Bit_ID) is -- mask : Unsigned_16_Mask procedure set_Bits( register : in out Unsigned_16; bit_mask : Unsigned_16_Mask) with Pre => register'Size = bit_mask'Size; procedure clear_Bits( register : in out Unsigned_16; bit_mask : Unsigned_16_Mask) with Pre => register'Size = bit_mask'Size; function isSet( register : Unsigned_16; bit_mask : Unsigned_16_Mask) return Boolean is ( ( register and Unsigned_16( bit_mask ) ) > 0 ); -- procedure Read_Buffer -- (Stream : not null access Streams.Root_Stream_Type'Class; -- Item : out Byte_Array); -- -- procedure Write_Buffer -- (Stream : not null access Streams.Root_Stream_Type'Class; -- Item : in Byte_Array); -- -- for Byte_Array'Read use Read_Buffer; -- for Byte_Array'Write use Write_Buffer; end HIL;
with Ada.Numerics.Discrete_Random; with SDL.Video.Windows.Makers; with SDL.Video.Renderers.Makers; with SDL.Events.Events; procedure Brownian_Tree is Width : constant := 800; Height : constant := 600; Points : constant := 50_000; subtype Width_Range is Integer range 1 .. Width; subtype Height_Range is Integer range 1 .. Height; type Direction is (N, NE, E, SE, S, SW, W, NW); package Random_Width is new Ada.Numerics.Discrete_Random (Width_Range); package Random_Height is new Ada.Numerics.Discrete_Random (Height_Range); package Random_Direc is new Ada.Numerics.Discrete_Random (Direction); Window : SDL.Video.Windows.Window; Renderer : SDL.Video.Renderers.Renderer; Event : SDL.Events.Events.Events; Width_Gen : Random_Width.Generator; Height_Gen : Random_Height.Generator; Direc_Gen : Random_Direc.Generator; function Poll_Quit return Boolean is use type SDL.Events.Event_Types; begin while SDL.Events.Events.Poll (Event) loop if Event.Common.Event_Type = SDL.Events.Quit then return True; end if; end loop; return False; end Poll_Quit; procedure Draw_Brownian_Tree is Field : array (Width_Range, Height_Range) of Boolean := (others => (others => False)); X : Width_Range; Y : Height_Range; Direc : Direction; procedure Random_Free (X : out Width_Range; Y : out Height_Range) is begin -- Find free random spot loop X := Random_Width.Random (Width_Gen); Y := Random_Height.Random (Height_Gen); exit when Field (X, Y) = False; end loop; end Random_Free; begin -- Seed Field (Random_Width.Random (Width_Gen), Random_Height.Random (Height_Gen)) := True; for I in 0 .. Points loop Random_Free (X, Y); loop -- If collide with wall then new random start while X = Width_Range'First or X = Width_Range'Last or Y = Height_Range'First or Y = Height_Range'Last loop Random_Free (X, Y); end loop; exit when Field (X - 1, Y - 1) or Field (X, Y - 1) or Field (X + 1, Y - 1); exit when Field (X - 1, Y) or Field (X + 1, Y); exit when Field (X - 1, Y + 1) or Field (X, Y + 1) or Field (X + 1, Y + 1); Direc := Random_Direc.Random (Direc_Gen); case Direc is when NW | N | NE => Y := Y - 1; when SW | S | SE => Y := Y + 1; when others => null; end case; case Direc is when NW | W | SW => X := X - 1; when SE | E | NE => X := X + 1; when others => null; end case; end loop; Field (X, Y) := True; Renderer.Draw (Point => (SDL.C.int (X), SDL.C.int (Y))); if I mod 100 = 0 then if Poll_Quit then return; end if; Window.Update_Surface; end if; end loop; end Draw_Brownian_Tree; begin Random_Width.Reset (Width_Gen); Random_Height.Reset (Height_Gen); Random_Direc.Reset (Direc_Gen); if not SDL.Initialise (Flags => SDL.Enable_Screen) then return; end if; SDL.Video.Windows.Makers.Create (Win => Window, Title => "Brownian tree", Position => SDL.Natural_Coordinates'(X => 10, Y => 10), Size => SDL.Positive_Sizes'(Width, Height), Flags => 0); SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface); Renderer.Set_Draw_Colour ((0, 0, 0, 255)); Renderer.Fill (Rectangle => (0, 0, Width, Height)); Renderer.Set_Draw_Colour ((200, 200, 200, 255)); Draw_Brownian_Tree; Window.Update_Surface; loop exit when Poll_Quit; delay 0.050; end loop; Window.Finalize; SDL.Finalise; end Brownian_Tree;
--=========================================================================== -- -- This application provides an embedded dashboard controller offering: -- - UART Interface -- - LED Area -- - 5x7 Matrix Display with two displays as one logical unit -- --=========================================================================== -- -- Copyright 2021 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with RP.Device; with ItsyBitsy; with Initializer; with Transport.Serial; with Evaluate.LEDs; with Evaluate.Matrices; with Execute; with Execute.LEDs; with Execute.Matrices; procedure Edc is -------------------------------------------------------------------------- -- Processes a request for the LED area -- * gets the serial command request -- * checks the input for correctness -- * if OK, then executes the command given -------------------------------------------------------------------------- procedure Process_LED (Instruction : Evaluate.LEDs.LED_Instruction); procedure Process_LED (Instruction : Evaluate.LEDs.LED_Instruction) is Error : Execute.LED_Errors; Action : Execute.LED_Actions; begin Error := Evaluate.LEDs.Check_Input (Instruction); case Error is when Execute.OK => ItsyBitsy.LED.Clear; Action := Evaluate.LEDs.Evaluate (Instruction); Execute.LEDs.Execute (Action); when others => ItsyBitsy.LED.Set; end case; end Process_LED; -------------------------------------------------------------------------- -- Processes a request for the Matrix area -- * gets the serial command request -- * checks the input for correctness -- * if OK, then executes the command given -------------------------------------------------------------------------- procedure Process_Matrix (Instruction : Evaluate.Matrices.Matrix_Instruction); procedure Process_Matrix (Instruction : Evaluate.Matrices.Matrix_Instruction) is Error : Execute.Matrix_Errors; Action : Execute.Matrix_Command; use Execute; begin Error := Evaluate.Matrices.Check_Input (Instruction); case Error is when Execute.M_OK => ItsyBitsy.LED.Clear; Action := Evaluate.Matrices.Evaluate (Instruction => Instruction); Execute.Matrices.Execute (Action); when others => ItsyBitsy.LED.Set; end case; end Process_Matrix; procedure Show_Patterns_After_Reset; procedure Show_Patterns_After_Reset is Word_Pattern_0000 : constant Execute.Matrix_Command := (Block => Execute.Block_0, Command => Execute.Word_0, Value => "00000000" ); Word_Pattern_000F : constant Execute.Matrix_Command := (Block => Execute.Block_0, Command => Execute.Word_0, Value => "000F0000" ); Word_Pattern_00F0 : constant Execute.Matrix_Command := (Block => Execute.Block_0, Command => Execute.Word_0, Value => "00F00000" ); Word_Pattern_0F00 : constant Execute.Matrix_Command := (Block => Execute.Block_0, Command => Execute.Word_0, Value => "0F000000" ); Word_Pattern_F000 : constant Execute.Matrix_Command := (Block => Execute.Block_0, Command => Execute.Word_0, Value => "F0000000" ); Word_Pattern_FFFF : constant Execute.Matrix_Command := (Block => Execute.Block_0, Command => Execute.Word_0, Value => "FFFF0000" ); Double_Word_Pattern_00000000 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "00000000" ); Double_Word_Pattern_0000000F : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "0000000F" ); Double_Word_Pattern_000000F0 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "000000F0" ); Double_Word_Pattern_00000F00 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "00000F00" ); Double_Word_Pattern_0000F000 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "0000F000" ); Double_Word_Pattern_000F0000 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "000F0000" ); Double_Word_Pattern_00F00000 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "00F00000" ); Double_Word_Pattern_0F000000 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "0F000000" ); Double_Word_Pattern_F0000000 : constant Execute.Matrix_Command := (Block => Execute.Block_1, Command => Execute.Double_Word_0, Value => "F0000000" ); TIME_BETWEEN_PATTERN : constant Integer := 100; begin ----------------------------------------------------------------------- -- Pattern with LEDs ON Execute.LEDs.Execute (Cmd => Execute.Red_On); Execute.LEDs.Execute (Cmd => Execute.Amber_On); Execute.LEDs.Execute (Cmd => Execute.Green_On); Execute.LEDs.Execute (Cmd => Execute.White_On); Execute.LEDs.Execute (Cmd => Execute.Blue_On); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); ----------------------------------------------------------------------- -- Pattern with Matrix Word Execute.Matrices.Execute (Cmd => Word_Pattern_0000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Word_Pattern_000F); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Word_Pattern_00F0); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Word_Pattern_0F00); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Word_Pattern_F000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); ----------------------------------------------------------------------- -- Pattern with Matrix Double Word Execute.Matrices.Execute (Cmd => Double_Word_Pattern_00000000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_0000000F); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_000000F0); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_00000F00); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_0000F000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_000F0000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_00F00000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_0F000000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); Execute.Matrices.Execute (Cmd => Double_Word_Pattern_F0000000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); ----------------------------------------------------------------------- -- Pattern with Matrix Word Execute.Matrices.Execute (Cmd => Word_Pattern_0000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); ----------------------------------------------------------------------- -- Pattern with Matrix Double Word Execute.Matrices.Execute (Cmd => Double_Word_Pattern_00000000); RP.Device.Timer.Delay_Milliseconds (TIME_BETWEEN_PATTERN); ----------------------------------------------------------------------- -- Pattern with LEDs OFF Execute.LEDs.Execute (Cmd => Execute.Red_Off); Execute.LEDs.Execute (Cmd => Execute.Amber_Off); Execute.LEDs.Execute (Cmd => Execute.Green_Off); Execute.LEDs.Execute (Cmd => Execute.White_Off); Execute.LEDs.Execute (Cmd => Execute.Blue_Off); end Show_Patterns_After_Reset; Area_Selector : Transport.Area_Selector; LED_Instruction : Evaluate.LEDs.LED_Instruction; Matrix_Instruction : Evaluate.Matrices.Matrix_Instruction; begin Initializer.Initialize_All; Show_Patterns_After_Reset; loop -- Check for Serial Channel input Area_Selector := Transport.Serial.Get_Area_Selector; case Area_Selector is when Transport.Led => -- something arrived on serial, handle it LED_Instruction := Transport.Serial.Get_LED_Instruction; Process_LED (LED_Instruction); when Transport.Matrix => -- something arrived on serial, handle it Matrix_Instruction := Transport.Serial.Get_Matrix_Instruction; Process_Matrix (Matrix_Instruction); when Transport.None => null; end case; end loop; end Edc; --=========================================================================== -- -- MAJOR TITLE HERE -- --=========================================================================== -------------------------------------------------------------------------- -- Minor Title Here -------------------------------------------------------------------------- --------------------- -- Subsection Header ---------------------
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . E N C O D E _ S T R I N G -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007-2020, 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 generic package provides utility routines for converting from -- Wide_String or Wide_Wide_String to encoded String using a specified -- encoding convention, which is supplied as the generic parameter. If -- this parameter is a known at compile time constant (e.g. a constant -- defined in System.WCh_Con), the instantiation is specialized so that -- it applies only to this specified coding. -- Note: this package is only about encoding sequences of 16- or 32-bit -- characters into a sequence of 8-bit codes. It knows nothing at all about -- the character encodings being used for the input Wide_Character and -- Wide_Wide_Character values, although some of the encoding methods (notably -- JIS and EUC) have built in assumptions about the range of possible input -- code values. Most often the input will be Unicode/ISO-10646 as specified by -- the Ada RM, but this package does not make any assumptions about the -- character coding, and in the case of UTF-8 all possible code values can be -- encoded. See also the packages Ada.Wide_[Wide_]Characters.Unicode for -- unicode specific functions. -- Note on brackets encoding (WCEM_Brackets). On input, upper half characters -- can be represented as ["hh"] but the routines in this package will only use -- brackets encodings for codes higher than 16#FF#, so upper half characters -- will be output as single Character values. with System.WCh_Con; generic Encoding_Method : System.WCh_Con.WC_Encoding_Method; package GNAT.Encode_String is pragma Pure; function Encode_Wide_String (S : Wide_String) return String; pragma Inline (Encode_Wide_String); -- Encode the given Wide_String, returning a String encoded using the -- given encoding method. Constraint_Error will be raised if the encoding -- method cannot accommodate the input data. procedure Encode_Wide_String (S : Wide_String; Result : out String; Length : out Natural); -- Encode the given Wide_String, storing the encoded string in Result, -- with Length being set to the length of the encoded string. The caller -- must ensure that Result is long enough (see useful constants defined -- in System.WCh_Con: WC_Longest_Sequence, WC_Longest_Sequences). If the -- length of Result is insufficient Constraint_Error will be raised. -- Constraint_Error will also be raised if the encoding method cannot -- accommodate the input data. function Encode_Wide_Wide_String (S : Wide_Wide_String) return String; pragma Inline (Encode_Wide_Wide_String); -- Same as above function but for Wide_Wide_String input procedure Encode_Wide_Wide_String (S : Wide_Wide_String; Result : out String; Length : out Natural); -- Same as above procedure, but for Wide_Wide_String input procedure Encode_Wide_Character (Char : Wide_Character; Result : in out String; Ptr : in out Natural); pragma Inline (Encode_Wide_Character); -- This is a lower level procedure that encodes the single character Char. -- The output is stored in Result starting at Result (Ptr), and Ptr is -- updated past the stored value. Constraint_Error is raised if Result -- is not long enough to accommodate the result, or if the encoding method -- specified does not accommodate the input character value, or if Ptr is -- outside the bounds of the Result string. procedure Encode_Wide_Wide_Character (Char : Wide_Wide_Character; Result : in out String; Ptr : in out Natural); -- Same as above procedure but with Wide_Wide_Character input end GNAT.Encode_String;
-- Cupcake TK Demo Application -- (c) Kristian Klomsten Skordal 2012 <kristian.skordal@gmail.com> -- Report bugs and issues on <http://github.com/skordal/cupcake/issues> -- vim:ts=3:sw=3:et:si:sta with Ada.Text_IO; use Ada.Text_IO; with Cupcake; with Cupcake.Primitives; with Cupcake.Windows; use Cupcake; procedure Demo is Test_Window : Windows.Window; Window_Size : constant Primitives.Dimension := (Width => 800, Height => 600); begin Put_Line ("Initializing cupcake... "); Initialize; Test_Window := Windows.New_Window (Window_Size, "Test Application"); Test_Window.Set_Visible; Enter_Main_Loop; Test_Window.Destroy; Finalize; exception when Cupcake.Initialization_Error => Put_Line ("Could not initialize cupcake!"); end Demo;
-- SPDX-FileCopyrightText: 2019-2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with System.Storage_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Identifiers; with Program.Safe_Element_Visitors; package body Program.Visibility is procedure Step (Self : Region_Immediate_Visible_Iterator'Class; Cursor : in out View_Cursor); procedure Step_Use (Self : Use_Visible_Iterator'Class; Cursor : in out View_Cursor); type Allocated_Snapshot is access all Snapshot; procedure Append_Item (Self : in out Context'Class; Value : in out Entity; Region : Boolean := True; Replace : Boolean := False); -- Append new Value to the Self.Top region, updating Value.Prev by -- pointer to an entity with the same symbol (or No_Entity if no such -- entity found). If Replace = True and there is an entity with the same -- Symbol in the region, the replace it by Value and don't appent the new -- entity function Get_View (Env : not null Constant_Context_Access; Index : Entity_Reference) return View; function To_Vector (List : View_Array) return Entity_References.Vector; function Find_Direct (Self : Context'Class; Symbol : Program.Symbols.Symbol) return Entity_Reference; -- Find a symbol in Self.Directly, return No_Entity if not found package Getters is type Visitor (Env : not null Constant_Context_Access) is new Program.Safe_Element_Visitors.Safe_Element_Visitor with record Result : View; end record; overriding procedure Identifier (Self : in out Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access); end Getters; package body Getters is overriding procedure Identifier (Self : in out Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access) is Name : constant Program.Elements.Defining_Identifiers .Defining_Identifier_Access := Element.Corresponding_Defining_Identifier; Cursor : constant Defining_Name_Maps.Cursor := Self.Env.Xref.Find (Name.To_Defining_Name); begin if Defining_Name_Maps.Has_Element (Cursor) then Self.Result := Get_View (Self.Env, Defining_Name_Maps.Element (Cursor)); end if; end Identifier; end Getters; --------------------- -- Add_Use_Package -- --------------------- not overriding procedure Add_Use_Package (Self : in out Context'Class; Pkg : View) is Item : Entity renames Self.Data (Pkg.Index.Region).Entities (Pkg.Index.Entity_Id); Reg : constant Region_Identifier := Item.Region; begin if not Self.Data (Self.Top).Uses.Contains (Reg) then Self.Data (Self.Top).Uses.Append (Reg); end if; end Add_Use_Package; ----------------- -- Append_Item -- ----------------- procedure Append_Item (Self : in out Context'Class; Value : in out Entity; Region : Boolean := True; Replace : Boolean := False) is Prev : constant Entity_Maps.Cursor := Self.Directly.Find (Value.Symbol); Next : constant Entity_Reference := (Self.Top, Self.Data (Self.Top).Entities.Last_Index + 1); begin if Entity_Maps.Has_Element (Prev) then declare Ref : constant Entity_Reference := Entity_Maps.Element (Prev); begin if Replace and then Ref.Region = Self.Top then Value.Prev := Self.Data (Self.Top).Entities (Ref.Entity_Id).Prev; Self.Data (Self.Top).Entities.Replace_Element (Ref.Entity_Id, Value); else Value.Prev := Ref; Self.Directly.Replace_Element (Prev, Next); Self.Data (Self.Top).Entities.Append (Value); Self.Xref.Insert (Value.Name, Next); end if; end; else Value.Prev := No_Entity; Self.Directly.Insert (Value.Symbol, Next); Self.Data (Self.Top).Entities.Append (Value); Self.Xref.Insert (Value.Name, Next); end if; if Region then Self.Data.Append ((Enclosing => Self.Top, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); Self.Top := Self.Data.Last_Index; end if; end Append_Item; --------------- -- Component -- --------------- function Component (Self : View) return View is Type_Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, Type_Item.Component); end Component; ----------------------- -- Create_Array_Type -- ----------------------- not overriding procedure Create_Array_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Indexes : View_Array; Component : View) is Value : Entity := (Kind => Array_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Indexes => To_Vector (Indexes), Component => Component.Index, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Array_Type; ------------------------------ -- Create_Character_Literal -- ------------------------------ not overriding procedure Create_Character_Literal (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Enumeration_Type : View) is Value : Entity := (Kind => Character_Literal_View, Symbol => Symbol, Name => Name, Prev => <>, Character_Type => Enumeration_Type.Index.Entity_Id); begin pragma Assert (Self.Top = Enumeration_Type.Index.Region); Self.Append_Item (Value, Region => False); declare Type_Item : Entity renames Self.Data (Enumeration_Type.Index.Region).Entities (Enumeration_Type.Index.Entity_Id); begin Type_Item.Last_Literal := Self.Data (Self.Top).Entities.Last_Index; Type_Item.Is_Character_Type := True; end; end Create_Character_Literal; ------------------------------ -- Create_Character_Literal -- ------------------------------ not overriding procedure Create_Character_Literal (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Meta_Character : Meta_Character_Literal_Kind; Enumeration_Type : View) is pragma Unreferenced (Meta_Character); begin Self.Create_Character_Literal (Symbol, Name, Enumeration_Type); end Create_Character_Literal; ---------------------- -- Create_Component -- ---------------------- procedure Create_Component (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Has_Default : Boolean) is Value : Entity := (Kind => Component_View, Symbol => Symbol, Name => Name, Prev => <>, Object_Def => (1, 1), Mode => <>, Has_Default => Has_Default, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Component; -------------------------- -- Create_Empty_Context -- -------------------------- procedure Create_Empty_Context (Self : in out Context'Class) is begin Self.Data.Clear; -- Reserve the very first region to be always empty Self.Data.Append ((Enclosing => 0, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); -- Append a root region Self.Data.Append ((Enclosing => 0, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); Self.Top := Self.Data.Last_Index; end Create_Empty_Context; -------------------------------- -- Create_Enumeration_Literal -- -------------------------------- not overriding procedure Create_Enumeration_Literal (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Enumeration_Type : View) is Value : Entity := (Kind => Enumeration_Literal_View, Symbol => Symbol, Name => Name, Prev => <>, Enumeration_Type => Enumeration_Type.Index.Entity_Id); begin pragma Assert (Self.Top = Enumeration_Type.Index.Region); Self.Append_Item (Value, Region => False); declare Type_Item : Entity renames Self.Data (Enumeration_Type.Index.Region).Entities (Enumeration_Type.Index.Entity_Id); begin Type_Item.Last_Literal := Self.Data (Self.Top).Entities.Last_Index; end; end Create_Enumeration_Literal; ----------------------------- -- Create_Enumeration_Type -- ----------------------------- procedure Create_Enumeration_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Last : constant Entity_Identifier'Base := Self.Data (Self.Top).Entities.Last_Index; Value : Entity := (Kind => Enumeration_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Is_Character_Type => False, First_Literal => Last + 2, Last_Literal => Last + 2); begin Self.Append_Item (Value, Region => False); end Create_Enumeration_Type; ---------------------- -- Create_Exception -- ---------------------- procedure Create_Exception (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Exception_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value, Region => False); end Create_Exception; ----------------------------- -- Create_Float_Point_Type -- ----------------------------- procedure Create_Float_Point_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Float_Point_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value); end Create_Float_Point_Type; --------------------- -- Create_Function -- --------------------- procedure Create_Function (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Function_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1, Result_Def => (1, 1)); begin Self.Append_Item (Value); end Create_Function; -------------------------- -- Create_Implicit_Type -- -------------------------- procedure Create_Implicit_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Implicit_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value, Region => False); end Create_Implicit_Type; ---------------------------- -- Create_Incomplete_Type -- ---------------------------- procedure Create_Incomplete_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Incomplete_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Incomplete_Type; ------------------------- -- Create_Modular_Type -- ------------------------- procedure Create_Modular_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Modular_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value); end Create_Modular_Type; ------------------------------- -- Create_Object_Access_Type -- ------------------------------- procedure Create_Object_Access_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Designated : View) is Value : Entity := (Kind => Object_Access_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Designated_Type => Designated.Index); begin Self.Append_Item (Value, Region => False); end Create_Object_Access_Type; -------------------- -- Create_Package -- -------------------- procedure Create_Package (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Package_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Package; ---------------------- -- Create_Parameter -- ---------------------- not overriding procedure Create_Parameter (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Mode : Parameter_Mode; Has_Default : Boolean) is Value : Entity := (Kind => Parameter_View, Symbol => Symbol, Name => Name, Prev => <>, Object_Def => (1, 1), Mode => Mode, Has_Default => Has_Default, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Parameter; ---------------------- -- Create_Procedure -- ---------------------- procedure Create_Procedure (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Procedure_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Procedure; ------------------------ -- Create_Record_Type -- ------------------------ procedure Create_Record_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Record_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value, Replace => True); end Create_Record_Type; -------------------------------- -- Create_Signed_Integer_Type -- -------------------------------- procedure Create_Signed_Integer_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Signed_Integer_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value); end Create_Signed_Integer_Type; --------------------- -- Create_Snapshot -- --------------------- function Create_Snapshot (Self : in out Context'Class) return Snapshot_Access is Top : Region renames Self.Data (Self.Top); Result : constant Allocated_Snapshot := new Snapshot'(Region_Id => Self.Top, Entities => Top.Entities, Uses => Top.Uses); begin return Snapshot_Access (Result); end Create_Snapshot; -------------------- -- Create_Subtype -- -------------------- not overriding procedure Create_Subtype (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Subtype_Mark : View; Has_Constraint : Boolean) is Value : Entity := (Kind => Subtype_View, Symbol => Symbol, Name => Name, Prev => <>, Subtype_Mark => Subtype_Mark.Index, Has_Constraint => Has_Constraint); begin Self.Append_Item (Value); end Create_Subtype; --------------------- -- Create_Variable -- --------------------- procedure Create_Variable (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Variable_View, Symbol => Symbol, Name => Name, Prev => <>, Object_Def => (1, 1), Mode => <>, Has_Default => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Variable; -------------------- -- Enter_Snapshot -- -------------------- not overriding procedure Enter_Snapshot (Self : in out Context'Class; Snapshot : not null Snapshot_Access) is begin if Snapshot.Entities.Is_Empty then Self.Data.Append ((Enclosing => Self.Data.Last_Index, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); Self.Top := Self.Data.Last_Index; else Self.Top := Snapshot.Region_Id; end if; Self.Restore_Snapshot (Snapshot); end Enter_Snapshot; -------------------------- -- Enumeration_Literals -- -------------------------- function Enumeration_Literals (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Index : Entity_Identifier := Item.First_Literal; Count : constant Natural := Natural (Item.Last_Literal - Index) + 1; begin return Result : View_Array (1 .. Count) do for X of Result loop X := Get_View (Self.Env, (Self.Index.Region, Index)); Index := Index + 1; end loop; end return; end Enumeration_Literals; ---------------------- -- Enumeration_Type -- ---------------------- function Enumeration_Type (Self : View) return View is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, (Self.Index.Region, Item.Enumeration_Type)); end Enumeration_Type; --------------------- -- Designated_Type -- --------------------- function Designated_Type (Self : View) return View is Value : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, Value.Designated_Type); end Designated_Type; ---------------------- -- Directly_Visible -- ---------------------- function Directly_Visible (Self : Context'Class; Symbol : Program.Visibility.Symbol) return Directly_Visible_Name_Iterator is begin return (Immediate => (Context => Self'Unchecked_Access, First => Self.Find_Direct (Symbol)), Uses => (Context => Self'Unchecked_Access, Region => Self.Top, Symbol => Symbol)); end Directly_Visible; ----------------- -- Find_Direct -- ----------------- function Find_Direct (Self : Context'Class; Symbol : Program.Symbols.Symbol) return Entity_Reference is Prev : constant Entity_Maps.Cursor := Self.Directly.Find (Symbol); begin if Entity_Maps.Has_Element (Prev) then return Entity_Maps.Element (Prev); else return No_Entity; end if; end Find_Direct; ----------- -- First -- ----------- overriding function First (Self : Region_Immediate_Visible_Iterator) return View_Cursor is begin return Result : View_Cursor := (Self.Region, 1, others => <>) do Self.Step (Result); end return; end First; ----------- -- First -- ----------- overriding function First (Self : Context_Immediate_Visible_Iterator) return View_Cursor is begin if Self.First = No_Entity then return (Region => Self.First.Region, Entity => 0, Use_Id => Positive'Last, View => <>); else return (Region => Self.First.Region, Entity => Self.First.Entity_Id, Use_Id => Positive'Last, View => Get_View (Self.Context, Self.First)); end if; end First; ----------- -- First -- ----------- overriding function First (Self : Use_Visible_Iterator) return View_Cursor is begin return Result : View_Cursor := (Self.Region, 1, 1, View => <>) do Self.Step_Use (Result); end return; end First; ----------- -- First -- ----------- overriding function First (Self : Directly_Visible_Name_Iterator) return View_Cursor is begin return Result : View_Cursor := First (Self.Immediate) do if not Has_Element (Result) then Result := Self.Uses.First; end if; end return; end First; ------------------- -- First_Subtype -- ------------------- function First_Subtype (Self : View) return View is Result : View := Self; begin while Result.Kind = Subtype_View loop Result := Subtype_Mark (Result); end loop; return Result; end First_Subtype; ------------------- -- Get_Name_View -- ------------------- function Get_Name_View (Self : Context'Class; Name : not null Program.Elements.Element_Access) return View is Visitor : Getters.Visitor (Self'Unchecked_Access); begin Visitor.Visit (Name); return Visitor.Result; end Get_Name_View; -------------- -- Get_View -- -------------- function Get_View (Env : not null Constant_Context_Access; Index : Entity_Reference) return View is Value : Entity renames Env.Data (Index.Region).Entities (Index.Entity_Id); begin return (Value.Kind, Env, Index); end Get_View; -------------- -- Get_View -- -------------- function Get_View (Self : View_Cursor) return View is begin return Self.View; end Get_View; -------------------- -- Has_Constraint -- -------------------- function Has_Constraint (Self : View) return Boolean is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Has_Constraint; end Has_Constraint; ----------------- -- Has_Default -- ----------------- function Has_Default (Self : View) return Boolean is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Has_Default; end Has_Default; ----------------- -- Has_Element -- ----------------- function Has_Element (Self : View_Cursor) return Boolean is begin return Self.Entity > 0; end Has_Element; ---------------- -- Has_Region -- ---------------- function Has_Region (Self : View) return Boolean is begin return Self.Kind in Has_Region_Kind; end Has_Region; ---------- -- Hash -- ---------- function Hash (Value : Program.Elements.Defining_Names.Defining_Name_Access) return Ada.Containers.Hash_Type is Addr : constant System.Storage_Elements.Integer_Address := System.Storage_Elements.To_Integer (Value.all'Address); begin return Ada.Containers.Hash_Type'Mod (Addr); end Hash; ----------------------- -- Immediate_Visible -- ----------------------- function Immediate_Visible (Self : View; Symbol : Program.Visibility.Symbol) return View_Iterator is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Region_Immediate_Visible_Iterator' (Context => Self.Env, Region => Item.Region, Symbol => Symbol); end Immediate_Visible; ----------------------- -- Immediate_Visible -- ----------------------- function Immediate_Visible (Self : Context'Class; Symbol : Program.Visibility.Symbol) return View_Iterator is begin return Context_Immediate_Visible_Iterator' (Context => Self'Unchecked_Access, First => Self.Find_Direct (Symbol)); end Immediate_Visible; ------------- -- Indexes -- ------------- function Indexes (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Last : Positive := 1; begin return Result : View_Array (1 .. Item.Indexes.Last_Index) do for J of Item.Indexes loop Result (Last) := Get_View (Self.Env, J); Last := Last + 1; end loop; end return; end Indexes; ----------------------- -- Is_Character_Type -- ----------------------- function Is_Character_Type (Self : View) return Boolean is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Is_Character_Type; end Is_Character_Type; ---------------------- -- Is_Expected_Type -- ---------------------- function Is_Expected_Type (Self, Expected : View) return Boolean is begin return Self = Expected; end Is_Expected_Type; ----------------- -- Latest_View -- ----------------- function Latest_View (Self : Context'Class) return View is Top : Region renames Self.Data (Self.Top); Index : Entity_Reference; begin if Top.Entities.Is_Empty then Index := (Top.Enclosing, Self.Data (Top.Enclosing).Entities.Last_Index); else Index := (Self.Top, Top.Entities.Last_Index); end if; return Get_View (Self'Unchecked_Access, Index); end Latest_View; ------------------------------ -- Leave_Declarative_Region -- ------------------------------ procedure Leave_Declarative_Region (Self : in out Context'Class) is Enclosing : constant Region_Identifier'Base := Self.Data (Self.Top).Enclosing; begin for E of reverse Self.Data (Self.Top).Entities loop if E.Prev = No_Entity then Self.Directly.Delete (E.Symbol); else Self.Directly.Replace (E.Symbol, E.Prev); end if; end loop; if Self.Data.Last_Index = Self.Top and then Self.Data (Self.Top).Entities.Is_Empty then -- Delete an unused (without any entity) region Self.Data.Delete_Last; declare Reg : Region renames Self.Data (Enclosing); Item : Entity renames Reg.Entities (Reg.Entities.Last_Index); begin if Item.Kind in Has_Region_Kind and then Item.Region = Self.Top then Item.Region := 1; -- Reserver always empty region end if; end; end if; Self.Top := Enclosing; end Leave_Declarative_Region; ---------- -- Mode -- ---------- function Mode (Self : View) return Parameter_Mode is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Mode; end Mode; ---------- -- Name -- ---------- function Name (Self : View) return Defining_Name is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Name; end Name; ---------- -- Next -- ---------- overriding function Next (Self : Region_Immediate_Visible_Iterator; Position : View_Cursor) return View_Cursor is begin return Result : View_Cursor := (Position.Region, Position.Entity + 1, others => <>) do Self.Step (Result); end return; end Next; ---------- -- Next -- ---------- overriding function Next (Self : Context_Immediate_Visible_Iterator; Position : View_Cursor) return View_Cursor is Prev : constant Entity_Reference := Self.Context.Data (Position.Region).Entities (Position.Entity).Prev; begin if Prev = No_Entity then return (Region => Self.First.Region, Entity => 0, Use_Id => 1, View => <>); else return (Region => Self.First.Region, Entity => Self.First.Entity_Id, Use_Id => 1, View => Get_View (Self.Context, Self.First)); end if; end Next; ---------- -- Next -- ---------- overriding function Next (Self : Use_Visible_Iterator; Position : View_Cursor) return View_Cursor is begin return Result : View_Cursor := (Position.Region, Position.Entity + 1, Position.Use_Id, View => <>) do Self.Step_Use (Result); end return; end Next; ---------- -- Next -- ---------- overriding function Next (Self : Directly_Visible_Name_Iterator; Position : View_Cursor) return View_Cursor is Result : View_Cursor; begin if Position.Use_Id = Positive'Last then Result := Self.Immediate.Next (Position); if Has_Element (Result) then return Result; else return Self.Uses.First; end if; end if; return Self.Uses.Next (Position); end Next; ---------------- -- Parameters -- ---------------- function Parameters (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Reg : Region renames Self.Env.Data (Item.Region); Last : Natural := 0; begin for J in 1 .. Reg.Entities.Last_Index loop if Reg.Entities (J).Kind = Parameter_View then Last := Last + 1; else exit; end if; end loop; return Result : View_Array (1 .. Last) do for J in Result'Range loop Result (J) := Get_View (Self.Env, (Item.Region, Entity_Identifier (J))); end loop; end return; end Parameters; ------------------ -- Region_Items -- ------------------ function Region_Items (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Reg : Region renames Self.Env.Data (Item.Region); begin return Result : View_Array (1 .. Natural (Reg.Entities.Last_Index)) do for J in Result'Range loop Result (J) := Get_View (Self.Env, (Item.Region, Entity_Identifier (J))); end loop; end return; end Region_Items; ---------------------- -- Restore_Snapshot -- ---------------------- not overriding procedure Restore_Snapshot (Self : in out Context'Class; Snapshot : not null Snapshot_Access) is use type Program.Visibility.Symbol; Top : Region renames Self.Data (Self.Top); Last_Common : constant Entity_Identifier := Entity_Identifier'Min (Top.Entities.Last_Index, Snapshot.Entities.Last_Index); begin -- Ignore Snapshot.Region_Id if empty, because we can recreate an empty -- region with a differect id. pragma Assert (Snapshot.Entities.Is_Empty or Self.Top = Snapshot.Region_Id); -- We expect all common entities have the same symbols. Reuse Prev for J in 1 .. Last_Common loop pragma Assert (Top.Entities (J).Symbol = Snapshot.Entities (J).Symbol); Snapshot.Entities (J).Prev := Top.Entities (J).Prev; end loop; -- Clean up old entities outside of common slice if Top.Entities.Last_Index > Last_Common then for Cursor in reverse Top.Entities.Iterate (Start => Top.Entities.To_Cursor (Last_Common + 1)) loop declare Value : Entity renames Top.Entities (Cursor); begin if Value.Prev = No_Entity then Self.Directly.Delete (Value.Symbol); else Self.Directly.Replace (Value.Symbol, Value.Prev); end if; end; end loop; end if; -- Update new entities outside of common slice if Snapshot.Entities.Last_Index > Last_Common then for Cursor in Snapshot.Entities.Iterate (Start => Snapshot.Entities.To_Cursor (Last_Common + 1)) loop declare Value : Entity renames Snapshot.Entities (Cursor); Next : constant Entity_Reference := (Self.Top, Entity_Vectors.To_Index (Cursor)); Prev : constant Entity_Maps.Cursor := Self.Directly.Find (Value.Symbol); begin if Entity_Maps.Has_Element (Prev) then Value.Prev := Entity_Maps.Element (Prev); Self.Directly.Replace_Element (Prev, Next); else Value.Prev := No_Entity; Self.Directly.Insert (Value.Symbol, Next); end if; end; end loop; end if; Top.Entities := Snapshot.Entities; Top.Uses := Snapshot.Uses; for J in 1 .. Snapshot.Entities.Last_Index loop Self.Xref.Include (Snapshot.Entities (J).Name, (Self.Top, J)); end loop; end Restore_Snapshot; ------------ -- Result -- ------------ function Result (Self : View) return View is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, Item.Result_Def); end Result; ------------------------ -- Set_Parameter_Type -- ------------------------ not overriding procedure Set_Object_Type (Self : in out Context'Class; Definition : View) is Top : Region renames Self.Data (Self.Top); Last : Entity renames Top.Entities (Top.Entities.Last_Index); begin pragma Assert (Last.Kind in Object_View); Last.Object_Def := Definition.Index; end Set_Object_Type; --------------------- -- Set_Result_Type -- --------------------- procedure Set_Result_Type (Self : in out Context'Class; Definition : View) is Top : Region renames Self.Data (Self.Top); Enclosing : Region renames Self.Data (Top.Enclosing); Last : Entity renames Enclosing.Entities (Enclosing.Entities.Last_Index); begin pragma Assert (Last.Kind = Function_View); Last.Result_Def := Definition.Index; end Set_Result_Type; ---------- -- Step -- ---------- procedure Step (Self : Region_Immediate_Visible_Iterator'Class; Cursor : in out View_Cursor) is use type Program.Symbols.Symbol; Value : Program.Visibility.Region renames Self.Context.Data (Cursor.Region); begin for Index in Cursor.Entity .. Value.Entities.Last_Index loop if Value.Entities (Index).Symbol = Self.Symbol then Cursor := (Cursor.Region, Index, 1, Get_View (Self.Context, (Cursor.Region, Index))); return; end if; end loop; Cursor.Entity := 0; end Step; -------------- -- Step_Use -- -------------- procedure Step_Use (Self : Use_Visible_Iterator'Class; Cursor : in out View_Cursor) is Next : Region_Identifier'Base := Cursor.Region; begin loop -- Over each nested region declare Top : Region renames Self.Context.Data (Next); begin if Cursor.Use_Id <= Top.Uses.Last_Index then -- have use_cl Cursor.Region := Top.Uses (Cursor.Use_Id); -- rewrite reg Self.Step (Cursor); else Cursor.Entity := 0; -- clear cursor end if; if Has_Element (Cursor) then Cursor.Region := Next; -- restore region return; elsif Cursor.Use_Id >= Top.Uses.Last_Index then Next := Self.Context.Data (Next).Enclosing; exit when Next = 0; Cursor.Use_Id := 1; else Cursor.Use_Id := Cursor.Use_Id + 1; end if; Cursor.Entity := 1; end; end loop; Cursor := (Self.Region, Entity => 0, others => <>); end Step_Use; ------------------ -- Subtype_Mark -- ------------------ function Subtype_Mark (Self : View) return View is Value : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin case Value.Kind is when Subtype_View => return Get_View (Self.Env, Value.Subtype_Mark); when Object_View => return Get_View (Self.Env, Value.Object_Def); when others => raise Constraint_Error; end case; end Subtype_Mark; --------------- -- To_Vector -- --------------- function To_Vector (List : View_Array) return Entity_References.Vector is begin return Result : Entity_References.Vector do Result.Reserve_Capacity (List'Length); for View of List loop Result.Append (View.Index); end loop; end return; end To_Vector; ------------- -- Type_Of -- ------------- function Type_Of (Self : View) return View is begin case Self.Kind is when Enumeration_Literal_View | Character_Literal_View => return Enumeration_Type (Self); when Object_View => return Subtype_Mark (Self); when others => raise Program_Error; end case; end Type_Of; ----------------- -- Use_Visible -- ----------------- function Use_Visible (Self : Context'Class; Symbol : Program.Visibility.Symbol) return View_Iterator is begin return Use_Visible_Iterator' (Context => Self'Unchecked_Access, Region => Self.Top, Symbol => Symbol); end Use_Visible; end Program.Visibility;
package P is type T; type T is record One: access T; -- Missing semicolon used to choke the Ada parser Two: access T end record; end P;
with PolyPaver.Floats; --# inherit PolyPaver.Exact, PolyPaver.Interval, PolyPaver.Integers, PolyPaver.Floats; package Riemann is function erfRiemann(x : Float; n : Integer) return Float; --# pre PolyPaver.Floats.Is_Range(x, 0.0, 4.0) --# and PolyPaver.Integers.Is_Range(n, 1, 100); --# return result => --# PolyPaver.Interval.Contained_In( --# result --# , --# PolyPaver.Exact.Integral(0.0,x,PolyPaver.Exact.Exp(-PolyPaver.Exact.Integration_Variable**2)) --# + --# PolyPaver.Interval.Hull( --# - 0.1*Float(n+1) --# , --# (1.0-PolyPaver.Exact.Exp(-x**2))*x/Float(n) --# + 0.1*Float(n+1) --# ) --# ); end Riemann;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . P E R F E C T _ H A S H _ G E N E R A T O R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2002-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 package provides a generator of static minimal perfect hash functions. -- To understand what a perfect hash function is, we define several notions. -- These definitions are inspired from the following paper: -- Zbigniew J. Czech, George Havas, and Bohdan S. Majewski ``An Optimal -- Algorithm for Generating Minimal Perfect Hash Functions'', Information -- Processing Letters, 43(1992) pp.257-264, Oct.1992 -- Let W be a set of m words. A hash function h is a function that maps the -- set of words W into some given interval I of integers [0, k-1], where k is -- an integer, usually k >= m. h (w) where w is a word in W computes an -- address or an integer from I for the storage or the retrieval of that -- item. The storage area used to store items is known as a hash table. Words -- for which the same address is computed are called synonyms. Due to the -- existence of synonyms a situation called collision may arise in which two -- items w1 and w2 have the same address. Several schemes for resolving -- collisions are known. A perfect hash function is an injection from the word -- set W to the integer interval I with k >= m. If k = m, then h is a minimal -- perfect hash function. A hash function is order preserving if it puts -- entries into the hash table in a prespecified order. -- A minimal perfect hash function is defined by two properties: -- Since no collisions occur each item can be retrieved from the table in -- *one* probe. This represents the "perfect" property. -- The hash table size corresponds to the exact size of W and *no larger*. -- This represents the "minimal" property. -- The functions generated by this package require the words to be known in -- advance (they are "static" hash functions). The hash functions are also -- order preserving. If w2 is inserted after w1 in the generator, then h (w1) -- < h (w2). These hashing functions are convenient for use with realtime -- applications. package GNAT.Perfect_Hash_Generators is Default_K_To_V : constant Float := 2.05; -- Default ratio for the algorithm. When K is the number of keys, V = -- (K_To_V) * K is the size of the main table of the hash function. To -- converge, the algorithm requires K_To_V to be strictly greater than 2.0. Default_Pkg_Name : constant String := "Perfect_Hash"; -- Default package name in which the hash function is defined Default_Position : constant String := ""; -- The generator allows selection of the character positions used in the -- hash function. By default, all positions are selected. Default_Tries : constant Positive := 20; -- This algorithm may not succeed to find a possible mapping on the first -- try and may have to iterate a number of times. This constant bounds the -- number of tries. type Optimization is (Memory_Space, CPU_Time); -- Optimize either the memory space or the execution time. Note: in -- practice, the optimization mode has little effect on speed. The tables -- are somewhat smaller with Memory_Space. Verbose : Boolean := False; -- Output the status of the algorithm. For instance, the tables, the random -- graph (edges, vertices) and selected char positions are output between -- two iterations. procedure Initialize (Seed : Natural; K_To_V : Float := Default_K_To_V; Optim : Optimization := Memory_Space; Tries : Positive := Default_Tries); -- Initialize the generator and its internal structures. Set the ratio of -- vertices over keys in the random graphs. This value has to be greater -- than 2.0 in order for the algorithm to succeed. The word set is not -- modified (in particular when it is already set). For instance, it is -- possible to run several times the generator with different settings on -- the same words. -- -- A classical way of doing is to Insert all the words and then to invoke -- Initialize and Compute. If Compute fails to find a perfect hash -- function, invoke Initialize another time with other configuration -- parameters (probably with a greater K_To_V ratio). Once successful, -- invoke Produce and Finalize. procedure Finalize; -- Deallocate the internal structures and the words table procedure Insert (Value : String); -- Insert a new word into the table. ASCII.NUL characters are not allowed. Too_Many_Tries : exception; -- Raised after Tries unsuccessful runs procedure Compute (Position : String := Default_Position); -- Compute the hash function. Position allows the definition of selection -- of character positions used in the word hash function. Positions can be -- separated by commas and ranges like x-y may be used. Character '$' -- represents the final character of a word. With an empty position, the -- generator automatically produces positions to reduce the memory usage. -- Raise Too_Many_Tries if the algorithm does not succeed within Tries -- attempts (see Initialize). procedure Produce (Pkg_Name : String := Default_Pkg_Name; Use_Stdout : Boolean := False); -- Generate the hash function package Pkg_Name. This package includes the -- minimal perfect Hash function. The output is normally placed in the -- current directory, in files X.ads and X.adb, where X is the standard -- GNAT file name for a package named Pkg_Name. If Use_Stdout is True, the -- output goes to standard output, and no files are written. ---------------------------------------------------------------- -- The routines and structures defined below allow producing the hash -- function using a different way from the procedure above. The procedure -- Define returns the lengths of an internal table and its item type size. -- The function Value returns the value of each item in the table. -- The hash function has the following form: -- h (w) = (g (f1 (w)) + g (f2 (w))) mod m -- G is a function based on a graph table [0,n-1] -> [0,m-1]. m is the -- number of keys. n is an internally computed value and it can be obtained -- as the length of vector G. -- F1 and F2 are two functions based on two function tables T1 and T2. -- Their definition depends on the chosen optimization mode. -- Only some character positions are used in the words because they are -- significant. They are listed in a character position table (P in the -- pseudo-code below). For instance, in {"jan", "feb", "mar", "apr", "jun", -- "jul", "aug", "sep", "oct", "nov", "dec"}, only positions 2 and 3 are -- significant (the first character can be ignored). In this example, P = -- {2, 3} -- When Optimization is CPU_Time, the first dimension of T1 and T2 -- corresponds to the character position in the word and the second to the -- character set. As all the character set is not used, we define a used -- character table which associates a distinct index to each used character -- (unused characters are mapped to zero). In this case, the second -- dimension of T1 and T2 is reduced to the used character set (C in the -- pseudo-code below). Therefore, the hash function has the following: -- function Hash (S : String) return Natural is -- F : constant Natural := S'First - 1; -- L : constant Natural := S'Length; -- F1, F2 : Natural := 0; -- J : <t>; -- begin -- for K in P'Range loop -- exit when L < P (K); -- J := C (S (P (K) + F)); -- F1 := (F1 + Natural (T1 (K, J))) mod <n>; -- F2 := (F2 + Natural (T2 (K, J))) mod <n>; -- end loop; -- return (Natural (G (F1)) + Natural (G (F2))) mod <m>; -- end Hash; -- When Optimization is Memory_Space, the first dimension of T1 and T2 -- corresponds to the character position in the word and the second -- dimension is ignored. T1 and T2 are no longer matrices but vectors. -- Therefore, the used character table is not available. The hash function -- has the following form: -- function Hash (S : String) return Natural is -- F : constant Natural := S'First - 1; -- L : constant Natural := S'Length; -- F1, F2 : Natural := 0; -- J : <t>; -- begin -- for K in P'Range loop -- exit when L < P (K); -- J := Character'Pos (S (P (K) + F)); -- F1 := (F1 + Natural (T1 (K) * J)) mod <n>; -- F2 := (F2 + Natural (T2 (K) * J)) mod <n>; -- end loop; -- return (Natural (G (F1)) + Natural (G (F2))) mod <m>; -- end Hash; type Table_Name is (Character_Position, Used_Character_Set, Function_Table_1, Function_Table_2, Graph_Table); procedure Define (Name : Table_Name; Item_Size : out Natural; Length_1 : out Natural; Length_2 : out Natural); -- Return the definition of the table Name. This includes the length of -- dimensions 1 and 2 and the size of an unsigned integer item. When -- Length_2 is zero, the table has only one dimension. All the ranges -- start from zero. function Value (Name : Table_Name; J : Natural; K : Natural := 0) return Natural; -- Return the value of the component (I, J) of the table Name. When the -- table has only one dimension, J is ignored. end GNAT.Perfect_Hash_Generators;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 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. with Orka.SIMD.SSE.Singles.Compare; with Orka.SIMD.SSE.Singles.Logical; with Orka.SIMD.SSE.Singles.Swizzle; package body Orka.SIMD.SSE.Singles.Arithmetic is function "*" (Left, Right : m128_Array) return m128_Array is Result : m128_Array; begin for I in Index_Homogeneous'Range loop Result (I) := Left * Right (I); end loop; return Result; end "*"; function "*" (Left : m128_Array; Right : m128) return m128 is use SIMD.SSE.Singles.Swizzle; Mask_0_0_0_0 : constant Unsigned_32 := 0 or 0 * 4 or 0 * 16 or 0 * 64; Mask_1_1_1_1 : constant Unsigned_32 := 1 or 1 * 4 or 1 * 16 or 1 * 64; Mask_2_2_2_2 : constant Unsigned_32 := 2 or 2 * 4 or 2 * 16 or 2 * 64; Mask_3_3_3_3 : constant Unsigned_32 := 3 or 3 * 4 or 3 * 16 or 3 * 64; XXXX, YYYY, ZZZZ, WWWW, M0, M1, M2, M3 : m128; begin XXXX := Shuffle (Right, Right, Mask_0_0_0_0); YYYY := Shuffle (Right, Right, Mask_1_1_1_1); ZZZZ := Shuffle (Right, Right, Mask_2_2_2_2); WWWW := Shuffle (Right, Right, Mask_3_3_3_3); M0 := XXXX * Left (X); M1 := YYYY * Left (Y); M2 := ZZZZ * Left (Z); M3 := WWWW * Left (W); M0 := M0 + M1; M2 := M2 + M3; return M0 + M2; end "*"; function Divide_Or_Zero (Left, Right : m128) return m128 is use SIMD.SSE.Singles.Compare; use SIMD.SSE.Singles.Logical; -- Create a mask with all 1's for each element that is non-zero Zero : constant m128 := (0.0, 0.0, 0.0, 0.0); Mask : constant m128 := Zero /= Right; Normalized : constant m128 := Left / Right; begin -- Any element in Right that is zero will result in a -- corresponding element consisting of all 0's in the Mask. -- This will avoid the divide-by-zero exception when dividing. return Mask and Normalized; end Divide_Or_Zero; function "abs" (Elements : m128) return m128 is use SIMD.SSE.Singles.Logical; begin return And_Not ((-0.0, -0.0, -0.0, -0.0), Elements); end "abs"; function Sum (Elements : m128) return Float_32 is use SIMD.SSE.Singles.Swizzle; -- From https://stackoverflow.com/a/35270026 Mask_1_0_3_2 : constant Unsigned_32 := 1 or 0 * 4 or 3 * 16 or 2 * 64; -- Elements: X Y Z W -- Shuffled: Y X W Z -- --------------- + -- Sum: X+Y X+Y Z+W Z+W Shuffled : constant m128 := Shuffle (Elements, Elements, Mask_1_0_3_2); Sum : constant m128 := Elements + Shuffled; -- Sum: X+Y X+Y Z+W Z+W -- Move: Z+W Z+W W Z -- --------------- + -- New sum: X+Y+Z+W . . . Result : constant m128 := Move_HL (Shuffled, Sum) + Sum; begin return Result (X); end Sum; end Orka.SIMD.SSE.Singles.Arithmetic;
pragma License (Unrestricted); -- implementation unit required by compiler with System.Exponentiations; with System.Unsigned_Types; package System.Exp_LLU is pragma Pure; -- required for "**" by compiler (s-expllu.ads) -- Modular types do not raise the exceptions. function Exp_Long_Long_Unsigned is new Exponentiations.Generic_Exp_Unsigned ( Unsigned_Types.Long_Long_Unsigned, Shift_Left => Unsigned_Types.Shift_Left); end System.Exp_LLU;
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com> -- -- 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, 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 -- AUTHORS OR 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. ------------------------------------------------------------------------------- with Ada.Containers.Indefinite_Vectors; with Ada.Strings.Unbounded; with LSE.Model.Grammar.Symbol_Utils; with LSE.Model.IO.Turtle_Utils; with LSE.Model.L_System.Error; with LSE.Model.L_System.Growth_Rule_Utils; with LSE.Model.L_System.L_System; with LSE.Utils.Angle; use Ada.Containers; use Ada.Strings.Unbounded; use LSE.Model.IO.Turtle_Utils; use LSE.Model.L_System.Error; use LSE.Model.L_System.Growth_Rule_Utils; use LSE.Model.L_System.L_System; use LSE.Model.Grammar.Symbol_Utils; use LSE.Utils.Angle; -- @description -- This package provide a set of methods to build a L-System. -- package LSE.Model.L_System.Concrete_Builder is -- Builder of L-System type Instance is tagged private; -- Constructor procedure Initialize (This : out Instance); -- Build product -- @return Return True if no error was encountered, False otherwise function Make (This : out Instance; Item : String) return Boolean; -- Get the finished product -- @param Turtle Reference to the turtle -- @return Return the finished product function Get_Product (This : Instance; Turtle : LSE.Model.IO.Turtle_Utils.Holder) return L_System.Instance; -- Get the finished product -- @param Turtle Reference to the turtle -- @param LS Reference to the L-System -- @return Return the finished product procedure Get_Product (This : Instance; LS : out L_System.Instance; Turtle : LSE.Model.IO.Turtle_Utils.Holder); -- Get encountered errors -- @return Return all errors messages function Get_Error (This : Instance) return String; private package Error_Vector is new Indefinite_Vectors (Natural, Error.Instance'Class); use Error_Vector; package String_Vector is new Indefinite_Vectors (Natural, String); use String_Vector; -- Regex to find unexpected characters Regexp_Global : constant String := "([^\s0-9a-zA-Z-+|\[\].]+)"; -- Regex to get angle Regexp_Angle : constant String := "^([0-9]+([.][0-9]*)?|[.][0-9]+)"; -- Regex to get axiom Regexp_Axiom : constant String := "^([a-zA-Z-+|\[\]]+)"; -- Regex to get rule Regexp_Rule : constant String := "^([a-zA-Z-+|\[\]]\s+[a-zA-Z-+|\[\]]+)"; type Instance is tagged record -- Axiom Axiom : LSE.Model.Grammar.Symbol_Utils.P_List.List; -- Angle Angle : LSE.Utils.Angle.Angle; -- Growth rules Rules : LSE.Model.L_System.Growth_Rule_Utils.P_List.List; -- Contains all errors found Error : Error_Vector.Vector; end record; -- Split string into several other. -- @param Item String to split -- @param Separator Separator used to split -- @param Vec List that will contains all splitted strings procedure Parse (Item : String; Separator : String; Vec : in out String_Vector.Vector); -- Concatenate a list of string into one. -- @param Item Unified string -- @param Separator Separator used to concatenate -- @param Vec List that contains all strings to concatenate procedure Concat (Item : out Unbounded_String; Separator : String; Vec : in out String_Vector.Vector); -- Check if a pattern is matched in string. -- @param Expression Regex -- @param Search_In String to check -- @param First Location of first character matched -- @param Last Location of last character matched -- @param Found True if Expression found in Search_In, False otherwise procedure Search_For_Pattern (Expression, Search_In : String; First, Last : out Positive; Found : out Boolean); -- Get next usable character (skip blanks char, etc.). -- @param Item String where working -- @param Last_Index Last index of the string -- @param First Location of first character matched to the last expression -- @param Last Location of last character matched to the last expression -- @return Return True if next sequence available, False otherwise function Get_Next_Token (Item : out Unbounded_String; Last_Index : out Positive; First, Last : Positive) return Boolean; -- Make angle. -- @param This Reference of the instance -- @param Input String where working -- @param First Location of first character matched -- @param Last Location of last character matched -- @return Return True if angle are get, False otherwise function Make_Angle (This : out Instance; Input : Unbounded_String; First, Last : in out Positive) return Boolean; -- Make axiom. -- @param This Reference of the instance -- @param Input String where working -- @param First Location of first character matched -- @param Last Location of last character matched -- @return Return True if axiom are get, False otherwise function Make_Axiom (This : out Instance; Input : out Unbounded_String; First, Last : in out Positive) return Boolean; -- Make rule (at least one rule are required). -- @param This Reference of the instance -- @param Input String where working -- @param First Location of first character matched -- @param Last Location of last character matched -- @return Return True if rule(s) are get, False otherwise function Make_Rule (This : out Instance; Input : out Unbounded_String; First, Last : in out Positive) return Boolean; end LSE.Model.L_System.Concrete_Builder;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This package provides a set of convenience routines for putting characters -- and strings out to the LCD. with BMP_Fonts; use BMP_Fonts; with HAL.Bitmap; with HAL.Framebuffer; package LCD_Std_Out is Black : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Black; Blue : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Blue; Light_Blue : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Light_Blue; Green : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Green; Cyan : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Cyan; Gray : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Gray; Magenta : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Magenta; Light_Green : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Light_Green; Brown : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Brown; Red : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Red; Orange : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Orange; Yellow : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.Yellow; White : HAL.Bitmap.Bitmap_Color renames HAL.Bitmap.White; Default_Text_Color : constant HAL.Bitmap.Bitmap_Color := White; Default_Background_Color : constant HAL.Bitmap.Bitmap_Color := Black; Default_Font : constant BMP_Font := Font16x24; -- Default_Orientation : constant LCD.Orientations := LCD.Portrait_2; -- Changes to these current values will appear on subsequent calls to the -- output routines. Current_Text_Color : HAL.Bitmap.Bitmap_Color := Default_Text_Color; Current_Background_Color : HAL.Bitmap.Bitmap_Color := Default_Background_Color; procedure Set_Font (To : BMP_Font); -- Changes the current font setting so that subsequent output is in the -- specified font. procedure Set_Orientation (To : HAL.Framebuffer.Display_Orientation); -- Configures the screen orientation and fills the screen with the current -- background color. All previously displayed content is lost. procedure Clear_Screen; ---------------------------------------------------------------------------- -- These routines maintain a logical line and column, such that text will -- wrap around to the next "line" when necessary, as determined by the -- current orientation of the screen. procedure Put_Line (Msg : String); -- Note: wraps around to the next line if necessary. -- Always calls procedure New_Line automatically after printing the string. procedure Put (Msg : String); -- Note: wraps around to the next line if necessary. procedure Put (Msg : Character); procedure New_Line; -- A subsequent call to Put or Put_Line will start printing characters at -- the beginning of the next line, wrapping around to the top of the LCD -- screen if necessary. ---------------------------------------------------------------------------- -- These routines are provided for convenience, as an alternative to -- using both this package and an instance of Bitmnapped_Drawing directly, -- when wanting both the wrap-around semantics and direct X/Y coordinate -- control. You can combine calls to these routines with the ones above but -- these do not update the logical line/column state, so more likely you -- will use one set or the other. If you only need X/Y coordinate control, -- consider directly using an instance of HAL.Bitmap. procedure Put (X, Y : Natural; Msg : Character); -- Prints the character at the specified location. Has no other effect -- whatsoever, especially none on the state of the current logical line -- or logical column. procedure Put (X, Y : Natural; Msg : String); -- Prints the string, starting at the specified location. Has no other -- effect whatsoever, especially none on the state of the current logical -- line or logical column. Does not wrap around. end LCD_Std_Out;
use Bitmap_Store; with Bitmap_Store; ... X : Image (1..64, 1..64); begin Fill (X, (255, 255, 255)); X (1, 2) := (R => 255, others => 0); X (3, 4) := X (1, 2);
package body Lto1_Pkg is procedure Initialize (Radar : in Radar_T) is Antenna1 : Antenna_Type_T; Antenna2 : Antenna_Type_T; begin case Radar.Sensor_Type is when radpr | radssr => Antenna1 := Radar.Sensor_Type; Antenna2 := Radar.Sensor_Type; when radcmb => Antenna1 := radpr; Antenna2 := radssr; when others => Antenna1 := radpr; Antenna2 := radssr; end case; if Antenna1 /= radpr or Antenna2 /= radssr then raise Program_Error; end if; end Initialize; end Lto1_Pkg;
with Ada.Command_Line; with Ada.Containers.Vectors; with Ada.Containers; with Ada.Direct_IO; with Ada.Directories; with Ada.Strings.Fixed; with Ada.Text_IO; procedure Day_07 is package Integer_Vectors is new Ada.Containers.Vectors(Index_Type => Natural, Element_Type => Integer); use Integer_Vectors; function Read_File(File_Path: String) return String is File_Size : Natural := Natural(Ada.Directories.Size(File_Path)); subtype File_String is String (1 .. File_Size); package File_String_IO is new Ada.Direct_IO(File_String); File : File_String_IO.File_Type; Contents : File_String; begin File_String_IO.Open(File, Mode => File_String_IO.In_File, Name => File_Path); File_String_IO.Read(File, Item => Contents); File_String_IO.Close(File); -- Ada.Text_IO.Put(Contents); return Contents; end Read_File; function Get_Positions(Contents: String) return Vector is Start: Natural; Idx: Natural; Cnt: Natural; V: Vector; begin Cnt := Ada.Strings.Fixed.Count(Source => Contents, Pattern => ","); Idx := 0; Start := 1; for I in 1 .. Cnt loop Idx := Ada.Strings.Fixed.Index(Source => Contents, Pattern => ",", From => Idx + 1); V.Append(Integer'Value(Contents(Start..Idx - 1))); Start := Idx + 1; end loop; V.Append(Integer'Value(Contents(Start..Contents'Last))); return V; end Get_Positions; function Total(Value: Integer) return Integer is begin if Value <= 1 then return Value; else return Value + Total(Value - 1); end if; end Total; procedure Part1(File_Path: String) is Contents: String := Read_File(File_Path); Median: Natural; Fuel: Natural; V: Vector; package Integer_Vectors_Sorting is new Integer_Vectors.Generic_Sorting; use Integer_Vectors_Sorting; begin V := Get_Positions(Contents); Sort(V); Median := V(Natural(V.Length) / 2); Fuel := 0; for E of V loop Fuel := Fuel + abs(E - Median); end loop; Ada.Text_IO.Put_Line("Part 1: " & Integer'Image(Fuel)); end Part1; procedure Part2(File_Path: String) is Contents: String := Read_File(File_Path); Min: Natural; Max: Natural; Fuel: Natural; Min_Fuel: Natural; V: Vector; package Integer_Vectors_Sorting is new Integer_Vectors.Generic_Sorting; use Integer_Vectors_Sorting; begin V := Get_Positions(Contents); Sort(V); Min := V.First_Element; Max := V.Last_Element; Min_Fuel := 99999999; for I in Min .. Max loop Fuel := 0; for Pos of V loop Fuel := Fuel + Total(abs(Pos - I)); end loop; if Fuel < Min_Fuel then Min_Fuel := Fuel; end if; end loop; Ada.Text_IO.Put_Line("Part 2: " & Integer'Image(Min_Fuel)); end Part2; begin for I in 1..Ada.Command_Line.Argument_Count loop Part1(Ada.Command_Line.Argument(I)); Part2(Ada.Command_Line.Argument(I)); end loop; end Day_07;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Containers.Vectors; with League.Text_Codecs; package body Torrent.Trackers is --------------- -- Event_URL -- --------------- function Event_URL (Tracker : League.IRIs.IRI; Info_Hash : SHA1; Peer_Id : SHA1; Port : Positive; Uploaded : Ada.Streams.Stream_Element_Count; Downloaded : Ada.Streams.Stream_Element_Count; Left : Ada.Streams.Stream_Element_Count; Event : Announcement_Kind) return League.IRIs.IRI is subtype SHA1_URL_Encoded is Wide_Wide_String (1 .. 60); function URL_Encoded (Value : SHA1) return SHA1_URL_Encoded; ----------------- -- URL_Encoded -- ----------------- function URL_Encoded (Value : SHA1) return SHA1_URL_Encoded is Text : constant SHA1_Image := Image (Value); begin return Result : SHA1_URL_Encoded do for J in 0 .. 19 loop Result (3 * J + 1) := '%'; Result (3 * J + 2) := Text (2 * J + 1); Result (3 * J + 3) := Text (2 * J + 2); end loop; end return; end URL_Encoded; Port_Img : constant Wide_Wide_String := Positive'Wide_Wide_Image (Port); Up_Img : constant Wide_Wide_String := Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Uploaded); Down_Img : constant Wide_Wide_String := Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Downloaded); Left_Img : constant Wide_Wide_String := Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Left); Query : League.Strings.Universal_String := Tracker.Query; Result : League.IRIs.IRI := Tracker; begin if not Query.Is_Empty then Query.Append ("&"); end if; Query.Append ("info_hash="); Query.Append (URL_Encoded (Info_Hash)); Query.Append ("&peer_id="); Query.Append (URL_Encoded (Peer_Id)); Query.Append ("&port="); Query.Append (Port_Img (2 .. Port_Img'Last)); Query.Append ("&uploaded="); Query.Append (Up_Img (2 .. Up_Img'Last)); Query.Append ("&downloaded="); Query.Append (Down_Img (2 .. Down_Img'Last)); Query.Append ("&left="); Query.Append (Left_Img (2 .. Left_Img'Last)); Query.Append ("&compact=1"); case Event is when Started => Query.Append ("&event="); Query.Append ("started"); when Completed => Query.Append ("&event="); Query.Append ("completed"); when Stopped => Query.Append ("&event="); Query.Append ("stopped"); when Regular => null; end case; Result.Set_Query (Query); return Result; end Event_URL; -------------------- -- Failure_Reason -- -------------------- function Failure_Reason (Self : Response'Class) return League.Strings.Universal_String is begin return Self.Failure_Reason; end Failure_Reason; -------------- -- Interval -- -------------- function Interval (Self : Response'Class) return Duration is begin return Self.Interval; end Interval; ---------------- -- Is_Failure -- ---------------- function Is_Failure (Self : Response'Class) return Boolean is begin return Self.Is_Failure; end Is_Failure; ----------- -- Parse -- ----------- function Parse (Data : Ada.Streams.Stream_Element_Array) return Response is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Count; use type League.Strings.Universal_String; subtype Digit is Ada.Streams.Stream_Element range Character'Pos ('0') .. Character'Pos ('9'); function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; Buffer : Ada.Streams.Stream_Element_Array renames Data; Next : Ada.Streams.Stream_Element_Count := Buffer'First; Error : constant String := "Can't parse tracker's reply."; Codec : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec (+"utf-8"); package Peer_Vectors is new Ada.Containers.Vectors (Positive, Peer); procedure Expect (Char : Ada.Streams.Stream_Element); procedure Parse_Int (Value : out Integer); procedure Parse_String (Value : out League.Strings.Universal_String); procedure Parse_Peers_String (Result : out Peer_Vectors.Vector); procedure Parse_IP (Value : out League.Strings.Universal_String); procedure Parse_Port (Value : out Natural); package Constants is Interval : constant League.Strings.Universal_String := +"interval"; Peers : constant League.Strings.Universal_String := +"peers"; Failure : constant League.Strings.Universal_String := +"failure reason"; end Constants; ------------ -- Expect -- ------------ procedure Expect (Char : Ada.Streams.Stream_Element) is begin if Buffer (Next) = Char then Next := Next + 1; else raise Constraint_Error with Error; end if; end Expect; --------------- -- Parse_Int -- --------------- procedure Parse_Int (Value : out Integer) is begin Expect (Character'Pos ('i')); Value := 0; while Buffer (Next) in Digit loop Value := Value * 10 + Integer (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; Expect (Character'Pos ('e')); end Parse_Int; -------------- -- Parse_IP -- -------------- procedure Parse_IP (Value : out League.Strings.Universal_String) is X1 : constant Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next)); X2 : Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next + 1)); X3 : Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next + 2)); X4 : Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next + 3)); begin X2 (1) := '.'; X3 (1) := '.'; X4 (1) := '.'; Value.Clear; Value.Append (X1 (2 .. X1'Last)); Value.Append (X2); Value.Append (X3); Value.Append (X4); Next := Next + 4; end Parse_IP; ------------------------ -- Parse_Peers_String -- ------------------------ procedure Parse_Peers_String (Result : out Peer_Vectors.Vector) is Len : Ada.Streams.Stream_Element_Count := 0; begin while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; if Len mod 6 /= 0 then raise Constraint_Error with Error; end if; Expect (Character'Pos (':')); Result.Reserve_Capacity (Ada.Containers.Count_Type (Len / 6)); for J in 1 .. Len / 6 loop declare Item : Peer; begin Item.Id := (others => 0); Parse_IP (Item.Address); Parse_Port (Item.Port); Result.Append (Item); end; end loop; end Parse_Peers_String; ---------------- -- Parse_Port -- ---------------- procedure Parse_Port (Value : out Natural) is begin Value := Natural (Buffer (Next)) * 256 + Natural (Buffer (Next + 1)); Next := Next + 2; end Parse_Port; ------------------ -- Parse_String -- ------------------ procedure Parse_String (Value : out League.Strings.Universal_String) is Len : Ada.Streams.Stream_Element_Count := 0; begin while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; Expect (Character'Pos (':')); Value := Codec.Decode (Buffer (Next .. Next + Len - 1)); Next := Next + Len; end Parse_String; Key : League.Strings.Universal_String; Failure : League.Strings.Universal_String; Interval : Integer := 0; Peers : Peer_Vectors.Vector; Ignore : Integer; begin Expect (Character'Pos ('d')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Key); if Key = Constants.Failure then Parse_String (Failure); elsif Key = Constants.Interval then Parse_Int (Interval); elsif Key = Constants.Peers then if Buffer (Next) in Digit then Parse_Peers_String (Peers); else raise Constraint_Error with "Unimplemented peers reading"; end if; elsif Buffer (Next) = Character'Pos ('i') then Parse_Int (Ignore); else raise Constraint_Error with Error; end if; end loop; Expect (Character'Pos ('e')); return Result : Response (Peer_Count => Peers.Last_Index) do Result.Is_Failure := not Failure.Is_Empty; Result.Failure_Reason := Failure; Result.Interval := Duration (Interval); for J in Result.Peers'Range loop Result.Peers (J) := Peers.Element (J); end loop; end return; end Parse; ------------------ -- Peer_Address -- ------------------ function Peer_Address (Self : Response'Class; Index : Positive) return League.Strings.Universal_String is begin return Self.Peers (Index).Address; end Peer_Address; ---------------- -- Peer_Count -- ---------------- function Peer_Count (Self : Response'Class) return Natural is begin return Self.Peer_Count; end Peer_Count; ------------- -- Peer_Id -- ------------- function Peer_Id (Self : Response'Class; Index : Positive) return SHA1 is begin return Self.Peers (Index).Id; end Peer_Id; --------------- -- Peer_Port -- --------------- function Peer_Port (Self : Response'Class; Index : Positive) return Natural is begin return Self.Peers (Index).Port; end Peer_Port; end Torrent.Trackers;
with Ada.Real_Time; use Ada.Real_Time; use type Ada.Real_Time.Time_Span; package tools is Big_Bang : constant Ada.Real_Time.Time := Clock; procedure Current_Time (Origen : Ada.Real_Time.Time); procedure Print_an_Integer (x: in integer); procedure Print_a_Float (x : in float); procedure Starting_Notice (T: in String); procedure Finishing_Notice (T: in String); procedure Execution_Time (Time : Ada.Real_Time.Time_Span); end tools;
----------------------------------------------------------------------- -- hestia-display-info -- Display information about the system -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with BMP_Fonts; with Interfaces; with Hestia.Network; with UI.Texts; package body Hestia.Display.Info is use type Interfaces.Unsigned_32; use type Interfaces.Unsigned_64; use UI.Texts; use type Net.Uint16; -- Convert the integer to a string without a leading space. function Image (Value : in Net.Uint32) return String; function Image (Value : in Net.Uint64) return String; function To_Digits (Val : Natural) return String; -- Kb, Mb, Gb units. KB : constant Net.Uint64 := 1024; MB : constant Net.Uint64 := KB * KB; GB : constant Net.Uint64 := MB * MB; -- Convert the integer to a string without a leading space. function Image (Value : in Net.Uint32) return String is Result : constant String := Net.Uint32'Image (Value); begin return Result (Result'First + 1 .. Result'Last); end Image; function Image (Value : in Net.Uint64) return String is Result : constant String := Net.Uint64'Image (Value); begin return Result (Result'First + 1 .. Result'Last); end Image; Dec_String : constant String := "0123456789"; function To_Digits (Val : Natural) return String is Result : String (1 .. 2); begin Result (1) := Dec_String (Positive ((Val / 10) + 1)); Result (2) := Dec_String (Positive ((Val mod 10) + 1)); return Result; end To_Digits; function Format_Packets (Value : in Net.Uint32) return String is begin return Net.Uint32'Image (Value); end Format_Packets; function Format_Bytes (Value : in Net.Uint64) return String is begin if Value < 10 * KB then return Image (Net.Uint32 (Value)); elsif Value < 10 * MB then return Image (Value / KB) & "." & Image (((Value mod KB) * 10) / KB) & "Kb"; elsif Value < 10 * GB then return Image (Value / MB) & "." & Image (((Value mod MB) * 10) / MB) & "Mb"; else return Image (Value / GB) & "." & Image (((Value mod GB) * 10) / GB) & "Gb"; end if; end Format_Bytes; function Format_Bandwidth (Value : in Net.Uint32) return String is begin if Value < Net.Uint32 (KB) then return Image (Value); elsif Value < Net.Uint32 (MB) then return Image (Value / Net.Uint32 (KB)) & "." & Image (((Value mod Net.Uint32 (KB)) * 10) / Net.Uint32 (KB)) & "Kbs"; else return Image (Value / Net.Uint32 (MB)) & "." & Image (((Value mod Net.Uint32 (MB)) * 10) / Net.Uint32 (MB)) & "Mbs"; end if; end Format_Bandwidth; use Ada.Real_Time; ONE_MS : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (1); -- ------------------------------ -- Draw the layout presentation frame. -- ------------------------------ overriding procedure On_Restore (Display : in out Display_Type; Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is begin Display.Back_Button.Pos := (0, 0); Display.Back_Button.Width := 100; Display.Back_Button.Height := 30; Buffer.Set_Source (UI.Texts.Background); Buffer.Fill; UI.Texts.Current_Font := BMP_Fonts.Font16x24; UI.Texts.Draw_String (Buffer => Buffer, Start => Display.Back_Button.Pos, Width => Display.Back_Button.Width, Msg => "Back", Justify => UI.Texts.CENTER); Display.Prev_Time := Ada.Real_Time.Clock; Display.Deadline := Display.Prev_time + Ada.Real_Time.Milliseconds (1000); end On_Restore; -- Refresh the current display. overriding procedure On_Refresh (Display : in out Display_Type; Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class; Deadline : out Ada.Real_Time.Time) is use type Net.Uint32; Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; Cur_Pkts : Net.Uint32; Cur_Bytes : Net.Uint64; D : Net.Uint32; C : Net.Uint32; begin if Display.Deadline < Now then Cur_Bytes := Hestia.Network.Ifnet.Rx_Stats.Bytes; Cur_Pkts := Hestia.Network.Ifnet.Rx_Stats.Packets; C := Net.Uint32 ((Now - Display.Prev_Time) / ONE_MS); D := Net.Uint32 (Cur_Pkts - Display.Pkts); Display.Speed := Net.Uint32 (D * 1000) / C; Display.Bandwidth := Natural (((Cur_Bytes - Display.Bytes) * 8000) / Net.Uint64 (C)); Display.Prev_Time := Now; Display.Deadline := Display.Deadline + Ada.Real_Time.Seconds (1); Display.Pkts := Cur_Pkts; Display.Bytes := Cur_Bytes; end if; Buffer.Set_Source (UI.Texts.Background); Buffer.Fill_Rect (Area => (Position => (0, 160), Width => 99, Height => Buffer.Height - 160)); UI.Texts.Current_Font := BMP_Fonts.Font12x12; UI.Texts.Draw_String (Buffer, Start => (3, 220), Width => 150, Msg => "pkts/s"); UI.Texts.Draw_String (Buffer, Start => (3, 160), Msg => "bps", Width => 150); UI.Texts.Current_Font := BMP_Fonts.Font16x24; UI.Texts.Draw_String (Buffer, Start => (0, 250), Width => 150, Msg => Image (Display.Speed)); UI.Texts.Draw_String (Buffer, Start => (0, 180), Width => 150, Msg => Format_Bandwidth (Interfaces.Unsigned_32 (Display.Bandwidth))); Deadline := Display.Deadline; end On_Refresh; -- Handle touch events on the display. overriding procedure On_Touch (Display : in out Display_Type; Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class; States : in HAL.Touch_Panel.TP_State) is use UI.Buttons; X : constant Natural := States (States'First).X; Y : constant Natural := States (States'First).Y; begin if UI.Buttons.Contains (Display.Back_Button, X, Y) then UI.Displays.Pop_Display; end if; end On_Touch; end Hestia.Display.Info;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements.Expressions; with Program.Lexical_Elements; package Program.Elements.Short_Circuit_Operations is pragma Pure (Program.Elements.Short_Circuit_Operations); type Short_Circuit_Operation is limited interface and Program.Elements.Expressions.Expression; type Short_Circuit_Operation_Access is access all Short_Circuit_Operation'Class with Storage_Size => 0; not overriding function Left (Self : Short_Circuit_Operation) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Right (Self : Short_Circuit_Operation) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Has_And_Then (Self : Short_Circuit_Operation) return Boolean is abstract; not overriding function Has_Or_Else (Self : Short_Circuit_Operation) return Boolean is abstract; type Short_Circuit_Operation_Text is limited interface; type Short_Circuit_Operation_Text_Access is access all Short_Circuit_Operation_Text'Class with Storage_Size => 0; not overriding function To_Short_Circuit_Operation_Text (Self : in out Short_Circuit_Operation) return Short_Circuit_Operation_Text_Access is abstract; not overriding function And_Token (Self : Short_Circuit_Operation_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Then_Token (Self : Short_Circuit_Operation_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Or_Token (Self : Short_Circuit_Operation_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Else_Token (Self : Short_Circuit_Operation_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Short_Circuit_Operations;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 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. with Ada.Numerics; package Orka.Inputs.Joysticks.Filtering is pragma Preelaborate; function RC (Cutoff_Frequency : GL.Types.Single) return GL.Types.Single is (1.0 / (2.0 * Ada.Numerics.Pi * Cutoff_Frequency)); -- Return the RC for a given cutoff frequency in Hertz -- -- 1 -- fc = --------- -- 2*Pi * RC function Low_Pass_Filter (Current, Last : Axis_Position; RC, DT : GL.Types.Single) return Axis_Position; function Dead_Zone (Value, Threshold : Axis_Position) return Axis_Position with Pre => Threshold >= 0.0; function Invert (Value : Axis_Position; Enable : Boolean) return Axis_Position; end Orka.Inputs.Joysticks.Filtering;
-- Milesian converter -- A simple converter to and from Milesian dates -- This programme is a console demonstrator for the referred packages -- copyright Miletus 2015-2019 - no transformation allowed, no commercial use -- application developed using GPS GPL 2014 of Adacore -- inquiries: see www.calendriermilesien.org -- Versions -- M2017-01-13 : adaptation to new package specifications -- M2019-01-16 : Milesian calendar intercalation back to Gregorian ---------------------------------------------------------------------------- -- Copyright Miletus 2015-2019 -- 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, 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: -- 1. The above copyright notice and this permission notice shall be included -- in all copies or substantial portions of the Software. -- 2. Changes with respect to any former version shall be documented. -- -- The software is provided "as is", without warranty of any kind, -- express of implied, including but not limited to the warranties of -- merchantability, fitness for a particular purpose and noninfringement. -- In no event shall the authors of 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. -- Inquiries: www.calendriermilesien.org ------------------------------------------------------------------------------- with Calendar; use Calendar; with Calendar.Formatting; use Calendar.Formatting; with Scaliger; use Scaliger; with Scaliger.Ada_conversion; use Scaliger.Ada_conversion; with Milesian_calendar; use Milesian_calendar; with Julian_calendar; use Julian_calendar; with Lunar_phase_computations; use Lunar_phase_computations; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Text_IO; use Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Milesian_environment; use Milesian_environment; use Milesian_environment.Week_Day_IO; use Milesian_environment.Julian_Day_IO; procedure Milesian_converter is NL : constant String := CR & LF ; Licence_text : constant String := "Date converter and moon phase computer using the Milesian calendar." & NL & "Written by Louis A. de Fouquieres, Miletus," & NL & "Initial version M2015-09-30, actual version M2019-01-16." & NL & "Generated with the GNAT Programming Studio GPL Edition 2014." & NL & "No warranty of any kind arising from or in connection with this application." & NL & "Library sources available on demand under GP licence." & NL & "No commercial usage allowed - inquiries: www.calendriermilesien.org"; Prompter : constant String := "Type command and figures, or H for Help:"; Help_text : constant String := "This line mode program converts dates from and to " & NL & "Julian day, Milesian, Gregorian, and Julian calendars." & NL & "Mean Moon age, residue and lunar time are also computed, " & NL & "as well as yearly key figures." & NL & "Syntax: <Command> <1 to 6 numbers separated with spaces>." & NL & "<Command> is one character as described hereunder." & NL & "Numbers are decimal possibly beginning with + or -, without spaces," & NL & "with a dot (.) as decimal separator when applicable." & NL & "When a date is expected, it must be entered as: year (-4800 to 9999)," & NL & "month number (1 to 12, by default: 1), day number (1 to 31, by default: 1)," & NL & "hours (0 to 23, default 12), minutes and seconds (default 0, max 59)." & NL & "Time of day is Terrestrial Time (64,184 s ahead of UTC in 2000)." & NL & "Lunar time is time of day where the mean Moon stands" & NL & "at the same azimuth than the mean Sun at this solar time." & NL & "Yearly key figures ('Y' command) include" & NL & "- doomsday, i.e. day of the week that falls at same dates every year," & NL & "- lunar figures at new year's eve at 7h30 UTC," & NL & "- Milesian epact and yearly lunar residue, in half-integer," & NL & "- spring full moon residue in integer value," & NL & "- for years A.D., days between 21st March and Easter" & NL & "following the Gregorian and Julian Catholic ecclesiastical computus," & NL & "and finally the delay, in days, of dates in Julian compared to Gregorian." & NL & "Available commands:" & NL & "D <Positive integer or decimal number>: Julian day;" & NL & "G <Date>: Date in Gregorian calendar (even before 1582);" & NL & "J <Date>: Date in Julian calendar;" & NL & "M <Date>: Date in Milesian calendar;" & NL & "Y <Year>: Yearly key figures (see above);" & NL & "A <Days> [<Hours> [<Minutes> [<Seconds>]]]: Add days, hours, mins, secs" & NL & "to current date, each figure is a signed integer, 0 by default;" & NL & "H: display this text;" & NL & "L: display licence notice;" & NL & "X: exit program."; Command : Character := ' '; Roman_calendar_type : Calendar_type := Unspecified; -- Duration to substract to Julian Day of first day of a year, in order -- to obtain time of "doomsday" at which the moon phase is computed. To_Doomsday_time_duration : constant Historical_Duration := 86_400.0 + 4*3600.0 + 30*60.0; -- To substract to Milesian epact to obtain a good estimate -- of Easter full moon residue To_Spring_Full_Moon : Constant := 12.52 * 86_400; This_year : Historical_year_number := 0; M_date: Milesian_date := (4, 12, -4713); R_date : Roman_date := (1, 1, -4712); This_Julian_day: Julian_day := 0; -- in integer days This_historical_time: Historical_Time := 0.0; -- in seconds Displayed_time: Fractional_day_duration := 0.0; -- in fractional days This_hour : Hour_Number := 12; This_minute : Minute_Number := 0; This_second : Second_Number :=0; Day_time : Day_Duration := 0.0; Julian_hour : Day_Historical_Duration := 0.0; Day_Number_in_Week : Integer range 0..6; Moon_time, Moon_time_shift : H24_Historical_Duration; Moon_hour : Hour_Number; Moon_minute: Minute_Number; Moon_second: Second_Number; Moon_subsecond: Second_Duration; Help_request, Licence_request : Exception; begin Put (Licence_text); New_Line; loop begin -- a block with exception handler Put (Prompter); New_Line; Get (Command); case Command is when 'H' => Skip_Line; raise Help_request; when 'L' => Skip_Line; raise Licence_request; when 'D' => --Get section Get (Displayed_time); Skip_Line; -- Conversion section This_historical_time := Convert_from_julian_day (Displayed_time); This_Julian_day := Julian_Day_Of (This_historical_time); M_date := jd_to_milesian (This_Julian_day); Julian_hour := This_historical_time - Julian_Duration_Of (This_Julian_day); Day_time := Day_Offset (Julian_hour); This_hour := Integer (Day_time) / 3600; This_minute := Integer (Day_time) / 60 - This_hour*60; This_second := Integer (Day_time) - This_hour*3600 - This_minute*60; when 'G' | 'J' => -- Get section. case Command is when 'G' => Roman_calendar_type := Gregorian; when 'J' => Roman_calendar_type := Julian; when others => Roman_calendar_type := Unspecified; end case; R_date := (1, 1, -4712); This_hour := 12; This_minute := 0; This_second := 0; Get (R_date.year); if not End_Of_Line then Get (R_date.month); end if; if not End_Of_Line then Get (R_date.day); end if; if not End_Of_Line then Get (This_hour); end if; if not End_Of_Line then Get (This_minute); end if; if not End_Of_Line then Get (This_second); end if; Skip_Line; -- Conversion section; This_Julian_day := Roman_to_JD (R_date, Roman_calendar_type); -- This function raises Time_Error if date is improper Day_time := 3600.0 * This_hour + 60.0 * This_minute + 1.0 * This_second; This_historical_time := Julian_Duration_Of (This_Julian_day) + Day_Julian_Offset (Day_time); Displayed_time := Fractionnal_day_of (This_historical_time); M_date := JD_to_Milesian (This_Julian_day); when 'M' => M_Date := (1, 1, -4712); This_hour := 12; This_minute := 0; This_second := 0; Get (M_date.year); if not End_Of_Line then Get (M_date.month); end if; if not End_Of_Line then Get (M_date.day); end if; if not End_Of_Line then Get (This_hour); end if; if not End_Of_Line then Get (This_minute); end if; if not End_Of_Line then Get (This_second); end if; Skip_Line; -- Conversion section; This_Julian_day := Milesian_to_JD (M_date); -- This function raises Time_Error if date is improper Day_time := 3600.0 * This_hour + 60.0 * This_minute + 1.0 * This_second; This_historical_time := Julian_Duration_Of (This_Julian_day) + Day_Julian_Offset (Day_time); Displayed_time := Fractionnal_day_of (This_historical_time); M_date := JD_to_Milesian (This_Julian_day); when 'Y' => M_Date := (1, 1, -4712); This_hour := 12; This_minute := 0; This_second := 0; Get (This_year); M_date.year := This_year; Skip_Line; -- Conversion section: compute "doomsday" This_Julian_day := Milesian_to_JD (M_date); -- Set to "doomsday" Day_time := 3600.0 * This_hour + 60.0 * This_minute + 1.0 * This_second; This_historical_time := Julian_Duration_Of (This_Julian_day) + Day_Julian_Offset (Day_time) - To_Doomsday_time_duration; This_Julian_day := Julian_Day_Of (This_historical_time); M_date := jd_to_milesian (This_Julian_day); Displayed_time := Fractionnal_day_of (This_historical_time); when 'A' => declare Days : Julian_Day_Duration := 0; Hour_Offset, Minute_Offset, Second_Offset : Integer := 0; Julian_Time_Offset : Historical_Duration := 0.0; begin -- Get section Get (Days); if not End_Of_Line then Get (Hour_Offset); end if; if not End_Of_Line then Get (Minute_Offset); end if; if not End_Of_Line then Get (Second_Offset); end if; Skip_Line; -- Conversion section Julian_Time_Offset := Julian_Duration_Of (3600.0 * Hour_Offset + 60.0 * Minute_Offset + 1.0 * Second_Offset); This_historical_time := This_historical_time + Julian_Duration_Of (Days) + Julian_Time_Offset ; This_Julian_day := Julian_Day_Of (This_historical_time); M_date := jd_to_milesian (This_Julian_day); Julian_hour := This_historical_time - Julian_Duration_Of (This_Julian_day); Displayed_time := Fractionnal_day_of (This_historical_time); begin Day_time := Day_Offset (Julian_hour); exception when Constraint_Error => Put("Day time out of bounds - correcting"); New_Line; Day_time := 86_399.88; -- avoids out of bounds. end; This_hour := Integer (Day_time) / 3600; This_minute := Integer (Day_time) / 60 - This_hour*60; This_second := Integer (Day_time) - This_hour*3600 - This_minute*60; end; when 'X' => put ("Bye"); when others => put (">Invalid command "); New_Line; Skip_Line; end case; exit when Command = 'X'; -- Display results section - Julian day and Milesian date. Day_Number_in_Week := This_Julian_day mod 7; If Command /= 'Y' then put ("Julian day : "); put (Displayed_time,1,6); put ("; "); put ("Milesian : "); put (Day_Name'Val (This_Julian_day mod 7),3, Lower_Case); Put (' '); put (M_date.day,1); put (' '); put (M_date.month, 1); put("m "); put (M_date.year, 1); put (", "); put (This_hour, 1); put ("h "); put (This_minute, 1); put ("mn "); put (This_second, 1); Put ("s"); New_Line; -- Put Julian and Gregorian calendar equivalent Put ("Julian : "); R_date := JD_to_Roman (This_Julian_day, Julian); Put (R_date.day,1); Put ('/'); Put (R_date.month,1); Put ('/'); Put (R_date.year,1); Put ("; Gregorian : "); R_date := JD_to_Roman (This_Julian_day, Gregorian); Put (R_date.day,1); Put ('/'); Put (R_date.month,1); Put ('/'); Put (R_date.year,1); else put ("Year: "); put (This_year, 4); put("; Doomsday: "); put (Day_Name'Val (This_Julian_day mod 7),3, Lower_Case); Put (' '); end if ; -- Give Lunar phase New_Line; Put ("Lunar age: "); Julian_Day_IO.Put (Fractionnal_day_of(Mean_lunar_age (This_historical_time)),1); Put ("; Lunar residue: "); Julian_Day_IO.Put (Fractionnal_day_of(Mean_lunar_residue (This_historical_time)),1); Put (";"); if Command /= 'Y' then -- Display lunar hour - not with year infos. New_Line; Put("Lunar time: "); Moon_time_shift := Mean_lunar_time_shift (This_historical_time); if Day_time >= Duration(Moon_time_shift) then Moon_time := H24_Historical_Duration(Day_time - Duration(Moon_time_shift)); else Moon_time := H24_Historical_Duration(86_400.0 + Day_time - Duration(Moon_time_shift)); end if; Split (Duration(Moon_time), Moon_hour, Moon_minute, Moon_second, Moon_subsecond); Put(Moon_hour,2); Put ("h "); Put (Moon_minute,2); Put ("mn "); Put (Moon_second,2); Put ("s (shift : -"); Split (Duration(Moon_time_shift), Moon_hour, Moon_minute, Moon_second, Moon_subsecond); Put(Moon_hour,2); Put ("h "); Put (Moon_minute,2); Put ("mn "); Put (Moon_second,2); Put ("s, or +"); Split (Duration(86_400.0 - Moon_time_shift), Moon_hour, Moon_minute, Moon_second, Moon_subsecond); Put(Moon_hour,2); Put ("h "); Put (Moon_minute,2); Put ("mn "); Put (Moon_second,2); Put ("s)"); end if; If Command = 'Y' then declare type Simplified_lunar_age is delta 0.5 range 0.0 .. 29.5; package Lunar_age_IO is new Text_IO.Fixed_IO (Num => Simplified_lunar_age); Age : Lunar_age := Mean_lunar_age (This_historical_time); Simple_Age : Simplified_lunar_age := Simplified_lunar_age (Float(Fractionnal_day_of(Age))); Simple_Residue : Simplified_lunar_age := 29.5 - Simple_Age; Spring_residue : Integer := 0; begin if Age <= To_Spring_Full_Moon then Spring_residue := Integer (Float'Floor (Float(Fractionnal_day_of(To_Spring_Full_Moon - Age)))); else Spring_residue := Integer (Float'Floor (Float(29.53 - Fractionnal_day_of (Age - To_Spring_Full_Moon)))); end if; New_Line; Put ("Year moon age: "); Lunar_age_IO.Put(Item => Simple_Age, Fore => 2, Aft => 1); Put ("; Year moon residue: "); Lunar_age_IO.Put(Item => Simple_Residue, Fore => 2, Aft => 1); Put ("; Spring full moon residue: "); Put(Spring_residue, 2); Put ("."); If This_year >= 1 then New_Line; Put ("21 March to Easter, Gregorian Computus: "); Put (Easter_days (This_year,Gregorian),2); Put (", Julian: "); Put (Easter_days (This_year,Julian),2); Put ("."); end if; New_Line; Put ("Delay in days of Julian calendar with respect to Gregorian :"); Put (Julian_to_Gregorian_Delay(This_year),3); end; end if; exception when Constraint_Error => Put (" Out of bounds"); when Data_Error => Put (" Invalid data"); when Scaliger.Time_Error => Put (" Invalid date"); when Help_request => Put (Help_text); when Licence_request => Put (Licence_text); when others => Put (" Unknown error"); end; New_Line; end loop; end Milesian_converter;
-- SPDX-FileCopyrightText: 2022 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Regions.Contexts.Environments.Nodes; with Regions.Contexts.Environments.Package_Nodes; package body Regions.Contexts.Environments.Factories is type Environment_Node_Access is access all Regions.Contexts.Environments.Nodes.Environment_Node; type Package_Node_Access is access all Regions.Contexts.Environments.Package_Nodes.Package_Node; ------------------- -- Append_Entity -- ------------------- overriding procedure Append_Entity (Self : access Factory; Region : in out Regions.Region'Class; Symbol : Regions.Symbols.Symbol; Entity : Regions.Entities.Entity_Access) is Name : constant Selected_Entity_Name := Nodes.Base_Entity'Class (Entity.all).Name; Reg : Nodes.Base_Entity'Class renames Nodes.Base_Entity'Class (Region); Env : constant Environments.Environment_Node_Access := Reg.Env; Node : constant Nodes.Entity_Node_Access := Env.Nodes.Element (Reg.Name); Pkg : constant Package_Node_Access := Package_Node_Access (Node); List : Selected_Entity_Name_Lists.List; begin pragma Assert (Env = Nodes.Base_Entity'Class (Entity.all).Env); if Pkg.Names.Contains (Symbol) then List := Pkg.Names.Element (Symbol); end if; List.Prepend (Name); Pkg.Names.Insert (Symbol, List); end Append_Entity; -------------------- -- Create_Package -- -------------------- overriding function Create_Package (Self : access Factory; Environment : Regions.Environments.Environment; Name : Regions.Contexts.Selected_Entity_Name) return Regions.Entities.Packages.Package_Access is Env : constant Environments.Environment_Node_Access := Environment.Data; Node : constant Package_Node_Access := new Regions.Contexts.Environments.Package_Nodes.Package_Node; begin Env.Nodes.Insert (Name, Environments.Nodes.Entity_Node_Access (Node)); return Regions.Entities.Packages.Package_Access (Env.Get_Entity (Name)); end Create_Package; ------------------ -- Enter_Region -- ------------------ overriding function Enter_Region (Self : access Factory; Environment : Regions.Environments.Environment; Region : not null Regions.Entities.Packages.Package_Access) return Regions.Environments.Environment is Reg : Nodes.Base_Entity'Class renames Nodes.Base_Entity'Class (Region.all); Env : constant Environments.Environment_Node_Access := Environment.Data; Node : constant Environments.Environment_Node_Access := new Regions.Contexts.Environments.Nodes.Environment_Node' (Context => Self.Context, Counter => 1, Nodes => Env.Nodes, Cache => Nodes.Entity_Maps.Empty_Map, Nested => Env.Nested); begin Node.Nested.Prepend (Reg.Name); -- Shell we copy Region to Env??? return (Ada.Finalization.Controlled with Data => Node); end Enter_Region; ---------------------- -- Root_Environment -- ---------------------- overriding function Root_Environment (Self : access Factory) return Regions.Environments.Environment is Name : constant Selected_Entity_Name := Self.Context.Root_Name; Environment : constant Environment_Node_Access := new Regions.Contexts.Environments.Nodes.Environment_Node (Self.Context); Node : constant Package_Node_Access := new Regions.Contexts.Environments.Package_Nodes.Package_Node; -- A pseudo-package to keep Standard in it. begin Environment.Nodes.Insert (Name, Nodes.Entity_Node_Access (Node)); Environment.Nested.Prepend (Name); return (Ada.Finalization.Controlled with Data => Environments.Environment_Node_Access (Environment)); end Root_Environment; end Regions.Contexts.Environments.Factories;
generic type Item_Type is private; package ACO.Utils.DS.Generic_Queue is pragma Preelaborate; type Queue (Max_Nof_Items : Positive) is tagged limited private; type Item_Array is array (Natural range <>) of Item_Type; function Is_Full (This : Queue) return Boolean with Inline; function Is_Empty (This : Queue) return Boolean with Inline; function Length (This : Queue) return Natural with Inline; function Free_Slots (This : Queue) return Natural with Inline; procedure Put (This : in out Queue; Item : in Item_Type) with Pre => not This.Is_Full; procedure Put (This : in out Queue; Items : in Item_Array) with Pre => Items'Length <= This.Free_Slots; procedure Get (This : in out Queue; Item : out Item_Type) with Pre => not This.Is_Empty; procedure Get (This : in out Queue; Items : out Item_Array) with Pre => Items'Length <= This.Length; procedure Flush (This : in out Queue) with Post => This.Is_Empty; function Peek (This : Queue) return Item_Type with Pre => not This.Is_Empty; function Peek (This : Queue) return Item_Array with Pre => not This.Is_Empty; private subtype Index is Positive; type Queue (Max_Nof_Items : Positive) is tagged limited record Items : Item_Array (1 .. Max_Nof_Items); Next : Index := Index'First; Old : Index := Index'First; Count : Natural := 0; end record; procedure Inc (This : in Queue; I : in out Index) with Inline; end ACO.Utils.DS.Generic_Queue;
------------------------------------------------------------------------------ -- -- -- Internet Protocol Suite Package -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- 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 copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This package provides the common TLS abstractions that are shared amongst -- both reliable-stream oriented TLS and unreliable datagram oriented DTLS. -- -- Note that DTLS support is not yet implemented, but is expected in the -- future. -- -- This package's TLS implementation is a binding to LibreSSL's libtls with Ada.Streams; private with Ada.Finalization; private with Ada.Strings.Unbounded; private with Interfaces.C; private with Interfaces.C.Strings; private with Interfaces.C.Pointers; private with INET.Internal.TLS; package INET.TLS is TLS_Error: exception; -- Raised when libtls indicates an error. The message will contain the -- error message reported by libtls. TLS_Handshake_Failed: exception; -- Raised explicitly in the case where a handshake fails. The message will -- contaion the error message reported by libtls. ----------------------- -- TLS_Security_Data -- ----------------------- type TLS_Security_Data(<>) is tagged limited private; -- TLS_Security_Data is used to either contain any number of TLS security -- objects, that are typically stores in files. These include: -- - Public certificates -- - Private keys -- - Root certificate chains -- - OCSP staples function Load_File (Path: String) return TLS_Security_Data; function Load_File (Path: String; Password: String) return TLS_Security_Data; -- Loads the content of the file at Path into memory. This implies heap -- allocation. The allocation is always explicitly zeroed and then -- freed at finalization. function Associate_File (Path: String) return TLS_Security_Data; -- Associates the file (including directories) at Path with the -- TLS_Security_Data. The file is not loaded into memory. -- -- See TLS_Configuration.Root_Certificates for information on including -- pointing to directories. procedure Output (Stream: not null access Ada.Streams.Root_Stream_Type'Class; Data : in TLS_Security_Data); for TLS_Security_Data'Output use Output; -- If the Data was either obtained through Load_File or -- TLS_Security_Data'Input of another TLS_Security_Data object that was -- itself obtained through Load_File, this- operation streams the actual -- data stored in memory, effectively copying it. -- -- If Data was obtained through Associate_File, this operation simply -- streams the path of the associated file, but does not transfer actual -- data. -- -- These streaming facilities (TLS_Security_Data'Output), allows for the -- transfer of TLS_Security_Objects from a parent process to a (less -- privledged) child process which likely could not read the actual file -- itself, as is common when implementing security best-practices function Input (Stream: not null access Ada.Streams.Root_Stream_Type'Class) return TLS_Security_Data; for TLS_Security_Data'Input use Input; -- The other side of Output - see above. System_CA_Chain: constant TLS_Security_Data; -- A file-type System_CA_Chain that can be used as the formal to the -- Root_CA_Certs parameter of TLS_Configuration.Root_Certificates. -- -- This value is set by a query to libtls during elaboration of this -- package. If libtls does not know where to find the CA root, that -- call will likely raise TLS_Error with a message from libtls -------------------- -- TLS_Session_ID -- -------------------- type TLS_Session_ID is private; -- The TLS_Session_ID type stores a session id. The type may be streamed to -- share it among multiple partitions. Alternatively, a value may be set by -- initializing it with a (true) random value. -- -- Any use of TLS_Session_ID by other subprograms in this package (and its -- children) raises a Program_Error. function Valid (ID: TLS_Session_ID) return Boolean; procedure Randomize_ID (ID: out TLS_Session_ID) with Post => Valid (ID); -------------------- -- TLS_Ticket_Key -- -------------------- type TLS_Ticket_Key is private; -- The TLS_Ticket_Key type stores a ticket key. The type may be streamed to -- share it among multiple partitions. Alternatively, a new key may be -- generated from a crayptographically random source. -- -- Any use of an unititialized TLS_Ticket_Key by other subprograms in this -- package (and its children) raises a Program_Error. function Valid (Key: TLS_Ticket_Key) return Boolean; -- Returns True iff the key has been initialized. procedure Randomize_Key (Key: out TLS_Ticket_Key) with Post => Valid (Key); -- Generates a random key from a high entropy source. Also generates a -- random "revision" value from the same source. procedure Zero_Key (Key: out TLS_Ticket_Key) with Post => not Valid (Key); -- Explicitly zeroes and invalidates a key. Can be used before deallocation. ----------------------- -- TLS_Configuration -- ----------------------- TLS_Configuration_Error: exception; -- Returned by most of the TLS_Configuration operations if the operation -- failed at the libtls level. The libtls error message becomes the -- TLS_Configuration_Error's message. type TLS_Configuration is abstract tagged limited private; -- TLS_Configuration'Class objects contains a set of configuration values -- that determine the parameters of a TLS connection. -- -- TLS_Server_Configuration objects may be reused among any number of -- TLS_Connection objects. Libressl's libtls ensures that the underlying -- structure is task-safe, and so is TLS_Configuration. -- -- The TLS_Configuration must have a lifetime that is the same as or -- longer than TLS_Connection objects that use it. -- -- Note, however, that any TLS_Security_Data objects have their data -- copied into the TLS_Configuration object, and need not have the -- same lifetime as the TLS_Configuration object itself. -- -- For security purposes, the TLS_Configuration object may have all -- secret data cleared. Doing so will prevent any further Server-side -- connections being established, unless the secrets are re-loaded. -- -- This may be useful for single-client server processes that are forked -- per connection, where maximum security is desired. type TLS_Protocol_Selection is record TLS_v1_0: Boolean := False; TLS_v1_1: Boolean := False; TLS_v1_2: Boolean := True; TLS_v1_3: Boolean := True; end record; -- Represents the selected (accepted) protocols for a configuration. The -- deaults as indicated will be the default for all TLS_Configurations -- without explicit configuration. This set of defaults is derrived from -- libressl's libtls defaults as described in tls_config_set_protocols(3) procedure Acceptable_Protocols (Configuration: in out TLS_Configuration; Protocols : in TLS_Protocol_Selection); -- Sets the acceptable protocols for Configuration procedure Root_Certificates (Configuration: in out TLS_Configuration; Root_CA_Certs: in TLS_Security_Data'Class); -- Sets a specific set of root certificates for verification of the remote -- peer's certificate. If Root_CA_Certs is Associated with a file which is -- actually a directory, the contents of the directory will be scanned for -- root certificates. procedure Key_Pair (Configuration: in out TLS_Configuration; Certificate : in TLS_Security_Data'Class; Key : in TLS_Security_Data'Class); -- Sets the public certificate and private key pair for the active -- authenication of a session. This is usually needed for servers, but may -- also be used when client authentication is requred. -- -- Note that this operation copies the data from Certificate and Key into -- the Configuration's own internal storage. procedure Clear_Keys (Configuration: in out TLS_Configuration); -- Removes and zeros any Key_Pair that has been stored in Configuration. -- After invoking Clear_Keys, any further connections created with -- Configuration will not be capable of authenticating themselves. procedure Certificate_Revocation_List (Configuration : in out TLS_Configuration; Revocation_List: in TLS_Security_Data'Class); -- Sets the Certificate Revocation List to be used to reject public -- certificates that have been revoked. procedure OCSP_Staple (Configuration: in out TLS_Configuration; Staple : in TLS_Security_Data'Class); -- Sets the OCSP_Staple from a DER encoded file typically generated by -- libressl's ocspcheck(8) utility, in conjuction with the local peer's -- certificate and their CA. -- -- The OCSP staple is sent with the local peer's certificate (typically -- a server), and allows the remote peer to validate the certificate -- without needing to contact the CA or rely on a revoation list. procedure Require_OCSP_Staple (Configuration: in out TLS_Configuration); -- Sets the configuration to require the remote peer always provide a -- OCSP staple during the handshake. procedure Supported_ALPNs (Configuration: in out TLS_Configuration; ALPN_List : in String); -- Sets the ALPN protocols to be supported by the configuration. -- ALPN_List shall be a "comma separated list of protocols, in order of -- preference" -- Implementation Facilities -- ------------------------------- procedure Get_External_Handle (Configuration: in TLS_Configuration; Handle : out INET_Extension_Handle); -- Useable only by the TLS implementation. This is used by the internal -- subprograms which need to pass libtls' internal handle of a configuration -- object as a parameter to the libtls library call. -- -- Note that this does not violate Ada privacy, since the handle is -- an external analog to a TLS_Configuration'Class object, which is -- visible. Obviously that actual handle needs to be a component of the -- TLS_Configuration object, but we don't want to expose all parts of the -- object, and so this acheives a similar end. It could be anagolous to -- associating a private type with an ID of some kind, which can be -- obtained through a similar primitive operation. -- -- The one "con" is that we lose some type safty with this approach, -- but with the use being so limited to internal implementation details, -- this presents a limited danger. -- -- That being said, the INET package has been designed such that a -- client of INET cannot ever obtain a handle anyways, and even if they -- did, they wouldn't have any use for it. -- -- If Handle is "null", Program_Error is raised. ------------------------------ -- TLS_Client_Configuration -- ------------------------------ type TLS_Client_Configuration is limited new TLS_Configuration with private; -- Using a TLS_Client_Configuration with TLS_Connection.Connect/Upgrade -- /Secure will cause the TLS session to be negotiated as if the local -- peer is the client. procedure Session_Storage (Configuration: in out TLS_Client_Configuration; Path : in String); -- Attaches a regular file at Path to the configuration for the storage of -- session data, such as tickets. This allows more efficient reconnection -- with servers within a session lifetime -- -- The file at path must be read-write accessible by only the user under -- which the partition is executing. -- -- If Session_Storage has already been invoked for Configuration, -- Program_Error is raised. ------------------------------ -- TLS_Server_Configuration -- ------------------------------ type TLS_Server_Configuration is limited new TLS_Configuration with private; -- Using a TLS_Server_Configuration with TLS_Connection.Connect/Upgrade -- /Secure will cause the TLS session to be negotiated as if the local -- peer is the server. procedure Session_Lifetime (Configuration: in out TLS_Server_Configuration; Lifetime : in Duration); -- Sets the session lifetime for session tickets. TLS_Server_Configuration -- objectes are initialized with a lifetime of 0.0. A lifetime of 0.0 -- disables session tickets. Therefore, by default, TLS_Server_Configuration -- objects will have session tickets disabled. Set this value to enable them -- -- For refence, the OpenBSD httpd server uses a 2 hour lifetime (as of -- OpenBSD 6.7). -- -- Note that Duration is rounded to the nearest second. procedure Session_ID (Configuration: in out TLS_Server_Configuration; ID : in TLS_Session_ID) with Pre'Class => Valid (ID); -- If Session_ID is not Valid, Program_Error is raised procedure Add_Ticket_Key (Configuration: in out TLS_Server_Configuration; Key : in TLS_Ticket_Key) with Pre'Class => Valid (Key); -- Each TLS_Server_Configuration contains some arbitrary list of ticket -- keys, which are rotated once per session lifetime. Add_Ticket_Key -- adds a key to this queue. If Add_Ticket_Key is not invoked, the -- TLS_Server_Configuration object will automatically generate random keys. -- -- The purpose of Add_Ticket_Key is to synchronize ticket keys amongst -- muiltiple TLS_Server_Configuration objects - typically in seperate -- processes. It is important to synchronize keys on period shorter than -- the session lifetime. The libressl documentation is sparse when it comes -- to explaining how this works, but the OpenBSD httpd server rekeys on -- a period that is 1/4 that of the session lifetime. -- -- If Key is not Valid, Program_Error is raised. procedure Verify_Client (Configuration: in out TLS_Server_Configuration); -- Requires the client to send a certificate to the server for verification private ----------------------- -- TLS_Security_Data -- ----------------------- use type Interfaces.Unsigned_8; use type Interfaces.C.size_t; package UBS renames Ada.Strings.Unbounded; subtype Security_Data_Element is Interfaces.Unsigned_8; type Raw_Security_Data is array (Interfaces.C.size_t range <>) of aliased Security_Data_Element with Pack; type Security_Data_Allocation is access Raw_Security_Data; package Security_Data_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => Security_Data_Element, Element_Array => Raw_Security_Data, Default_Terminator => 0); -- Not used -- <tls.h> libtls defines all such data as uint8_t pointers type Security_Data_Format is (File, Memory); type TLS_Security_Data (Format: Security_Data_Format) is limited new Ada.Finalization.Limited_Controlled with record case Format is when File => Path: UBS.Unbounded_String; when Memory => Data : Security_Data_Pointers.Pointer := null; Length : Interfaces.C.size_t := 0; Ada_Allocation: Security_Data_Allocation := null; -- If non-null, must be deallocated via Unchecked_Deallocation. -- Data points to the element at Ada_Allocation'First. -- -- If null, Data points at a C-style equivalent to -- Raw_Security_Data (first element), and must be deallocated -- through libtls' unload_file(3) end case; end record; -- Unlike with the the likes of TLS_Configuration and TLS_Context, we cannot -- simply store a handle to some transparent type, since we want the ability -- to stream these data. Therefore we need more awareness of the data itself, -- and who exactly allocated it. overriding procedure Finalize (Data: in out TLS_Security_Data); -- If Data is of Format = Memory, the associated Data is explicitly zeroed -- if Dont_Zero is False, and is then deallocated function tls_default_ca_cert_file return Interfaces.C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "tls_default_ca_cert_file"; System_CA_Chain: constant TLS_Security_Data := (Ada.Finalization.Limited_Controlled with Format => File, Path => UBS.To_Unbounded_String (Interfaces.C.Strings.Value (tls_default_ca_cert_file))); -------------------- -- TLS_Session_ID -- -------------------- -- TLS_Session_ID is an array of "unsigned chars". LibreSSL's tls.h defines -- a "maximum size", as a macro. We will simply hard-code that value here. -- This is safe and harmless since all of the libtls operations that accept -- a session id also take a length parameter. -- -- To detect changes during testing, additional Assert pragmas exist in the -- body to explicitly check against the value of the macro. TLS_MAX_SESSION_ID_LENGTH: constant := 32; -- <tls.h> subtype Session_ID_Data is INET.Internal.TLS.Random_Data (1 .. TLS_MAX_SESSION_ID_LENGTH); type TLS_Session_ID is record ID : Session_ID_Data; Initialized: Boolean := False; end record; -------------------- -- TLS_Ticket_Key -- -------------------- -- Similarly as per TLS_Session_ID above TLS_TICKET_KEY_SIZE: constant := 48; use type Interfaces.Unsigned_32; subtype Key_Revision is Interfaces.Unsigned_32; -- <tls.h> subtype Ticket_Key_Data is INET.Internal.TLS.Random_Data (1 .. TLS_MAX_SESSION_ID_LENGTH); type TLS_Ticket_Key is record Key : Ticket_Key_Data; Revision : Key_Revision; Initialized: Boolean := False; end record; ----------------------- -- TLS_Configuration -- ----------------------- -- TLS_Configuration holds a (C) pointer to the "struct tls_config" -- configuration structure that is managed by libtls -- (the "extension"/"external" handle). TLS_Configuration automatically -- initializes a new configuration, and automatically invokes -- tls_config_free at finalization type Configuration_Handle is new INET_Extension_Handle; Null_Configuration_Handle: constant Configuration_Handle := Configuration_Handle (Null_Handle); type TLS_Configuration is limited new Ada.Finalization.Limited_Controlled with record Handle: Configuration_Handle := Null_Configuration_Handle; end record; overriding procedure Initialize (Configuration: in out TLS_Configuration); -- Allocates a new default configuration overriding procedure Finalize (Configuration: in out TLS_Configuration); -- Deallocates the Configuration external structure use type Interfaces.C.int; type TLS_Client_Configuration is limited new TLS_Configuration with record Session_Storage_FD: Interfaces.C.int := -1; -- If Session_Storage is set, end record; overriding procedure Finalize (Configuration: in out TLS_Client_Configuration); -- Closes Session_Storage_FD and then dispatches up type TLS_Server_Configuration is limited new TLS_Configuration with null record; end INET.TLS;
with Text_IO; package renaming1 is procedure Fo (A : Text_IO.File_Access); end;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 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. with Orka.OS; package body Orka.Inputs.Joysticks.Sequences is function Create_Sequence (Buttons : Button_Index_Array; Max_Time : Duration) return Sequence is begin return (Button_Count => Buttons'Length, Buttons => Buttons, Index => Buttons'First, Max_Time => Max_Time, Start_Press => Orka.OS.Monotonic_Clock - Max_Time); end Create_Sequence; function Detect_Activation (Object : in out Sequence; Joystick : Joystick_Input'Class) return Boolean is Current_Time : constant Time := Orka.OS.Monotonic_Clock; On_Time : constant Boolean := Current_Time - Object.Start_Press < Object.Max_Time; Pressed_Buttons : constant Boolean_Button_States := Joystick.Just_Pressed; Expected_Button : Boolean_Button_States := (others => False); begin Expected_Button (Object.Buttons (Object.Index)) := True; declare Unexpected_Buttons : constant Boolean_Button_States := Pressed_Buttons and not Expected_Button; begin -- If the user presses a wrong button, it might actually be -- the correct button of the start of the sequence. Therefore, -- do not stop, but just reset the sequence if (for some Button of Unexpected_Buttons => Button) then Object.Index := 1; end if; if Pressed_Buttons (Object.Buttons (Object.Index)) then if Object.Index = 1 then Object.Start_Press := Current_Time; Object.Index := Object.Index + 1; elsif On_Time then if Object.Index = Object.Button_Count then Object.Index := 1; return True; else Object.Index := Object.Index + 1; end if; else Object.Index := 1; end if; end if; end; return False; end Detect_Activation; end Orka.Inputs.Joysticks.Sequences;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. with Ada.Assertions, Ada.Characters.Handling, Apsepp_Testing_System_Test_Fixture, Apsepp.Generic_Fixture.Creator, Apsepp.Scope_Debug, Apsepp.Tags, Apsepp_Test_Node_Barrier, Apsepp.Test_Event_Class; package body Apsepp_Test_Node_Class_Early_Test_Case is use Ada.Characters.Handling, Apsepp.Test_Node_Class, Apsepp_Testing_System_Test_Fixture, Apsepp_Test_Node_Barrier, Apsepp.Test_Event_Class; ---------------------------------------------------------------------------- function TSF return Testing_System_Test_Fixture_Access renames Instance; ---------------------------------------------------------------------------- function Expected_Routine_State_Array return Routine_State_Array is ((T => TSF.A_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 1, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 1, Assert_C => 1, Assert_O => Passed), (T => TSF.A, Routine_I => 1, Assert_C => 2, Assert_O => Passed), (T => TSF.A, Routine_I => 1, Assert_C => 3, Assert_O => Passed), (T => TSF.A, Routine_I => 1, Assert_C => 3, Assert_O => Passed), (T => TSF.A, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 2, Assert_C => 1, Assert_O => Passed), (T => TSF.A, Routine_I => 2, Assert_C => 2, Assert_O => Passed), (T => TSF.A, Routine_I => 2, Assert_C => 3, Assert_O => Failed), (T => TSF.C, Routine_I => 2, Assert_C => 3, Assert_O => Failed), (T => TSF.C, Routine_I => 1, Assert_C => 0, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 1, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 2, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 3, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 4, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 5, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 6, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 7, Assert_O => Passed), (T => TSF.C, Routine_I => 1, Assert_C => 7, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 1, Assert_O => Passed), (T => TSF.A, Routine_I => 2, Assert_C => 3, Assert_O => Failed), (T => TSF.A, Routine_I => 3, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 3, Assert_C => 1, Assert_O => Passed), (T => TSF.A, Routine_I => 3, Assert_C => 1, Assert_O => Passed), (T => TSF.A, Routine_I => 4, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 4, Assert_C => 0, Assert_O => Passed), (T => TSF.A, Routine_I => 4, Assert_C => 0, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 2, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 3, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 4, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 5, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 6, Assert_O => Passed), (T => TSF.C, Routine_I => 2, Assert_C => 6, Assert_O => Passed), (T => TSF.C, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.C_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 0, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 1, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 2, Assert_O => Passed), (T => TSF.D, Routine_I => 1, Assert_C => 5, Assert_O => Passed), (T => TSF.D, Routine_I => 1, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 1, Assert_C => 1, Assert_O => Passed), (T => TSF.D, Routine_I => 1, Assert_C => 1, Assert_O => Passed), (T => TSF.D, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.D, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 1, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 1, Assert_C => 1, Assert_O => Passed), (T => TSF.E, Routine_I => 1, Assert_C => 2, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 3, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 4, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 5, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 5, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 5, Assert_O => Passed), (T => TSF.B, Routine_I => 1, Assert_C => 5, Assert_O => Passed), (T => TSF.E, Routine_I => 1, Assert_C => 3, Assert_O => Passed), (T => TSF.E, Routine_I => 1, Assert_C => 4, Assert_O => Failed), (T => TSF.E, Routine_I => 1, Assert_C => 4, Assert_O => Failed), (T => TSF.E, Routine_I => 2, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 2, Assert_C => 1, Assert_O => Passed), (T => TSF.E, Routine_I => 2, Assert_C => 2, Assert_O => Passed), (T => TSF.E, Routine_I => 2, Assert_C => 2, Assert_O => Passed), (T => TSF.E, Routine_I => 3, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 3, Assert_C => 1, Assert_O => Passed), (T => TSF.E, Routine_I => 3, Assert_C => 2, Assert_O => Passed), (T => TSF.E, Routine_I => 3, Assert_C => 3, Assert_O => Passed), (T => TSF.E, Routine_I => 3, Assert_C => 4, Assert_O => Passed), (T => TSF.E, Routine_I => 3, Assert_C => 4, Assert_O => Passed), (T => TSF.E, Routine_I => 4, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 4, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 4, Assert_C => 0, Assert_O => Passed), (T => TSF.E, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.E_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.B_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.D_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed), (T => TSF.A_R, Routine_I => 0, Assert_C => 0, Assert_O => Passed)); ---------------------------------------------------------------------------- function Routine_State_Array_To_Tag_Array (A : Routine_State_Array) return Tag_Array is Ret : Tag_Array (A'Range); begin for K in A'Range loop Ret(K) := A(K).T; end loop; return Ret; end Routine_State_Array_To_Tag_Array; ---------------------------------------------------------------------------- procedure Validate (K : Positive; Event_Kind : Test_Event_Kind; Event_Data : Test_Event_Data; Char : ISO_646; Char_To_Tag : Char_To_Tag_Func; Msg_Pref : String) is pragma Unreferenced (Event_Kind, Event_Data); ----------------------------------------------------- procedure Put_Array (A : Routine_State_Array; Msg_Pref : String) is use Apsepp.Scope_Debug, Apsepp.Tags; Entity_Name : constant String := "Apsepp_Test_Node_Class_Early_Test_Case.Put_Array"; C_D_T : constant Controlled_Debug_Tracer := Create_N (Entity_Name); Line : constant String (1 .. 53) := (others => '-'); First_Done : Boolean := False; begin for E of A loop if not First_Done then First_Done := True; C_D_T.Trace (Msg_Pref & Line); end if; C_D_T.Trace (Test_Routine_Count'Image (E.Routine_I) & " " & Test_Assert_Count'Image (E.Assert_C) & " " & Test_Outcome'Image (E.Assert_O) & " " & Total_Expanded_Name (E.T)); end loop; if First_Done then C_D_T.Trace (Msg_Pref & Line); end if; end Put_Array; ----------------------------------------------------- Is_Runner : constant Boolean := Ada.Characters.Handling.Is_Lower (Char); Exp : constant Flattened_Routine_State := Expected_Routine_State_Array(K); Exp_R_I : constant Test_Routine_Count := Exp.Routine_I; Exp_A_C : constant Test_Assert_Count := Exp.Assert_C; Exp_A_O : constant Test_Outcome := Exp.Assert_O; begin if Is_Runner then -- Just check that Expected contains conventional values (0 / Passed). -- TODO: Refactor (use generics). <2019-08-11> Ada.Assertions.Assert (Exp_R_I = 0, "Exp_R_I =" & Test_Routine_Count'Image (Exp_R_I) & ", 0 expected"); Ada.Assertions.Assert (Exp_A_C = 0, "Exp_A_C =" & Test_Assert_Count'Image (Exp_A_C) & ", 0 expected"); Ada.Assertions.Assert (Exp_A_O = Passed, "Exp_A_O = " & Test_Outcome'Image (Exp_A_O) & ", PASSED expected"); else -- Do a real validation. declare A : constant Routine_State_Array := To_Array; K_T : Positive := A'First; T : constant Tag := Char_To_Tag (Char); function Positive_Image (K : Positive) return String is Img : constant String := Positive'Image (K); begin return Img(Img'First + 1 .. Img'Last); end Positive_Image; -- TODO: Refactor (use generics). <2019-06-30> function A_K_R_I (K : Natural) return Test_Routine_Count is (if K in A'Range then A(K).Routine_I else 0); function A_K_A_C (K : Natural) return Test_Assert_Count is (if K in A'Range then A(K).Assert_C else 0); function A_K_A_O (K : Natural) return Test_Outcome is (if K in A'Range then A(K).Assert_O else Passed); begin Put_Array (A, Msg_Pref); -- Validate the "Routine_State_Map_Handler in initial state" case. -- TODO: Refactor (use generics). <2019-08-11> Ada.Assertions.Assert (A'Length > 0 or else Exp_R_I = 0, "A'Length =" & Integer'Image (A'Length) & ", Exp_R_I should be 0"); Ada.Assertions.Assert (A'Length > 0 or else Exp_A_C = 0, "A'Length =" & Integer'Image (A'Length) & ", Exp_A_C should be 0"); Ada.Assertions.Assert (A'Length > 0 or else Exp_A_O = Passed, "A'Length =" & Integer'Image (A'Length) & ", Exp_A_O should be PASSED"); -- TODO: Write function Find or Find_First in -- Generic_Array_Operations. <2019-08-11> if A'Length > 0 then while A(K_T).T /= T and then K_T < A'Last loop K_T := K_T + 1; end loop; end if; -- Validate the Routine_State_Map_Handler private component S -- (retrieved in A at index K_T) in the -- "Routine_State_Map_Handler no more in initial state" case. Ada.Assertions.Assert ((A'Length = 0 or else A(K_T).T /= T) or else A_K_R_I (K_T) = Exp_R_I, "A'Length =" & Integer'Image (A'Length) & "," & Test_Routine_Count'Image (A_K_R_I (K_T)) & " (A_K_R_I (" & Positive_Image (K_T) & ")) /=" & Test_Routine_Count'Image (Exp_R_I) & " (Exp_R_I)"); Ada.Assertions.Assert ((A'Length = 0 or else A(K_T).T /= T) or else A_K_A_C (K_T) = Exp_A_C, "A'Length =" & Integer'Image (A'Length) & "," & Test_Assert_Count'Image (A_K_A_C (K_T)) & " (A_K_A_C (" & Positive_Image (K_T) & ")) /=" & Test_Assert_Count'Image (Exp_A_C) & " (Exp_A_C)"); Ada.Assertions.Assert ((A'Length = 0 or else A(K_T).T /= T) or else A_K_A_O (K_T) = Exp_A_O, "A'Length =" & Integer'Image (A'Length) & ", " & Test_Outcome'Image (A_K_A_O (K_T)) & " (A_K_A_O (" & Positive_Image (K_T) & ")) /= " & Test_Outcome'Image (Exp_A_O) & " (Exp_A_O)"); end; end if; end Validate; ---------------------------------------------------------------------------- procedure Early_Test_TNCETC is package Testing_System_T_F_Creator is new Testing_System_T_F.Creator; Expected_Tag : Apsepp.Tags.Tag_Array_Access; begin Ada.Assertions.Assert (Testing_System_T_F_Creator.Has_Actually_Created, "Test fixture already locked"); Expected_Tag := new Tag_Array'(Routine_State_Array_To_Tag_Array (Expected_Routine_State_Array)); TSF.Run_Test (Expected_Tag, Validate'Access); Apsepp.Tags.Free (Expected_Tag); exception when others => Apsepp.Tags.Free (Expected_Tag); raise; end Early_Test_TNCETC; ---------------------------------------------------------------------------- overriding function Early_Routine (Obj : Apsepp_Test_Node_Class_E_T_C) return Apsepp.Abstract_Early_Test_Case.Test_Routine is (Early_Test_TNCETC'Access); ---------------------------------------------------------------------------- end Apsepp_Test_Node_Class_Early_Test_Case;
package body zlib.Strings is procedure Deflate ( Stream : in out zlib.Stream; In_Item : in String; In_Last : out Natural; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : in Boolean; Finished : out Boolean) is SEA_In_Item : Ada.Streams.Stream_Element_Array ( Ada.Streams.Stream_Element_Offset (In_Item'First) .. Ada.Streams.Stream_Element_Offset (In_Item'Last)); for SEA_In_Item'Address use In_Item'Address; SEA_In_Last : Ada.Streams.Stream_Element_Offset; begin Deflate ( Stream, SEA_In_Item, SEA_In_Last, Out_Item, Out_Last, Finish, Finished); In_Last := Natural (SEA_In_Last); end Deflate; procedure Deflate ( Stream : in out zlib.Stream; In_Item : in String; In_Last : out Natural; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset) is SEA_In_Item : Ada.Streams.Stream_Element_Array ( Ada.Streams.Stream_Element_Offset (In_Item'First) .. Ada.Streams.Stream_Element_Offset (In_Item'Last)); for SEA_In_Item'Address use In_Item'Address; SEA_In_Last : Ada.Streams.Stream_Element_Offset; begin Deflate ( Stream, SEA_In_Item, SEA_In_Last, Out_Item, Out_Last); In_Last := Natural (SEA_In_Last); end Deflate; procedure Inflate ( Stream : in out zlib.Stream; In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out String; Out_Last : out Natural; Finish : in Boolean; Finished : out Boolean) is SEA_Out_Item : Ada.Streams.Stream_Element_Array ( Ada.Streams.Stream_Element_Offset (Out_Item'First) .. Ada.Streams.Stream_Element_Offset (Out_Item'Last)); for SEA_Out_Item'Address use Out_Item'Address; SEA_Out_Last : Ada.Streams.Stream_Element_Offset; begin Inflate ( Stream, In_Item, In_Last, SEA_Out_Item, SEA_Out_Last, Finish, Finished); Out_Last := Natural (SEA_Out_Last); end Inflate; procedure Inflate ( Stream : in out zlib.Stream; In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out String; Out_Last : out Natural) is SEA_Out_Item : Ada.Streams.Stream_Element_Array ( Ada.Streams.Stream_Element_Offset (Out_Item'First) .. Ada.Streams.Stream_Element_Offset (Out_Item'Last)); for SEA_Out_Item'Address use Out_Item'Address; SEA_Out_Last : Ada.Streams.Stream_Element_Offset; begin Inflate ( Stream, In_Item, In_Last, SEA_Out_Item, SEA_Out_Last); Out_Last := Natural (SEA_Out_Last); end Inflate; procedure Inflate ( Stream : in out zlib.Stream; Out_Item : out String; Out_Last : out Natural; Finish : in Boolean; Finished : out Boolean) is SEA_Out_Item : Ada.Streams.Stream_Element_Array ( Ada.Streams.Stream_Element_Offset (Out_Item'First) .. Ada.Streams.Stream_Element_Offset (Out_Item'Last)); for SEA_Out_Item'Address use Out_Item'Address; SEA_Out_Last : Ada.Streams.Stream_Element_Offset; begin Inflate ( Stream, SEA_Out_Item, SEA_Out_Last, Finish, Finished); Out_Last := Natural (SEA_Out_Last); end Inflate; end zlib.Strings;
pragma Check_Policy (Trace => Off); with Ada.Command_Line; with Ada.Environment_Variables; with Ada.Processes; with Ada.Streams.Stream_IO.Pipes; with Ada.Text_IO.Text_Streams; procedure process is use type Ada.Command_Line.Exit_Status; Target : constant String := Standard'Target_Name; In_Windows : constant Boolean := Target (Target'Length - 6 .. Target'Last) = "mingw32"; begin declare -- making command line Command : Ada.Processes.Command_Type; begin Ada.Processes.Append (Command, "echo"); Ada.Processes.Append (Command, "x"); Ada.Processes.Append (Command, "y z"); declare S1 : constant String := Ada.Processes.Image (Command); C2 : constant Ada.Processes.Command_Type := Ada.Processes.Value (S1); S2 : constant String := Ada.Processes.Image (C2); begin pragma Check (Trace, Ada.Debug.Put (S1)); pragma Assert (S1 = S2); null; end; end; declare -- transfer command line Command : Ada.Processes.Command_Type; begin Ada.Processes.Append (Command, "echo"); Ada.Processes.Append (Command, Ada.Command_Line.Iterate); pragma Check (Trace, Ada.Debug.Put (Ada.Processes.Image (Command))); end; declare -- shell Code : Ada.Command_Line.Exit_Status; begin -- ls if In_Windows then Ada.Processes.Shell ("cmd /c dir > nul", Code); else Ada.Processes.Shell ("ls > /dev/null", Code); end if; pragma Check (Trace, Ada.Debug.Put (Ada.Command_Line.Exit_Status'Image (Code))); pragma Assert (Code = 0); if In_Windows then Ada.Processes.Shell ("cmd /c dir $$$ > nul 2> nul", Code); else Ada.Processes.Shell ("ls @@@ 2> /dev/null", Code); -- is not existing end if; pragma Check (Trace, Ada.Debug.Put (Ada.Command_Line.Exit_Status'Image (Code))); pragma Assert (Code in 1 .. 2); -- GNU ls returns 2 -- error case begin Ada.Processes.Shell ("acats 2> /dev/null", Code); -- dir raise Program_Error; exception when Ada.Processes.Name_Error => null; end; end; declare -- spawn C : Ada.Processes.Process; Input_Reading, Input_Writing: Ada.Streams.Stream_IO.File_Type; Output_Reading, Output_Writing: Ada.Streams.Stream_IO.File_Type; begin -- env Ada.Environment_Variables.Set ("ahaha", "ufufu"); Ada.Streams.Stream_IO.Pipes.Create (Output_Reading, Output_Writing); if In_Windows then Ada.Processes.Create (C, "C:\msys32\usr\bin\env.exe", Output => Output_Writing); else Ada.Processes.Create (C, "/usr/bin/env", Output => Output_Writing); end if; Ada.Streams.Stream_IO.Close (Output_Writing); Ada.Processes.Wait (C); declare File : Ada.Text_IO.File_Type; Success : Boolean := False; begin Ada.Text_IO.Text_Streams.Open ( File, Ada.Text_IO.In_File, Ada.Streams.Stream_IO.Stream (Output_Reading)); Reading : begin loop declare Line : constant String := Ada.Text_IO.Get_Line (File); begin pragma Check (Trace, Ada.Debug.Put (Line)); if Line = "ahaha=ufufu" then Success := True; end if; end; end loop; exception when Ada.Text_IO.End_Error => null; end Reading; pragma Assert (Ada.Text_IO.End_Of_File (File)); Ada.Text_IO.Close (File); pragma Assert (Success); end; Ada.Streams.Stream_IO.Close (Output_Reading); -- cat Ada.Streams.Stream_IO.Pipes.Create (Input_Reading, Input_Writing); Ada.Streams.Stream_IO.Pipes.Create (Output_Reading, Output_Writing); String'Write (Ada.Streams.Stream_IO.Stream (Input_Writing), "0123456789" & ASCII.LF); Ada.Streams.Stream_IO.Close (Input_Writing); if In_Windows then Ada.Processes.Create (C, "C:\msys32\usr\bin\cat.exe", Input => Input_Reading, Output => Output_Writing); else Ada.Processes.Create (C, "cat", Search_Path => True, Input => Input_Reading, Output => Output_Writing); end if; declare Terminated : Boolean; begin Ada.Processes.Wait_Immediate (C, Terminated => Terminated); pragma Assert (not Terminated); end; Ada.Streams.Stream_IO.Close (Input_Reading); Ada.Streams.Stream_IO.Close (Output_Writing); Ada.Processes.Wait (C); declare Buffer : String (1 .. 11); begin String'Read (Ada.Streams.Stream_IO.Stream (Output_Reading), Buffer); pragma Check (Trace, Ada.Debug.Put (Buffer)); pragma Assert (Buffer = "0123456789" & ASCII.LF); pragma Assert (Ada.Streams.Stream_IO.End_Of_File (Output_Reading)); end; Ada.Streams.Stream_IO.Close (Output_Reading); -- sleep and abort if In_Windows then Ada.Processes.Create (C, "C:\msys32\usr\bin\sleep.exe 2"); else Ada.Processes.Create (C, "sleep 2", Search_Path => True); end if; Ada.Processes.Abort_Process (C); declare Code : Ada.Command_Line.Exit_Status; begin Ada.Processes.Wait (C, Code); pragma Check (Trace, Check => Ada.Debug.Put (Ada.Command_Line.Exit_Status'Image (Code))); end; -- error case begin Ada.Processes.Create (C, "acats"); -- dir Ada.Debug.Put ("fallthrough from Create"); declare Code : Ada.Command_Line.Exit_Status; begin -- In Linux and glibc < 2.26, posix_spawn can't return the error. Ada.Processes.Wait (C, Code); if Code = 127 then raise Ada.Processes.Name_Error; end if; Ada.Debug.Put (Ada.Command_Line.Exit_Status'Image (Code)); end; raise Program_Error; exception when Ada.Processes.Use_Error => -- In Darwin, errno may be EACCES. null; when Ada.Processes.Name_Error => -- In FreeBSD, errno may be ENOENT. -- In Windows, the executable attribute is missing. -- ERROR_FILE_NOT_FOUND may be returned. null; end; end; pragma Debug (Ada.Debug.Put ("OK")); end process;
package body Srv_Quit is procedure Detect_Quits (Irc_Dir : String) is begin null; -- TODO detect and handle parting commands -- TODO for each server -- TODO continue reading out -- TODO purge if '/part' end Detect_Quits; end Srv_Quit;
-- {{Ada/Sourceforge|to_lower_2.adb}} pragma License (Gpl); pragma Ada_95; with Ada.Text_IO; with Ada.Command_Line; with Ada.Characters.Handling; procedure To_Lower_2 is package CL renames Ada.Command_Line; package T_IO renames Ada.Text_IO; function Equal_Ignore_Case (S : String; T : String) return Boolean; Value_1 : constant String := CL.Argument (1); Value_2 : constant String := CL.Argument (2); function To_Lower (C : Character) return Character renames Ada.Characters.Handling.To_Lower; -- equal-ignore-case -- returns true if s or t are equal, -- ignoring case function Equal_Ignore_Case (S : String; T : String) return Boolean is O : constant Integer := S'First - T'First; begin if T'Length /= S'Length then return False; -- if they aren't the same length, they -- aren't equal else for I in S'Range loop if To_Lower (S (I)) /= To_Lower (T (I + O)) then return False; end if; end loop; end if; return True; end Equal_Ignore_Case; begin T_IO.Put (Value_1); T_IO.Put (" and "); T_IO.Put (Value_2); T_IO.Put (" are "); if not Equal_Ignore_Case (Value_1, Value_2) then T_IO.Put ("not "); end if; T_IO.Put ("same."); return; end To_Lower_2; ---------------------------------------------------------------------------- -- $Author: krischik $ -- -- $Revision: 226 $ -- $Date: 2007-12-02 15:11:44 +0000 (Sun, 02 Dec 2007) $ -- -- $Id: to_lower_2.adb 226 2007-12-02 15:11:44Z krischik $ -- $HeadURL: file:///svn/p/wikibook-ada/code/trunk/demos/Source/to_lower_2.adb $ ---------------------------------------------------------------------------- -- vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab -- vim: filetype=ada encoding=utf-8 fileformat=unix foldmethod=indent
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C; use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C; procedure aaa_missing is type stringptr is access all char_array; procedure PString(s : stringptr) is begin String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all)); end; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; procedure SkipSpaces is C : Character; Eol : Boolean; begin loop Look_Ahead(C, Eol); exit when Eol or C /= ' '; Get(C); end loop; end; -- -- Ce test a été généré par Metalang. -- type b is Array (Integer range <>) of Boolean; type b_PTR is access b; type c is Array (Integer range <>) of Integer; type c_PTR is access c; function result(len : in Integer; tab : in c_PTR) return Integer is tab2 : b_PTR; begin tab2 := new b (0..len - 1); for i in integer range 0..len - 1 loop tab2(i) := FALSE; end loop; for i1 in integer range 0..len - 1 loop PInt(tab(i1)); PString(new char_array'( To_C(" "))); tab2(tab(i1)) := TRUE; end loop; PString(new char_array'( To_C("" & Character'Val(10)))); for i2 in integer range 0..len - 1 loop if not tab2(i2) then return i2; end if; end loop; return (-1); end; tab : c_PTR; len : Integer; begin Get(len); SkipSpaces; PInt(len); PString(new char_array'( To_C("" & Character'Val(10)))); tab := new c (0..len - 1); for a in integer range 0..len - 1 loop Get(tab(a)); SkipSpaces; end loop; PInt(result(len, tab)); PString(new char_array'( To_C("" & Character'Val(10)))); end;
with System.Standard_Allocators; with System.System_Allocators; package body System.Storage_Pools.Standard_Pools is pragma Suppress (All_Checks); overriding procedure Allocate ( Pool : in out Standard_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count) is pragma Unreferenced (Pool); begin Storage_Address := System_Allocators.Allocate ( Size_In_Storage_Elements, Alignment => Alignment); if Storage_Address = Null_Address then Standard_Allocators.Raise_Heap_Exhausted; end if; end Allocate; overriding procedure Deallocate ( Pool : in out Standard_Pool; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count) is pragma Unreferenced (Pool); pragma Unreferenced (Size_In_Storage_Elements); pragma Unreferenced (Alignment); begin System_Allocators.Free (Storage_Address); end Deallocate; end System.Storage_Pools.Standard_Pools;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M A K E U S G -- -- -- -- B o d y -- -- -- -- $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. -- -- -- ------------------------------------------------------------------------------ with Osint; use Osint; with Output; use Output; with Usage; procedure Makeusg is procedure Write_Switch_Char; -- Write two spaces followed by appropriate switch character procedure Write_Switch_Char is begin Write_Str (" "); Write_Char (Switch_Character); end Write_Switch_Char; -- Start of processing for Makeusg begin -- Usage line Write_Str ("Usage: "); Osint.Write_Program_Name; Write_Str (" opts name "); Write_Str ("{[-cargs opts] [-bargs opts] [-largs opts] [-margs opts]}"); Write_Eol; Write_Eol; Write_Str (" name is one or more file name from which you"); Write_Str (" can omit the .adb or .ads suffix"); Write_Eol; Write_Eol; -- GNATMAKE switches Write_Str ("gnatmake switches:"); Write_Eol; -- Line for -a Write_Switch_Char; Write_Str ("a Consider all files, even readonly ali files"); Write_Eol; -- Line for -b Write_Switch_Char; Write_Str ("b Bind only"); Write_Eol; -- Line for -c Write_Switch_Char; Write_Str ("c Compile only"); Write_Eol; -- Line for -f Write_Switch_Char; Write_Str ("f Force recompilations of non predefined units"); Write_Eol; -- Line for -i Write_Switch_Char; Write_Str ("i In place. Replace existing ali file, "); Write_Str ("or put it with source"); Write_Eol; -- Line for -jnnn Write_Switch_Char; Write_Str ("jnum Use nnn processes to compile"); Write_Eol; -- Line for -k Write_Switch_Char; Write_Str ("k Keep going after compilation errors"); Write_Eol; -- Line for -l Write_Switch_Char; Write_Str ("l Link only"); Write_Eol; -- Line for -m Write_Switch_Char; Write_Str ("m Minimal recompilation"); Write_Eol; -- Line for -M Write_Switch_Char; Write_Str ("M List object file dependences for Makefile"); Write_Eol; -- Line for -n Write_Switch_Char; Write_Str ("n Check objects up to date, output next file "); Write_Str ("to compile if not"); Write_Eol; -- Line for -o Write_Switch_Char; Write_Str ("o name Choose an alternate executable name"); Write_Eol; -- Line for -P Write_Switch_Char; Write_Str ("Pproj Use GNAT Project File proj"); Write_Eol; -- Line for -q Write_Switch_Char; Write_Str ("q Be quiet/terse"); Write_Eol; -- Line for -s Write_Switch_Char; Write_Str ("s Recompile if compiler switches have changed"); Write_Eol; -- Line for -u Write_Switch_Char; Write_Str ("u Unique compilation. Only compile the given file."); Write_Eol; -- Line for -v Write_Switch_Char; Write_Str ("v Display reasons for all (re)compilations"); Write_Eol; -- Line for -vPx Write_Switch_Char; Write_Str ("vPx Specify verbosity when parsing GNAT Project Files"); Write_Eol; -- Line for -X Write_Switch_Char; Write_Str ("Xnm=val Specify an external reference for GNAT Project Files"); Write_Eol; -- Line for -z Write_Switch_Char; Write_Str ("z No main subprogram (zero main)"); Write_Eol; Write_Eol; Write_Str (" --GCC=command Use this gcc command"); Write_Eol; Write_Str (" --GNATBIND=command Use this gnatbind command"); Write_Eol; Write_Str (" --GNATLINK=command Use this gnatlink command"); Write_Eol; Write_Eol; -- Source and Library search path switches Write_Str ("Source and Library search path switches:"); Write_Eol; -- Line for -aL Write_Switch_Char; Write_Str ("aLdir Skip missing library sources if ali in dir"); Write_Eol; -- Line for -A Write_Switch_Char; Write_Str ("Adir like -aLdir -aIdir"); Write_Eol; -- Line for -aO switch Write_Switch_Char; Write_Str ("aOdir Specify library/object files search path"); Write_Eol; -- Line for -aI switch Write_Switch_Char; Write_Str ("aIdir Specify source files search path"); Write_Eol; -- Line for -I switch Write_Switch_Char; Write_Str ("Idir Like -aIdir -aOdir"); Write_Eol; -- Line for -I- switch Write_Switch_Char; Write_Str ("I- Don't look for sources & library files"); Write_Str (" in the default directory"); Write_Eol; -- Line for -L Write_Switch_Char; Write_Str ("Ldir Look for program libraries also in dir"); Write_Eol; -- Line for -nostdinc Write_Switch_Char; Write_Str ("nostdinc Don't look for sources"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -nostdlib Write_Switch_Char; Write_Str ("nostdlib Don't look for library files"); Write_Str (" in the system default directory"); Write_Eol; Write_Eol; -- General Compiler, Binder, Linker switches Write_Str ("To pass an arbitrary switch to the Compiler, "); Write_Str ("Binder or Linker:"); Write_Eol; -- Line for -cargs Write_Switch_Char; Write_Str ("cargs opts opts are passed to the compiler"); Write_Eol; -- Line for -bargs Write_Switch_Char; Write_Str ("bargs opts opts are passed to the binder"); Write_Eol; -- Line for -largs Write_Switch_Char; Write_Str ("largs opts opts are passed to the linker"); Write_Eol; -- Line for -largs Write_Switch_Char; Write_Str ("margs opts opts are passed to gnatmake"); Write_Eol; -- Add usage information for gcc Usage; end Makeusg;
with Printable_Calendar; procedure Cal is C: Printable_Calendar.Calendar := Printable_Calendar.Init_80; begin C.Print_Line_Centered("[reserved for Snoopy]"); C.New_Line; C.Print(1969, "Nineteen-Sixty-Nine"); end Cal;
with AWS.Utils; with WBlocks.Widget_Counter; package body @_Project_Name_@.Ajax is use AWS; use AWS.Services; ------------------ -- Onclick_Incr -- ------------------ procedure Onclick_Incr (Request : in Status.Data; Context : not null access Web_Block.Context.Object; Translations : in out Templates.Translate_Set) is N : Natural := 0; begin if Context.Exist ("N") then N := Natural'Value (Context.Get_Value ("N")); end if; N := N + 1; Context.Set_Value ("N", Utils.Image (N)); Templates.Insert (Translations, Templates.Assoc (WBlocks.Widget_Counter.COUNTER, N)); end Onclick_Incr; end @_Project_Name_@.Ajax;
-- { dg-do compile } -- { dg-options "-gnatws" } procedure Pack21 is type Enum is (ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN); type Rec1 is record I1 : INTEGER range 0 .. 800; I2 : INTEGER range 0 .. 15 := 0; E : Enum; end record; pragma PACK (Rec1); type Rec2 is record F : Rec1; end record; for Rec2 use record F at 0 range 2 .. 19; end record; R1, R2 : Rec2; begin null; end;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; package body ST7735R is --------------------------- -- Register definitions -- --------------------------- type MADCTL is record Reserved1, Reserved2 : Boolean; MH : Horizontal_Refresh_Order; RGB : RGB_BGR_Order; ML : Vertical_Refresh_Order; MV : Boolean; MX : Column_Address_Order; MY : Row_Address_Order; end record with Size => 8, Bit_Order => System.Low_Order_First; for MADCTL use record Reserved1 at 0 range 0 .. 0; Reserved2 at 0 range 1 .. 1; MH at 0 range 2 .. 2; RGB at 0 range 3 .. 3; ML at 0 range 4 .. 4; MV at 0 range 5 .. 5; MX at 0 range 6 .. 6; MY at 0 range 7 .. 7; end record; function To_UInt8 is new Ada.Unchecked_Conversion (MADCTL, UInt8); procedure Write_Command (LCD : ST7735R_Screen'Class; Cmd : UInt8); procedure Write_Command (LCD : ST7735R_Screen'Class; Cmd : UInt8; Data : HAL.UInt8_Array); procedure Write_Pix_Repeat (LCD : ST7735R_Screen'Class; Data : UInt16; Count : Natural); -- Send the same pixel data Count times. This is used to fill an area with -- the same color without allocating a buffer. procedure Write_Data (LCD : ST7735R_Screen'Class; Data : HAL.UInt8_Array); procedure Read_Data (LCD : ST7735R_Screen'Class; Data : out UInt16); procedure Set_Command_Mode (LCD : ST7735R_Screen'Class); procedure Set_Data_Mode (LCD : ST7735R_Screen'Class); procedure Start_Transaction (LCD : ST7735R_Screen'Class); procedure End_Transaction (LCD : ST7735R_Screen'Class); ---------------------- -- Set_Command_Mode -- ---------------------- procedure Set_Command_Mode (LCD : ST7735R_Screen'Class) is begin LCD.RS.Clear; end Set_Command_Mode; ------------------- -- Set_Data_Mode -- ------------------- procedure Set_Data_Mode (LCD : ST7735R_Screen'Class) is begin LCD.RS.Set; end Set_Data_Mode; ----------------------- -- Start_Transaction -- ----------------------- procedure Start_Transaction (LCD : ST7735R_Screen'Class) is begin LCD.CS.Clear; end Start_Transaction; --------------------- -- End_Transaction -- --------------------- procedure End_Transaction (LCD : ST7735R_Screen'Class) is begin LCD.CS.Set; end End_Transaction; ------------------- -- Write_Command -- ------------------- procedure Write_Command (LCD : ST7735R_Screen'Class; Cmd : UInt8) is Status : SPI_Status; begin Start_Transaction (LCD); Set_Command_Mode (LCD); LCD.Port.Transmit (SPI_Data_8b'(1 => Cmd), Status); End_Transaction (LCD); if Status /= Ok then -- No error handling... raise Program_Error; end if; end Write_Command; ------------------- -- Write_Command -- ------------------- procedure Write_Command (LCD : ST7735R_Screen'Class; Cmd : UInt8; Data : HAL.UInt8_Array) is begin Write_Command (LCD, Cmd); Write_Data (LCD, Data); end Write_Command; ---------------- -- Write_Data -- ---------------- procedure Write_Data (LCD : ST7735R_Screen'Class; Data : HAL.UInt8_Array) is Status : SPI_Status; begin Start_Transaction (LCD); Set_Data_Mode (LCD); LCD.Port.Transmit (SPI_Data_8b (Data), Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; End_Transaction (LCD); end Write_Data; ---------------------- -- Write_Pix_Repeat -- ---------------------- procedure Write_Pix_Repeat (LCD : ST7735R_Screen'Class; Data : UInt16; Count : Natural) is Status : SPI_Status; Data8 : constant SPI_Data_8b := SPI_Data_8b'(1 => UInt8 (Shift_Right (Data, 8) and 16#FF#), 2 => UInt8 (Data and 16#FF#)); begin Write_Command (LCD, 16#2C#); Start_Transaction (LCD); Set_Data_Mode (LCD); for X in 1 .. Count loop LCD.Port.Transmit (Data8, Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; end loop; End_Transaction (LCD); end Write_Pix_Repeat; --------------- -- Read_Data -- --------------- procedure Read_Data (LCD : ST7735R_Screen'Class; Data : out UInt16) is SPI_Data : SPI_Data_16b (1 .. 1); Status : SPI_Status; begin Start_Transaction (LCD); Set_Data_Mode (LCD); LCD.Port.Receive (SPI_Data, Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; End_Transaction (LCD); Data := SPI_Data (SPI_Data'First); end Read_Data; ---------------- -- Initialize -- ---------------- procedure Initialize (LCD : in out ST7735R_Screen) is begin LCD.Layer.LCD := LCD'Unchecked_Access; LCD.RST.Clear; LCD.Time.Delay_Milliseconds (100); LCD.RST.Set; LCD.Time.Delay_Milliseconds (100); -- Sleep Exit Write_Command (LCD, 16#11#); LCD.Time.Delay_Milliseconds (100); LCD.Initialized := True; end Initialize; ----------------- -- Initialized -- ----------------- overriding function Initialized (LCD : ST7735R_Screen) return Boolean is (LCD.Initialized); ------------- -- Turn_On -- ------------- procedure Turn_On (LCD : ST7735R_Screen) is begin Write_Command (LCD, 16#29#); end Turn_On; -------------- -- Turn_Off -- -------------- procedure Turn_Off (LCD : ST7735R_Screen) is begin Write_Command (LCD, 16#28#); end Turn_Off; -------------------------- -- Display_Inversion_On -- -------------------------- procedure Display_Inversion_On (LCD : ST7735R_Screen) is begin Write_Command (LCD, 16#21#); end Display_Inversion_On; --------------------------- -- Display_Inversion_Off -- --------------------------- procedure Display_Inversion_Off (LCD : ST7735R_Screen) is begin Write_Command (LCD, 16#20#); end Display_Inversion_Off; --------------- -- Gamma_Set -- --------------- procedure Gamma_Set (LCD : ST7735R_Screen; Gamma_Curve : UInt4) is begin Write_Command (LCD, 16#26#, (0 => UInt8 (Gamma_Curve))); end Gamma_Set; ---------------------- -- Set_Pixel_Format -- ---------------------- procedure Set_Pixel_Format (LCD : ST7735R_Screen; Pix_Fmt : Pixel_Format) is Value : constant UInt8 := (case Pix_Fmt is when Pixel_12bits => 2#011#, when Pixel_16bits => 2#101#, when Pixel_18bits => 2#110#); begin Write_Command (LCD, 16#3A#, (0 => Value)); end Set_Pixel_Format; ---------------------------- -- Set_Memory_Data_Access -- ---------------------------- procedure Set_Memory_Data_Access (LCD : ST7735R_Screen; Color_Order : RGB_BGR_Order; Vertical : Vertical_Refresh_Order; Horizontal : Horizontal_Refresh_Order; Row_Addr_Order : Row_Address_Order; Column_Addr_Order : Column_Address_Order; Row_Column_Exchange : Boolean) is Value : MADCTL; begin Value.MY := Row_Addr_Order; Value.MX := Column_Addr_Order; Value.MV := Row_Column_Exchange; Value.ML := Vertical; Value.RGB := Color_Order; Value.MH := Horizontal; Write_Command (LCD, 16#36#, (0 => To_UInt8 (Value))); end Set_Memory_Data_Access; --------------------------- -- Set_Frame_Rate_Normal -- --------------------------- procedure Set_Frame_Rate_Normal (LCD : ST7735R_Screen; RTN : UInt4; Front_Porch : UInt6; Back_Porch : UInt6) is begin Write_Command (LCD, 16#B1#, (UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch))); end Set_Frame_Rate_Normal; ------------------------- -- Set_Frame_Rate_Idle -- ------------------------- procedure Set_Frame_Rate_Idle (LCD : ST7735R_Screen; RTN : UInt4; Front_Porch : UInt6; Back_Porch : UInt6) is begin Write_Command (LCD, 16#B2#, (UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch))); end Set_Frame_Rate_Idle; --------------------------------- -- Set_Frame_Rate_Partial_Full -- --------------------------------- procedure Set_Frame_Rate_Partial_Full (LCD : ST7735R_Screen; RTN_Part : UInt4; Front_Porch_Part : UInt6; Back_Porch_Part : UInt6; RTN_Full : UInt4; Front_Porch_Full : UInt6; Back_Porch_Full : UInt6) is begin Write_Command (LCD, 16#B3#, (UInt8 (RTN_Part), UInt8 (Front_Porch_Part), UInt8 (Back_Porch_Part), UInt8 (RTN_Full), UInt8 (Front_Porch_Full), UInt8 (Back_Porch_Full))); end Set_Frame_Rate_Partial_Full; --------------------------- -- Set_Inversion_Control -- --------------------------- procedure Set_Inversion_Control (LCD : ST7735R_Screen; Normal, Idle, Full_Partial : Inversion_Control) is Value : UInt8 := 0; begin if Normal = Line_Inversion then Value := Value or 2#100#; end if; if Idle = Line_Inversion then Value := Value or 2#010#; end if; if Full_Partial = Line_Inversion then Value := Value or 2#001#; end if; Write_Command (LCD, 16#B4#, (0 => Value)); end Set_Inversion_Control; ------------------------- -- Set_Power_Control_1 -- ------------------------- procedure Set_Power_Control_1 (LCD : ST7735R_Screen; AVDD : UInt3; VRHP : UInt5; VRHN : UInt5; MODE : UInt2) is P1, P2, P3 : UInt8; begin P1 := Shift_Left (UInt8 (AVDD), 5) or UInt8 (VRHP); P2 := UInt8 (VRHN); P3 := Shift_Left (UInt8 (MODE), 6) or 2#00_0100#; Write_Command (LCD, 16#C0#, (P1, P2, P3)); end Set_Power_Control_1; ------------------------- -- Set_Power_Control_2 -- ------------------------- procedure Set_Power_Control_2 (LCD : ST7735R_Screen; VGH25 : UInt2; VGSEL : UInt2; VGHBT : UInt2) is P1 : UInt8; begin P1 := Shift_Left (UInt8 (VGH25), 6) or Shift_Left (UInt8 (VGSEL), 2) or UInt8 (VGHBT); Write_Command (LCD, 16#C1#, (0 => P1)); end Set_Power_Control_2; ------------------------- -- Set_Power_Control_3 -- ------------------------- procedure Set_Power_Control_3 (LCD : ST7735R_Screen; P1, P2 : UInt8) is begin Write_Command (LCD, 16#C2#, (P1, P2)); end Set_Power_Control_3; ------------------------- -- Set_Power_Control_4 -- ------------------------- procedure Set_Power_Control_4 (LCD : ST7735R_Screen; P1, P2 : UInt8) is begin Write_Command (LCD, 16#C3#, (P1, P2)); end Set_Power_Control_4; ------------------------- -- Set_Power_Control_5 -- ------------------------- procedure Set_Power_Control_5 (LCD : ST7735R_Screen; P1, P2 : UInt8) is begin Write_Command (LCD, 16#C4#, (P1, P2)); end Set_Power_Control_5; -------------- -- Set_Vcom -- -------------- procedure Set_Vcom (LCD : ST7735R_Screen; VCOMS : UInt6) is begin Write_Command (LCD, 16#C5#, (0 => UInt8 (VCOMS))); end Set_Vcom; ------------------------ -- Set_Column_Address -- ------------------------ procedure Set_Column_Address (LCD : ST7735R_Screen; X_Start, X_End : UInt16) is P1, P2, P3, P4 : UInt8; begin P1 := UInt8 (Shift_Right (X_Start and 16#FF#, 8)); P2 := UInt8 (X_Start and 16#FF#); P3 := UInt8 (Shift_Right (X_End and 16#FF#, 8)); P4 := UInt8 (X_End and 16#FF#); Write_Command (LCD, 16#2A#, (P1, P2, P3, P4)); end Set_Column_Address; --------------------- -- Set_Row_Address -- --------------------- procedure Set_Row_Address (LCD : ST7735R_Screen; Y_Start, Y_End : UInt16) is P1, P2, P3, P4 : UInt8; begin P1 := UInt8 (Shift_Right (Y_Start and 16#FF#, 8)); P2 := UInt8 (Y_Start and 16#FF#); P3 := UInt8 (Shift_Right (Y_End and 16#FF#, 8)); P4 := UInt8 (Y_End and 16#FF#); Write_Command (LCD, 16#2B#, (P1, P2, P3, P4)); end Set_Row_Address; ----------------- -- Set_Address -- ----------------- procedure Set_Address (LCD : ST7735R_Screen; X_Start, X_End, Y_Start, Y_End : UInt16) is begin Set_Column_Address (LCD, X_Start, X_End); Set_Row_Address (LCD, Y_Start, Y_End); end Set_Address; --------------- -- Set_Pixel -- --------------- procedure Set_Pixel (LCD : ST7735R_Screen; X, Y : UInt16; Color : UInt16) is Data : HAL.UInt16_Array (1 .. 1) := (1 => Color); begin Set_Address (LCD, X, X + 1, Y, Y + 1); Write_Raw_Pixels (LCD, Data); end Set_Pixel; ----------- -- Pixel -- ----------- function Pixel (LCD : ST7735R_Screen; X, Y : UInt16) return UInt16 is Ret : UInt16; begin Set_Address (LCD, X, X + 1, Y, Y + 1); Read_Data (LCD, Ret); return Ret; end Pixel; ---------------------- -- Write_Raw_Pixels -- ---------------------- procedure Write_Raw_Pixels (LCD : ST7735R_Screen; Data : in out HAL.UInt8_Array) is Index : Natural := Data'First + 1; Tmp : UInt8; begin -- The ST7735R uses a different endianness than our bitmaps while Index <= Data'Last loop Tmp := Data (Index); Data (Index) := Data (Index - 1); Data (Index - 1) := Tmp; Index := Index + 1; end loop; Write_Command (LCD, 16#2C#); Write_Data (LCD, Data); end Write_Raw_Pixels; ---------------------- -- Write_Raw_Pixels -- ---------------------- procedure Write_Raw_Pixels (LCD : ST7735R_Screen; Data : in out HAL.UInt16_Array) is Data_8b : HAL.UInt8_Array (1 .. Data'Length * 2) with Address => Data'Address; begin Write_Raw_Pixels (LCD, Data_8b); end Write_Raw_Pixels; -------------------- -- Get_Max_Layers -- -------------------- overriding function Max_Layers (Display : ST7735R_Screen) return Positive is (1); ------------------ -- Is_Supported -- ------------------ overriding function Supported (Display : ST7735R_Screen; Mode : FB_Color_Mode) return Boolean is (Mode = HAL.Bitmap.RGB_565); --------------------- -- Set_Orientation -- --------------------- overriding procedure Set_Orientation (Display : in out ST7735R_Screen; Orientation : Display_Orientation) is begin null; end Set_Orientation; -------------- -- Set_Mode -- -------------- overriding procedure Set_Mode (Display : in out ST7735R_Screen; Mode : Wait_Mode) is begin null; end Set_Mode; --------------- -- Get_Width -- --------------- overriding function Width (Display : ST7735R_Screen) return Positive is (Screen_Width); ---------------- -- Get_Height -- ---------------- overriding function Height (Display : ST7735R_Screen) return Positive is (Screen_Height); ---------------- -- Is_Swapped -- ---------------- overriding function Swapped (Display : ST7735R_Screen) return Boolean is (False); -------------------- -- Set_Background -- -------------------- overriding procedure Set_Background (Display : ST7735R_Screen; R, G, B : UInt8) is begin -- Does it make sense when there's no alpha channel... raise Program_Error; end Set_Background; ---------------------- -- Initialize_Layer -- ---------------------- overriding procedure Initialize_Layer (Display : in out ST7735R_Screen; Layer : Positive; Mode : FB_Color_Mode; X : Natural := 0; Y : Natural := 0; Width : Positive := Positive'Last; Height : Positive := Positive'Last) is pragma Unreferenced (X, Y); begin if Layer /= 1 or else Mode /= RGB_565 then raise Program_Error; end if; Display.Layer.Width := Width; Display.Layer.Height := Height; end Initialize_Layer; ----------------- -- Initialized -- ----------------- overriding function Initialized (Display : ST7735R_Screen; Layer : Positive) return Boolean is pragma Unreferenced (Display); begin return Layer = 1; end Initialized; ------------------ -- Update_Layer -- ------------------ overriding procedure Update_Layer (Display : in out ST7735R_Screen; Layer : Positive; Copy_Back : Boolean := False) is pragma Unreferenced (Copy_Back, Display); begin if Layer /= 1 then raise Program_Error; end if; end Update_Layer; ------------------- -- Update_Layers -- ------------------- overriding procedure Update_Layers (Display : in out ST7735R_Screen) is begin Display.Update_Layer (1); end Update_Layers; -------------------- -- Get_Color_Mode -- -------------------- overriding function Color_Mode (Display : ST7735R_Screen; Layer : Positive) return FB_Color_Mode is pragma Unreferenced (Display); begin if Layer /= 1 then raise Program_Error; end if; return RGB_565; end Color_Mode; ----------------------- -- Get_Hidden_Buffer -- ----------------------- overriding function Hidden_Buffer (Display : in out ST7735R_Screen; Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer is begin if Layer /= 1 then raise Program_Error; end if; return Display.Layer'Unchecked_Access; end Hidden_Buffer; ---------------- -- Pixel_Size -- ---------------- overriding function Pixel_Size (Display : ST7735R_Screen; Layer : Positive) return Positive is (16); ---------------- -- Set_Source -- ---------------- overriding procedure Set_Source (Buffer : in out ST7735R_Bitmap_Buffer; Native : UInt32) is begin Buffer.Native_Source := Native; end Set_Source; ------------ -- Source -- ------------ overriding function Source (Buffer : ST7735R_Bitmap_Buffer) return UInt32 is begin return Buffer.Native_Source; end Source; --------------- -- Set_Pixel -- --------------- overriding procedure Set_Pixel (Buffer : in out ST7735R_Bitmap_Buffer; Pt : Point) is begin Buffer.LCD.Set_Pixel (UInt16 (Pt.X), UInt16 (Pt.Y), UInt16 (Buffer.Native_Source)); end Set_Pixel; --------------------- -- Set_Pixel_Blend -- --------------------- overriding procedure Set_Pixel_Blend (Buffer : in out ST7735R_Bitmap_Buffer; Pt : Point) renames Set_Pixel; ----------- -- Pixel -- ----------- overriding function Pixel (Buffer : ST7735R_Bitmap_Buffer; Pt : Point) return UInt32 is (UInt32 (Buffer.LCD.Pixel (UInt16 (Pt.X), UInt16 (Pt.Y)))); ---------- -- Fill -- ---------- overriding procedure Fill (Buffer : in out ST7735R_Bitmap_Buffer) is begin -- Set the drawing area over the entire layer Set_Address (Buffer.LCD.all, 0, UInt16 (Buffer.Width - 1), 0, UInt16 (Buffer.Height - 1)); -- Fill the drawing area with a single color Write_Pix_Repeat (Buffer.LCD.all, UInt16 (Buffer.Native_Source and 16#FFFF#), Buffer.Width * Buffer.Height); end Fill; --------------- -- Fill_Rect -- --------------- overriding procedure Fill_Rect (Buffer : in out ST7735R_Bitmap_Buffer; Area : Rect) is begin -- Set the drawing area coresponding to the rectangle to draw Set_Address (Buffer.LCD.all, UInt16 (Area.Position.X), UInt16 (Area.Position.X + Area.Width - 1), UInt16 (Area.Position.Y), UInt16 (Area.Position.Y + Area.Height - 1)); -- Fill the drawing area with a single color Write_Pix_Repeat (Buffer.LCD.all, UInt16 (Buffer.Native_Source and 16#FFFF#), Area.Width * Area.Height); end Fill_Rect; ------------------------ -- Draw_Vertical_Line -- ------------------------ overriding procedure Draw_Vertical_Line (Buffer : in out ST7735R_Bitmap_Buffer; Pt : Point; Height : Integer) is begin -- Set the drawing area coresponding to the line to draw Set_Address (Buffer.LCD.all, UInt16 (Pt.X), UInt16 (Pt.X), UInt16 (Pt.Y), UInt16 (Pt.Y + Height - 1)); -- Fill the drawing area with a single color Write_Pix_Repeat (Buffer.LCD.all, UInt16 (Buffer.Native_Source and 16#FFFF#), Height); end Draw_Vertical_Line; -------------------------- -- Draw_Horizontal_Line -- -------------------------- overriding procedure Draw_Horizontal_Line (Buffer : in out ST7735R_Bitmap_Buffer; Pt : Point; Width : Integer) is begin -- Set the drawing area coresponding to the line to draw Set_Address (Buffer.LCD.all, UInt16 (Pt.X), UInt16 (Pt.X + Width), UInt16 (Pt.Y), UInt16 (Pt.Y)); -- Fill the drawing area with a single color Write_Pix_Repeat (Buffer.LCD.all, UInt16 (Buffer.Native_Source and 16#FFFF#), Width); end Draw_Horizontal_Line; end ST7735R;
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ stream to skill tokens -- -- |___/_|\_\_|_|____| by: Timm Felden, Dennis Przytarski -- -- -- pragma Ada_2012; with Ada.Characters.Latin_1; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with Interfaces; with Skill.Types; with Interfaces.C.Strings; with System; with Skill.Errors; with Interfaces.C_Streams; with System.Storage_Elements; with System.Address_To_Access_Conversions; with System.Address_Image; package body Skill.Streams.Writer is use Skill; use Interfaces; use type System.Address; --- common type conversions --- -- @note they are required at this level, because otherwise inlining will crash function Cast is new Ada.Unchecked_Conversion (Types.v64, Types.Uv64); package Casts is new System.Address_To_Access_Conversions (C.unsigned_char); function Convert is new Ada.Unchecked_Conversion (Casts.Object_Pointer, Map_Pointer); function Convert is new Ada.Unchecked_Conversion (Map_Pointer, Casts.Object_Pointer); function Open (Path : not null Types.String_Access; Mode : String) return Output_Stream is F : Interfaces.C_Streams.FILEs := C_Streams.fopen (C.To_C (Path.all)'Address, Mode'Address); R : Output_Stream; -- throwaway value required by ada ... U : Integer; use System.Storage_Elements; begin if C_Streams.NULL_Stream = F then raise Skill.Errors.Skill_Error with "failed to write file: " & Path.all; end if; U := C_Streams.Fseek(F, 0, C_Streams.SEEK_END); R := new Output_Stream_T' (Path => Path, File => F, Map => Invalid_Pointer, Base => Invalid_Pointer, EOF => Invalid_Pointer, Bytes_Written => Types.V64(C_Streams.Ftell(F)), Buffer => <>, Block_Map_Mode => False, Client_Map => Invalid_Pointer, Client_Base => Invalid_Pointer, Client_EOF => Invalid_Pointer); R.Map := Convert (Casts.To_Pointer (R.Buffer'Address)); R.Base := Convert (Casts.To_Pointer (R.Buffer'Address)); R.EOF := Convert (Casts.To_Pointer (R.Buffer'Address + 1024)); return R; end Open; procedure Flush_Buffer (This : access Output_Stream_T) is use type Map_Pointer; use type C_Streams.size_t; package Casts is new System.Address_To_Access_Conversions (C.unsigned_char); function Convert is new Ada.Unchecked_Conversion (Casts.Object_Pointer, Map_Pointer); function Convert is new Ada.Unchecked_Conversion (Map_Pointer, Casts.Object_Pointer); Length : C_Streams.size_t := C_Streams.size_t (This.Map - This.Base); begin if 0 /= Length then if Length /= Interfaces.C_Streams.fwrite (Casts.To_Address (Convert (This.Base)), 1, Length, This.File) then raise Skill.Errors.Skill_Error with "something went sideways while flushing a buffer"; end if; This.Bytes_Written := This.Bytes_Written + Types.v64 (Length); This.Map := This.Base; end if; end Flush_Buffer; -- creates a map for a block and enables usage of map function procedure Begin_Block_Map (This : access Output_Stream_T; Size : Types.v64) is use type Uchar.Pointer; use type Interfaces.Integer_64; Map : Uchar.Pointer; begin pragma Assert (not This.Block_Map_Mode); This.Block_Map_Mode := True; -- Save Our Buffer To Disk Flush_Buffer (This); if 0 = Size then This.Client_Map := Invalid_Pointer; This.Client_Base := Invalid_Pointer; This.Client_EOF := Invalid_Pointer; else Map := MMap_Write_Map (This.File, Size) + C.ptrdiff_t (This.Position); if null = Map then raise Skill.Errors.Skill_Error with "failed to create map of size" & Long_Long_Integer'Image (Long_Long_Integer (Size)) & " in file: " & This.Path.all; end if; -- Advance File Pointer -- @Note: File Position Was Updated By C Code This.Bytes_Written := This.Bytes_Written + Size; This.Client_Map := Map_Pointer (Map); This.Client_Base := Map_Pointer (Map); This.Client_EOF := Map_Pointer (Map) + C.ptrdiff_t (Size); end if; end Begin_Block_Map; -- unmaps backing memory map procedure End_Block_Map (This : access Output_Stream_T) is use type Uchar.Pointer; begin pragma Assert (This.Block_Map_Mode); This.Block_Map_Mode := False; if Invalid_Pointer /= This.Client_Base then MMap_Unmap (This.Client_Base, This.Client_EOF); end if; end End_Block_Map; function Map (This : access Output_Stream_T; Size : Types.v64) return Sub_Stream is use type Uchar.Pointer; use type Interfaces.Integer_64; Result : Sub_Stream; begin pragma Assert (This.Block_Map_Mode); Result := new Sub_Stream_T' (Map => This.Client_Map, Base => This.Client_Map, EOF => This.Client_Map + C.ptrdiff_t (Size)); This.Client_Map := Result.EOF; return Result; end Map; procedure Close (This : access Output_Stream_T) is type S is access all Output_Stream_T; procedure Delete is new Ada.Unchecked_Deallocation (Output_Stream_T, S); D : S := S (This); Exit_Code : Integer; begin -- do Pending Writes Flush_Buffer (This); Exit_Code := Interfaces.C_Streams.fclose (This.File); Delete (D); end Close; procedure Close (This : access Sub_Stream_T) is type S is access all Sub_Stream_T; procedure Delete is new Ada.Unchecked_Deallocation (Sub_Stream_T, S); D : S := S (This); begin Delete (D); end Close; function Position (This : access Output_Stream_T) return Skill.Types.v64 is use type Map_Pointer; begin return This.Bytes_Written + Types.v64 (This.Map - This.Base); end Position; function Position (This : access Sub_Stream_T) return Skill.Types.v64 is use type Map_Pointer; begin return Types.v64 (This.Map - This.Base); end Position; function Remaining_Bytes (This : access Abstract_Stream'Class) return Skill.Types.v64 is use type Map_Pointer; begin return Types.v64 (This.EOF - This.Map); end Remaining_Bytes; function Eof (This : access Sub_Stream_T) return Boolean is use C; function Cast is new Ada.Unchecked_Conversion (Uchar.Pointer, Types.i64); use type Interfaces.Integer_64; begin return Cast (This.Map) >= Cast (This.EOF); end Eof; procedure Advance (P : in out Map_Pointer) is use C; use Uchar; use System.Storage_Elements; begin P := Convert (Casts.To_Pointer (Casts.To_Address (Convert (P)) + 1)); end Advance; pragma Inline_Always (Advance); procedure Advance (P : in out Map_Pointer; Diff : System.Storage_Elements.Storage_Offset) is use C; use Uchar; use System.Storage_Elements; package Casts is new System.Address_To_Access_Conversions (C.unsigned_char); function Convert is new Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Skill.Types.i8); function Convert is new Ada.Unchecked_Conversion (Casts.Object_Pointer, Map_Pointer); function Convert is new Ada.Unchecked_Conversion (Map_Pointer, Casts.Object_Pointer); begin P := Convert (Casts.To_Pointer (Casts.To_Address (Convert (P)) + Diff)); end Advance; procedure Ensure_Size (This : not null access Output_Stream_T; V : C.ptrdiff_t) is use type Map_Pointer; use type C.ptrdiff_t; use type C_Streams.size_t; begin if This.EOF - This.Map < 1 + V then Flush_Buffer (This); end if; end Ensure_Size; function Cast is new Ada.Unchecked_Conversion (Types.i8, C.unsigned_char); procedure I8 (This : access Output_Stream_T; V : Skill.Types.i8) is P : Map_Pointer := Invalid_Pointer; begin This.Ensure_Size (1); P := This.Map; P.all := Cast (V); Advance (P); This.Map := P; end I8; procedure I8 (This : access Sub_Stream_T; V : Skill.Types.i8) is P : Map_Pointer := This.Map; begin P := This.Map; P.all := Cast (V); Advance (P); This.Map := P; end I8; procedure Bool (This : access Sub_Stream_T; V : Boolean) is P : Map_Pointer := This.Map; begin if V then P.all := 16#ff#; else P.all := 0; end if; Advance (P); This.Map := P; end Bool; procedure I16 (This : access Output_Stream_T; V : Skill.Types.i16) is pragma Warnings (Off); use C; use Uchar; function Cast is new Ada.Unchecked_Conversion (Unsigned_16, C.unsigned_char); function Cast is new Ada.Unchecked_Conversion (Types.i16, Unsigned_16); P : Map_Pointer := Invalid_Pointer; begin This.Ensure_Size (2); P := This.Map; P.all := Cast (Interfaces.Shift_Right (Cast (V), 8)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 0)); Advance (P); This.Map := P; end I16; procedure I16 (This : access Sub_Stream_T; V : Skill.Types.i16) is pragma Warnings (Off); use C; use Uchar; function Cast is new Ada.Unchecked_Conversion (Unsigned_16, C.unsigned_char); function Cast is new Ada.Unchecked_Conversion (Types.i16, Unsigned_16); P : Map_Pointer := This.Map; begin P.all := Cast (Interfaces.Shift_Right (Cast (V), 8)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 0)); Advance (P); This.Map := P; end I16; procedure I32 (This : access Output_Stream_T; V : Skill.Types.i32) is pragma Warnings (Off); use C; use Uchar; function Cast is new Ada.Unchecked_Conversion (Unsigned_32, C.unsigned_char); function Cast is new Ada.Unchecked_Conversion (Types.i32, Unsigned_32); P : Map_Pointer := Invalid_Pointer; begin This.Ensure_Size (4); P := This.Map; P.all := Cast (Interfaces.Shift_Right (Cast (V), 24)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 16)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 8)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 0)); Advance (P); This.Map := P; end I32; procedure I32 (This : access Sub_Stream_T; V : Skill.Types.i32) is use C; use Uchar; function Cast is new Ada.Unchecked_Conversion (Unsigned_32, C.unsigned_char); function Cast is new Ada.Unchecked_Conversion (Types.i32, Unsigned_32); P : Map_Pointer := This.Map; begin P.all := Cast (Interfaces.Shift_Right (Cast (V), 24)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 16)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 8)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 0)); Advance (P); This.Map := P; end I32; procedure I64 (This : access Output_Stream_T; V : Skill.Types.i64) is use C; use Uchar; function Cast is new Ada.Unchecked_Conversion (Unsigned_64, C.unsigned_char); function Cast is new Ada.Unchecked_Conversion (Types.i64, Unsigned_64); P : Map_Pointer := Invalid_Pointer; begin This.Ensure_Size (8); P := This.Map; P.all := Cast (Interfaces.Shift_Right (Cast (V), 56)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 48)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 40)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 32)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 24)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 16)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 8)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 0)); Advance (P); This.Map := P; end I64; procedure I64 (This : access Sub_Stream_T; V : Skill.Types.i64) is use C; use Uchar; function Cast is new Ada.Unchecked_Conversion (Unsigned_64, C.unsigned_char); function Cast is new Ada.Unchecked_Conversion (Types.i64, Unsigned_64); P : Map_Pointer := This.Map; begin P.all := Cast (Interfaces.Shift_Right (Cast (V), 56)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 48)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 40)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 32)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 24)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 16)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 8)); Advance (P); P.all := Cast (Interfaces.Shift_Right (Cast (V), 0)); Advance (P); This.Map := P; end I64; procedure F32 (This : access Sub_Stream_T; V : Skill.Types.F32) is function Cast is new Ada.Unchecked_Conversion (Types.F32, Types.i32); begin This.I32 (Cast (V)); end F32; procedure F64 (This : access Sub_Stream_T; V : Skill.Types.F64) is function Cast is new Ada.Unchecked_Conversion (Types.F64, Types.i64); begin This.I64 (Cast (V)); end F64; function To_Byte is new Ada.Unchecked_Conversion (Skill.Types.Uv64, C.unsigned_char); procedure V64 (This : access Output_Stream_T; Value : Skill.Types.v64) is V : Types.Uv64 := Cast (Value); use C; use Uchar; use System.Storage_Elements; package Casts is new System.Address_To_Access_Conversions (C.unsigned_char); function Convert is new Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Skill.Types.i8); function Convert is new Ada.Unchecked_Conversion (Casts.Object_Pointer, Map_Pointer); function Convert is new Ada.Unchecked_Conversion (Map_Pointer, Casts.Object_Pointer); P : Map_Pointer := Invalid_Pointer; begin This.Ensure_Size (9); P := This.Map; if 0 = (V and 16#FFFFFFFFFFFFFF80#) then P.all := To_Byte (V); Advance (P); else P.all := To_Byte (16#80# or V); Advance (P); if 0 = (V and 16#FFFFFFFFFFFFC000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 7)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 7)); Advance (P); if 0 = (V and 16#FFFFFFFFFFE00000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 14)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 14)); Advance (P); if 0 = (V and 16#FFFFFFFFF0000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 21)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 21)); Advance (P); if 0 = (V and 16#FFFFFFF800000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 28)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 28)); Advance (P); if 0 = (V and 16#FFFFFC0000000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 35)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 35)); Advance (P); if 0 = (V and 16#FFFE000000000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 42)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 42)); Advance (P); if 0 = (V and 16#FF00000000000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 49)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 49)); Advance (P); P.all := To_Byte (Interfaces.Shift_Right (V, 56)); Advance (P); end if; end if; end if; end if; end if; end if; end if; end if; This.Map := P; end V64; procedure V64 (This : access Sub_Stream_T; Value : Skill.Types.v64) is V : Types.Uv64 := Cast (Value); use C; use Uchar; use System.Storage_Elements; package Casts is new System.Address_To_Access_Conversions (C.unsigned_char); function Convert is new Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Skill.Types.i8); function Convert is new Ada.Unchecked_Conversion (Casts.Object_Pointer, Map_Pointer); function Convert is new Ada.Unchecked_Conversion (Map_Pointer, Casts.Object_Pointer); P : Map_Pointer := This.Map; begin if 0 = (V and 16#FFFFFFFFFFFFFF80#) then P.all := To_Byte (V); Advance (P); else P.all := To_Byte (16#80# or V); Advance (P); if 0 = (V and 16#FFFFFFFFFFFFC000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 7)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 7)); Advance (P); if 0 = (V and 16#FFFFFFFFFFE00000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 14)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 14)); Advance (P); if 0 = (V and 16#FFFFFFFFF0000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 21)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 21)); Advance (P); if 0 = (V and 16#FFFFFFF800000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 28)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 28)); Advance (P); if 0 = (V and 16#FFFFFC0000000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 35)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 35)); Advance (P); if 0 = (V and 16#FFFE000000000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 42)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 42)); Advance (P); if 0 = (V and 16#FF00000000000000#) then P.all := To_Byte (Interfaces.Shift_Right (V, 49)); Advance (P); else P.all := To_Byte (16#80# or Interfaces.Shift_Right (V, 49)); Advance (P); P.all := To_Byte (Interfaces.Shift_Right (V, 56)); Advance (P); end if; end if; end if; end if; end if; end if; end if; end if; This.Map := P; end V64; use type Interfaces.C.Ptrdiff_T; function Cast is new Ada.Unchecked_Conversion (Character, C.unsigned_char); procedure Put_Plain_String (This : access Output_Stream_T; V : Skill.Types.String_Access) is P : Map_Pointer := Invalid_Pointer; begin if(V.all'Length >= Buffer_Size) then Flush_Buffer (This); declare use C_Streams; use C.Strings; Str : chars_ptr := New_String(V.all); function Convert is new Ada.Unchecked_Conversion(Chars_Ptr, Voids); Length : Size_T := Size_T(Strlen(Str)); use type Size_T; begin if Length /= Interfaces.C_Streams.fwrite (Convert(Str), 1, Length, This.File) then Free(Str); raise Skill.Errors.Skill_Error with "something went sideways while flushing a buffer"; end if; Free(Str); This.Bytes_Written := This.Bytes_Written + Types.v64 (Length); end; else This.Ensure_Size (V.all'Length); P := This.Map; for C of V.all loop P.all := Cast (C); Advance (P); end loop; This.Map := P; end if; end Put_Plain_String; end Skill.Streams.Writer;
--------------------------------------------------------------------------- -- package body Givens_Rotation -- Copyright (C) 2018 Jonathan S. Parker. -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --------------------------------------------------------------------------- with Hypot; package body Givens_Rotation is package Hypotenuse is new Hypot (Real); use Hypotenuse; Zero : constant Real := +0.0; One : constant Real := +1.0; Two : constant Real := +2.0; ----------------------------------- -- Get_Rotation_That_Zeros_Out_L -- ----------------------------------- -- P = Pivot, L = Low. -- -- cos = P/r, sin = L/r, Hypot = r = sqrt(P*P + L*L) -- -- clockwise rotation: notice all rotations are centered on the diagonal -- -- 1 0 0 0 0 0 0 -- 0 c s 0 0 P r -- 0 -s c 0 0 x L = 0 -- 0 0 0 1 0 0 0 -- 0 0 0 0 1 0 0 -- -- -- if |L| >= |P| then t = P/L <= 1 -- if |P| > |L| then t = L/P < 1 -- -- -- let t = smaller / larger -- -- let u = 1/sqrt(1+t*t) and w = sqrt(t*t/(1+t*t)) with -- -- use (1 - 1/sqrt(1+t*t)) * (1 + 1/sqrt(1+t*t)) = t*t / (1 + t*t) -- -- 1/sqrt(1+t*t) - 1 = - t*t/(sqrt(1+t*t) + 1+t*t) -- = -(t/(sqrt(1+t*t))*(t/(1 + Sqrt(1+t*t))) -- = - Abs (w) * Abs (t)/(1+ sqrt(1+t*t)) -- = u_lo -- -- u_hi = 1 => u_lo + u_hi = 1/sqrt(1+t*t) = u = Abs (cs) if a<b -- -- hypot = |L| * sqrt(1+t*t) = |L| * (1 + t*t/(1+sqrt(1+t*t)) = hi + lo if t<1 -- -- P : Real := A(Pivot_Row, Pivot_Col); -- P is for Pivot -- L : Real := A(Low_Row, Pivot_Col); procedure Get_Rotation_That_Zeros_Out_Low (Pivot, Low : in Real; sn, cs : out Real; cs_minus_1 : out Real; sn_minus_1 : out Real; hypot : out Real; P_bigger_than_L : out Boolean; Skip_Rotation : out Boolean) is Emax : constant Integer := Real'Machine_Emax; Emin : constant Integer := Real'Machine_Emin; P, L, Abs_P, Abs_L : Real; min_arg_over_hypot, max_arg_over_hypot_minus_1 : Real; begin if (not Low'Valid) or (not Pivot'Valid) then raise Constraint_Error with "Invalid input data in Get_Rotation..."; end if; P := Pivot; L := Low; Abs_P := Abs (P); Abs_L := Abs (L); -- default: no rotation is performed. sn := Zero; cs := One; sn_minus_1 := -One; cs_minus_1 := Zero; hypot := Abs_P; P_bigger_than_L := True; Skip_Rotation := True; if Abs_L < Two**Emin then Skip_Rotation := True; -- use defaults return; end if; if Abs_P < Two**Emin then if Abs_L > Two**Emin then sn := One; cs := Zero; sn_minus_1 := Zero; cs_minus_1 := -One; hypot := Abs_L; P_bigger_than_L := False; Skip_Rotation := False; return; else Skip_Rotation := True; -- use defaults return; end if; end if; -- if the Low val is too small compared to the pivot, then -- it contributes nothing to pivot after rotation ... but the row -- still might contribute elsewhere. if Abs_L < Two**(Emax - Emax/10 - Real'Machine_Radix - 1) and then Abs_L * Two**(Emax/10 + Real'Machine_Radix) < Abs_P then Skip_Rotation := True; return; -- use defaults, Skip_Rotation. end if; -- essential optimisation. if Abs_P > Abs_L then -- |s| <= |c| Skip_Rotation := False; P_bigger_than_L := True; -- Want P>0 always, (for efficiency, since we use cos = P/R = 1 + (cos-1)), -- so if P<0 then flip signs of both P and L -- to ensure zero'd out element. if P < Zero then P := -P; L := -L; end if; Get_Hypotenuse (P, L, hypot, min_arg_over_hypot, max_arg_over_hypot_minus_1); --cs := P / hypot; -- normally unused; set to default sn := Real'Copy_Sign (min_arg_over_hypot, L); --sn := L / hypot; cs_minus_1 := max_arg_over_hypot_minus_1; --cs_minus_1 := -Abs (sn) * Abs_L / hypot_plus_max_arg; --cs_minus_1_over_sn := -L / hypot_plus_max_arg; else -- Abs_P <= Abs_L, so abs t := abs (P / L) <= 1: NOTICE <= ! Skip_Rotation := False; P_bigger_than_L := False; -- Want L>0 always. If L<0 then flip signs of both P and L -- to ensure zero'd out element. if L < Zero then P := -P; L := -L; end if; Get_Hypotenuse (P, L, hypot, min_arg_over_hypot, max_arg_over_hypot_minus_1); --sn := L / hypot; -- set to default; unused cs := Real'Copy_Sign (min_arg_over_hypot, P); --cs := P / hypot; sn_minus_1 := max_arg_over_hypot_minus_1; --sn_minus_1 := -Abs (cs) * Abs_P / hypot_plus_max_arg; --sn_minus_1_over_cs := -P / hypot_plus_max_arg; end if; end Get_Rotation_That_Zeros_Out_Low; end Givens_Rotation;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Exceptions; use Ada.Exceptions; with UXAS.Common.Configuration_Manager; use UXAS.Common.Configuration_Manager; procedure Test_Configuration_Manager is Successfull_Load : Boolean; begin Instance.Load_Base_XML_File (XML_File_Path => "./cfg_WaterwaySearch.xml", Result => Successfull_Load); if Successfull_Load then Put_Line (Instance.Get_Entity_Id'Image); Put_Line (Instance.Get_Entity_Type); end if; Put_Line ("Done"); exception when Error : others => Put_Line (Exception_Name (Error)); Put_Line (Exception_Message (Error)); end Test_Configuration_Manager;
with Ada.Text_IO; use Ada.Text_IO; procedure Oups is type R is record A: Integer; end record; V : access R := null; begin if V.A = 1 then New_Line; end if; end;
with SPARK.Text_IO; use SPARK.Text_IO; package power_station with SPARK_Mode is procedure Start_Reactor with Global => (In_Out => (Standard_Input, Standard_Output)), Depends => (Standard_Output => (Standard_Input, Standard_Output), Standard_Input => (Standard_Input)), Pre => Status (Standard_Output) = Success, Post => Status (Standard_Output) = Success; private procedure Check_Reading(Value : in Integer; Warning, Danger : out Boolean) with Depends => (Warning => Value, Danger => Value), Pre => (Value >= 0 and Value <= 3), Post => ((if Value >= 2 then Warning = True) and (if Value < 2 then Warning = False) and (if Value = 3 then Danger = True) and (if Value < 3 then Danger = False)); procedure Decrease_Pressure with Global => (In_Out => (Standard_Output)), Depends => (Standard_Output => (Standard_Output)), Pre => Status (Standard_Output) = Success, Post => Status (Standard_Output) = Success; procedure Emergency_Shutdown with Global => (In_Out => (Standard_Output)), Depends => (Standard_Output => (Standard_Output)), Pre => Status (Standard_Output) = Success, Post => Status (Standard_Output) = Success; procedure Increase_Pressure with Global => (In_Out => (Standard_Output)), Depends => (Standard_Output => (Standard_Output)), Pre => Status (Standard_Output) = Success, Post => Status (Standard_Output) = Success; procedure Update_Reading(Name : in String; Value : in out Integer; Shutdown : out Boolean) with Global => (In_Out => (Standard_Input, Standard_Output)), Depends => (Standard_Output => (Standard_Input, Standard_Output, Name, Value), Standard_Input => (Standard_Input), Value => (Standard_Input, Value), Shutdown => (Standard_Input)), Pre => (Status (Standard_Output) = Success and Value >= 0 and Value <= 3), Post => (Status (Standard_Output) = Success and (if Value'Old = 0 then (Value = 0 or Value = 1)) and (if Value'Old = 1 then (Value = 0 or Value = 1 or Value = 2)) and (if Value'Old = 2 then (Value = 1 or Value = 2 or Value = 3)) and (if Value'Old = 3 then (Value = 2 or Value = 3))); end power_station;
with Ada.Finalization; package Obj is type Obj_T is new Ada.Finalization.Controlled with private; function New_Obj( I : in Integer ) return Obj_T; procedure Put( O : Obj_T ); private type Obj_T is new Ada.Finalization.Controlled with record X : Integer := 0; Serial : Integer := 0; end record; procedure Initialize( Object: in out Obj_T ); procedure Adjust( Object: in out Obj_T ); procedure Finalize( Object: in out Obj_T ); end Obj;
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- 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. -- * The name of the copyright holder may not 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 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. ------------------------------------------------------------------------------- with Keccak.Generic_CSHAKE; with Keccak.Types; use Keccak.Types; -- @summary -- Generic implementation of the TupleHash algorithm. -- -- @description -- TupleHash is a SHA-3-derived hash function with variable-length output -- that is designed to simply hash a tuple of input strings, any or all of -- which may be empty strings, in an unambiguous way. -- -- This API is used as follows: -- -- 1 Call Init to initialise a new TupleHash context. -- -- 2 Call Update_Tuple_Item for each item in the tuple. -- -- 3 Call either Finish or Extract to produce the desired type of output -- (TupleHash or TupleHashXOF): -- -- * Finish is used to produce a single output of arbitrary length (TupleHash). -- The requested output length affects the output. For example, requesting -- a 10-byte output will produce an unrelated hash to requesting a 20-byte -- output. -- -- * Extract can be called one or more times to produce an arbitrary number -- of output bytes (TupleHashXOF). In this case, the total output length is -- unknown in advance so the output does not change based on the overall length. -- For example, a 10-byte output is the truncated version of a 20-byte output. -- -- @group TupleHash generic with package CSHAKE is new Generic_CSHAKE (<>); package Keccak.Generic_Tuple_Hash is type Context is private; type States is (Updating, Extracting, Finished); -- @value Updating When in this state additional data can be input into the -- TupleHash context. -- -- @value Extracting When in this state, the TupleHash context can generate -- output bytes by calling the Extract procedure. -- -- @value Finished When in this state the context is finished and no more data -- can be input or output. procedure Init (Ctx : out Context; Customization : in String := "") with Global => null, Depends => (Ctx => Customization), Post => State_Of (Ctx) = Updating; -- Initialise the TupleHash context. -- -- @param Ctx The TupleHash context to initialise. -- -- @param Customization An optional customisation string to provide domain -- separation between different instances of TupleHash. procedure Update_Tuple_Item (Ctx : in out Context; Item : in Byte_Array) with Global => null, Depends => (Ctx =>+ Item), Pre => State_Of (Ctx) = Updating, Post => State_Of (Ctx) = Updating; -- Process the next tuple item. -- -- The entire tuple item must be passed into this procedure. -- -- This may be called multiple times to process an arbitrary number of items. procedure Finish (Ctx : in out Context; Digest : out Byte_Array) with Global => null, Depends => ((Ctx, Digest) => (Ctx, Digest)), Pre => State_Of (Ctx) = Updating, Post => State_Of (Ctx) = Finished; -- Produce a TupleHash digest (TupleHash variant) -- -- After calling this procedure the context can no longer be used. However, -- it can be re-initialized to perform a new TupleHash computation. -- -- The number of output bytes requested is determined from the length of -- the Digest array (i.e. Digest'Length) and has an effect on the value of the -- output digest. For example, two different ParallelHash computations with identical -- inputs (same key and input data) but with different digest lengths will -- produce independent digest values. -- -- Note that this procedure can only be called once for each ParallelHash -- computation. This requires that the required digest length is known before -- calling this procedure, and a Byte_Array with the correct length is -- given to this procedure. For applications where the number of required -- output bytes is not known until after bytes are output, see the Extract -- procedure. procedure Extract (Ctx : in out Context; Digest : out Byte_Array) with Global => null, Depends => ((Ctx, Digest) => (Ctx, Digest)), Pre => State_Of (Ctx) in Updating | Extracting, Post => State_Of (Ctx) = Extracting; -- Produce a TupleHash digest (TupleHashXOF variant) -- -- After calling this procudure no more data can be input into the ParllelHash -- computation. -- -- This function can be called multiple times to produce an arbitrary -- number of output bytes. function State_Of (Ctx : in Context) return States with Global => null; private use type CSHAKE.States; type Context is record Ctx : CSHAKE.Context; Finished : Boolean; end record; function State_Of (Ctx : in Context) return States is (if Ctx.Finished then Finished elsif CSHAKE.State_Of (Ctx.Ctx) = CSHAKE.Updating then Updating else Extracting); end Keccak.Generic_Tuple_Hash;
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package body Program.Interpretations.Names is procedure Step (Self : Iterator'Class; Cursor : in out Names.Cursor); ---------- -- Each -- ---------- function Each (Set : Interpretation_Set) return Iterator is begin return (Set => Set); end Each; ----------- -- First -- ----------- overriding function First (Self : Iterator) return Cursor is begin return Result : Cursor := (Index => Self.Set.From, State => <>) do Self.Step (Result); end return; end First; ----------------- -- Has_Element -- ----------------- function Has_Element (Self : Cursor) return Boolean is begin return Self.Index > 0; end Has_Element; ---------- -- Next -- ---------- overriding function Next (Self : Iterator; Position : Cursor) return Cursor is begin return Result : Cursor := Position do if Position.State.Is_Symbol then Result.State.Cursor := Result.State.Iter.Next (Result.State.Cursor); if Program.Visibility.Has_Element (Result.State.Cursor) then return; end if; end if; Result.Index := Result.Index + 1; Self.Step (Result); end return; end Next; ---------- -- View -- ---------- function View (Self : Cursor) return Program.Visibility.View is begin if Self.State.Is_Symbol then return Program.Visibility.Get_View (Self.State.Cursor); else return Self.State.View; end if; end View; ---------- -- Step -- ---------- procedure Step (Self : Iterator'Class; Cursor : in out Names.Cursor) is Env : constant Program.Visibility.Context_Access := Self.Set.Context.Env; begin while Cursor.Index <= Self.Set.To loop declare Item : Interpretation renames Self.Set.Context.Data (Cursor.Index); begin case Item.Kind is when Name => Cursor.State := (Is_Symbol => False, View => Item.Name_View); return; when Symbol => Cursor.State := (Is_Symbol => True, Iter => Env.Directly_Visible (Item.Symbol), Cursor => <>); Cursor.State.Cursor := Cursor.State.Iter.First; if Program.Visibility.Has_Element (Cursor.State.Cursor) then return; end if; when Expression | Expression_Category => null; end case; end; Cursor.Index := Cursor.Index + 1; end loop; Cursor.Index := 0; end Step; end Program.Interpretations.Names;
-- CC1220A.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. --* -- OBJECTIVE: -- CHECK THAT A GENERIC UNIT CAN REFER TO AN IMPLICITLY -- DECLARED PREDEFINED OPERATOR. -- HISTORY: -- DAT 08/20/81 CREATED ORIGINAL TEST. -- SPS 05/03/82 -- BCB 08/04/88 MODIFIED HEADER FORMAT AND ADDED CHECKS FOR OTHER -- OPERATIONS OF A DISCRETE TYPE. -- RJW 03/27/90 REVISED TEST TO CHECK FOR A GENERIC FORMAL -- DISCRETE TYPE. -- CJJ 10/14/90 ADDED CHECKS FOR RELATIONAL OPERATOR (<, <=, >, >=); -- MADE FAILED MESSAGES IN PROCEDURE BODY MORE SPECIFIC. WITH REPORT; USE REPORT; WITH SYSTEM; USE SYSTEM; PROCEDURE CC1220A IS BEGIN TEST ("CC1220A", "GENERIC UNIT CAN REFER TO IMPLICITLY " & "DECLARED OPERATORS"); DECLARE GENERIC TYPE T IS (<>); STR : STRING; P1 : T := T'FIRST; P2 : T := T(T'SUCC (P1)); P3 : T := T'(T'PRED (P2)); P4 : INTEGER := IDENT_INT(T'WIDTH); P5 : BOOLEAN := (P1 < P2) AND (P2 > P3); P6: BOOLEAN := (P1 <= P3) AND (P2 >= P1); P7 : BOOLEAN := (P3 = P1); P8 : T := T'BASE'FIRST; P10 : T := T'LAST; P11 : INTEGER := T'SIZE; P12 : ADDRESS := P10'ADDRESS; P13 : INTEGER := T'WIDTH; P14 : INTEGER := T'POS(T'LAST); P15 : T := T'VAL(1); P16 : INTEGER := T'POS(P15); P17 : STRING := T'IMAGE(T'BASE'LAST); P18 : T := T'VALUE(P17); P19 : BOOLEAN := (P15 IN T); WITH FUNCTION IDENT (X : T) RETURN T; PACKAGE PKG IS ARR : ARRAY (1 .. 3) OF T := (P1,P2,P3); B1 : BOOLEAN := P7 AND P19; B2 : BOOLEAN := P5 AND P6; END PKG; PACKAGE BODY PKG IS BEGIN IF P1 /= T(T'FIRST) THEN FAILED ("IMPROPER VALUE FOR 'FIRST - " & STR); END IF; IF T'SUCC (P1) /= IDENT (P2) OR T'PRED (P2) /= IDENT (P1) THEN FAILED ("IMPROPER VALUE FOR 'SUCC, PRED - " & STR); END IF; IF P10 /= T(T'LAST) THEN FAILED ("IMPROPER VALUE FOR 'LAST - " & STR); END IF; IF NOT EQUAL(P11,T'SIZE) THEN FAILED ("IMPROPER VALUE FOR 'SIZE - " & STR); END IF; IF NOT EQUAL(P13,T'WIDTH) THEN FAILED ("IMPROPER VALUE FOR 'WIDTH - " & STR); END IF; IF NOT EQUAL (P16, T'POS (P15)) OR T'VAL (P16) /= T(IDENT (P15)) THEN FAILED ("IMPROPER VALUE FOR 'POS, 'VAL - " & STR); END IF; IF T'VALUE (P17) /= T'BASE'LAST OR T'IMAGE (P18) /= T'IMAGE (T'BASE'LAST) THEN FAILED ("IMPROPER VALUE FOR 'VALUE, 'IMAGE - " & STR); END IF; END PKG; BEGIN DECLARE TYPE CHAR IS ('A', 'B', 'C', 'D', 'E'); FUNCTION IDENT (C : CHAR) RETURN CHAR IS BEGIN RETURN CHAR'VAL (IDENT_INT (CHAR'POS (C))); END IDENT; PACKAGE N_CHAR IS NEW PKG (T => CHAR, STR => "CHAR", IDENT => IDENT); BEGIN IF N_CHAR.ARR (1) /= IDENT ('A') OR N_CHAR.ARR (2) /= IDENT ('B') OR N_CHAR.ARR (3) /= 'A' OR N_CHAR.B1 /= TRUE OR N_CHAR.B2 /= TRUE THEN FAILED ("IMPROPER VALUES FOR ARRAY COMPONENTS" & " IN INSTANTIATION OF N_CHAR."); END IF; END; DECLARE TYPE ENUM IS (JOVIAL, ADA, FORTRAN, BASIC); FUNCTION IDENT (C : ENUM) RETURN ENUM IS BEGIN RETURN ENUM'VAL (IDENT_INT (ENUM'POS (C))); END IDENT; PACKAGE N_ENUM IS NEW PKG (T => ENUM, STR => "ENUM", IDENT => IDENT); BEGIN IF N_ENUM.ARR (1) /= IDENT (JOVIAL) OR N_ENUM.ARR (2) /= IDENT (ADA) OR N_ENUM.ARR (3) /= JOVIAL OR N_ENUM.B1 /= TRUE OR N_ENUM.B2 /= TRUE THEN FAILED ("IMPROPER VALUES FOR ARRAY COMPONENTS" & " IN INSTANTIATION OF N_ENUM."); END IF; END; DECLARE PACKAGE N_INT IS NEW PKG (T => INTEGER, STR => "INTEGER", IDENT => IDENT_INT); BEGIN IF N_INT.ARR (1) /= IDENT_INT (INTEGER'FIRST) OR N_INT.ARR (2) /= IDENT_INT (INTEGER'FIRST + 1) OR N_INT.ARR (3) /= INTEGER'FIRST OR N_INT.B1 /= TRUE OR N_INT.B2 /= TRUE THEN FAILED ("IMPROPER VALUES FOR ARRAY COMPONENTS" & " IN INSTANTIATION OF N_INT."); END IF; END; END; RESULT; END CC1220A;
-- AOC 2020, Day 7 with Ada.Text_IO; use Ada.Text_IO; with Day; use Day; procedure main is bag_colors : constant Natural := valid_bag_colors; nested : constant Natural := nested_bags; begin put_line("Part 1: " & Natural'Image(bag_colors)); put_line("Part 2: " & Natural'Image(nested)); end main;
with J_String_Pkg, Text_IO, Ada.Integer_Text_IO; use J_String_Pkg, Text_IO, Ada.Integer_Text_IO; procedure spec is Str : String := "test"; Js : J_String := Create(Str); Js1 : J_String := Create("test"); Js2 : J_String := Create("tes"); numberOfTests : Natural := 46; numberOfpassedTests : Natural := 0; procedure passed(Func : String) is begin Put_Line(Func & " - passed"); numberOfpassedTests := numberOfpassedTests + 1; end passed; begin if Value_Of(Create("asd")) = "asd" then passed("Create"); end if; if Value_Of(Js) = "test" then passed("Value_Of"); end if; if Char_At(Js, 1) = 't' then passed("Char_At"); end if; if Compare_To(Js, Js1) then passed("Compare_To"); end if; if Compare_To(Js, Js2) = false then passed("Compare_To"); end if; if Value_Of(Concat(Js1, Js2)) = "testtes" then passed("Concat"); end if; if Contains(Js1, "es") then passed("Contains"); end if; if Contains(Js2, "os") = false then passed("Contains"); end if; if Ends_With(Js1, 't') then passed("Ends_With"); end if; if Ends_With(Js1, 'a') = false then passed("Ends_With"); end if; if Ends_With(Js1, "st") then passed("Ends_With"); end if; if Ends_With(Js1, "at") = false then passed("Ends_With"); end if; if Js = Js1 then passed("="); end if; if Js1 /= Js2 then passed("="); end if; if Index_Of(Js1, 's') = 3 then passed("Index_Of"); end if; if Index_Of(Js1, 't') = 1 then passed("Index_Of"); end if; if Index_Of(Js1, 'x') = -1 then passed("Index_Of"); end if; if Index_Of(Js1, 'e', 5) = -1 then passed("Index_Of"); end if; if Index_Of(Js1, "est") = 2 then passed("Index_Of"); end if; if Index_Of(Js1, "tes") = 1 then passed("Index_Of"); end if; if Index_Of(Js1, "testt") = -1 then passed("Index_Of"); end if; if Index_Of(Js1, "os") = -1 then passed("Index_Of"); end if; if Is_Empty(Create("")) then passed("Is_Empty"); end if; if Is_Empty(Create("a")) = false then passed("Is_Empty"); end if; if Last_Index_Of(Create("abca"), 'a') = 4 then passed("Last_Index_Of"); end if; if Last_Index_Of(Create("abca"), 'x') = -1 then passed("Last_Index_Of"); end if; if Last_Index_Of(Create("abca"), 'a', 3) = 1 then passed("Last_Index_Of"); end if; if Last_Index_Of(Create("abca"), 'c', 2) = -1 then passed("Last_Index_Of"); end if; if Last_Index_Of(Create("abc"), 'c', 4) = -1 then passed("Last_Index_Of"); end if; if Length(Create("abc")) = 3 then passed("Length"); end if; if Length(Create("a")) = 1 then passed("Length"); end if; if Length(Create("")) = 0 then passed("Length"); end if; if Value_Of(Replace(Create("abc"), 'b', 'x')) = "axc" then passed("Replace"); end if; if Value_Of(Replace(Create("abca"), 'a', 'x')) = "xbcx" then passed("Replace"); end if; if Starts_With(Create("abc"), 'a') then passed("Starts_With"); end if; if Starts_With(Create("bc"), 'a') = false then passed("Starts_With"); end if; if Starts_With(Create("a"), 'a') then passed("Starts_With"); end if; if Starts_With(Create("b"), 'a') = false then passed("Starts_With"); end if; if Starts_With(Create("abc"), "ab") then passed("Starts_With"); end if; if Starts_With(Create("abc"), "ba") = false then passed("Starts_With"); end if; if Starts_With(Create("abc"), "abc") then passed("Starts_With"); end if; if Starts_With(Create("abc"), "abcd") = false then passed("Starts_With"); end if; if Value_Of(Substring(Create("abc"), 1)) = "abc" then passed("Substring"); end if; if Value_Of(Substring(Create("abc"), 2)) = "bc" then passed("Substring"); end if; if Value_Of(Substring(Create("abc"), 1, 2)) = "ab" then passed("Substring"); end if; if Value_Of(Substring(Create("abc"), 1, 1)) = "a" then passed("Substring"); end if; Put_Line("==============="); Put(numberOfpassedTests, 0); Put(" / "); Put(numberOfTests, 0); Put(" passed"); end spec;
-- part of ParserTools, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Finalization; package Lexer.Source is pragma Preelaborate; -- a Source is anything that provides a character stream. Sources are always -- single-use objects; the lexer takes ownership of sources and deallocates -- them. type Instance is abstract new Ada.Finalization.Limited_Controlled with null record; type Pointer is access all Instance'Class; procedure Read_Data (S : in out Instance; Buffer : out String; Length : out Natural) is abstract; end Lexer.Source;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J . E X T -- -- -- -- B o d y -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Osint; use Osint; with Ada.Unchecked_Deallocation; package body Prj.Ext is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : out External_References; Copy_From : External_References := No_External_Refs) is N : Name_To_Name_Ptr; N2 : Name_To_Name_Ptr; begin if Self.Refs = null then Self.Refs := new Name_To_Name_HTable.Instance; if Copy_From.Refs /= null then N := Name_To_Name_HTable.Get_First (Copy_From.Refs.all); while N /= null loop N2 := new Name_To_Name' (Key => N.Key, Value => N.Value, Source => N.Source, Next => null); Name_To_Name_HTable.Set (Self.Refs.all, N2); N := Name_To_Name_HTable.Get_Next (Copy_From.Refs.all); end loop; end if; end if; end Initialize; --------- -- Add -- --------- procedure Add (Self : External_References; External_Name : String; Value : String; Source : External_Source := External_Source'First; Silent : Boolean := False) is Key : Name_Id; N : Name_To_Name_Ptr; begin -- For external attribute, set the environment variable if Source = From_External_Attribute and then External_Name /= "" then declare Env_Var : String_Access := Getenv (External_Name); begin if Env_Var = null or else Env_Var.all = "" then Setenv (Name => External_Name, Value => Value); if not Silent then Debug_Output ("Environment variable """ & External_Name & """ = """ & Value & '"'); end if; elsif not Silent then Debug_Output ("Not overriding existing environment variable """ & External_Name & """, value is """ & Env_Var.all & '"'); end if; Free (Env_Var); end; end if; Name_Len := External_Name'Length; Name_Buffer (1 .. Name_Len) := External_Name; Canonical_Case_Env_Var_Name (Name_Buffer (1 .. Name_Len)); Key := Name_Find; -- Check whether the value is already defined, to properly respect the -- overriding order. if Source /= External_Source'First then N := Name_To_Name_HTable.Get (Self.Refs.all, Key); if N /= null then if External_Source'Pos (N.Source) < External_Source'Pos (Source) then if not Silent then Debug_Output ("Not overridding existing external reference '" & External_Name & "', value was defined in " & N.Source'Img); end if; return; end if; end if; end if; Name_Len := Value'Length; Name_Buffer (1 .. Name_Len) := Value; N := new Name_To_Name' (Key => Key, Source => Source, Value => Name_Find, Next => null); if not Silent then Debug_Output ("Add external (" & External_Name & ") is", N.Value); end if; Name_To_Name_HTable.Set (Self.Refs.all, N); end Add; ----------- -- Check -- ----------- function Check (Self : External_References; Declaration : String) return Boolean is begin for Equal_Pos in Declaration'Range loop if Declaration (Equal_Pos) = '=' then exit when Equal_Pos = Declaration'First; Add (Self => Self, External_Name => Declaration (Declaration'First .. Equal_Pos - 1), Value => Declaration (Equal_Pos + 1 .. Declaration'Last), Source => From_Command_Line); return True; end if; end loop; return False; end Check; ----------- -- Reset -- ----------- procedure Reset (Self : External_References) is begin if Self.Refs /= null then Debug_Output ("Reset external references"); Name_To_Name_HTable.Reset (Self.Refs.all); end if; end Reset; -------------- -- Value_Of -- -------------- function Value_Of (Self : External_References; External_Name : Name_Id; With_Default : Name_Id := No_Name) return Name_Id is Value : Name_To_Name_Ptr; Val : Name_Id; Name : String := Get_Name_String (External_Name); begin Canonical_Case_Env_Var_Name (Name); if Self.Refs /= null then Name_Len := Name'Length; Name_Buffer (1 .. Name_Len) := Name; Value := Name_To_Name_HTable.Get (Self.Refs.all, Name_Find); if Value /= null then Debug_Output ("Value_Of (" & Name & ") is in cache", Value.Value); return Value.Value; end if; end if; -- Find if it is an environment, if it is, put value in the hash table declare Env_Value : String_Access := Getenv (Name); begin if Env_Value /= null and then Env_Value'Length > 0 then Name_Len := Env_Value'Length; Name_Buffer (1 .. Name_Len) := Env_Value.all; Val := Name_Find; if Current_Verbosity = High then Debug_Output ("Value_Of (" & Name & ") is", Val); end if; if Self.Refs /= null then Value := new Name_To_Name' (Key => External_Name, Value => Val, Source => From_Environment, Next => null); Name_To_Name_HTable.Set (Self.Refs.all, Value); end if; Free (Env_Value); return Val; else if Current_Verbosity = High then Debug_Output ("Value_Of (" & Name & ") is default", With_Default); end if; Free (Env_Value); return With_Default; end if; end; end Value_Of; ---------- -- Free -- ---------- procedure Free (Self : in out External_References) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Name_To_Name_HTable.Instance, Instance_Access); begin if Self.Refs /= null then Reset (Self); Unchecked_Free (Self.Refs); end if; end Free; -------------- -- Set_Next -- -------------- procedure Set_Next (E : Name_To_Name_Ptr; Next : Name_To_Name_Ptr) is begin E.Next := Next; end Set_Next; ---------- -- Next -- ---------- function Next (E : Name_To_Name_Ptr) return Name_To_Name_Ptr is begin return E.Next; end Next; ------------- -- Get_Key -- ------------- function Get_Key (E : Name_To_Name_Ptr) return Name_Id is begin return E.Key; end Get_Key; end Prj.Ext;
-- call5.ada -- -- call for an entry of a completed but not yet terminated task -- WITH text_io; PROCEDURE main IS task t1 is entry e1; end t1; task body t1 is task t2 is -- t2 depends on t1 entry e2; end t2; task body t2 is begin loop select accept e2; -- or -- terminate; end select; end loop; end t2; task t3; -- t3 depends on t1 task body t3 is begin loop t2.e2; delay 0.5; end loop; end t3; begin accept e1; text_io.put_line("--------------------------------> TASK T1 COMPLETED"); -- t1 is completed but not terminated end t1; BEGIN t1.e1; delay 1.0; text_io.put_line("T1'TERMINATED = " & boolean'image(T1'terminated)); text_io.put_line("T1'CALLABLE = " & boolean'image(T1'callable)); t1.e1; text_io.put_line("-------------------------------------> MAIN COMPLETED"); END main;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . N U M E R I C S . A U X -- -- -- -- S p e c -- -- (C Library Version for x86) -- -- -- -- Copyright (C) 1992-2005, 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, 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. -- -- -- ------------------------------------------------------------------------------ -- This package provides the basic computational interface for the generic -- elementary functions. The C library version interfaces with the routines -- in the C mathematical library, and is thus quite portable, although it may -- not necessarily meet the requirements for accuracy in the numerics annex. -- One advantage of using this package is that it will interface directly to -- hardware instructions, such as the those provided on the Intel x86. -- Note: there are two versions of this package. One using the 80-bit x86 -- long double format (which is this version), and one using 64-bit IEEE -- double (see file a-numaux.ads). package Ada.Numerics.Aux is pragma Pure; pragma Linker_Options ("-lm"); type Double is digits 18; -- We import these functions directly from C. Note that we label them -- all as pure functions, because indeed all of them are in fact pure! function Sin (X : Double) return Double; pragma Import (C, Sin, "sinl"); pragma Pure_Function (Sin); function Cos (X : Double) return Double; pragma Import (C, Cos, "cosl"); pragma Pure_Function (Cos); function Tan (X : Double) return Double; pragma Import (C, Tan, "tanl"); pragma Pure_Function (Tan); function Exp (X : Double) return Double; pragma Import (C, Exp, "expl"); pragma Pure_Function (Exp); function Sqrt (X : Double) return Double; pragma Import (C, Sqrt, "sqrtl"); pragma Pure_Function (Sqrt); function Log (X : Double) return Double; pragma Import (C, Log, "logl"); pragma Pure_Function (Log); function Acos (X : Double) return Double; pragma Import (C, Acos, "acosl"); pragma Pure_Function (Acos); function Asin (X : Double) return Double; pragma Import (C, Asin, "asinl"); pragma Pure_Function (Asin); function Atan (X : Double) return Double; pragma Import (C, Atan, "atanl"); pragma Pure_Function (Atan); function Sinh (X : Double) return Double; pragma Import (C, Sinh, "sinhl"); pragma Pure_Function (Sinh); function Cosh (X : Double) return Double; pragma Import (C, Cosh, "coshl"); pragma Pure_Function (Cosh); function Tanh (X : Double) return Double; pragma Import (C, Tanh, "tanhl"); pragma Pure_Function (Tanh); function Pow (X, Y : Double) return Double; pragma Import (C, Pow, "powl"); pragma Pure_Function (Pow); end Ada.Numerics.Aux;
with Ada.Calendar; with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Text_IO; with GNATCOLL.VFS; with Command_Line; with Extraction; with GraphML_Writers; procedure Dependency_Graph_Extractor is package G_W renames GraphML_Writers; package S_U renames Ada.Strings.Unbounded; package V_F_S renames GNATCOLL.VFS; use type Ada.Calendar.Time; use type S_U.Unbounded_String; use type V_F_S.Filesystem_String; use type V_F_S.Virtual_File; Output_File : S_U.Unbounded_String; Directory_Prefix : S_U.Unbounded_String; Recurse_Projects : Boolean; Input_Files : Command_Line.Input_File_Vectors.Vector; Start_Time : constant Ada.Calendar.Time := Ada.Calendar.Clock; begin if not Command_Line.Parse_Command_Line (Input_Files, Recurse_Projects, Directory_Prefix, Output_File) then return; end if; if Output_File = S_U.Null_Unbounded_String then Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "No output file provided"); Ada.Command_Line.Set_Exit_Status (1); return; end if; declare use Extraction; Filename : constant String := S_U.To_String (Output_File); Prefix : constant V_F_S.Virtual_File := (if Directory_Prefix = S_U.Null_Unbounded_String then V_F_S.No_File else V_F_S.Create_From_Base (+S_U.To_String (Directory_Prefix))); Graph : G_W.GraphML_File := G_W.Create_GraphML_Writer (Filename, Node_Attributes, Edge_Attributes); begin Prefix.Normalize_Path; for Input_File of Input_Files loop Extract_Dependency_Graph (S_U.To_String (Input_File), Recurse_Projects, Prefix, Graph); end loop; Graph.Close; end; Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Duration'Image (Ada.Calendar.Clock - Start_Time)); end Dependency_Graph_Extractor;