content
stringlengths
23
1.05M
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. (gh+flacada@heisenbug.eu) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); package body Flac.CRC with SPARK_Mode => On, Refined_State => (Constant_State => (CRC_8_Table, CRC_16_Table)) is CRC_8_Table : array (Ada.Streams.Stream_Element) of Checksum_8 with Constant_After_Elaboration => True; CRC_16_Table : array (Ada.Streams.Stream_Element) of Checksum_16 with Constant_After_Elaboration => True; --------------------------------------------------------------------------- -- CRC8 --------------------------------------------------------------------------- procedure CRC8 (CRC : in out Checksum_8; Data : in Ada.Streams.Stream_Element_Array) is use type Ada.Streams.Stream_Element; begin for Byte of Data loop CRC := CRC_8_Table (Ada.Streams.Stream_Element (CRC) xor Byte); end loop; end CRC8; --------------------------------------------------------------------------- -- CRC16 --------------------------------------------------------------------------- procedure CRC16 (CRC : in out Checksum_16; Data : in Ada.Streams.Stream_Element_Array) is use type Ada.Streams.Stream_Element; begin for Byte of Data loop CRC := CRC_16_Table (Ada.Streams.Stream_Element (CRC and 16#00FF#) xor Byte); end loop; end CRC16; begin for Byte in CRC_8_Table'Range loop declare CRC : Checksum_8 := Checksum_8 (Byte); begin for Bit in 0 .. 7 loop if (CRC and 2#1000_0000#) /= 0 then CRC := Shift_Left (Value => CRC, Amount => 1) xor 16#07#; else CRC := Shift_Left (Value => CRC, Amount => 1); end if; end loop; CRC_8_Table (Byte) := CRC; end; end loop; for Byte in CRC_16_Table'Range loop declare CRC : Checksum_16 := Checksum_16 (Byte); begin for Bit in 0 .. 15 loop if (CRC and 2#1000_0000_0000_0000#) /= 0 then CRC := Shift_Left (Value => CRC, Amount => 1) xor 2#1000_0000_0000_0101#; else CRC := Shift_Left (Value => CRC, Amount => 1); end if; end loop; CRC_16_Table (Byte) := CRC; end; end loop; end Flac.CRC;
with Common_Formal_Containers; use Common_Formal_Containers; package AFRL.CMASI.OperatingRegion.SPARK_Boundary with SPARK_Mode is pragma Annotate (GNATprove, Terminating, SPARK_Boundary); type OperatingRegionAreas is record KeepInAreas : Int64_Vect; KeepOutAreas : Int64_Vect; end record; function Get_Areas (Region : OperatingRegion) return OperatingRegionAreas with Global => null; end AFRL.CMASI.OperatingRegion.SPARK_Boundary;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ S P A R K -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; with Exp_Ch5; use Exp_Ch5; with Exp_Dbug; use Exp_Dbug; with Exp_Util; use Exp_Util; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Rtsfind; use Rtsfind; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Exp_SPARK is ----------------------- -- Local Subprograms -- ----------------------- procedure Expand_SPARK_Attribute_Reference (N : Node_Id); -- Replace occurrences of System'To_Address by calls to -- System.Storage_Elements.To_Address procedure Expand_SPARK_N_Object_Renaming_Declaration (N : Node_Id); -- Perform name evaluation for a renamed object ------------------ -- Expand_SPARK -- ------------------ procedure Expand_SPARK (N : Node_Id) is begin case Nkind (N) is -- Qualification of entity names in formal verification mode -- is limited to the addition of a suffix for homonyms (see -- Exp_Dbug.Qualify_Entity_Name). We used to qualify entity names -- as full expansion does, but this was removed as this prevents the -- verification back-end from using a short name for debugging and -- user interaction. The verification back-end already takes care -- of qualifying names when needed. when N_Block_Statement | N_Entry_Declaration | N_Package_Body | N_Package_Declaration | N_Protected_Type_Declaration | N_Subprogram_Body | N_Task_Type_Declaration => Qualify_Entity_Names (N); when N_Expanded_Name | N_Identifier => Expand_SPARK_Potential_Renaming (N); when N_Object_Renaming_Declaration => Expand_SPARK_N_Object_Renaming_Declaration (N); -- Replace occurrences of System'To_Address by calls to -- System.Storage_Elements.To_Address when N_Attribute_Reference => Expand_SPARK_Attribute_Reference (N); -- Loop iterations over arrays need to be expanded, to avoid getting -- two names referring to the same object in memory (the array and -- the iterator) in GNATprove, especially since both can be written -- (thus possibly leading to interferences due to aliasing). No such -- problem arises with quantified expressions over arrays, which are -- dealt with specially in GNATprove. when N_Loop_Statement => declare Scheme : constant Node_Id := Iteration_Scheme (N); begin if Present (Scheme) and then Present (Iterator_Specification (Scheme)) and then Is_Iterator_Over_Array (Iterator_Specification (Scheme)) then Expand_Iterator_Loop_Over_Array (N); end if; end; -- In SPARK mode, no other constructs require expansion when others => null; end case; end Expand_SPARK; -------------------------------------- -- Expand_SPARK_Attribute_Reference -- -------------------------------------- procedure Expand_SPARK_Attribute_Reference (N : Node_Id) is Aname : constant Name_Id := Attribute_Name (N); Attr_Id : constant Attribute_Id := Get_Attribute_Id (Aname); Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Expr : Node_Id; begin if Attr_Id = Attribute_To_Address then -- Extract and convert argument to expected type for call Expr := Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Integer_Address), Loc), Expression => Relocate_Node (First (Expressions (N)))); -- Replace attribute reference with call Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_To_Address), Loc), Parameter_Associations => New_List (Expr))); Analyze_And_Resolve (N, Typ); -- For attributes which return Universal_Integer, introduce a conversion -- to the expected type with the appropriate check flags set. elsif Attr_Id = Attribute_Alignment or else Attr_Id = Attribute_Bit or else Attr_Id = Attribute_Bit_Position or else Attr_Id = Attribute_Descriptor_Size or else Attr_Id = Attribute_First_Bit or else Attr_Id = Attribute_Last_Bit or else Attr_Id = Attribute_Length or else Attr_Id = Attribute_Max_Size_In_Storage_Elements or else Attr_Id = Attribute_Pos or else Attr_Id = Attribute_Position or else Attr_Id = Attribute_Range_Length or else Attr_Id = Attribute_Object_Size or else Attr_Id = Attribute_Size or else Attr_Id = Attribute_Value_Size or else Attr_Id = Attribute_VADS_Size or else Attr_Id = Attribute_Aft or else Attr_Id = Attribute_Max_Alignment_For_Allocation then -- If the expected type is Long_Long_Integer, there will be no check -- flag as the compiler assumes attributes always fit in this type. -- Since in SPARK_Mode we do not take Storage_Error into account, we -- cannot make this assumption and need to produce a check. -- ??? It should be enough to add this check for attributes 'Length -- and 'Range_Length when the type is as big as Long_Long_Integer. declare Typ : Entity_Id := Empty; begin if Attr_Id = Attribute_Range_Length then Typ := Etype (Prefix (N)); elsif Attr_Id = Attribute_Length then Typ := Etype (Prefix (N)); declare Indx : Node_Id; J : Int; begin if Is_Access_Type (Typ) then Typ := Designated_Type (Typ); end if; if No (Expressions (N)) then J := 1; else J := UI_To_Int (Expr_Value (First (Expressions (N)))); end if; Indx := First_Index (Typ); while J > 1 loop Next_Index (Indx); J := J - 1; end loop; Typ := Etype (Indx); end; end if; Apply_Universal_Integer_Attribute_Checks (N); if Present (Typ) and then RM_Size (Typ) = RM_Size (Standard_Long_Long_Integer) then Set_Do_Overflow_Check (N); end if; end; end if; end Expand_SPARK_Attribute_Reference; ------------------------------------------------ -- Expand_SPARK_N_Object_Renaming_Declaration -- ------------------------------------------------ procedure Expand_SPARK_N_Object_Renaming_Declaration (N : Node_Id) is begin -- Unconditionally remove all side effects from the name Evaluate_Name (Name (N)); end Expand_SPARK_N_Object_Renaming_Declaration; ------------------------------------- -- Expand_SPARK_Potential_Renaming -- ------------------------------------- procedure Expand_SPARK_Potential_Renaming (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ren_Id : constant Entity_Id := Entity (N); Typ : constant Entity_Id := Etype (N); Obj_Id : Node_Id; begin -- Replace a reference to a renaming with the actual renamed object if Ekind (Ren_Id) in Object_Kind then Obj_Id := Renamed_Object (Ren_Id); if Present (Obj_Id) then -- The renamed object is an entity when instantiating generics -- or inlining bodies. In this case the renaming is part of the -- mapping "prologue" which links actuals to formals. if Nkind (Obj_Id) in N_Entity then Rewrite (N, New_Occurrence_Of (Obj_Id, Loc)); -- Otherwise the renamed object denotes a name else Rewrite (N, New_Copy_Tree (Obj_Id, New_Sloc => Loc)); Reset_Analyzed_Flags (N); end if; Analyze_And_Resolve (N, Typ); end if; end if; end Expand_SPARK_Potential_Renaming; end Exp_SPARK;
with Ada.Exception_Identification.From_Here; with System.Address_To_Named_Access_Conversions; with System.Standard_Allocators; with System.Storage_Elements; with System.Zero_Terminated_Strings; with C.errno; with C.fnmatch; with C.stdint; with C.sys.types; package body System.Native_Directories.Searching is use Ada.Exception_Identification.From_Here; use type Storage_Elements.Storage_Offset; use type C.char; use type C.signed_int; use type C.unsigned_char; -- d_namelen in FreeBSD use type C.dirent.DIR_ptr; use type C.size_t; use type C.sys.dirent.struct_dirent_ptr; use type C.sys.types.mode_t; package char_ptr_Conv is new Address_To_Named_Access_Conversions (C.char, C.char_ptr); package dirent_ptr_Conv is new Address_To_Named_Access_Conversions ( C.dirent.struct_dirent, C.sys.dirent.struct_dirent_ptr); procedure memcpy ( dst : not null C.sys.dirent.struct_dirent_ptr; src : not null C.sys.dirent.struct_dirent_ptr; n : Storage_Elements.Storage_Count) with Import, Convention => Intrinsic, External_Name => "__builtin_memcpy"; procedure Get_Information ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Information : aliased out C.sys.stat.struct_stat; errno : out C.signed_int); procedure Get_Information ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Information : aliased out C.sys.stat.struct_stat; errno : out C.signed_int) is S_Length : constant C.size_t := C.size_t (Directory_Entry.d_namlen); Full_Name : C.char_array ( 0 .. Directory'Length * Zero_Terminated_Strings.Expanding + 1 -- '/' + S_Length); Full_Name_Length : C.size_t; begin -- compose Zero_Terminated_Strings.To_C ( Directory, Full_Name (0)'Access, Full_Name_Length); Full_Name (Full_Name_Length) := '/'; Full_Name_Length := Full_Name_Length + 1; Full_Name (Full_Name_Length .. Full_Name_Length + S_Length - 1) := Directory_Entry.d_name (0 .. S_Length - 1); Full_Name_Length := Full_Name_Length + S_Length; Full_Name (Full_Name_Length) := C.char'Val (0); -- stat if C.sys.stat.lstat (Full_Name (0)'Access, Information'Access) < 0 then errno := C.errno.errno; else errno := 0; end if; end Get_Information; -- implementation function New_Directory_Entry (Source : not null Directory_Entry_Access) return not null Directory_Entry_Access is Result : constant Directory_Entry_Access := dirent_ptr_Conv.To_Pointer ( Standard_Allocators.Allocate ( Storage_Elements.Storage_Offset (Source.d_reclen))); begin memcpy ( Result, Source, Storage_Elements.Storage_Offset (Source.d_reclen)); return Result; end New_Directory_Entry; procedure Free (X : in out Directory_Entry_Access) is begin Standard_Allocators.Free (dirent_ptr_Conv.To_Address (X)); X := null; end Free; procedure Start_Search ( Search : aliased in out Search_Type; Directory : String; Pattern : String; Filter : Filter_Type; Directory_Entry : out Directory_Entry_Access; Has_Next_Entry : out Boolean) is begin if Directory'Length = 0 then -- reject Raise_Exception (Name_Error'Identity); end if; declare C_Directory : C.char_array ( 0 .. Directory'Length * Zero_Terminated_Strings.Expanding); Handle : C.dirent.DIR_ptr; begin Zero_Terminated_Strings.To_C ( Directory, C_Directory (0)'Access); Handle := C.dirent.opendir (C_Directory (0)'Access); if Handle = null then Raise_Exception (Named_IO_Exception_Id (C.errno.errno)); end if; Search.Handle := Handle; end; Search.Filter := Filter; Search.Pattern := char_ptr_Conv.To_Pointer ( Standard_Allocators.Allocate ( Storage_Elements.Storage_Offset (Pattern'Length) * Zero_Terminated_Strings.Expanding + 1)); -- NUL Zero_Terminated_Strings.To_C (Pattern, Search.Pattern); Get_Next_Entry (Search, Directory_Entry, Has_Next_Entry); end Start_Search; procedure End_Search ( Search : aliased in out Search_Type; Raise_On_Error : Boolean) is Handle : constant C.dirent.DIR_ptr := Search.Handle; begin Search.Handle := null; Standard_Allocators.Free (char_ptr_Conv.To_Address (Search.Pattern)); Search.Pattern := null; if C.dirent.closedir (Handle) < 0 and then Raise_On_Error then Raise_Exception (IO_Exception_Id (C.errno.errno)); end if; end End_Search; procedure Get_Next_Entry ( Search : aliased in out Search_Type; Directory_Entry : out Directory_Entry_Access; Has_Next_Entry : out Boolean) is begin loop C.errno.error.all := 0; -- clear errno Directory_Entry := C.dirent.readdir (Search.Handle); declare errno : constant C.signed_int := C.errno.errno; begin if errno /= 0 then Raise_Exception (IO_Exception_Id (errno)); elsif Directory_Entry = null then Has_Next_Entry := False; -- end exit; end if; end; if Search.Filter (Kind (Directory_Entry)) and then C.fnmatch.fnmatch ( Search.Pattern, Directory_Entry.d_name (0)'Access, 0) = 0 and then ( Directory_Entry.d_name (0) /= '.' or else ( Directory_Entry.d_namlen > 1 and then ( Directory_Entry.d_name (1) /= '.' or else Directory_Entry.d_namlen > 2))) then Has_Next_Entry := True; exit; -- found end if; end loop; end Get_Next_Entry; procedure Get_Entry ( Directory : String; Name : String; Directory_Entry : aliased out Directory_Entry_Access; Additional : aliased in out Directory_Entry_Additional_Type) is Dummy_dirent : C.sys.dirent.struct_dirent; -- to use 'Position Name_Length : constant C.size_t := Name'Length; Record_Length : constant Storage_Elements.Storage_Count := Storage_Elements.Storage_Offset'Max ( C.sys.dirent.struct_dirent'Size / Standard'Storage_Unit, Dummy_dirent.d_name'Position + Storage_Elements.Storage_Offset (Name_Length + 1)); errno : C.signed_int; begin -- allocation Directory_Entry := dirent_ptr_Conv.To_Pointer ( Standard_Allocators.Allocate (Record_Length)); -- filling components -- Directory_Entry.d_seekoff := 0; -- missing in FreeBSD Directory_Entry.d_reclen := C.stdint.uint16_t (Record_Length); declare function To_namlen (X : C.size_t) return C.stdint.uint16_t; -- OSX function To_namlen (X : C.size_t) return C.stdint.uint16_t is begin return C.stdint.uint16_t (X); end To_namlen; function To_namlen (X : C.size_t) return C.stdint.uint8_t; -- FreeBSD function To_namlen (X : C.size_t) return C.stdint.uint8_t is begin return C.stdint.uint8_t (X); end To_namlen; pragma Warnings (Off, To_namlen); begin Directory_Entry.d_namlen := To_namlen (Name_Length); end; Zero_Terminated_Strings.To_C (Name, Directory_Entry.d_name (0)'Access); Get_Information (Directory, Directory_Entry, Additional.Information, errno => errno); if errno /= 0 then Raise_Exception (Named_IO_Exception_Id (errno)); end if; Directory_Entry.d_ino := Additional.Information.st_ino; Directory_Entry.d_type := C.stdint.uint8_t ( C.Shift_Right (Additional.Information.st_mode, 12)); Additional.Filled := True; end Get_Entry; function Simple_Name (Directory_Entry : not null Directory_Entry_Access) return String is begin return Zero_Terminated_Strings.Value ( Directory_Entry.d_name (0)'Access, C.size_t (Directory_Entry.d_namlen)); end Simple_Name; function Kind (Directory_Entry : not null Directory_Entry_Access) return File_Kind is begin -- DTTOIF return Kind ( C.Shift_Left (C.sys.types.mode_t (Directory_Entry.d_type), 12)); end Kind; function Size ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Additional : aliased in out Directory_Entry_Additional_Type) return Ada.Streams.Stream_Element_Count is begin if not Additional.Filled then Get_Information (Directory, Directory_Entry, Additional.Information); Additional.Filled := True; end if; return Ada.Streams.Stream_Element_Offset ( Additional.Information.st_size); end Size; function Modification_Time ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Additional : aliased in out Directory_Entry_Additional_Type) return Native_Calendar.Native_Time is begin if not Additional.Filled then Get_Information (Directory, Directory_Entry, Additional.Information); Additional.Filled := True; end if; return Additional.Information.st_mtim; end Modification_Time; procedure Get_Information ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Information : aliased out C.sys.stat.struct_stat) is errno : C.signed_int; begin Get_Information (Directory, Directory_Entry, Information, errno => errno); if errno /= 0 then Raise_Exception (IO_Exception_Id (errno)); end if; end Get_Information; end System.Native_Directories.Searching;
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. (gh+flacada@heisenbug.eu) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------------ -- FLAC/Ada -- -- Headers -- -- The meta data block. ------------------------------------------------------------------------------ with Ada.Streams.Stream_IO; with SPARK_Stream_IO; package FLAC.Headers.Meta_Data with Preelaborate => True, SPARK_Mode => On is -- METADATA_BLOCK_HEADER -- <1> Last-metadata-block flag: '1' if this block is the last metadata -- block before the audio blocks, '0' otherwise. -- <7> BLOCK_TYPE -- 0 : STREAMINFO -- 1 : PADDING -- 2 : APPLICATION -- 3 : SEEKTABLE -- 4 : VORBIS_COMMENT -- 5 : CUESHEET -- 6 : PICTURE -- 7-126 : reserved -- 127 : invalid, to avoid confusion with a frame sync code -- <24> Length (in bytes) of metadata to follow (does not include the size -- of the METADATA_BLOCK_HEADER) type T is record Last : Boolean; Block_Type : Types.Block_Type; Length : Types.Length_24; end record; Meta_Data_Length : constant := 32 / Ada.Streams.Stream_Element'Size; --------------------------------------------------------------------------- -- Read --------------------------------------------------------------------------- procedure Read (File : in Ada.Streams.Stream_IO.File_Type; Item : out T; Error : out Boolean) with Relaxed_Initialization => Item, Pre => SPARK_Stream_IO.Is_Open (File => File), Post => (if not Error then Item'Initialized), Depends => ((Error, Item) => File); end FLAC.Headers.Meta_Data;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2020, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision: 5682 $ $Date: 2017-01-11 00:55:53 +0300 (Wed, 11 Jan 2017) $ ------------------------------------------------------------------------------ -- Abstract_GL_Widget provides integration between implementation of OpenGL -- API and application. ------------------------------------------------------------------------------ with Web.HTML.Canvases; private with OpenGL.Contexts; with OpenGL.Functions; package Web.UI.Widgets.GL_Widgets is type Abstract_GL_Widget is abstract new Web.UI.Widgets.Abstract_Widget with private; function Functions (Self : in out Abstract_GL_Widget'Class) return access OpenGL.Functions.OpenGL_Functions'Class; -- Returns OpenGL functions to be used with OpenGL context of widget. procedure Update (Self : in out Abstract_GL_Widget); -- Requests redraw. not overriding procedure Initialize_GL (Self : in out Abstract_GL_Widget) is abstract; -- This dispatching subprogram is called once before the first call to -- Paint_GL. Reimplement it in a derived type. -- -- This subprogram should set up any required OpenGL resources and state. -- -- The framebuffer is not yet available at this stage, so avoid issuing -- draw calls from here. not overriding procedure Paint_GL (Self : in out Abstract_GL_Widget) is abstract; -- This dispatching subprogram is called whenever the widget needs to be -- painted. Reimplement it in a derived type. -- -- Current context is set to context of this widget. -- -- Before invoking this function, the context and the framebuffer are -- bound, and the viewport is set up by a call to glViewport. No other -- state is set and no clearing or drawing is performed by the framework. not overriding procedure Resize_GL (Self : in out Abstract_GL_Widget; Width : Integer; Height : Integer) is null; -- This dispatching subprogram is called whenever the widget has been -- resized. Reimplement it in a subclass. The new size is passed in Width -- and Height. not overriding procedure Context_Lost (Self : in out Abstract_GL_Widget) is null; not overriding procedure Context_Restored (Self : in out Abstract_GL_Widget) is null; overriding procedure Set_Disabled (Self : in out Abstract_GL_Widget; Disabled : Boolean := True) is null; package Constructors is procedure Initialize (Self : in out Abstract_GL_Widget'Class; Canvas : in out Web.HTML.Canvases.HTML_Canvas_Element'Class); end Constructors; private type Context_Lost_Dispatcher (Owner : not null access Abstract_GL_Widget'Class) is limited new Web.DOM.Event_Listeners.Event_Listener with null record; overriding procedure Handle_Event (Self : in out Context_Lost_Dispatcher; Event : in out Web.DOM.Events.Event'Class); type Context_Restored_Dispatcher (Owner : not null access Abstract_GL_Widget'Class) is limited new Web.DOM.Event_Listeners.Event_Listener with null record; overriding procedure Handle_Event (Self : in out Context_Restored_Dispatcher; Event : in out Web.DOM.Events.Event'Class); type Abstract_GL_Widget is abstract new Web.UI.Widgets.Abstract_Widget with record Canvas : Web.HTML.Canvases.HTML_Canvas_Element; Context : OpenGL.Contexts.OpenGL_Context_Access; Lost : aliased Context_Lost_Dispatcher (Abstract_GL_Widget'Unchecked_Access); Restored : aliased Context_Restored_Dispatcher (Abstract_GL_Widget'Unchecked_Access); Initialized : Boolean := False; Redraw_Needed : Boolean := True; -- Redraw should be done on next handling of animation frame. end record; end Web.UI.Widgets.GL_Widgets;
-- { dg-do compile } -- { dg-options "-O2 -gnatp -fdump-tree-optimized" } -- The raise statement must be optimized away by -- virtue of DECL_NONADDRESSABLE_P set on R.I. package body Aliasing1 is function F (P : Ptr) return Integer is begin R.I := 0; P.all := 1; if R.I /= 0 then raise Program_Error; end if; return 0; end; end Aliasing1; -- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } }
-- AOC 2020, Day 22 package Day is function combat(filename : in String) return Natural; function recursive_combat(filename : in String) return Natural; end Day;
-- -- Copyright (C) 2015-2016 secunet Security Networks AG -- -- This program 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. -- with HW.GFX.GMA.Registers; with HW.Debug; with GNAT.Source_Info; package body HW.GFX.GMA.PCH.HDMI is PCH_HDMI_ENABLE : constant := 1 * 2 ** 31; PCH_HDMI_COLOR_FORMAT_8BPC : constant := 0 * 2 ** 26; PCH_HDMI_COLOR_FORMAT_12BPC : constant := 3 * 2 ** 26; PCH_HDMI_COLOR_FORMAT_MASK : constant := 7 * 2 ** 26; PCH_HDMI_SDVO_ENCODING_SDVO : constant := 0 * 2 ** 10; PCH_HDMI_SDVO_ENCODING_HDMI : constant := 2 * 2 ** 10; PCH_HDMI_SDVO_ENCODING_MASK : constant := 3 * 2 ** 10; PCH_HDMI_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4; PCH_HDMI_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3; PCH_HDMI_PORT_DETECT : constant := 1 * 2 ** 2; PCH_HDMI_MASK : constant Word32 := PCH_TRANSCODER_SELECT_MASK or PCH_HDMI_ENABLE or PCH_HDMI_COLOR_FORMAT_MASK or PCH_HDMI_SDVO_ENCODING_MASK or PCH_HDMI_HSYNC_ACTIVE_HIGH or PCH_HDMI_VSYNC_ACTIVE_HIGH; type PCH_HDMI_Array is array (PCH_HDMI_Port) of Registers.Registers_Index; PCH_HDMI : constant PCH_HDMI_Array := PCH_HDMI_Array' (PCH_HDMI_B => Registers.PCH_HDMIB, PCH_HDMI_C => Registers.PCH_HDMIC, PCH_HDMI_D => Registers.PCH_HDMID); ---------------------------------------------------------------------------- procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) is Polarity : constant Word32 := (if Port_Cfg.Mode.H_Sync_Active_High then PCH_HDMI_HSYNC_ACTIVE_HIGH else 0) or (if Port_Cfg.Mode.V_Sync_Active_High then PCH_HDMI_VSYNC_ACTIVE_HIGH else 0); begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); -- registers are just sufficient for setup with DVI adaptor Registers.Unset_And_Set_Mask (Register => PCH_HDMI (Port_Cfg.PCH_Port), Mask_Unset => PCH_HDMI_MASK, Mask_Set => PCH_HDMI_ENABLE or PCH_TRANSCODER_SELECT (FDI_Port) or PCH_HDMI_SDVO_ENCODING_HDMI or Polarity); end On; ---------------------------------------------------------------------------- procedure Off (Port : PCH_HDMI_Port) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Unset_And_Set_Mask (Register => PCH_HDMI (Port), Mask_Unset => PCH_HDMI_MASK, Mask_Set => PCH_HDMI_HSYNC_ACTIVE_HIGH or PCH_HDMI_VSYNC_ACTIVE_HIGH); end Off; procedure All_Off is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); for Port in PCH_HDMI_Port loop Off (Port); end loop; end All_Off; end HW.GFX.GMA.PCH.HDMI;
----------------------------------------------------------------------- -- util-beans-basic -- Interface Definition with Getter and Setters -- Copyright (C) 2009, 2010, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Beans.Objects; -- == Bean Interface == -- An Ada Bean is an object which implements the `Util.Beans.Basic.Readonly_Bean` or the -- `Util.Beans.Basic.Bean` interface. By implementing these interface, the object provides -- a behavior that is close to the Java Beans: a getter and a setter operation are available. -- package Util.Beans.Basic is pragma Preelaborate; -- ------------------------------ -- Read-only Bean interface. -- ------------------------------ -- The ''Readonly_Bean'' interface allows to plug a complex -- runtime object to the expression resolver. This interface -- must be implemented by any tagged record that should be -- accessed as a variable for an expression. -- -- For example, if 'foo' is bound to an object implementing that -- interface, expressions like 'foo.name' will resolve to 'foo' -- and the 'Get_Value' method will be called with 'name'. -- type Readonly_Bean is limited interface; type Readonly_Bean_Access is access all Readonly_Bean'Class; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. function Get_Value (From : in Readonly_Bean; Name : in String) return Util.Beans.Objects.Object is abstract; -- ------------------------------ -- Bean interface. -- ------------------------------ -- The ''Bean'' interface allows to modify a property value. type Bean is limited interface and Readonly_Bean; -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. procedure Set_Value (From : in out Bean; Name : in String; Value : in Util.Beans.Objects.Object) is abstract; -- ------------------------------ -- List of objects -- ------------------------------ -- The <b>List_Bean</b> interface gives access to a list of objects. type List_Bean is limited interface and Readonly_Bean; type List_Bean_Access is access all List_Bean'Class; -- Get the number of elements in the list. function Get_Count (From : in List_Bean) return Natural is abstract; -- Set the current row index. Valid row indexes start at 1. procedure Set_Row_Index (From : in out List_Bean; Index : in Natural) is abstract; -- Get the element at the current row index. function Get_Row (From : in List_Bean) return Util.Beans.Objects.Object is abstract; -- ------------------------------ -- Arrays of objects -- ------------------------------ -- The <tt>Array_Bean</tt> interface gives access to an array of objects. -- Unlike the <tt>List_Bean</tt> interface, it does not maintain any current position. -- The drawback is that there is no current row concept and a position must be specified -- to return a given row. type Array_Bean is limited interface and Readonly_Bean; type Array_Bean_Access is access all Array_Bean'Class; -- Get the number of elements in the array. function Get_Count (From : in Array_Bean) return Natural is abstract; -- Get the element at the given position. function Get_Row (From : in Array_Bean; Position : in Natural) return Util.Beans.Objects.Object is abstract; end Util.Beans.Basic;
with Ada.Containers.Vectors; with Ada.Strings.Unbounded; package Command_Line is package SU renames Ada.Strings.Unbounded; package Input_File_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => SU.Unbounded_String, "=" => SU."="); function Parse_Command_Line (Input_Files : out Input_File_Vectors.Vector; Recurse_Projects : out Boolean; Directory_Prefix : out SU.Unbounded_String; Output_File : out SU.Unbounded_String) return Boolean; end Command_Line;
----------------------------------------------------------------------- -- asf-lifecycles -- Lifecycle -- Copyright (C) 2010, 2011, 2012, 2018, 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.Finalization; with ASF.Events.Phases; with ASF.Contexts.Faces; with Util.Concurrent.Arrays; with ASF.Applications.Views; -- = Request Processing Lifecycle = -- The request lifecycle is decomposed in two groups: an execute group handles the -- incoming request and a render group handles the production of the response. -- The execution group is decomposed in several phases with some of them being -- executed. After each phase, some decision is made to proceed, to render the -- response or finish the request when it is completed. The request lifecycle -- handles both initial requests (an HTTP GET) and postbacks (an HTTP POST). -- -- The `Restore View` phase is always executed to handle the request and it is -- responsible for building the components in the view. The XHTML file associated -- with the view is read or obtained from the facelet cache and the components -- described by the XHTML tags are created to form the component tree. -- -- The `Apply Request Values` phase is then handled to obtain the request parameters. -- -- The `Process Validators` phase executes the input validators on the component -- tree to validate the request parameters. If a parameter is invalid, some message -- can be posted and associated with the component that triggered it. -- -- [images/asf-lifecycle.png] -- -- The `Update Model Values` phase invokes the `Set_Value` procedure on every -- Ada bean for which an input parameter was submitted and was valid. The Ada bean -- may raise and exception and an error will be associated with the associated component. -- -- The `Invoke Application` phase executes the Ada bean actions that have been triggered -- by the `f:viewAction` for an initial requests or by the postback actions. -- The Ada bean method is invoked so that it gets the control of the request and -- it returns an outcome that serves for the request navigation. -- -- The `Render Response` phase is the final phase that walks the component tree -- and renders the HTML response. -- package ASF.Lifecycles is subtype Phase_Type is Events.Phases.Phase_Type range Events.Phases.RESTORE_VIEW .. Events.Phases.RENDER_RESPONSE; type Phase_Controller is abstract tagged limited private; type Phase_Controller_Access is access all Phase_Controller'Class; type Phase_Controller_Array is array (Phase_Type) of Phase_Controller_Access; -- Execute the phase. procedure Execute (Controller : in Phase_Controller; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is abstract; -- Initialize the phase controller. procedure Initialize (Controller : in out Phase_Controller; Views : ASF.Applications.Views.View_Handler_Access) is null; type Lifecycle is abstract new Ada.Finalization.Limited_Controlled with private; type Lifecycle_Access is access all Lifecycle'Class; -- Creates the phase controllers by invoking the <b>Set_Controller</b> -- procedure for each phase. This is called by <b>Initialize</b> to build -- the lifecycle handler. procedure Create_Phase_Controllers (Controller : in out Lifecycle) is abstract; -- Initialize the the lifecycle handler. procedure Initialize (Controller : in out Lifecycle; Views : ASF.Applications.Views.View_Handler_Access); -- Finalize the lifecycle handler, freeing the allocated storage. overriding procedure Finalize (Controller : in out Lifecycle); -- Set the controller to be used for the given phase. procedure Set_Controller (Controller : in out Lifecycle; Phase : in Phase_Type; Instance : in Phase_Controller_Access); -- Register a bundle and bind it to a facelet variable. procedure Execute (Controller : in Lifecycle; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- Render the response by executing the response phase. procedure Render (Controller : in Lifecycle; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- Add a phase listener in the lifecycle controller. procedure Add_Phase_Listener (Controller : in out Lifecycle; Listener : in ASF.Events.Phases.Phase_Listener_Access); -- Remove a phase listener that was registered in the lifecycle controller. procedure Remove_Phase_Listener (Controller : in out Lifecycle; Listener : in ASF.Events.Phases.Phase_Listener_Access); private type Phase_Controller is abstract tagged limited null record; use type ASF.Events.Phases.Phase_Listener_Access; -- Use the concurrent arrays package so that we can insert phase listeners while -- we also have the lifecycle manager which invokes listeners for the existing requests. package Listener_Vectors is new Util.Concurrent.Arrays (Element_Type => ASF.Events.Phases.Phase_Listener_Access); -- Execute the lifecycle controller associated with the phase defined in <b>Phase</b>. -- Before processing, setup the faces context to update the current phase, then invoke -- the <b>Before_Phase</b> actions of the phase listeners. After execution of the controller -- invoke the <b>After_Phase</b> actions of the phase listeners. -- If an exception is raised, catch it and save it in the faces context. procedure Execute (Controller : in Lifecycle; Context : in out ASF.Contexts.Faces.Faces_Context'Class; Listeners : in Listener_Vectors.Ref; Phase : in Phase_Type); type Lifecycle is abstract new Ada.Finalization.Limited_Controlled with record Controllers : Phase_Controller_Array; Listeners : Listener_Vectors.Vector; end record; end ASF.Lifecycles;
with Interfaces; use Interfaces; package Some_Package with SPARK_Mode is procedure bar; end Some_Package;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" private with GL.Low_Level; package GL.Objects.Shaders is pragma Preelaborate; type Shader_Type is (Fragment_Shader, Vertex_Shader, Geometry_Shader, Tess_Evaluation_Shader, Tess_Control_Shader); type Shader (Kind : Shader_Type) is new GL_Object with private; procedure Set_Source (Subject : Shader; Source : String); function Source (Subject : Shader) return String; procedure Compile (Subject : Shader); procedure Release_Shader_Compiler; function Compile_Status (Subject : Shader) return Boolean; function Info_Log (Subject : Shader) return String; -- low-level. creates a Shader object linking to the given OpenGL ID. -- doesn't take ownership of the ID and therefore doesn't automatically -- delete it when the last reference vanishes. function Create_From_Id (Id : UInt) return Shader; private type Shader (Kind : Shader_Type) is new GL_Object with null record; overriding procedure Internal_Create_Id (Object : Shader; Id : out UInt); overriding procedure Internal_Release_Id (Object : Shader; Id : UInt); for Shader_Type use (Fragment_Shader => 16#8B30#, Vertex_Shader => 16#8B31#, Geometry_Shader => 16#8DD9#, Tess_Evaluation_Shader => 16#8E87#, Tess_Control_Shader => 16#8E88#); for Shader_Type'Size use Low_Level.Enum'Size; end GL.Objects.Shaders;
-- The Village of Vampire by YT, このソースコードはNYSLです package body Vampire.Forms.Full is use type Villages.Village_State; function Create return Form_Type is begin return (null record); end Create; overriding function HTML_Version (Form : Form_Type) return Web.HTML.HTML_Version is begin return Web.HTML.XHTML; end HTML_Version; overriding function Template_Set (Form : Form_Type) return Template_Set_Type is begin return For_Full; end Template_Set; overriding function Parameters_To_Index_Page ( Form : Form_Type; User_Id : String; User_Password : String) return Web.Query_Strings is begin return Web.String_Maps.Empty_Map; end Parameters_To_Index_Page; overriding function Parameters_To_User_Page ( Form : Form_Type; User_Id : String; User_Password : String) return Web.Query_Strings is begin return Parameters : Web.Query_Strings do Web.Include (Parameters, "user", User_Id); end return; end Parameters_To_User_Page; overriding function Parameters_To_Village_Page ( Form : Form_Type; Village_Id : Villages.Village_Id; Day : Integer := -1; First : Tabula.Villages.Speech_Index'Base := -1; Last : Tabula.Villages.Speech_Index'Base := -1; Latest : Tabula.Villages.Speech_Positive_Count'Base := -1; User_Id : String; User_Password : String) return Web.Query_Strings is begin return Parameters : Web.Query_Strings do Web.Include (Parameters, "village", Village_Id); if Day >= 0 then Web.Include (Parameters, "day", Image (Day)); end if; if Day = 0 and then First = 0 then Web.Include (Parameters, "range", "all"); end if; end return; end Parameters_To_Village_Page; overriding procedure Write_In_HTML ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Form_Type; Item : in String; Pre : in Boolean := False) is begin Web.HTML.Write_In_HTML (Stream, Web.HTML.XHTML, Item, Pre); end Write_In_HTML; overriding procedure Write_In_Attribute ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Form_Type; Item : in String) is begin Web.HTML.Write_In_Attribute (Stream, Web.HTML.XHTML, Item); end Write_In_Attribute; overriding function Paging (Form : Form_Type) return Boolean is begin return False; end Paging; overriding function Speeches_Per_Page (Form : Form_Type) return Tabula.Villages.Speech_Positive_Count'Base is begin return 0; end Speeches_Per_Page; overriding function Get_User_Id ( Form : Form_Type; Query_Strings : Web.Query_Strings; Cookie : Web.Cookie) return String is begin return Web.Element (Cookie, "id"); end Get_User_Id; overriding function Get_User_Password ( Form : Form_Type; Query_Strings : Web.Query_Strings; Cookie : Web.Cookie) return String is begin return Web.Element (Cookie, "password"); end Get_User_Password; overriding procedure Set_User ( Form : in out Form_Type; Cookie : in out Web.Cookie; New_User_Id : in String; New_User_Password : in String) is begin Web.String_Maps.Include (Cookie, "id", New_User_Id); Web.String_Maps.Include (Cookie, "password", New_User_Password); end Set_User; overriding function Is_User_Page ( Form : Form_Type; Query_Strings : Web.Query_Strings; Cookie : Web.Cookie) return Boolean is User_Id : constant String := Form.Get_User_Id (Query_Strings, Cookie); begin if User_Id'Length = 0 then return False; else return Web.Element (Query_Strings, "user") = User_Id; end if; end Is_User_Page; overriding function Get_Village_Id ( Form : Form_Type; Query_Strings : Web.Query_Strings) return Villages.Village_Id is S : constant String := Web.Element (Query_Strings, "village"); begin if S'Length = Villages.Village_Id'Length then return S; else return Villages.Invalid_Village_Id; end if; end Get_Village_Id; overriding function Get_Day ( Form : Form_Type; Village : Villages.Village_Type'Class; Query_Strings : Web.Query_Strings) return Natural is S : constant String := Web.Element (Query_Strings, "day"); begin return Natural'Value (S); exception when Constraint_Error => declare State : Villages.Village_State; Today : Natural; begin Village.Get_State (State, Today); if State /= Villages.Closed then return Today; else return 0; end if; end; end Get_Day; overriding function Get_Range ( Form : Form_Type; Village : Villages.Village_Type'Class; Day : Natural; Now : Ada.Calendar.Time; Query_Strings : Web.Query_Strings) return Villages.Speech_Range_Type is Speech_Range : Villages.Speech_Range_Type; begin if String'(Web.Element (Query_Strings, "range"))'Length = 0 then Speech_Range := Village.Recent_Only_Speech_Range (Day, Now => Now); else Speech_Range := Village.Speech_Range (Day); end if; return ( First => Speech_Range.First, Last => Tabula.Villages.Speech_Index'Base'Max ( Speech_Range.First, Speech_Range.Last)); end Get_Range; overriding function Get_New_Village_Name ( Form : Form_Type; Inputs : Web.Query_Strings) return String is begin return Trim_Name (Web.Element (Inputs, "name")); end Get_New_Village_Name; overriding function Get_Text ( Form : Form_Type; Inputs : Web.Query_Strings) return String is begin return Trim_Text (Web.Element (Inputs, "text")); end Get_Text; end Vampire.Forms.Full;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- -- -- This package provides timeout events to yield. -- with Ada.Calendar; package Coroutines.Timeouts is procedure Initialize; -- Call this before use function Timeout (Value : Duration) return Event_Id; -- Wake the coroutine up after given timeout expired. function Timeout (Value : Ada.Calendar.Time) return Event_Id; -- Wake the coroutine up at given time. end Coroutines.Timeouts;
with openGL.Texture, openGL.GlyphImpl.texture; package openGL.Font.texture -- -- A texture font is a specialisation of the font class for handling texture mapped fonts. -- is type Item is new Font.item with private; type View is access all Item'Class; --------- -- Forge -- function to_Font_texture (fontFilePath : in String) return Font.texture.item; -- -- -- Open and read a font file. Sets Error flag. function new_Font_texture (fontFilePath : in String) return Font.texture.view; function to_Font_texture (pBufferBytes : in FontImpl.unsigned_char_Pointer; bufferSizeInBytes : in Natural) return Font.texture.item; -- -- Open and read a font from a buffer in memory. Sets Error flag. -- -- The buffer is owned by the client and is NOT copied by FTGL. The -- pointer must be valid while using FTGL. -- -- pBufferBytes: The in-memory buffer. -- bufferSizeInBytes: The length of the buffer in bytes. overriding procedure destruct (Self : in out Item); procedure free (Self : in out View); -------------- -- Attributes -- function gl_Texture (Self : in Item) return openGL.Texture.texture_Name; function Quad (Self : in Item; for_Character : in Character) return GlyphImpl.Texture.Quad_t; private type Item is new Font.item with null record; overriding function MakeGlyph (Self : access Item; Slot : in freetype_c.FT_GlyphSlot.item) return glyph.Container.Glyph_view; -- -- Construct a glyph of the correct type. -- -- Clients must override the function and return their specialised FTGlyph. -- Returns an FTGlyph or null on failure. -- -- Slot: A FreeType glyph slot. end openGL.Font.texture;
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Characters.Conversions; with Ada.Hierarchical_File_Names; with Ada.Strings.Functions.Maps; with Ada.Strings.Maps.Constants; with Ada.Strings.Maps.Naked; with Ada.Strings.Naked_Maps.General_Category; package body Vampire.Forms is use type Ada.Strings.Maps.Character_Set; use type Ada.Strings.Unbounded.Unbounded_String; function Self return String is begin -- "http://.../vampire/" -> "" -- "http://localhost/vampire.cgi" -> "vampire.cgi" return Ada.Hierarchical_File_Names.Unchecked_Simple_Name ( Web.Request_Path); end Self; function Parameters_To_Base_Page ( Form : Root_Form_Type'Class; Base_Page : Forms.Base_Page; Village_Id : Villages.Village_Id; User_Id : String; User_Password : String) return Web.Query_Strings is begin case Base_Page is when Index_Page => return Form.Parameters_To_Index_Page ( User_Id => User_Id, User_Password => User_Password); when User_Page => return Form.Parameters_To_User_Page ( User_Id => User_Id, User_Password => User_Password); when Forms.User_List_Page => raise Program_Error with "unimplemented"; when Forms.Village_Page => return Form.Parameters_To_Village_Page ( Village_Id => Village_Id, User_Id => User_Id, User_Password => User_Password); end case; end Parameters_To_Base_Page; procedure Write_Attribute_Name ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Name : in String) is begin String'Write (Stream, Name); Character'Write (Stream, '='); end Write_Attribute_Name; procedure Write_Attribute_Open ( Stream : not null access Ada.Streams.Root_Stream_Type'Class) is begin Character'Write (Stream, '"'); end Write_Attribute_Open; procedure Write_Attribute_Close ( Stream : not null access Ada.Streams.Root_Stream_Type'Class) renames Write_Attribute_Open; procedure Write_Link ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Root_Form_Type'Class; Current_Directory : in String; Resource : in String; Parameters : in Web.Query_Strings := Web.String_Maps.Empty_Map) is Relative : constant String := Ada.Hierarchical_File_Names.Relative_Name ( Name => Resource, From => Current_Directory); begin Write_Attribute_Open (Stream); if Parameters.Is_Empty then if Relative'Length = 0 or else Ada.Hierarchical_File_Names.Is_Current_Directory_Name (Relative) then Web.HTML.Write_In_Attribute (Stream, Form.HTML_Version, "./"); else Web.HTML.Write_In_Attribute (Stream, Form.HTML_Version, Relative); end if; else Web.HTML.Write_In_Attribute (Stream, Form.HTML_Version, Relative); Web.HTML.Write_Query_In_Attribute ( Stream, Form.HTML_Version, Parameters); -- Parameters should contain ASCII only end if; Write_Attribute_Close (Stream); end Write_Link; procedure Write_Link_To_Village_Page ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Root_Form_Type'Class; Current_Directory : in String; HTML_Directory : in String; Log : in Boolean; Village_Id : Tabula.Villages.Village_Id; Day : Integer := -1; First : Tabula.Villages.Speech_Index'Base := -1; Last : Tabula.Villages.Speech_Index'Base := -1; Latest : Tabula.Villages.Speech_Positive_Count'Base := -1; User_Id : in String; User_Password : in String) is begin if Log then Write_Link ( Stream, Form, Current_Directory => Current_Directory, Resource => Ada.Hierarchical_File_Names.Compose ( Directory => HTML_Directory, Relative_Name => Village_Id & "-" & Image (Integer'Max (0, Day)), Extension => "html")); else Write_Link ( Stream, Form, Current_Directory => Current_Directory, Resource => Self, Parameters => Form.Parameters_To_Village_Page ( Village_Id => Village_Id, Day => Day, First => First, Last => Last, Latest => Latest, User_Id => User_Id, User_Password => User_Password)); end if; end Write_Link_To_Village_Page; function Get_New_User_Id ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "id"); end Get_New_User_Id; function Get_New_User_Password ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "password"); end Get_New_User_Password; function Get_New_User_Confirmation_Password ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "password2"); end Get_New_User_Confirmation_Password; function Get_Base_Page ( Form : Root_Form_Type'Class; Query_Strings : Web.Query_Strings; Cookie : Web.Cookie) return Base_Page is begin if Form.Get_Village_Id (Query_Strings) /= Tabula.Villages.Invalid_Village_Id then return Village_Page; elsif Form.Is_User_Page (Query_Strings, Cookie) then return User_Page; elsif Form.Is_User_List_Page (Query_Strings) then return User_List_Page; else return Index_Page; end if; end Get_Base_Page; function Is_User_List_Page ( Form : Root_Form_Type'Class; Query_Strings : Web.Query_Strings) return Boolean is begin return Web.Element (Query_Strings, "users") = "all"; end Is_User_List_Page; function Get_Command ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "cmd"); end Get_Command; function Get_Group ( Form : Root_Form_Type; Inputs : Web.Query_Strings) return Integer is begin return Integer'Value (Web.Element (Inputs, "group")); end Get_Group; function Get_Joining ( Form : Root_Form_Type; Inputs : Web.Query_Strings) return Joining is begin return ( Work_Index => Integer'Value (Web.Element (Inputs, "work")), Name_Index => Natural'Value (Web.Element (Inputs, "name")), Request => +Web.Element (Inputs, "request")); end Get_Joining; function Get_Answered ( Form : Root_Form_Type; Inputs : Web.Query_Strings) return Mark is begin declare X : constant Integer := Integer'Value (Web.Element (Inputs, "x")); Y : constant Integer := Integer'Value (Web.Element (Inputs, "y")); Z : constant Integer := Integer'Value (Web.Element (Inputs, "z")); begin if X + Y = Z then return OK; else return NG; end if; end; exception when Constraint_Error => return Missing; end Get_Answered; function Get_Reedit_Kind ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "kind"); end Get_Reedit_Kind; function Get_Action ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "action"); end Get_Action; function Get_Target ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return Villages.Person_Index'Base is begin return Villages.Person_Index'Base'Value (Web.Element (Inputs, "target")); end Get_Target; function Get_Special ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return Boolean is begin return Web.HTML.Checkbox_Value (Web.Element (Inputs, "special")); end Get_Special; procedure Set_Rule ( Form : in Root_Form_Type'Class; Village : in out Tabula.Villages.Village_Type'Class; Inputs : in Web.Query_Strings) is procedure Process (Item : in Tabula.Villages.Root_Option_Item'Class) is begin Tabula.Villages.Change (Village, Item, Web.Element (Inputs, Item.Name)); end Process; begin Tabula.Villages.Iterate_Options (Village, Process'Access); end Set_Rule; -- implementation of private function Spacing_Set return Ada.Strings.Maps.Character_Set is function Space_Separator_Set is new Ada.Strings.Maps.Naked.To_Set ( Ada.Strings.Naked_Maps.General_Category.Space_Separator); begin return Space_Separator_Set or Ada.Strings.Maps.Constants.Control_Set; end Spacing_Set; function Trim_Name (S : String) return String is Set : Ada.Strings.Maps.Character_Set renames Spacing_Set; begin return Ada.Strings.Functions.Maps.Trim (S, Left => Set, Right => Set); end Trim_Name; function Trim_Text (S : String) return String is First : Positive; Last : Natural; begin declare Set : Ada.Strings.Maps.Character_Set renames Spacing_Set; begin Ada.Strings.Functions.Maps.Trim (S, Left => Set, Right => Set, First => First, Last => Last); end; while First > S'First loop declare I : Positive; C : Wide_Wide_Character; Is_Illegal_Sequence : Boolean; begin Ada.Characters.Conversions.Get_Reverse ( S (S'First .. First - 1), First => I, Value => C, Is_Illegal_Sequence => Is_Illegal_Sequence); exit when Is_Illegal_Sequence or else Ada.Strings.Maps.Overloaded_Is_In ( C, Ada.Strings.Maps.Constants.Control_Set); First := I; end; end loop; return S (First .. Last); end Trim_Text; end Vampire.Forms;
with Ada.Strings.Unbounded; package body Nestable_Lists is procedure Append (L : in out List; E : Element_Type) is begin if L = null then L := new Node (Kind => Data_Node); L.Data := E; else Append (L.Next, E); end if; end Append; procedure Append (L : in out List; N : List) is begin if L = null then L := new Node (Kind => List_Node); L.Sublist := N; else Append (L.Next, N); end if; end Append; function Flatten (L : List) return List is Result : List; Current : List := L; Temp : List; begin while Current /= null loop case Current.Kind is when Data_Node => Append (Result, Current.Data); when List_Node => Temp := Flatten (Current.Sublist); while Temp /= null loop Append (Result, Temp.Data); Temp := Temp.Next; end loop; end case; Current := Current.Next; end loop; return Result; end Flatten; function New_List (E : Element_Type) return List is begin return new Node'(Kind => Data_Node, Data => E, Next => null); end New_List; function New_List (N : List) return List is begin return new Node'(Kind => List_Node, Sublist => N, Next => null); end New_List; function To_String (L : List) return String is Current : List := L; Result : Ada.Strings.Unbounded.Unbounded_String; begin Ada.Strings.Unbounded.Append (Result, "["); while Current /= null loop case Current.Kind is when Data_Node => Ada.Strings.Unbounded.Append (Result, To_String (Current.Data)); when List_Node => Ada.Strings.Unbounded.Append (Result, To_String (Current.Sublist)); end case; if Current.Next /= null then Ada.Strings.Unbounded.Append (Result, ", "); end if; Current := Current.Next; end loop; Ada.Strings.Unbounded.Append (Result, "]"); return Ada.Strings.Unbounded.To_String (Result); end To_String; end Nestable_Lists;
------------------------------------------------------------------------------ -- -- -- JSON Parser/Constructor -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- * Ensi Martini (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. -- -- -- ------------------------------------------------------------------------------ --with AURA.JSON; with Ada.Streams; with Ada.Containers; with Ada.Strings.UTF_Encoding; with Ada.Strings.Wide_Wide_Bounded; package JSON is subtype UTF_8_String is Ada.Strings.UTF_Encoding.UTF_8_String; type JSON_Value_Kind is (JSON_Object, JSON_Array, JSON_String, JSON_Integer, JSON_Float, JSON_Boolean, JSON_Null); subtype JSON_Structure_Kind is JSON_Value_Kind range JSON_Object .. JSON_Array; -- JSON "primitive" types subtype JSON_String_Value is Wide_Wide_String; subtype JSON_Integer_Value is Integer; subtype JSON_Float_Value is Float; -------------------------------- -- Codec Limits Configuration -- -------------------------------- -- The following configuration limit record type is used to configure the -- bounded properties of Bounded_JSON_Codecs, but may also be used to -- explicitly configure limits for Unbounded_JSON_Codecs. -- -- Using Bounded_JSON_Codecs, or applying limits to Unbounded_JSON_Codecs -- provide excellent security (specifically DoS evasion) properties to -- externally sourced JSON streams. -- -- While these properties are obligatory for Bounded_JSON_Codecs, it is -- often suboptimal to use Bounded_JSON_Codecs in environments where memory -- is plentiful, but security is important. In these environments, the -- the bounded codec can impose unacceptable memory overhead when the -- the inbound JSON stream is expected to be extremely variable. -- -- Applying these limits to Unbounded_JSON_Codecs allows for the setting of -- appropriate limits without incurring a high baseline memory load that -- would be expected when applying a bounded codec to a highly dynamic -- object size. type Codec_Limits is record String_Limit: Positive; -- Configures a maximum length for JSON_String values -- (in Wide_Wide_Characters) Deserialized into the Codec. The default -- is unlimited. If a limit is set, any string that exceeds this limit -- will cause the parser state machine to halt. Invalid will then -- return True, and the condition will be expressed via Error_Message Entity_Limit: Positive; -- Configures the maximum number of values (primitive or structural) -- that may be Deserialized into the Codec. This value, multiplied -- by String_Limit, multiplied by the size of a Wide_Wide_Character -- gives a wost-case memory consumption estimate before the limit is -- triggered Depth_Limit: Positive; -- Configures the maximum depth of the Deserialized JSON tree. A depth -- of 1 would not allow for any objects or arrays in the root object. -- -- This limit is potentially extremely effective against attacks, -- since maximum depths are often known, or can be fixed, as a -- property of an application's design. -- -- If no known depth limit is applicable, this value can be set to -- equal Entity_Limit, which is then effectively "unlimited" end record; end JSON;
with freetype_C.FT_GlyphSlot; package openGL.GlyphImpl -- -- Implements an openGL glyph. -- is type Item is tagged private; type View is access all Item'Class; --------- -- Types -- subtype error_Kind is freetype_C.FT_Error; no_Error : constant error_Kind; --------- -- Forge -- procedure define (Self : in out Item; glyth_Slot : in freetype_c.FT_GlyphSlot.item); -- -- glyth_Slot: The Freetype glyph to be processed. -------------- -- Attributes -- function Advance (Self : in Item) return Real; -- The advance distance for this glyph. function BBox (Self : in Item) return Bounds; -- Return the bounding box for this glyph. function Error (Self : in Item) return error_Kind; -- Return the current error code. private type Item is tagged record Advance : Vector_3; bBox : Bounds; Err : error_Kind; end record; procedure destruct (Self : in out Item); no_Error : constant error_Kind := 0; end openGL.GlyphImpl;
pragma Ada_2012; with Ada.Strings.Fixed; with Ada.Strings.Maps; package body EU_Projects.Times.Time_Expressions.Parsing is ------------------------ -- Fill_With_Defaults -- ------------------------ procedure Fill_With_Defaults (Container : in out Symbol_Table) is begin Define_Function (Container => Container, Name => To_Id ("max"), N_Params => At_Least (1)); Define_Function (Container => Container, Name => To_Id ("min"), N_Params => At_Least (1)); Define_Function (Container => Container, Name => To_Id ("lt"), N_Params => Exactly (2)); Define_Function (Container => Container, Name => To_Id ("le"), N_Params => Exactly (2)); Define_Function (Container => Container, Name => To_Id ("gt"), N_Params => Exactly (2)); Define_Function (Container => Container, Name => To_Id ("ge"), N_Params => Exactly (2)); Define_Function (Container => Container, Name => To_Id ("eq"), N_Params => Exactly (2)); Define_Function (Container => Container, Name => To_Id ("ne"), N_Params => Exactly (2)); Define_Function (Container => Container, Name => To_Id ("if"), N_Params => Exactly (3)); end Fill_With_Defaults; --------------------- -- Define_Variable -- --------------------- procedure Define_Variable (Container : in out Symbol_Table; Name : Simple_Identifier) is begin Internal_Parsing.Define_Variable (Container => Container.T, Name => Name); end Define_Variable; --------------------- -- Define_Function -- --------------------- procedure Define_Function (Container : in out Symbol_Table; Name : Simple_Identifier; N_Params : Parameter_Count) is begin Internal_Parsing.Define_Function (Container => Container.T, Name => Name, N_Params => N_Params.C); end Define_Function; ----------------- -- Read_Scalar -- ----------------- procedure Read_Scalar (Input : in String; Success : out Boolean; Consumed : out Natural; Result : out Scalar_Type) is procedure Get_tbd (X : String; First : out Natural; Last : out Natural; Found : out Boolean) is use Ada.Strings.Fixed; Index : constant Natural := Index_Non_Blank (X); begin if (Index + 2 <= X'Last) and then To_Upper (X (Index .. Index + 2)) = "TBD" then First := Index; Last := Index + 2; Found := Standard.True; else First := 0; Last := 0; Found := False; end if; end Get_tbd; ------------- -- Get_Int -- ------------- procedure Get_Int (X : String; First : out Natural; Last : out Natural; Found : out Boolean) is use Ada.Strings.Fixed; use Ada.Strings.Maps; Index : constant Natural := Index_Non_Blank (X); Int_Chars : constant Character_Set := To_Set (Character_Range'('0', '9')); begin -- Ada.Text_Io.Put_Line ("Called [" & X & "]"); if Index = 0 or else not Is_In (X (Index), Int_Chars) then First := 0; Last := 0; Found := False; return; end if; Found := Standard.True; Find_Token (Source => X (Index .. X'Last), Set => Int_Chars, Test => Ada.Strings.Inside, First => First, Last => Last); -- Last should not be zero since we checked that X(Index) is a digit pragma Assert (Last /= 0); end Get_Int; First : Natural; Last : Natural; Found : Boolean; begin Get_Int (Input, First, Last, Found); if Found then Consumed := Last - Input'First + 1; Success := Standard.True; -- Without any specifier, the time is in months Result := Scalar_Type (Scalar (Integer'Value (Input (First .. Last)) * 4)); return; end if; Get_Tbd (Input, First, Last, Found); if Found then Consumed := Last - Input'First + 1; Success := Standard.True; Result := TBD; return; end if; Consumed := 0; Success := False; end Read_Scalar; end EU_Projects.Times.Time_Expressions.Parsing;
-- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 Lionel Draghi <lionel.draghi@free.fr> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- with Smk.IO; use Smk.IO; with Smk.Runfiles; with Smk.Runs.Strace_Analyzer; with Smk.Settings; use Smk.Settings; with Ada.Text_IO; separate (Smk.Runs) -- ----------------------------------------------------------------------------- procedure Analyze_Run (Assertions : out Condition_Lists.List) is Strace_Ouput : Ada.Text_IO.File_Type; use Smk.Runs.Strace_Analyzer; -- -------------------------------------------------------------------------- procedure Add (Cond : in Condition) is begin if not In_Ignore_List (+Cond.Name) and then (not Exists (+Cond.Name) or else Kind (+Cond.Name) /= Special_File) then IO.Put ("Add " & (+Cond.Name) & " " & Trigger_Image (Cond.Trigger), Level => IO.Debug); declare use Condition_Lists; C : constant Cursor := Assertions.Find (Cond); begin if C = No_Element then Assertions.Append (Cond); IO.Put (" : inserted", Level => IO.Debug); else if Override (Cond.Trigger, Element (C).Trigger) then IO.Put (" : trigger modified, was " & Trigger_Image (Element (C).Trigger), Level => IO.Debug); Assertions.Replace_Element (C, Cond); else IO.Put (" : already known", Level => IO.Debug); end if; end if; end; IO.New_Line (Level => IO.Debug); end if; end Add; begin -- -------------------------------------------------------------------------- Open (File => Strace_Ouput, Name => Strace_Outfile_Name, Mode => In_File); while not End_Of_File (Strace_Ouput) loop declare Line : constant String := Get_Line (Strace_Ouput); Operation : Operation_Type; begin Analyze_Line (Line, Operation); case Operation.Kind is when None => null; when Read => Add ((Name => Operation.Name, File => Operation.File, Trigger => File_Update)); when Write => Add ((Name => Operation.Name, File => Operation.File, Trigger => File_Absence)); when Delete => Add ((Name => Operation.Name, File => Operation.File, Trigger => File_Presence)); when Move => Add ((Name => Operation.Source_Name, File => Operation.Source, Trigger => File_Presence)); Add ((Name => Operation.Target_Name, File => Operation.Target, Trigger => File_Absence)); end case; end; end loop; -- Add directories informations: if a directory was open, it may be -- because the command is searching files in it. In this case, we will -- take a picture of the dir (that is store all files even non accessed) -- to be able to compare the picture during future run, and detect added -- files in that dir. -- -- declare -- Search : Search_Type; -- File : Directory_Entry_Type; -- New_Dirs : File_Lists.Map; -- -- begin -- for D in Dirs.Iterate loop -- Start_Search (Search, -- Directory => +File_Lists.Key (D), -- Pattern => "./*", -- Filter => (Ordinary_File => True, -- others => False)); -- IO.Put_Line ("scanning dir " & (+File_Lists.Key (D)), -- Level => IO.Debug); -- while More_Entries (Search) loop -- Get_Next_Entry (Search, File); -- -- if Settings.In_Ignore_List (Full_Name (File)) then -- IO.Put_Line ("Ignoring " & (Full_Name (File)), -- Level => IO.Debug); -- -- elsif Is_Dir (Full_Name (File)) then -- -- Dir processing -- if Dirs.Contains (+Full_Name (File)) then -- IO.Put_Line ("dir " & Simple_Name (File) & " already known"); -- else -- IO.Put_Line ("recording not accessed new dir " -- & Simple_Name (File)); -- New_Dirs.Add (+Full_Name (File), -- Create (+Full_Name (File), Unused)); -- -- end if; -- -- else -- -- File processing -- if Sources_And_Targets.Contains (+Full_Name (File)) then -- IO.Put_Line ("file " & Simple_Name (File) & " already known"); -- else -- IO.Put_Line ("recording not accessed new file " -- & Simple_Name (File)); -- Sources_And_Targets.Add -- (+Full_Name (File), -- Create (+Full_Name (File), Unused)); -- -- end if; -- -- end if; -- -- -- end loop; -- -- end loop; -- -- -- Merge unused files into dir list: -- for F in New_Dirs.Iterate loop -- Dirs.Add (Key => File_Lists.Key (F), -- New_Item => New_Dirs (F)); -- end loop; -- -- end; -- if Debug_Mode then Close (Strace_Ouput); else Delete (Strace_Ouput); end if; Name_Sorting.Sort (Assertions); end Analyze_Run;
----------------------------------------------------------------------- -- servlet-rest -- REST Support -- Copyright (C) 2016, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; with Util.Serialize.IO; with Servlet.Requests; with Servlet.Responses; with Servlet.Core; with EL.Contexts; with Security.Permissions; -- == REST == -- The <tt>Servlet.Rest</tt> package provides support to implement easily some RESTful API. package Servlet.Rest is subtype Request is Servlet.Requests.Request; subtype Response is Servlet.Responses.Response; subtype Output_Stream is Util.Serialize.IO.Output_Stream; -- The HTTP rest method. type Method_Type is (GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT, OPTIONS, PATCH); type Descriptor is abstract tagged limited private; type Descriptor_Access is access all Descriptor'Class; -- Get the permission index associated with the REST operation. function Get_Permission (Handler : in Descriptor) return Security.Permissions.Permission_Index; -- Dispatch the request to the API handler. procedure Dispatch (Handler : in Descriptor; Req : in out Servlet.Rest.Request'Class; Reply : in out Servlet.Rest.Response'Class; Stream : in out Output_Stream'Class) is abstract; type Operation_Access is access procedure (Req : in out Servlet.Rest.Request'Class; Reply : in out Servlet.Rest.Response'Class; Stream : in out Servlet.Rest.Output_Stream'Class); -- Register the API definition in the servlet registry. procedure Register (Registry : in out Servlet.Core.Servlet_Registry'Class; Definition : in Descriptor_Access); private type Descriptor is abstract tagged limited record Next : Descriptor_Access; Method : Method_Type; Pattern : Util.Strings.Name_Access; Permission : Security.Permissions.Permission_Index := 0; end record; -- Register the API descriptor in a list. procedure Register (List : in out Descriptor_Access; Item : in Descriptor_Access); -- Register the list of API descriptors for a given servlet and a root path. procedure Register (Registry : in out Servlet.Core.Servlet_Registry; Name : in String; URI : in String; ELContext : in EL.Contexts.ELContext'Class; List : in Descriptor_Access); type Static_Descriptor is new Descriptor with record Handler : Operation_Access; end record; -- Dispatch the request to the API handler. overriding procedure Dispatch (Handler : in Static_Descriptor; Req : in out Servlet.Rest.Request'Class; Reply : in out Servlet.Rest.Response'Class; Stream : in out Output_Stream'Class); end Servlet.Rest;
package body agar.gui.widget.icon is package cbinds is function allocate_from_bitmap (filename : cs.chars_ptr) return icon_access_t; pragma import (c, allocate_from_bitmap, "AG_IconFromBMP"); procedure set_text (icon : icon_access_t; str : cs.chars_ptr); pragma import (c, set_text, "AG_IconSetTextS"); procedure set_background_fill (icon : icon_access_t; fill : c.int; color : agar.core.types.uint32_t); pragma import (c, set_background_fill, "AG_IconSetBackgroundFill"); -- procedure set_padding -- (icon : icon_access_t; -- left : c.int; -- right : c.int; -- top : c.int; -- bottom : c.int); -- pragma import (c, set_padding, "AG_IconSetPadding"); end cbinds; function allocate_from_bitmap (filename : string) return icon_access_t is ca_name : aliased c.char_array := c.to_c (filename); begin return cbinds.allocate_from_bitmap (filename => cs.to_chars_ptr (ca_name'unchecked_access)); end allocate_from_bitmap; procedure set_text (icon : icon_access_t; text : string) is ca_text : aliased c.char_array := c.to_c (text); begin cbinds.set_text (icon => icon, str => cs.to_chars_ptr (ca_text'unchecked_access)); end set_text; -- procedure set_padding -- (icon : icon_access_t; -- left : natural; -- right : natural; -- top : natural; -- bottom : natural) is -- begin -- cbinds.set_padding -- (icon => icon, -- left => c.int (left), -- right => c.int (right), -- top => c.int (top), -- bottom => c.int (bottom)); -- end set_padding; procedure set_background_fill (icon : icon_access_t; fill : boolean; color : agar.core.types.uint32_t) is c_fill : c.int := 0; begin if fill then c_fill := 1; end if; cbinds.set_background_fill (icon => icon, fill => c_fill, color => color); end set_background_fill; end agar.gui.widget.icon;
----------------------------------------------------------------------- -- net-buffers -- Network buffers -- Copyright (C) 2016, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with System; with Net.Headers; -- === Network Buffers === -- The <b>Net.Buffers</b> package provides support for network buffer management. -- A network buffer can hold a single packet frame so that it is limited to 1500 bytes -- of payload with 14 or 16 bytes for the Ethernet header. The network buffers are -- allocated by the Ethernet driver during the initialization to setup the -- Ethernet receive queue. The allocation of network buffers for the transmission -- is under the responsibility of the application. -- -- Before receiving a packet, the application also has to allocate a network buffer. -- Upon successful reception of a packet by the <b>Receive</b> procedure, the allocated -- network buffer will be given to the Ethernet receive queue and the application -- will get back the received buffer. There is no memory copy. -- -- The package defines two important types: <b>Buffer_Type</b> and <b>Buffer_List</b>. -- These two types are limited types to forbid copies and force a strict design to -- applications. The <b>Buffer_Type</b> describes the packet frame and it provides -- various operations to access the buffer. The <b>Buffer_List</b> defines a list of buffers. -- -- The network buffers are kept within a single linked list managed by a protected object. -- Because interrupt handlers can release a buffer, that protected object has the priority -- <b>System.Max_Interrupt_Priority</b>. The protected operations are very basic and are -- in O(1) complexity so that their execution is bounded in time whatever the arguments. -- -- Before anything, the network buffers have to be allocated. The application can do this -- by reserving some memory region (using <b>STM32.SDRAM.Reserve</b>) and adding the region with -- the <b>Add_Region</b> procedure. The region must be a multiple of <b>NET_ALLOC_SIZE</b> -- constant. To allocate 32 buffers, you can do the following: -- -- NET_BUFFER_SIZE : constant Interfaces.Unsigned_32 := Net.Buffers.NET_ALLOC_SIZE * 32; -- ... -- Net.Buffers.Add_Region (STM32.SDRAM.Reserve (Amount => NET_BUFFER_SIZE), NET_BUFFER_SIZE); -- -- An application will allocate a buffer by using the <b>Allocate</b> operation and this is as -- easy as: -- -- Packet : Net.Buffers.Buffer_Type; -- ... -- Net.Buffers.Allocate (Packet); -- -- What happens if there is no available buffer? No exception is raised because the networks -- stack is intended to be used in embedded systems where exceptions are not available. -- You have to check if the allocation succeeded by using the <b>Is_Null</b> function: -- -- if Packet.Is_Null then -- null; -- Oops -- end if; -- -- === Serialization === -- Several serialization operations are provided to build or extract information from a packet. -- Before proceeding to the serialization, it is necessary to set the packet type. The packet -- type is necessary to reserve room for the protocol headers. To build a UDP packet, the -- <tt>UDP_PACKET</tt> type will be used: -- -- Packet.Set_Type (Net.Buffers.UDP_PACKET); -- -- Then, several <tt>Put</tt> operations are provided to serialize the data. By default -- integers are serialized in network byte order. The <tt>Put_Uint8</tt> serializes one byte, -- the <tt>Put_Uint16</tt> two bytes, the <tt>Put_Uint32</tt> four bytes. The <tt>Put_String</tt> -- operation will serialize a string. A NUL byte is optional and can be added when the -- <tt>With_Null</tt> optional parameter is set. The example below creates a DNS query packet: -- -- Packet.Put_Uint16 (1234); -- XID -- Packet.Put_Uint16 (16#0100#); -- Flags -- Packet.Put_Uint16 (1); -- # queries -- Packet.Put_Uint16 (0); -- Packet.Put_Uint32 (0); -- Packet.Put_Uint8 (16#3#); -- Query -- Packet.Put_String ("www.google.fr", With_Null => True); -- Packet.Put_Uint16 (16#1#); -- A record -- Packet.Put_Uint16 (16#1#); -- IN class -- -- After a packet is serialized, the length get be obtained by using the -- -- Len : Net.Uint16 := Packet.Get_Data_Length; package Net.Buffers is pragma Preelaborate; -- The size of a packet buffer for memory allocation. NET_ALLOC_SIZE : constant Uint32; -- The maximum available size of the packet buffer for the application. -- We always have NET_BUF_SIZE < NET_ALLOC_SIZE. NET_BUF_SIZE : constant Uint32; -- The packet type identifies the content of the packet for the serialization/deserialization. type Packet_Type is (RAW_PACKET, ETHER_PACKET, ARP_PACKET, IP_PACKET, UDP_PACKET, ICMP_PACKET, DHCP_PACKET); type Data_Type is array (Net.Uint16 range 0 .. 1500 + 31) of aliased Uint8 with Alignment => 32; type Buffer_Type is tagged limited private; -- Returns true if the buffer is null (allocation failed). function Is_Null (Buf : in Buffer_Type) return Boolean; -- Allocate a buffer from the pool. No exception is raised if there is no available buffer. -- The <tt>Is_Null</tt> operation must be used to check the buffer allocation. procedure Allocate (Buf : out Buffer_Type); -- Release the buffer back to the pool. procedure Release (Buf : in out Buffer_Type) with Post => Buf.Is_Null; -- Transfer the ownership of the buffer from <tt>From</tt> to <tt>To</tt>. -- If the destination has a buffer, it is first released. procedure Transfer (To : in out Buffer_Type; From : in out Buffer_Type) with Pre => not From.Is_Null, Post => From.Is_Null and not To.Is_Null; -- Switch the ownership of the two buffers. The typical usage is on the Ethernet receive -- ring to peek a received packet and install a new buffer on the ring so that there is -- always a buffer on the ring. procedure Switch (To : in out Buffer_Type; From : in out Buffer_Type) with Pre => not From.Is_Null and not To.Is_Null, Post => not From.Is_Null and not To.Is_Null; -- function Get_Data_Address (Buf : in Buffer_Type) return System.Address; function Get_Data_Size (Buf : in Buffer_Type; Kind : in Packet_Type) return Uint16; procedure Set_Data_Size (Buf : in out Buffer_Type; Size : in Uint16); function Get_Length (Buf : in Buffer_Type) return Uint16; procedure Set_Length (Buf : in out Buffer_Type; Size : in Uint16); -- Set the packet type. procedure Set_Type (Buf : in out Buffer_Type; Kind : in Packet_Type); -- Add a byte to the buffer data, moving the buffer write position. procedure Put_Uint8 (Buf : in out Buffer_Type; Value : in Net.Uint8) with Pre => not Buf.Is_Null; -- Add a 16-bit value in network byte order to the buffer data, -- moving the buffer write position. procedure Put_Uint16 (Buf : in out Buffer_Type; Value : in Net.Uint16) with Pre => not Buf.Is_Null; -- Add a 32-bit value in network byte order to the buffer data, -- moving the buffer write position. procedure Put_Uint32 (Buf : in out Buffer_Type; Value : in Net.Uint32) with Pre => not Buf.Is_Null; -- Add a string to the buffer data, moving the buffer write position. -- When <tt>With_Null</tt> is set, a NUL byte is added after the string. procedure Put_String (Buf : in out Buffer_Type; Value : in String; With_Null : in Boolean := False) with Pre => not Buf.Is_Null; -- Add an IP address to the buffer data, moving the buffer write position. procedure Put_Ip (Buf : in out Buffer_Type; Value : in Ip_Addr) with Pre => not Buf.Is_Null; -- Get a byte from the buffer, moving the buffer read position. function Get_Uint8 (Buf : in out Buffer_Type) return Net.Uint8 with Pre => not Buf.Is_Null; -- Get a 16-bit value in network byte order from the buffer, moving the buffer read position. function Get_Uint16 (Buf : in out Buffer_Type) return Net.Uint16 with Pre => not Buf.Is_Null; -- Get a 32-bit value in network byte order from the buffer, moving the buffer read position. function Get_Uint32 (Buf : in out Buffer_Type) return Net.Uint32 with Pre => not Buf.Is_Null; -- Get an IPv4 value from the buffer, moving the buffer read position. function Get_Ip (Buf : in out Buffer_Type) return Net.Ip_Addr with Pre => not Buf.Is_Null; -- Get a string whose length is specified by the target value. procedure Get_String (Buf : in out Buffer_Type; Into : out String) with Pre => not Buf.Is_Null; -- Skip a number of bytes in the buffer, moving the buffer position <tt>Size<tt> bytes ahead. procedure Skip (Buf : in out Buffer_Type; Size : in Net.Uint16) with Pre => not Buf.Is_Null; -- Get the number of bytes still available when reading the packet. function Available (Buf : in Buffer_Type) return Net.Uint16 with Pre => not Buf.Is_Null; -- Get access to the Ethernet header. function Ethernet (Buf : in Buffer_Type) return Net.Headers.Ether_Header_Access with Pre => not Buf.Is_Null; -- Get access to the ARP packet. function Arp (Buf : in Buffer_Type) return Net.Headers.Arp_Packet_Access with Pre => not Buf.Is_Null; -- Get access to the IPv4 header. function IP (Buf : in Buffer_Type) return Net.Headers.IP_Header_Access with Pre => not Buf.Is_Null; -- Get access to the UDP header. function UDP (Buf : in Buffer_Type) return Net.Headers.UDP_Header_Access with Pre => not Buf.Is_Null; -- Get access to the TCP header. function TCP (Buf : in Buffer_Type) return Net.Headers.TCP_Header_Access with Pre => not Buf.Is_Null; -- Get access to the IGMP header. function IGMP (Buf : in Buffer_Type) return Net.Headers.IGMP_Header_Access with Pre => not Buf.Is_Null; -- Get access to the ICMP header. function ICMP (Buf : in Buffer_Type) return Net.Headers.ICMP_Header_Access with Pre => not Buf.Is_Null; -- Get access to the DHCP header. function DHCP (Buf : in Buffer_Type) return Net.Headers.DHCP_Header_Access with Pre => not Buf.Is_Null; -- The <tt>Buffer_List</tt> holds a set of network buffers. type Buffer_List is limited private; -- Returns True if the list is empty. function Is_Empty (List : in Buffer_List) return Boolean; -- Insert the buffer to the list. procedure Insert (Into : in out Buffer_List; Buf : in out Buffer_Type) with Pre => not Buf.Is_Null, Post => Buf.Is_Null and not Is_Empty (Into); -- Release all the buffers held by the list. procedure Release (List : in out Buffer_List); -- Allocate <tt>Count</tt> buffers and add them to the list. -- There is no guarantee that the required number of buffers will be allocated. procedure Allocate (List : in out Buffer_List; Count : in Natural); -- Peek a buffer from the list. procedure Peek (From : in out Buffer_List; Buf : in out Buffer_Type); -- Transfer the list of buffers held by <tt>From</tt> at end of the list held -- by <tt>To</tt>. After the transfer, the <tt>From</tt> list is empty. -- The complexity is in O(1). procedure Transfer (To : in out Buffer_List; From : in out Buffer_List) with Post => Is_Empty (From); use type System.Address; -- Add a memory region to the buffer pool. procedure Add_Region (Addr : in System.Address; Size : in Uint32) with Pre => Size mod NET_ALLOC_SIZE = 0 and Size > 0 and Addr /= System.Null_Address; private type Packet_Buffer; type Packet_Buffer_Access is access all Packet_Buffer; type Packet_Buffer is limited record Next : Packet_Buffer_Access; Size : Uint16; Data : aliased Data_Type; end record; type Buffer_Type is tagged limited record Kind : Packet_Type := RAW_PACKET; Size : Uint16 := 0; Pos : Uint16 := 0; Packet : Packet_Buffer_Access; end record; type Buffer_List is limited record Head : Packet_Buffer_Access := null; Tail : Packet_Buffer_Access := null; end record; NET_ALLOC_SIZE : constant Uint32 := 4 + (Packet_Buffer'Size / 8); NET_BUF_SIZE : constant Uint32 := Data_Type'Size / 8; end Net.Buffers;
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro> -- -- 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 DNSCatcher.DNS.Processor.Packet; use DNSCatcher.DNS.Processor.Packet; with DNSCatcher.DNS.Processor.RData.A_Parser; use DNSCatcher.DNS.Processor.RData.A_Parser; with DNSCatcher.DNS.Processor.RData.SOA_Parser; use DNSCatcher.DNS.Processor.RData.SOA_Parser; with DNSCatcher.DNS.Processor.RData.OPT_Parser; use DNSCatcher.DNS.Processor.RData.OPT_Parser; with DNSCatcher.DNS.Processor.RData.Domain_Name_Response_Parser; use DNSCatcher.DNS.Processor.RData.Domain_Name_Response_Parser; with DNSCatcher.DNS.Processor.RData.Unknown_Parser; use DNSCatcher.DNS.Processor.RData.Unknown_Parser; package body DNSCatcher.DNS.Processor.RData is function To_Parsed_RData (DNS_Header : DNS_Packet_Header; Parsed_RR : Parsed_DNS_Resource_Record) return Parsed_RData_Access is Working_Record : Parsed_RData_Access; begin case Parsed_RR.RType is when A => Working_Record := new Parsed_A_RData; when SOA => Working_Record := new Parsed_SOA_RData; when OPT => Working_Record := new Parsed_OPT_RData; -- Handle all DNS responses which are just a name when CNAME => Working_Record := new Parsed_DNR_RData; when PTR => Working_Record := new Parsed_DNR_RData; when NS => Working_Record := new Parsed_DNR_RData; when others => Working_Record := new Parsed_Unknown_RData; end case; Working_Record.RName := Parsed_RR.RName; Working_Record.RType := Parsed_RR.RType; Working_Record.TTL := Parsed_RR.TTL; Working_Record.From_Parsed_RR (DNS_Header, Parsed_RR); return Working_Record; end To_Parsed_RData; end DNSCatcher.DNS.Processor.RData;
-- Advanced Resource Embedder 1.2.0 with Interfaces; use Interfaces; package body Concat is function Hash (S : String) return Natural; P : constant array (0 .. 0) of Natural := (0 .. 0 => 1); T1 : constant array (0 .. 0) of Unsigned_8 := (0 .. 0 => 0); T2 : constant array (0 .. 0) of Unsigned_8 := (0 .. 0 => 1); G : constant array (0 .. 4) of Unsigned_8 := (0, 1, 0, 0, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 5; F2 := (F2 + Natural (T2 (K)) * J) mod 5; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 2; end Hash; C_0 : aliased constant Ada.Streams.Stream_Element_Array := (98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125, 98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125, 10, 112, 114, 101, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 52, 97, 52, 97, 52, 97, 59, 32, 32, 10, 125, 10, 98, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 48, 97, 48, 97, 48, 97, 59, 32, 32, 10, 125, 10, 100, 105, 118, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 48, 50, 48, 50, 48, 59, 32, 32, 10, 125, 10, 98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125, 10, 112, 114, 101, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 52, 97, 52, 97, 52, 97, 59, 32, 32, 10, 125, 10, 98, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 48, 97, 48, 97, 48, 97, 59, 32, 32, 10, 125, 10, 100, 105, 118, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 48, 50, 48, 50, 48, 59, 32, 32, 10, 125, 10, 98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125); C_1 : aliased constant Ada.Streams.Stream_Element_Array := (118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10, 118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10, 118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10, 118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10); type Name_Access is access constant String; type Name_Array is array (Natural range <>) of Name_Access; K_0 : aliased constant String := "css/css/main.css"; K_1 : aliased constant String := "js/js/main.js"; Names : constant Name_Array := ( K_0'Access, K_1'Access); type Content_List_Array is array (Natural range <>) of Content_Access; Contents : constant Content_List_Array := ( C_0'Access, C_1'Access); function Get_Content (Name : String) return Content_Access is H : constant Natural := Hash (Name); begin return (if Names (H).all = Name then Contents (H) else null); end Get_Content; end Concat;
-- BinToAsc_Suite -- Unit tests for BinToAsc -- Copyright (c) 2015, James Humphry - see LICENSE file for details with Ada.Strings, Ada.Strings.Bounded; with AUnit.Test_Suites; package BinToAsc_Suite is package Test_Vector_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length(Max => 16); use all type Test_Vector_Strings.Bounded_String; function TBS (Source : in String; Drop : in Ada.Strings.Truncation := Ada.Strings.Error) return Test_Vector_Strings.Bounded_String renames Test_Vector_Strings.To_Bounded_String; subtype Test_Vector_String is Test_Vector_Strings.Bounded_String; type Test_Vector is record Unencoded : Test_Vector_String; Encoded : Test_Vector_String; end record; type Test_Vector_Array is array (Natural range <>) of Test_Vector; function Suite return AUnit.Test_Suites.Access_Test_Suite; end BinToAsc_Suite;
with Ada.Assertions; use Ada.Assertions; with Ada.Text_IO; use Ada.Text_IO; package body Memory.Dup is function Create_Dup return Dup_Pointer is begin return new Dup_Type; end Create_Dup; function Clone(mem : Dup_Type) return Memory_Pointer is result : constant Dup_Pointer := new Dup_Type'(mem); begin return Memory_Pointer(result); end Clone; procedure Add_Memory(mem : in out Dup_Type; other : access Memory_Type'Class) is begin mem.memories.Append(Memory_Pointer(other)); end Add_Memory; procedure Update_Time(mem : in out Dup_Type) is max_time : Time_Type := 0; begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop declare t : constant Time_Type := mem.memories.Element(i).time; begin max_time := max_time + t; end; end loop; mem.time := max_time; end Update_Time; procedure Reset(mem : in out Dup_Type; context : in Natural) is begin Reset(Memory_Type(mem), context); for i in mem.memories.First_Index .. mem.memories.Last_Index loop Reset(mem.memories.Element(i).all, context); end loop; end Reset; procedure Read(mem : in out Dup_Type; address : in Address_Type; size : in Positive) is begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop Read(mem.memories.Element(i).all, address, size); end loop; Update_Time(mem); end Read; procedure Write(mem : in out Dup_Type; address : in Address_Type; size : in Positive) is begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop Write(mem.memories.Element(i).all, address, size); end loop; Update_Time(mem); end Write; procedure Idle(mem : in out Dup_Type; cycles : in Time_Type) is begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop Idle(mem.memories.Element(i).all, cycles); end loop; Update_Time(mem); end Idle; procedure Show_Stats(mem : in out Dup_Type) is begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop declare other : constant Memory_Pointer := mem.memories.Element(i); begin Put(Integer'Image(i) & ": "); Show_Stats(other.all); end; end loop; end Show_Stats; function To_String(mem : Dup_Type) return Unbounded_String is result : Unbounded_String; begin Append(result, "(dup "); for i in mem.memories.First_Index .. mem.memories.Last_Index loop declare other : constant Memory_Pointer := mem.memories.Element(i); begin Append(result, To_String(other.all)); end; end loop; Append(result, ")"); return result; end To_String; function Get_Cost(mem : Dup_Type) return Cost_Type is result : Cost_Type := 0; begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop result := result + Get_Cost(mem.memories.Element(i).all); end loop; return result; end Get_Cost; function Get_Writes(mem : Dup_Type) return Long_Integer is result : Long_Integer := 0; begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop result := result + Get_Writes(mem.memories.Element(i).all); end loop; return result; end Get_Writes; function Get_Word_Size(mem : Dup_Type) return Positive is temp : Positive; result : Positive := 1; begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop temp := Get_Word_Size(mem.memories.Element(i).all); result := Positive'Max(result, temp); end loop; return result; end Get_Word_Size; function Get_Ports(mem : Dup_Type) return Port_Vector_Type is result : Port_Vector_Type; begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop declare ptr : constant Memory_Pointer := mem.memories.Element(i); pvec : constant Port_Vector_Type := Get_Ports(ptr.all); begin result.Append(pvec); end; end loop; return result; end Get_Ports; procedure Generate(mem : in Dup_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is begin Assert(False, "Memory.Dup.Generate not implemented"); end Generate; procedure Adjust(mem : in out Dup_Type) is ptr : Memory_Pointer; begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop ptr := Clone(mem.memories.Element(i).all); mem.memories.Replace_Element(i, ptr); end loop; end; procedure Finalize(mem : in out Dup_Type) is begin for i in mem.memories.First_Index .. mem.memories.Last_Index loop declare ptr : Memory_Pointer := mem.memories.Element(i); begin Destroy(ptr); end; end loop; end Finalize; end Memory.Dup;
-- -- Copyright (C) 2016 secunet Security Networks AG -- -- This program 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. -- with HW.Sub_Regs; with HW.MMIO_Range; use type HW.Word64; generic with package Range_P is new MMIO_Range (<>); Byte_Offset_O : Natural := 0; with package Subs_P is new Sub_Regs (<>); Regs : Subs_P.Array_T; package HW.MMIO_Regs is Byte_Offset : Natural := Byte_Offset_O; ---------------------------------------------------------------------------- procedure Read (Value : out Word8; Idx : Subs_P.Index_T) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word8'Size; procedure Read (Value : out Word16; Idx : Subs_P.Index_T) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word16'Size; procedure Read (Value : out Word32; Idx : Subs_P.Index_T) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word32'Size; procedure Read (Value : out Word64; Idx : Subs_P.Index_T) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word64'Size; ---------------------------------------------------------------------------- procedure Write (Idx : Subs_P.Index_T; Value : Word8) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); procedure Write (Idx : Subs_P.Index_T; Value : Word16) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); procedure Write (Idx : Subs_P.Index_T; Value : Word32) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); procedure Write (Idx : Subs_P.Index_T; Value : Word64) with Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and ((Byte_Offset + Regs (Idx).Byte_Offset) / (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and Range_P.Element_T'Size <= Word64'Size and Regs (Idx).MSB < Range_P.Element_T'Size and Regs (Idx).MSB >= Regs (Idx).LSB and Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); end HW.MMIO_Regs;
pragma License (Unrestricted); -- implementation unit required by compiler with Ada.Calendar; function System.Tasking.Async_Delays.Enqueue_Calendar ( T : Ada.Calendar.Time; D : not null access Delay_Block) return Boolean;
with Ada.Finalization; package Object is type Object is new Ada.Finalization.Controlled with private; function New_Object( X : in Integer ) return Object; procedure Put( O : Object ); private type Object is new Ada.Finalization.Controlled with record X : Integer := 0; end record;
------------------------------------------------------------------------------- -- Copyright 2021, The Trendy Terminal Developers (see AUTHORS file) -- 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 Ada.Text_IO; with Trendy_Terminal.Maps; with Trendy_Terminal.Platform; package body Trendy_Terminal.VT100 is use Trendy_Terminal.Maps; procedure Cursor_Left is begin Platform.Put (CSI & "1D"); end Cursor_Left; procedure Cursor_Right is begin Platform.Put (CSI & "1C"); end Cursor_Right; procedure Cursor_Down is begin Platform.Put (CSI & "B"); end Cursor_Down; procedure Cursor_Up is begin Platform.Put (CSI & "A"); end Cursor_Up; procedure Hide_Cursor is begin Platform.Put (CSI & "?25l"); end Hide_Cursor; procedure Show_Cursor is begin Platform.Put (CSI & "?25h"); end Show_Cursor; procedure Scroll_Down is begin Platform.Put (CSI & "T"); end Scroll_Down; procedure Scroll_Up is begin Platform.Put (CSI & "S"); end Scroll_Up; procedure Cursor_Next_Line is begin Platform.Put (CSI & "E"); end Cursor_Next_Line; procedure Erase is begin Platform.Put (CSI & 'X'); end Erase; procedure Beginning_Of_Line is begin Platform.Put (CSI & "1G"); end Beginning_Of_Line; procedure Clear_Line is begin Platform.Put (CSI & 'K'); end Clear_Line; procedure Report_Cursor_Position is begin Platform.Put (CSI & "6n"); end Report_Cursor_Position; procedure Set_Cursor_Position (C : Cursor_Position) is use Ada.Strings; use Ada.Strings.Fixed; begin Platform.Put (CSI & Trim (C.Row'Image, Left) & ";" & Trim (C.Col'Image, Left) & "H"); end Set_Cursor_Position; function Get_Cursor_Position return VT100.Cursor_Position is begin loop VT100.Report_Cursor_Position; declare Result : constant String := Platform.Get_Input; Semicolon_Index : constant Natural := Ada.Strings.Fixed.Index(Result, ";", 1); Row : Integer := 1; Col : Integer := 1; begin -- The cursor position is reported as -- ESC [ ROW ; COL R -- May throw on bad parse. Row := Integer'Value(Result(3 .. Semicolon_Index - 1)); Col := Integer'Value(Result(Semicolon_Index + 1 .. Result'Length - 1)); return VT100.Cursor_Position'(Row => Row, Col => Col); exception -- Bad parse due to existing input on the line. when Constraint_Error => null; end; end loop; end Get_Cursor_Position; end Trendy_Terminal.VT100;
------------------------------------------------------------------------------- -- Copyright 2021, The Septum Developers (see AUTHORS file) -- 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 SP.Strings; -- Septum data is stored locally in the Next_Dir working directory on load or in the home directory of the user -- running the command. This allows users to maintain general configuration in their home directory based -- on the settings they want to work with, and then have per-project settings that they can use. -- -- Septum configuration setup. -- Containing_Directory/ -- .septum/ Directory to contain all Septum related data. -- .config Commands to run on startup. package SP.Config is use SP.Strings; Config_Dir_Name : constant String := ".septum"; Config_File_Name : constant String := "config"; -- A list of all possible locations which might have a configuration which -- can be read on program startup. function Config_Locations return String_Vectors.Vector; -- Creates a configuration in the given directory. procedure Create_Local_Config; end SP.Config;
with Ada.Containers.Vectors; use Ada.Containers; with MathUtils; package DataBatch is pragma Assertion_Policy (Pre => Check, Post => Check, Type_Invariant => Check); package VecPkg is new Ada.Containers.Vectors(Index_Type => Positive, Element_Type => MathUtils.Vector, "=" => MathUtils.Float_Vec."="); type Batch is tagged limited record data: VecPkg.Vector; end record; function size(b: in Batch) return Natural; procedure reserve(b: in out Batch; count: Positive); procedure randomize(b: in out Batch); procedure append(b: in out Batch; vec: MathUtils.Vector); function contains(b: in Batch; vec: in MathUtils.Vector) return Boolean; end DataBatch;
-- { dg-do run } with Ada.Streams; use Ada.Streams; procedure Array_Bounds_Test is One : constant Stream_Element := 1; Two : constant Stream_Element := 2; Sample : constant Stream_Element_Array := (0 => One) & Two; begin if Sample'First /= 0 then raise Program_Error; end if; if Sample'Last /= 1 then raise Program_Error; end if; end Array_Bounds_Test;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ada.unchecked_conversion; with m4.mpu; use m4.mpu; with ewok.mpu.handler; with ewok.layout; with ewok.debug; with soc.layout; with applications; -- generated package body ewok.mpu with spark_mode => on is procedure init (success : out boolean) with spark_mode => off -- handler is not SPARK compatible is -- Layout mapping validation of generated constants pragma assert (applications.txt_kern_size + applications.txt_kern_region_base <= applications.txt_user_region_base); function get_region_size (size : t_region_size) return unsigned_32 is (2**(natural (size) + 1)); begin -- -- Initializing the MPU -- -- Testing if there's an MPU m4.mpu.is_mpu_available (success); if not success then pragma DEBUG (debug.log (debug.ERROR, "No MPU!")); return; end if; -- Register memory fault handler -- Note: unproved because SPARK doesn't allow "'address" attribute ewok.mpu.handler.init; -- not PARK compatible -- Disable MPU m4.mpu.disable; -- Enable privileged software access (PRIVDEFENA) to default memory map -- and enable the memory fault exception. When ENABLE and PRIVDEFENA are -- both set to 1, privileged code can freely access the default memory -- map. Any access by unprivileged software that does not address an -- enabled memory region causes a memory management fault. m4.mpu.init; -- -- Configuring MPU regions -- -- Region: kernel code if get_region_size (REGION_SIZE_64KB) /= ewok.layout.FW1_KERN_SIZE then pragma DEBUG (debug.log (debug.ERROR, "MPU: invalid 'KERNEL CODE' size")); return; end if; set_region (region_number => KERN_CODE_REGION, addr => applications.txt_kern_region_base, size => applications.txt_kern_region_size, region_type => REGION_TYPE_KERN_CODE, subregion_mask => 0); -- Region: devices that may be accessed by the kernel set_region (region_number => KERN_DEVICES_REGION, addr => soc.layout.PERIPH_BASE, size => REGION_SIZE_512MB, region_type => REGION_TYPE_KERN_DEVICES, subregion_mask => 0); -- Region: kernel data + stack if get_region_size (REGION_SIZE_64KB) /= ewok.layout.KERN_DATA_SIZE then pragma DEBUG (debug.log (debug.ERROR, "MPU: invalid 'KERNEL DATA' size")); return; end if; set_region (region_number => KERN_DATA_REGION, addr => ewok.layout.KERN_DATA_BASE, size => REGION_SIZE_64KB, region_type => REGION_TYPE_KERN_DATA, subregion_mask => 0); -- Region: user data -- Note: This is for the whole area. Each task will use only a fixed -- number of sub-regions if get_region_size (REGION_SIZE_128KB) /= ewok.layout.USER_RAM_SIZE then pragma DEBUG (debug.log (debug.ERROR, "MPU: invalid 'USER DATA' size")); return; end if; set_region (region_number => USER_DATA_REGION, addr => ewok.layout.USER_DATA_BASE, size => REGION_SIZE_128KB, region_type => REGION_TYPE_USER_DATA, subregion_mask => 0); -- Region: user code -- Note: This is for the whole area. Each task will use only a fixed -- number of sub-regions if get_region_size (REGION_SIZE_256KB) /= ewok.layout.FW1_USER_SIZE then pragma DEBUG (debug.log (debug.ERROR, "MPU: invalid 'USER CODE' size")); return; end if; set_region (region_number => USER_CODE_REGION, addr => applications.txt_user_region_base, size => applications.txt_user_region_size, region_type => REGION_TYPE_USER_CODE, subregion_mask => 0); pragma DEBUG (debug.log (debug.INFO, "MPU is configured")); m4.mpu.enable; pragma DEBUG (debug.log (debug.INFO, "MPU is enabled")); end init; procedure enable_unrestricted_kernel_access is begin m4.mpu.enable_unrestricted_kernel_access; end enable_unrestricted_kernel_access; procedure disable_unrestricted_kernel_access is begin m4.mpu.disable_unrestricted_kernel_access; end disable_unrestricted_kernel_access; procedure set_region (region_number : in m4.mpu.t_region_number; addr : in system_address; size : in m4.mpu.t_region_size; region_type : in t_region_type; subregion_mask : in unsigned_8) is access_perm : m4.mpu.t_region_perm; xn, b, s : boolean; region_config : m4.mpu.t_region_config; begin -- A memory region must never be mapped RWX case (region_type) is when REGION_TYPE_KERN_CODE => access_perm := REGION_PERM_PRIV_RO_USER_NO; xn := false; b := false; s := false; when REGION_TYPE_KERN_DATA => access_perm := REGION_PERM_PRIV_RW_USER_NO; xn := true; b := false; s := true; when REGION_TYPE_KERN_DEVICES => access_perm := REGION_PERM_PRIV_RW_USER_NO; xn := true; b := true; s := true; when REGION_TYPE_USER_CODE => access_perm := REGION_PERM_PRIV_RO_USER_RO; xn := false; b := false; s := false; when REGION_TYPE_USER_DATA => access_perm := REGION_PERM_PRIV_RW_USER_RW; xn := true; b := false; s := true; when REGION_TYPE_USER_DEV => access_perm := REGION_PERM_PRIV_RW_USER_RW; xn := true; b := true; s := true; when REGION_TYPE_USER_DEV_RO => access_perm := REGION_PERM_PRIV_RW_USER_RO; xn := true; b := true; s := true; when REGION_TYPE_ISR_STACK => access_perm := REGION_PERM_PRIV_RW_USER_RW; xn := true; b := false; s := true; end case; region_config := (region_number => region_number, addr => addr, size => size, access_perm => access_perm, xn => xn, b => b, s => s, subregion_mask => subregion_mask); m4.mpu.configure_region (region_config); end set_region; procedure update_subregions (region_number : in m4.mpu.t_region_number; subregion_mask : in unsigned_8) is begin m4.mpu.update_subregion_mask (region_number, subregion_mask); end update_subregions; procedure bytes_to_region_size (bytes : in unsigned_32; region_size : out m4.mpu.t_region_size; success : out boolean) is begin success := true; case (bytes) is when 32 => region_size := REGION_SIZE_32B; when 64 => region_size := REGION_SIZE_64B; when 128 => region_size := REGION_SIZE_128B; when 256 => region_size := REGION_SIZE_256B; when 512 => region_size := REGION_SIZE_512B; when 1*KBYTE => region_size := REGION_SIZE_1KB; when 2*KBYTE => region_size := REGION_SIZE_2KB; when 4*KBYTE => region_size := REGION_SIZE_4KB; when 8*KBYTE => region_size := REGION_SIZE_8KB; when 16*KBYTE => region_size := REGION_SIZE_16KB; when 32*KBYTE => region_size := REGION_SIZE_32KB; when 64*KBYTE => region_size := REGION_SIZE_64KB; when 128*KBYTE => region_size := REGION_SIZE_128KB; when 256*KBYTE => region_size := REGION_SIZE_256KB; when 512*KBYTE => region_size := REGION_SIZE_512KB; when 1*MBYTE => region_size := REGION_SIZE_1MB; when 2*MBYTE => region_size := REGION_SIZE_2MB; when 4*MBYTE => region_size := REGION_SIZE_4MB; when 8*MBYTE => region_size := REGION_SIZE_8MB; when 16*MBYTE => region_size := REGION_SIZE_16MB; when 32*MBYTE => region_size := REGION_SIZE_32MB; when 64*MBYTE => region_size := REGION_SIZE_64MB; when 128*MBYTE => region_size := REGION_SIZE_128MB; when 256*MBYTE => region_size := REGION_SIZE_256MB; when 512*MBYTE => region_size := REGION_SIZE_512MB; when 1*GBYTE => region_size := REGION_SIZE_1GB; when 2*GBYTE => region_size := REGION_SIZE_2GB; when others => region_size := REGION_SIZE_32B; success := false; end case; end bytes_to_region_size; function can_be_mapped return boolean is begin for region in regions_pool'range loop if not regions_pool(region).used then return true; end if; end loop; return false; end can_be_mapped; procedure map (addr : in system_address; size : in unsigned_32; region_type : in ewok.mpu.t_region_type; subregion_mask : in unsigned_8; success : out boolean) is region_size : m4.mpu.t_region_size; ok : boolean; begin for region in regions_pool'range loop if not regions_pool(region).used then ewok.mpu.bytes_to_region_size (size, region_size, ok); if not ok then raise program_error; end if; regions_pool(region).used := true; regions_pool(region).addr := addr; ewok.mpu.set_region (region, addr, region_size, region_type, subregion_mask); success := true; return; end if; end loop; success := false; end map; procedure unmap (addr : in system_address) is begin for region in regions_pool'range loop if regions_pool(region).addr = addr and then regions_pool(region).used then m4.mpu.disable_region (region); regions_pool(region) := (false, 0); return; end if; end loop; raise program_error; end unmap; procedure unmap_all is begin for region in regions_pool'range loop if regions_pool(region).used then regions_pool(region) := (false, 0); m4.mpu.disable_region (region); end if; end loop; end unmap_all; end ewok.mpu;
-- Ce module permet de tester le module conversion_type.adb with Conversion_Type; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; procedure test_Conversion_Type is package conversion_float is new Conversion_Type(T_Element => float); use conversion_float; -- Tester la procedure de conversion en entier procedure test_To_Integer is useless : Integer; begin -- Test avec un entier long useless := To_Integer(To_Unbounded_String("10000")); pragma assert(useless=10000); -- Test avec 0 pragma assert(To_Integer(To_Unbounded_String("0"))=0); -- Test avec un character begin useless := To_Integer(To_Unbounded_String("z")); pragma assert (False); exception when Bad_Type_Conversion_Error => pragma assert( True); end; -- Test avec un flottant begin useless := To_Integer(To_Unbounded_String("0.3")); pragma assert (False); exception when Bad_Type_Conversion_Error => pragma assert( True); end; end test_To_Integer; -- Tester la procedure de conversion en réel procedure test_To_reel is useless : float; begin -- Test avec un réel sur 10 digit useless := conversion_float.To_reel(To_Unbounded_String("0.85000002384")); pragma assert (useless=float(0.85000002384)); -- Test avec un entier de taille 1 begin useless := conversion_float.To_reel(To_Unbounded_String("3")); pragma assert (False); exception when Bad_Type_Conversion_Error => pragma assert( True); end; -- Test avec un entier de taille 2 begin useless :=conversion_float.To_reel(To_Unbounded_String("33")); pragma assert (False); exception when Bad_Type_Conversion_Error => pragma assert( True); end; -- Test avec un flottant ne commençant pas par 0,... pragma assert (conversion_float.To_reel(To_Unbounded_String("1.3")) = float(1.3)); -- Test avec un flottant compatible, attention le test d'égalité sur les float ne marchera pas car ada arrondit pragma assert (conversion_float.To_reel(To_Unbounded_String("0.009"))-float(0.009)<float(0.000001)); -- Test avec 0 begin useless :=conversion_float.To_reel(To_Unbounded_String("0")); pragma assert (False); exception when Bad_Type_Conversion_Error => pragma assert( True); end; -- Test avec un character begin useless :=conversion_float.To_reel(To_Unbounded_String("z")); pragma assert (False); exception when Bad_Type_Conversion_Error => pragma assert( True); end; end test_To_reel; -- Tester la procédure convertissant en entier ou réel avec sortie d'un indicateur sur le type produit procedure test_Integer_or_reel is indicateur_1 : Character; -- indicateur du premier test indicateur_2 : Character; indicateur_3 : Character; indicateur_4 : Character; useless_reel : float; -- valeur réellle produite mais non utilisée ici useless_integer : Integer; -- valeur entière produite mais non utilisée ici begin -- Test avec un entier Integer_or_reel(To_Unbounded_String("99"),useless_reel,useless_integer,indicateur_1); pragma assert (indicateur_1 = 'i'); -- Test avec un T_Element Integer_or_reel(To_Unbounded_String("0.3"),useless_reel,useless_integer,indicateur_2); pragma assert (indicateur_2 ='f'); -- Test avec un flottant ne commençant pas par 0,... Integer_or_reel(To_Unbounded_String("1.3"),useless_reel,useless_integer,indicateur_3); pragma assert (indicateur_3 = 'f'); -- Test avec un character Integer_or_reel(To_Unbounded_String("a"),useless_reel,useless_integer,indicateur_4); pragma assert (indicateur_4 ='o'); end test_Integer_or_reel; begin Put_Line("Test conversion des entiers"); test_To_Integer; Put_Line("Test conversion en réel de précision variable"); test_To_reel; Put_Line("Test indicateur du type"); test_Integer_or_reel; Put_Line ("Fin des tests : OK."); end test_Conversion_Type;
with lace.Text.utility, ada.Text_IO; procedure test_Text_replace is use lace.Text, lace.Text.utility, ada.Text_IO; test_Error : exception; begin put_Line ("Begin Test"); new_Line; -- Test 'replace' function. -- declare Initial : aliased constant lace.Text.item := to_Text ("<TOKEN>"); Final : constant String := +replace (Initial, "<TOKEN>", ""); begin if Final /= "" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("<TOKEN>"); Final : constant String := +replace (Initial, "<TOKEN>", "Linux"); begin if Final /= "Linux" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("123<TOKEN>456"); Final : constant String := +replace (Initial, "<TOKEN>", "Linux"); begin if Final /= "123Linux456" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("123<TOKEN>"); Final : constant String := +replace (Initial, "<TOKEN>", "Linux"); begin if Final /= "123Linux" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("<TOKEN>456"); Final : constant String := +replace (Initial, "<TOKEN>", "Linux"); begin if Final /= "Linux456" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("<TOKEN>123<TOKEN>"); Final : constant String := +replace (Initial, "<TOKEN>", "Linux"); begin if Final /= "Linux123Linux" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("<TOKEN><TOKEN>"); Final : constant String := +replace (Initial, "<TOKEN>", "Linux"); begin if Final /= "LinuxLinux" then raise test_Error with "replace fails: Initial => '" & (+Initial) & "' " & "Final => '" & Final & "'"; end if; end; declare Initial : aliased constant lace.Text.item := to_Text ("<TOKEN>", capacity => 64); Final : constant String := +replace (Initial, "<TOKEN>", "Longish String") with Unreferenced; begin put_Line ("No capacity error raised, as expected."); end; -- Test 'replace' procedure. -- declare Initial : constant String := "<TOKEN>"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", ""); if +Text /= "" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "<TOKEN>"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Linux"); if +Text /= "Linux" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "123<TOKEN>456"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Linux"); if +Text /= "123Linux456" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "123<TOKEN>"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Linux"); if +Text /= "123Linux" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "<TOKEN>456"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Linux"); if +Text /= "Linux456" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "<TOKEN>123<TOKEN>"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Linux"); if +Text /= "Linux123Linux" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "<TOKEN><TOKEN>"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Linux"); if +Text /= "LinuxLinux" then raise test_Error with "replace fails: Initial => '" & Initial & "' " & "Final => '" & (+Text) & "'"; end if; end; declare Initial : constant String := "<TOKEN>"; Text : lace.Text.item := to_Text (Initial); begin replace (Text, "<TOKEN>", "Longish String"); exception when lace.Text.Error => put_Line ("Capacity error raised, as expected."); end; declare Initial : constant String := "<TOKEN>"; Text : lace.Text.item := to_Text (Initial, capacity => 64); begin replace (Text, "<TOKEN>", "Longish String"); put_Line ("No capacity error raised, as expected."); end; new_Line; put_Line ("Success"); put_Line ("End Test"); end test_Text_replace;
pragma License (Unrestricted); generic type Object (<>) is limited private; type Name is access Object; procedure Ada.Unchecked_Deallocation (X : in out Name) with Import, Convention => Intrinsic; pragma Preelaborate (Ada.Unchecked_Deallocation);
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2013, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This is implementation for POSIX operation systems. ------------------------------------------------------------------------------ with Interfaces.C.Strings; with Matreshka.Internals.Calendars.Gregorian; with Matreshka.Internals.Calendars.Times; package body Matreshka.Internals.Calendars.Clocks is type time_t is new Interfaces.C.long; type suseconds_t is new Interfaces.C.long; type timeval is record tv_sec : aliased time_t; tv_usec : suseconds_t; end record; pragma Convention (C, timeval); type timezone is record tz_minuteswest : Interfaces.C.int; tz_dsttime : Interfaces.C.int; end record; pragma Convention (C, timezone); type tm is record tm_sec : Interfaces.C.int; tm_min : Interfaces.C.int; tm_hour : Interfaces.C.int; tm_mday : Interfaces.C.int; tm_mon : Interfaces.C.int; tm_year : Interfaces.C.int; tm_wday : Interfaces.C.int; tm_yday : Interfaces.C.int; tm_isdst : Interfaces.C.int; tm_gmtoff : Interfaces.C.long; tm_zone : Interfaces.C.Strings.chars_ptr; end record; pragma Convention (C, tm); function gettimeofday (tv : not null access timeval; tz : access timezone) return Interfaces.C.int; pragma Import (C, gettimeofday); function gmtime_r (timep : not null access constant time_t; result : not null access tm) return access tm; pragma Import (C, gmtime_r); ----------- -- Clock -- ----------- function Clock return Absolute_Time is use type Interfaces.C.int; Current_Time : aliased timeval; Break_Down : aliased tm; begin if gettimeofday (Current_Time'Access, null) /= 0 then return 0; end if; if gmtime_r (Current_Time.tv_sec'Access, Break_Down'Access) = null then return 0; end if; return Times.Create (Matreshka.Internals.Calendars.UTC_Time_Zone'Access, Gregorian.Julian_Day (Integer (Break_Down.tm_year) + 1_900, Integer (Break_Down.tm_mon) + 1, Integer (Break_Down.tm_mday)), Integer (Break_Down.tm_hour), Integer (Break_Down.tm_min), Integer (Break_Down.tm_sec), Integer (Current_Time.tv_usec) * 10); end Clock; end Matreshka.Internals.Calendars.Clocks;
with SPARKNaCl.Core; with SPARKNaCl.Stream; package SPARKNaCl.Cryptobox with Pure, SPARK_Mode => On is -------------------------------------------------------- -- Public Key Authenticated Encryption - "Crypto Box" -- -------------------------------------------------------- -- Limited, so no assignment or comparison, and always -- pass-by-reference. type Secret_Key is limited private; type Public_Key is limited private; Plaintext_Zero_Bytes : constant := 32; Ciphertext_Zero_Bytes : constant := 16; -- Key generation procedure Keypair (Raw_SK : in Bytes_32; PK : out Public_Key; SK : out Secret_Key) with Global => null; function Construct (K : in Bytes_32) return Secret_Key with Global => null; function Construct (K : in Bytes_32) return Public_Key with Global => null; function Serialize (K : in Secret_Key) return Bytes_32 with Global => null; function Serialize (K : in Public_Key) return Bytes_32 with Global => null; -- Sanitization procedure Sanitize (K : out Secret_Key) with Global => null; procedure Sanitize (K : out Public_Key) with Global => null; -- Precomputation procedure BeforeNM (K : out Core.Salsa20_Key; PK : in Public_Key; SK : in Secret_Key) with Global => null; -- Postcomputation for Create procedure AfterNM (C : out Byte_Seq; Status : out Boolean; M : in Byte_Seq; N : in Stream.HSalsa20_Nonce; K : in Core.Salsa20_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and C'Last = M'Last and M'Length >= 32) and then Equal (M (0 .. 31), Zero_Bytes_32), Post => Equal (C (0 .. 15), Zero_Bytes_16); -- Postcomputation for Open procedure Open_AfterNM (M : out Byte_Seq; -- Output plaintext Status : out Boolean; C : in Byte_Seq; -- Input ciphertext N : in Stream.HSalsa20_Nonce; K : in Core.Salsa20_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and M'Last = C'Last and C'Length >= 32) and then Equal (C (0 .. 15), Zero_Bytes_16), Post => Equal (M (0 .. 31), Zero_Bytes_32); -- Top-level all-in-one Create operation procedure Create (C : out Byte_Seq; Status : out Boolean; M : in Byte_Seq; N : in Stream.HSalsa20_Nonce; Recipient_PK : in Public_Key; Sender_SK : in Secret_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and C'Last = M'Last and M'Length >= 32) and then Equal (M (0 .. 31), Zero_Bytes_32), Post => Equal (C (0 .. 15), Zero_Bytes_16); -- Top-level all-in-one Open operation procedure Open (M : out Byte_Seq; Status : out Boolean; C : in Byte_Seq; N : in Stream.HSalsa20_Nonce; Sender_PK : in Public_Key; Recipient_SK : in Secret_Key) with Global => null, Pre => (M'First = 0 and C'First = 0 and M'Last = C'Last and C'Length >= 32) and then Equal (C (0 .. 15), Zero_Bytes_16), Post => Equal (M (0 .. 31), Zero_Bytes_32); private -- Note - also limited types here in the full view to ensure -- no assignment and pass-by-reference in the body. type Secret_Key is limited record F : Bytes_32; end record; type Public_Key is limited record F : Bytes_32; end record; end SPARKNaCl.Cryptobox;
----------------------------------------------------------------------- -- ado.schemas -- Database Schemas -- Copyright (C) 2009, 2010, 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 Ada.Unchecked_Deallocation; with Ada.Strings.Equal_Case_Insensitive; package body ADO.Schemas is procedure Free is new Ada.Unchecked_Deallocation (Object => Column, Name => Column_Definition); procedure Free is new Ada.Unchecked_Deallocation (Object => Table, Name => Table_Definition); procedure Free is new Ada.Unchecked_Deallocation (Object => Schema, Name => Schema_Access); -- ------------------------------ -- Get the hash value associated with the class mapping. -- ------------------------------ function Hash (Mapping : Class_Mapping_Access) return Ada.Containers.Hash_Type is begin if Mapping = null then return 0; else return Util.Strings.Hash (Mapping.Table); end if; end Hash; -- ------------------------------ -- Column Representation -- ------------------------------ -- ------------------------------ -- Get the column name -- ------------------------------ function Get_Name (Column : Column_Definition) return String is begin return To_String (Column.Name); end Get_Name; -- ------------------------------ -- Get the column type -- ------------------------------ function Get_Type (Column : Column_Definition) return Column_Type is begin return Column.Col_Type; end Get_Type; -- ------------------------------ -- Get the default column value -- ------------------------------ function Get_Default (Column : Column_Definition) return String is begin return To_String (Column.Default); end Get_Default; -- ------------------------------ -- Get the column collation (for string based columns) -- ------------------------------ function Get_Collation (Column : Column_Definition) return String is begin return To_String (Column.Collation); end Get_Collation; -- ------------------------------ -- Check whether the column can be null -- ------------------------------ function Is_Null (Column : Column_Definition) return Boolean is begin return Column.Is_Null; end Is_Null; -- ------------------------------ -- Check whether the column is an unsigned number -- ------------------------------ function Is_Unsigned (Column : Column_Definition) return Boolean is begin return Column.Is_Unsigned; end Is_Unsigned; -- ------------------------------ -- Returns true if the column can hold a binary string -- ------------------------------ function Is_Binary (Column : Column_Definition) return Boolean is begin return Column.Is_Binary; end Is_Binary; -- ------------------------------ -- Returns true if the column is a primary key. -- ------------------------------ function Is_Primary (Column : Column_Definition) return Boolean is begin return Column.Is_Primary; end Is_Primary; -- ------------------------------ -- Get the column length -- ------------------------------ function Get_Size (Column : Column_Definition) return Natural is begin return Column.Size; end Get_Size; -- ------------------------------ -- Column iterator -- ------------------------------ -- ------------------------------ -- Returns true if the iterator contains more column -- ------------------------------ function Has_Element (Cursor : Column_Cursor) return Boolean is begin return Cursor.Current /= null; end Has_Element; -- ------------------------------ -- Move to the next column -- ------------------------------ procedure Next (Cursor : in out Column_Cursor) is begin if Cursor.Current /= null then Cursor.Current := Cursor.Current.Next_Column; end if; end Next; -- ------------------------------ -- Get the current column definition -- ------------------------------ function Element (Cursor : Column_Cursor) return Column_Definition is begin return Cursor.Current; end Element; -- ------------------------------ -- Table Representation -- ------------------------------ -- ------------------------------ -- Get the table name -- ------------------------------ function Get_Name (Table : Table_Definition) return String is begin return To_String (Table.Name); end Get_Name; -- ------------------------------ -- Get the column iterator -- ------------------------------ function Get_Columns (Table : Table_Definition) return Column_Cursor is begin return Column_Cursor '(Current => Table.First_Column); end Get_Columns; -- ------------------------------ -- Find the column having the given name -- ------------------------------ function Find_Column (Table : Table_Definition; Name : String) return Column_Definition is Column : Column_Definition := Table.First_Column; begin while Column /= null loop if Ada.Strings.Equal_Case_Insensitive (To_String (Column.Name), Name) then return Column; end if; Column := Column.Next_Column; end loop; return null; end Find_Column; -- ------------------------------ -- Table iterator -- ------------------------------ -- ------------------------------ -- Returns true if the iterator contains more tables -- ------------------------------ function Has_Element (Cursor : Table_Cursor) return Boolean is begin return Cursor.Current /= null; end Has_Element; -- ------------------------------ -- Move to the next column -- ------------------------------ procedure Next (Cursor : in out Table_Cursor) is begin if Cursor.Current /= null then Cursor.Current := Cursor.Current.Next_Table; end if; end Next; -- ------------------------------ -- Get the current table definition -- ------------------------------ function Element (Cursor : Table_Cursor) return Table_Definition is begin return Cursor.Current; end Element; -- ------------------------------ -- Database Schema -- ------------------------------ -- ------------------------------ -- Find a table knowing its name -- ------------------------------ function Find_Table (Schema : Schema_Definition; Name : String) return Table_Definition is Table : Table_Definition; begin if Schema.Schema /= null then Table := Schema.Schema.First_Table; while Table /= null loop if Ada.Strings.Equal_Case_Insensitive (To_String (Table.Name), Name) then return Table; end if; Table := Table.Next_Table; end loop; end if; return null; end Find_Table; function Get_Tables (Schema : Schema_Definition) return Table_Cursor is begin if Schema.Schema = null then return Table_Cursor '(Current => null); else return Table_Cursor '(Current => Schema.Schema.First_Table); end if; end Get_Tables; procedure Finalize (Schema : in out Schema_Definition) is begin if Schema.Schema /= null then declare Table : Table_Definition; Column : Column_Definition; begin loop Table := Schema.Schema.First_Table; exit when Table = null; loop Column := Table.First_Column; exit when Column = null; Table.First_Column := Column.Next_Column; Free (Column); end loop; Schema.Schema.First_Table := Table.Next_Table; Free (Table); end loop; end; Free (Schema.Schema); end if; end Finalize; end ADO.Schemas;
----------------------------------------------------------------------- -- openapi-server -- Rest server support -- Copyright (C) 2017, 2018, 2020, 2022 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 Servlet.Rest; with Servlet.Core; with Security.Permissions; package OpenAPI.Servers is subtype Application_Type is Servlet.Core.Servlet_Registry; subtype Request is Servlet.Rest.Request; subtype Response is Servlet.Rest.Response; subtype Output_Stream is Servlet.Rest.Output_Stream; subtype Method_Type is Servlet.Rest.Method_Type; GET : constant Method_Type := Servlet.Rest.GET; POST : constant Method_Type := Servlet.Rest.POST; DELETE : constant Method_Type := Servlet.Rest.DELETE; PUT : constant Method_Type := Servlet.Rest.PUT; HEAD : constant Method_Type := Servlet.Rest.HEAD; OPTIONS : constant Method_Type := Servlet.Rest.OPTIONS; PATCH : constant Method_Type := Servlet.Rest.PATCH; subtype Descriptor_Access is Servlet.Rest.Descriptor_Access; -- Get a request parameter defined in the URI path. procedure Get_Path_Parameter (Req : in Request'Class; Pos : in Positive; Value : out UString); -- Get a request parameter defined in the URI path. procedure Get_Path_Parameter (Req : in Request'Class; Pos : in Positive; Value : out Long); -- Get a request parameter from the query string. procedure Get_Query_Parameter (Req : in Request'Class; Name : in String; Value : out UString); procedure Get_Query_Parameter (Req : in Request'Class; Name : in String; Value : out Nullable_UString); -- Get a request parameter from the query string. procedure Get_Query_Parameter (Req : in Request'Class; Name : in String; Value : out UString_Vectors.Vector); procedure Get_Query_Parameter (Req : in Request'Class; Name : in String; Value : out Nullable_UString_Vectors.Vector); -- Get a request parameter from the query as boolean. procedure Get_Query_Parameter (Req : in Request'Class; Name : in String; Value : out Boolean); procedure Get_Query_Parameter (Req : in Request'Class; Name : in String; Value : out Nullable_Boolean); -- Read the request body and get a value object tree. procedure Read (Req : in Request'Class; Value : out Value_Type); type Context_Type is tagged limited private; procedure Initialize (Context : in out Context_Type; Req : in out Request'Class; Reply : in out Response'Class; Stream : in out Output_Stream'Class); procedure Register (Registry : in out Servlet.Core.Servlet_Registry'Class; Definition : in Descriptor_Access) renames Servlet.Rest.Register; -- Get a request parameter passed in the form. procedure Get_Parameter (Req : in out Context_Type; Name : in String; Value : out Long); -- Get a request parameter passed in the form. procedure Get_Parameter (Req : in out Context_Type; Name : in String; Value : out Integer); -- Get a request parameter passed in the form. procedure Get_Parameter (Req : in out Context_Type; Name : in String; Value : out UString); procedure Get_Parameter (Req : in out Context_Type; Name : in String; Value : out Nullable_UString); -- Get a request parameter passed in the form. procedure Get_Parameter (Req : in out Context_Type; Name : in String; Value : out Boolean); -- Set the response error code with a message to return. procedure Set_Error (Context : in out Context_Type; Code : in Natural; Message : in String); -- Set the HTTP status in the response. procedure Set_Status (Context : in out Context_Type; Code : in Natural); -- Send a Location: header in the response. procedure Set_Location (Context : in out Context_Type; URL : in String); -- Get the HTTP status that will be sent in the response. function Get_Status (Context : in Context_Type) return Natural; -- Returns True if the API request is authenticated. function Is_Authenticated (Context : in Context_Type) return Boolean; -- Returns True if the client doing the request has the given permission. function Has_Permission (Context : in Context_Type; Permission : in Security.Permissions.Permission_Index) return Boolean; private function Get_Parameter (Req : in out Context_Type; Name : in String) return String; procedure Read (Context : in out Context_Type); type Context_Type is tagged limited record Req : access Request'Class; Reply : access Response'Class; Stream : access Output_Stream'Class; Params : Util.Beans.Objects.Object; Use_Map : Boolean := False; end record; end OpenAPI.Servers;
----------------------------------------------------------------------- -- net-buffers -- Network buffers -- Copyright (C) 2016, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Conversion; package body Net.Buffers is ETHER_POS : constant Uint16 := 0; IP_POS : constant Uint16 := ETHER_POS + 14; UDP_POS : constant Uint16 := IP_POS + 20; -- Note: this is wrong due to IP options. -- TCP_POS : constant Uint16 := IP_POS + 24; -- Note: this is wrong due to IP options. IGMP_POS : constant Uint16 := IP_POS + 24; ICMP_POS : constant Uint16 := IP_POS + 20; DHCP_POS : constant Uint16 := IP_POS + 20 + 8; -- DATA_POS : constant Natural := UDP_POS + 8; type Offset_Table is array (Packet_Type) of Uint16; Offsets : constant Offset_Table := (RAW_PACKET => 0, ETHER_PACKET => 14, ARP_PACKET => 14 + 8, IP_PACKET => 14 + 20, ICMP_PACKET => 14 + 20 + 8, UDP_PACKET => 14 + 20 + 8, DHCP_PACKET => 14 + 20 + 8 + 236); function As_Ethernet is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.Ether_Header_Access); function As_Arp is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.Arp_Packet_Access); function As_Ip_Header is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.IP_Header_Access); function As_Udp_Header is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.UDP_Header_Access); function As_Tcp_Header is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.TCP_Header_Access); function As_Igmp_Header is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.IGMP_Header_Access); function As_Icmp_Header is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.ICMP_Header_Access); function As_Dhcp_Header is new Ada.Unchecked_Conversion (Source => System.Address, Target => Net.Headers.DHCP_Header_Access); protected Manager with Priority => Net.Network_Priority is procedure Allocate (Packet : out Packet_Buffer_Access); procedure Release (Packet : in out Packet_Buffer_Access); procedure Add_Region (Addr : in System.Address; Count : in Uint32); procedure Release (List : in out Buffer_List); procedure Allocate (List : in out Buffer_List; Count : in Natural); private Free_List : Packet_Buffer_Access; end Manager; -- ------------------------------ -- Returns true if the buffer is null (allocation failed). -- ------------------------------ function Is_Null (Buf : in Buffer_Type) return Boolean is begin return Buf.Packet = null; end Is_Null; -- ------------------------------ -- Allocate a buffer from the pool. No exception is raised if there is no available buffer. -- The <tt>Is_Null</tt> operation must be used to check the buffer allocation. -- ------------------------------ procedure Allocate (Buf : out Buffer_Type) is begin Manager.Allocate (Buf.Packet); Buf.Size := 0; end Allocate; -- ------------------------------ -- Release the buffer back to the pool. -- ------------------------------ procedure Release (Buf : in out Buffer_Type) is begin if Buf.Packet /= null then Manager.Release (Buf.Packet); end if; end Release; -- ------------------------------ -- Transfer the ownership of the buffer from <tt>From</tt> to <tt>To</tt>. -- If the destination has a buffer, it is first released. -- ------------------------------ procedure Transfer (To : in out Buffer_Type; From : in out Buffer_Type) is begin if To.Packet /= null then Manager.Release (To.Packet); end if; To.Packet := From.Packet; To.Size := From.Size; From.Packet := null; end Transfer; -- ------------------------------ -- Switch the ownership of the two buffers. The typical usage is on the Ethernet receive -- ring to peek a received packet and install a new buffer on the ring so that there is -- always a buffer on the ring. -- ------------------------------ procedure Switch (To : in out Buffer_Type; From : in out Buffer_Type) is Size : constant Uint16 := To.Size; Packet : constant Packet_Buffer_Access := To.Packet; begin To.Size := From.Size; To.Packet := From.Packet; From.Size := Size; From.Packet := Packet; end Switch; function Get_Data_Address (Buf : in Buffer_Type) return System.Address is begin return Buf.Packet.Data (Buf.Packet.Data'First)'Address; end Get_Data_Address; function Get_Data_Size (Buf : in Buffer_Type; Kind : in Packet_Type) return Uint16 is begin if Buf.Size = 0 then return Buf.Pos - Offsets (Kind); else return Buf.Size - Offsets (Kind); end if; end Get_Data_Size; procedure Set_Data_Size (Buf : in out Buffer_Type; Size : in Uint16) is begin Buf.Pos := Size + Offsets (Buf.Kind); Buf.Size := 0; end Set_Data_Size; function Get_Length (Buf : in Buffer_Type) return Uint16 is begin return Buf.Size; end Get_Length; procedure Set_Length (Buf : in out Buffer_Type; Size : in Uint16) is begin Buf.Size := Size; Buf.Packet.Size := Size; end Set_Length; -- ------------------------------ -- Set the packet type. -- ------------------------------ procedure Set_Type (Buf : in out Buffer_Type; Kind : in Packet_Type) is begin Buf.Kind := Kind; Buf.Pos := Offsets (Kind); end Set_Type; -- ------------------------------ -- Add a byte to the buffer data, moving the buffer write position. -- ------------------------------ procedure Put_Uint8 (Buf : in out Buffer_Type; Value : in Net.Uint8) is begin Buf.Packet.Data (Buf.Pos) := Value; Buf.Pos := Buf.Pos + 1; end Put_Uint8; -- ------------------------------ -- Add a 16-bit value in network byte order to the buffer data, -- moving the buffer write position. -- ------------------------------ procedure Put_Uint16 (Buf : in out Buffer_Type; Value : in Net.Uint16) is begin Buf.Packet.Data (Buf.Pos) := Net.Uint8 (Interfaces.Shift_Right (Value, 8)); Buf.Packet.Data (Buf.Pos + 1) := Net.Uint8 (Value and 16#0ff#); Buf.Pos := Buf.Pos + 2; end Put_Uint16; -- ------------------------------ -- Add a 32-bit value in network byte order to the buffer data, -- moving the buffer write position. -- ------------------------------ procedure Put_Uint32 (Buf : in out Buffer_Type; Value : in Net.Uint32) is begin Buf.Packet.Data (Buf.Pos) := Net.Uint8 (Interfaces.Shift_Right (Value, 24)); Buf.Packet.Data (Buf.Pos + 1) := Net.Uint8 (Interfaces.Shift_Right (Value, 16) and 16#0ff#); Buf.Packet.Data (Buf.Pos + 2) := Net.Uint8 (Interfaces.Shift_Right (Value, 8) and 16#0ff#); Buf.Packet.Data (Buf.Pos + 3) := Net.Uint8 (Value and 16#0ff#); Buf.Pos := Buf.Pos + 4; end Put_Uint32; -- ------------------------------ -- Add a string to the buffer data, moving the buffer write position. -- When <tt>With_Null</tt> is set, a NUL byte is added after the string. -- ------------------------------ procedure Put_String (Buf : in out Buffer_Type; Value : in String; With_Null : in Boolean := False) is Pos : Uint16 := Buf.Pos; begin for C of Value loop Buf.Packet.Data (Pos) := Character'Pos (C); Pos := Pos + 1; end loop; if With_Null then Buf.Packet.Data (Pos) := 0; Pos := Pos + 1; end if; Buf.Pos := Pos; end Put_String; -- ------------------------------ -- Add an IP address to the buffer data, moving the buffer write position. -- ------------------------------ procedure Put_Ip (Buf : in out Buffer_Type; Value : in Ip_Addr) is Pos : Uint16 := Buf.Pos; begin for C of Value loop Buf.Packet.Data (Pos) := C; Pos := Pos + 1; end loop; Buf.Pos := Pos; end Put_Ip; -- ------------------------------ -- Get a byte from the buffer, moving the buffer read position. -- ------------------------------ function Get_Uint8 (Buf : in out Buffer_Type) return Net.Uint8 is Pos : constant Net.Uint16 := Buf.Pos; begin Buf.Pos := Pos + 1; return Buf.Packet.Data (Pos); end Get_Uint8; -- ------------------------------ -- Get a 16-bit value in network byte order from the buffer, moving the buffer read position. -- ------------------------------ function Get_Uint16 (Buf : in out Buffer_Type) return Net.Uint16 is Pos : constant Net.Uint16 := Buf.Pos; begin Buf.Pos := Pos + 2; return Interfaces.Shift_Left (Net.Uint16 (Buf.Packet.Data (Pos)), 8) or Net.Uint16 (Buf.Packet.Data (Pos + 1)); end Get_Uint16; -- ------------------------------ -- Get a 32-bit value in network byte order from the buffer, moving the buffer read position. -- ------------------------------ function Get_Uint32 (Buf : in out Buffer_Type) return Net.Uint32 is Pos : constant Net.Uint16 := Buf.Pos; begin Buf.Pos := Pos + 4; return Interfaces.Shift_Left (Net.Uint32 (Buf.Packet.Data (Pos)), 24) or Interfaces.Shift_Left (Net.Uint32 (Buf.Packet.Data (Pos + 1)), 16) or Interfaces.Shift_Left (Net.Uint32 (Buf.Packet.Data (Pos + 2)), 8) or Net.Uint32 (Buf.Packet.Data (Pos + 3)); end Get_Uint32; -- ------------------------------ -- Get an IPv4 value from the buffer, moving the buffer read position. -- ------------------------------ function Get_Ip (Buf : in out Buffer_Type) return Net.Ip_Addr is Pos : constant Net.Uint16 := Buf.Pos; Result : Ip_Addr; begin Buf.Pos := Pos + 4; Result (1) := Buf.Packet.Data (Pos); Result (2) := Buf.Packet.Data (Pos + 1); Result (3) := Buf.Packet.Data (Pos + 2); Result (4) := Buf.Packet.Data (Pos + 3); return Result; end Get_Ip; -- ------------------------------ -- Get a string whose length is specified by the target value. -- ------------------------------ procedure Get_String (Buf : in out Buffer_Type; Into : out String) is Pos : Net.Uint16 := Buf.Pos; begin for I in Into'Range loop Into (I) := Character'Val (Buf.Packet.Data (Pos)); Pos := Pos + 1; end loop; Buf.Pos := Pos; end Get_String; -- ------------------------------ -- Skip a number of bytes in the buffer, moving the buffer position <tt>Size<tt> bytes ahead. -- ------------------------------ procedure Skip (Buf : in out Buffer_Type; Size : in Net.Uint16) is begin Buf.Pos := Buf.Pos + Size; end Skip; -- ------------------------------ -- Get the number of bytes still available when reading the packet. -- ------------------------------ function Available (Buf : in Buffer_Type) return Net.Uint16 is begin return Buf.Size - Buf.Pos; end Available; -- ------------------------------ -- Get access to the Ethernet header. -- ------------------------------ function Ethernet (Buf : in Buffer_Type) return Net.Headers.Ether_Header_Access is begin return As_Ethernet (Buf.Packet.Data (Buf.Packet.Data'First)'Address); end Ethernet; -- ------------------------------ -- Get access to the ARP packet. -- ------------------------------ function Arp (Buf : in Buffer_Type) return Net.Headers.Arp_Packet_Access is begin return As_Arp (Buf.Packet.Data (Buf.Packet.Data'First)'Address); end Arp; -- ------------------------------ -- Get access to the IPv4 header. -- ------------------------------ function IP (Buf : in Buffer_Type) return Net.Headers.IP_Header_Access is begin return As_Ip_Header (Buf.Packet.Data (IP_POS)'Address); end IP; -- ------------------------------ -- Get access to the UDP header. -- ------------------------------ function UDP (Buf : in Buffer_Type) return Net.Headers.UDP_Header_Access is begin return As_Udp_Header (Buf.Packet.Data (UDP_POS)'Address); end UDP; -- ------------------------------ -- Get access to the TCP header. -- ------------------------------ function TCP (Buf : in Buffer_Type) return Net.Headers.TCP_Header_Access is begin return As_Tcp_Header (Buf.Packet.Data (20 + 14 + 2)'Address); end TCP; -- ------------------------------ -- Get access to the IGMP header. -- ------------------------------ function IGMP (Buf : in Buffer_Type) return Net.Headers.IGMP_Header_Access is begin return As_Igmp_Header (Buf.Packet.Data (IGMP_POS)'Address); end IGMP; -- ------------------------------ -- Get access to the ICMP header. -- ------------------------------ function ICMP (Buf : in Buffer_Type) return Net.Headers.ICMP_Header_Access is begin return As_Icmp_Header (Buf.Packet.Data (ICMP_POS)'Address); end ICMP; -- ------------------------------ -- Get access to the DHCP header. -- ------------------------------ function DHCP (Buf : in Buffer_Type) return Net.Headers.DHCP_Header_Access is begin return As_Dhcp_Header (Buf.Packet.Data (DHCP_POS)'Address); end DHCP; -- ------------------------------ -- Returns True if the list is empty. -- ------------------------------ function Is_Empty (List : in Buffer_List) return Boolean is begin return List.Head = null; end Is_Empty; -- ------------------------------ -- Insert the buffer to the list. -- ------------------------------ procedure Insert (Into : in out Buffer_List; Buf : in out Buffer_Type) is begin if Into.Tail = null then Into.Tail := Buf.Packet; Buf.Packet.Next := null; else Buf.Packet.Next := Into.Head; end if; Into.Head := Buf.Packet; Buf.Packet := null; end Insert; -- ------------------------------ -- Release all the buffers held by the list. -- ------------------------------ procedure Release (List : in out Buffer_List) is begin Manager.Release (List); end Release; -- ------------------------------ -- Allocate <tt>Count</tt> buffers and add them to the list. -- There is no guarantee that the required number of buffers will be allocated. -- ------------------------------ procedure Allocate (List : in out Buffer_List; Count : in Natural) is begin Manager.Allocate (List, Count); end Allocate; -- ------------------------------ -- Peek a buffer from the list. -- ------------------------------ procedure Peek (From : in out Buffer_List; Buf : in out Buffer_Type) is begin Buf.Packet := From.Head; Buf.Size := Buf.Packet.Size; From.Head := From.Head.Next; if From.Head = null then From.Tail := null; end if; end Peek; -- ------------------------------ -- Transfer the list of buffers held by <tt>From</tt> at end of the list held -- by <tt>To</tt>. After the transfer, the <tt>From</tt> list is empty. -- The complexity is in O(1). -- ------------------------------ procedure Transfer (To : in out Buffer_List; From : in out Buffer_List) is begin if To.Tail /= null then To.Tail.Next := From.Head; From.Head := To.Head; else To.Tail := From.Tail; To.Head := From.Head; end if; From.Head := null; From.Tail := null; end Transfer; -- ------------------------------ -- Add a memory region to the buffer pool. -- ------------------------------ procedure Add_Region (Addr : in System.Address; Size : in Uint32) is Count : constant Uint32 := Size / NET_ALLOC_SIZE; begin Manager.Add_Region (Addr, Count); end Add_Region; protected body Manager is procedure Allocate (Packet : out Packet_Buffer_Access) is begin Packet := Free_List; if Packet /= null then Free_List := Packet.Next; Packet.Size := 0; end if; end Allocate; procedure Allocate (List : in out Buffer_List; Count : in Natural) is Packet : Packet_Buffer_Access; begin for I in 1 .. Count loop exit when Free_List = null; Packet := Free_List; Free_List := Packet.Next; if List.Tail = null then List.Tail := Packet; else Packet.Next := List.Head; end if; List.Head := Packet; end loop; end Allocate; procedure Release (Packet : in out Packet_Buffer_Access) is begin Packet.Next := Free_List; Free_List := Packet; Packet := null; end Release; procedure Release (List : in out Buffer_List) is begin List.Tail.Next := Free_List; Free_List := List.Head; List.Head := null; List.Tail := null; end Release; procedure Add_Region (Addr : in System.Address; Count : in Uint32) is type Packet_Array is array (1 .. Count) of aliased Packet_Buffer; type Packet_Array_Access is access all Packet_Array; function As_Packet_List is new Ada.Unchecked_Conversion (Source => System.Address, Target => Packet_Array_Access); Packets : Packet_Array_Access := As_Packet_List (Addr); begin for I in 1 .. Count loop Packets (I).Next := Free_List; Free_List := Packets (I)'Unchecked_Access; end loop; end Add_Region; end Manager; end Net.Buffers;
with HTTP; use HTTP; with HTTP.Request; use HTTP.Request; procedure Test is CRLF : constant String := ASCII.CR & ASCII.LF; Test_String : constant String := "GET /index.html HTTP/1.1" & CRLF & "User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)" & CRLF & "Host: www.adaisquitecool.com" & CRLF & "Accept-Language: en-us" & CRLF & "Accept-Encoding: gzip, deflate" & CRLF & "Connection: Keep-Alive" & CRLF & CRLF; HTTP_Parser : Parse.Context; Read_Length : Natural; begin Parse.Str_Read (HTTP_Parser, Test_String, Read_Length); Parse.Debug (HTTP_Parser, Test_String); end Test;
------------------------------------------------------------------------------ -- G P S -- -- -- -- Copyright (C) 2000-2016, AdaCore -- -- -- -- This 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. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with this software; see file -- -- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- -- of the license. -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Containers; use Ada.Containers; with Ada.Strings.Hash; with Ada.Strings.Hash_Case_Insensitive; with Ada.Strings.Fixed; with Ada.Unchecked_Deallocation; with Ada.Wide_Wide_Characters.Handling; use Ada.Wide_Wide_Characters.Handling; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; use Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with GNAT.Strings; use GNAT.Strings; with GNATCOLL.Scripts.Utils; use GNATCOLL.Scripts.Utils; with GNATCOLL.Utils; use GNATCOLL.Utils; with GNATCOLL.Xref; with UTF8_Utils; use UTF8_Utils; package body String_Utils is use type GNATCOLL.Xref.Visible_Column; ----------------- -- Lines_Count -- ----------------- function Lines_Count (Text : String) return Natural is Count : Natural := 1; begin for T in Text'Range loop if Text (T) = ASCII.LF then Count := Count + 1; end if; end loop; return Count; end Lines_Count; ----------------- -- Blank_Slice -- ----------------- function Blank_Slice (Count : Integer; Use_Tabs : Boolean := False; Tab_Width : Positive := 8) return String is begin if Count <= 0 then return ""; elsif Use_Tabs then return (1 .. Count / Tab_Width => ASCII.HT) & (1 .. Count mod Tab_Width => ' '); else return (1 .. Count => ' '); end if; end Blank_Slice; ------------- -- Replace -- ------------- procedure Replace (S : in out GNAT.Strings.String_Access; Value : String) is begin if S /= null then if S'Length = Value'Length then -- Let's try to avoid memory fragmentation S.all := Value; return; else GNAT.Strings.Free (S); end if; end if; S := new String'(Value); end Replace; procedure Replace (S : in out GNAT.Strings.String_Access; Value : GNAT.Strings.String_Access) is begin if Value = null then GNAT.Strings.Free (S); else Replace (S, Value.all); end if; end Replace; ------------------- -- Skip_To_Blank -- ------------------- procedure Skip_To_Blank (Type_Str : String; Index : in out Natural) is begin while Index <= Type_Str'Last and then Type_Str (Index) /= ' ' and then Type_Str (Index) /= ASCII.HT and then Type_Str (Index) /= ASCII.LF and then Type_Str (Index) /= ASCII.CR loop Index := Index + 1; end loop; end Skip_To_Blank; -------------- -- Is_Blank -- -------------- function Is_Blank (C : Character) return Boolean is begin return C = ' ' or else C = ASCII.LF or else C = ASCII.CR or else C = ASCII.HT; end Is_Blank; ------------------- -- Skip_To_Index -- ------------------- procedure Skip_To_Index (Buffer : String; Columns : out Visible_Column_Type; Index_In_Line : String_Index_Type; Index : in out String_Index_Type; Tab_Width : Positive := 8) is Start_Of_Line : constant String_Index_Type := Index; begin Columns := 1; loop exit when Index - Start_Of_Line + 1 >= Index_In_Line; if Natural (Index) <= Buffer'Last and then Buffer (Natural (Index)) = ASCII.HT then Columns := Columns + Visible_Column_Type (Tab_Width - ((Positive (Columns) - 1) mod Tab_Width)); else Columns := Columns + 1; end if; Index := String_Index_Type (UTF8_Next_Char (Buffer, Natural (Index))); end loop; end Skip_To_Index; ------------------- -- Skip_To_Index -- ------------------- procedure Skip_To_Index (Buffer : Unbounded_String; Columns : out Visible_Column_Type; Index_In_Line : String_Index_Type; Index : in out String_Index_Type; Tab_Width : Positive := 8) is Start_Of_Line : constant String_Index_Type := Index; begin Columns := 1; loop exit when Index - Start_Of_Line + 1 >= Index_In_Line; if Natural (Index) <= Length (Buffer) and then Element (Buffer, Natural (Index)) = ASCII.HT then Columns := Columns + Visible_Column_Type (Tab_Width - ((Positive (Columns) - 1) mod Tab_Width)); else Columns := Columns + 1; end if; Index := String_Index_Type (UTF8_Next_Char (Buffer, Natural (Index))); end loop; end Skip_To_Index; --------------- -- Tab_Width -- --------------- function Tab_Width return Positive is begin return 8; end Tab_Width; --------------- -- Next_Line -- --------------- procedure Next_Line (Buffer : String; P : Natural; Next : out Natural; Success : out Boolean) is begin for J in P .. Buffer'Last - 1 loop if Buffer (J) = ASCII.LF then Next := J + 1; Success := True; return; end if; end loop; Success := False; Next := Buffer'Last; end Next_Line; --------------------- -- Skip_Hexa_Digit -- --------------------- procedure Skip_Hexa_Digit (Type_Str : String; Index : in out Natural) is begin -- skips initial 0x if present if Index + 1 <= Type_Str'Last and then Type_Str (Index) = '0' and then Type_Str (Index + 1) = 'x' then Index := Index + 2; end if; while Index <= Type_Str'Last and then Is_Hexadecimal_Digit (Type_Str (Index)) loop Index := Index + 1; end loop; end Skip_Hexa_Digit; ------------------ -- Skip_To_Char -- ------------------ procedure Skip_To_Char (Type_Str : String; Index : in out Natural; Char : Character; Step : Integer := 1) is begin while Index <= Type_Str'Last and then Index >= Type_Str'First and then Type_Str (Index) /= Char loop Index := Index + Step; end loop; end Skip_To_Char; ------------------ -- Skip_To_Char -- ------------------ procedure Skip_To_Char (Type_Str : Unbounded_String; Index : in out Natural; Char : Character; Step : Integer := 1) is begin while Index <= Length (Type_Str) and then Index >= 1 and then Element (Type_Str, Index) /= Char loop Index := Index + Step; end loop; end Skip_To_Char; --------------- -- Parse_Num -- --------------- procedure Parse_Num (Type_Str : String; Index : in out Natural; Result : out Long_Integer) is Tmp_Index : constant Natural := Index; begin -- Recognize negative numbers as well if Type_Str (Index) = '-' then Index := Index + 1; end if; while Index <= Type_Str'Last and then Type_Str (Index) in '0' .. '9' loop Index := Index + 1; end loop; -- If at least one valid character was found, we have a number if Index > Tmp_Index then Result := Long_Integer'Value (Type_Str (Tmp_Index .. Index - 1)); else Result := 0; end if; exception when Constraint_Error => Result := -1; end Parse_Num; ---------------- -- Looking_At -- ---------------- function Looking_At (Type_Str : String; Index : Natural; Substring : String) return Boolean is begin return Index + Substring'Length - 1 <= Type_Str'Last and then Type_Str (Index .. Index + Substring'Length - 1) = Substring; end Looking_At; ---------------------- -- Parse_Cst_String -- ---------------------- procedure Parse_Cst_String (Type_Str : String; Index : in out Natural; Str : out String; Str_Last : out Natural; Backslash_Special : Boolean := True) is procedure Parse_Next_Char (Index : in out Natural; Char : out Character); -- Parse the character pointed to by Index, including special characters In_String : Boolean; --------------------- -- Parse_Next_Char -- --------------------- procedure Parse_Next_Char (Index : in out Natural; Char : out Character) is Int : Natural; begin -- Special characters are represented as ["00"] or ["""] -- Note that we can have '[" ' that represents the character -- '[' followed by the end of the string if Index + 4 <= Type_Str'Last and then Type_Str (Index) = '[' and then Type_Str (Index + 1) = '"' and then (Type_Str (Index + 2 .. Index + 4) = """""]" or else Type_Str (Index + 2) in '0' .. '9' or else Type_Str (Index + 2) in 'a' .. 'f') then if Type_Str (Index + 2) = '"' then Index := Index + 5; Char := '"'; else if Type_Str (Index + 2) in 'a' .. 'f' then Int := 16 * (Character'Pos (Type_Str (Index + 2)) - Character'Pos ('a') + 10); else Int := 16 * (Character'Pos (Type_Str (Index + 2)) - Character'Pos ('0')); end if; if Type_Str (Index + 3) in 'a' .. 'f' then Int := Int + Character'Pos (Type_Str (Index + 3)) - Character'Pos ('a') + 10; else Int := Int + Character'Pos (Type_Str (Index + 3)) - Character'Pos ('0'); end if; Char := Character'Val (Int); Index := Index + 6; end if; -- Else, a standard character else Char := Type_Str (Index); Index := Index + 1; end if; end Parse_Next_Char; S_Index : Natural := Str'First; Char : Character; Num : Long_Integer; Last : Natural; begin -- Parse_Cst_String if Str'Length = 0 then Last := Natural'Last; else Last := Str'Last; end if; In_String := Type_Str (Index) = '"'; if In_String then Index := Index + 1; end if; -- Note: this is a slightly complex loop, since a string might not -- appear as a single string in gdb, but can be made of multiple -- elements, including characters repeated a number of times, as in: -- "["af"]["c7"]", '["00"]' <repeats 12 times>, "BA" while S_Index <= Last and then Index <= Type_Str'Last and then Type_Str (Index) /= ASCII.LF loop case Type_Str (Index) is when '"' => -- Handling of Ada-style strings: A""double quote if In_String and then Index < Type_Str'Last and then Type_Str (Index + 1) = '"' then Index := Index + 2; Str (S_Index) := '"'; S_Index := S_Index + 1; else In_String := not In_String; Index := Index + 1; -- In cases like {field = 0x8048f88 "bar"}, we need to -- consider the string finished, but not for -- "bar", 'cd' <repeats 12 times> if not In_String and then Index <= Type_Str'Last and then Type_Str (Index) /= ' ' and then Type_Str (Index) /= ',' then Index := Index + 1; Str_Last := S_Index - 1; return; end if; end if; when ''' => if In_String then if Str'Length /= 0 then Str (S_Index) := '''; end if; S_Index := S_Index + 1; Index := Index + 1; else Index := Index + 1; -- skips initial ''' Parse_Next_Char (Index, Char); if Str'Length /= 0 then Str (S_Index) := Char; end if; Index := Index + 2; -- skips "' " at the end if Looking_At (Type_Str, Index, "<repeats ") then Index := Index + 9; Parse_Num (Type_Str, Index, Num); if Str'Length /= 0 then Str (S_Index .. S_Index + Integer (Num) - 1) := (others => Char); end if; S_Index := S_Index + Integer (Num); Index := Index + 7; -- skips " times>" else S_Index := S_Index + 1; end if; end if; when '\' => if Backslash_Special then if Str'Length /= 0 then Str (S_Index) := Type_Str (Index + 1); S_Index := S_Index + 1; end if; Index := Index + 2; else Str (S_Index) := Type_Str (Index); S_Index := S_Index + 1; Index := Index + 1; end if; when ' ' | ',' => if In_String then if Str'Length /= 0 then Str (S_Index) := ' '; end if; S_Index := S_Index + 1; -- ',' is still part of the string output only if it is -- followed by a constant string or character (repeats). -- Otherwise, ',' simply denotes the end of a struct field, -- as in "field3 = "ab", field4 = 1" elsif Type_Str (Index) = ',' and then (Index >= Type_Str'Last - 1 or else (Type_Str (Index + 2) /= ''' and then Type_Str (Index + 2) /= '"')) then Index := Index + 1; Str_Last := S_Index - 1; return; end if; Index := Index + 1; when others => Parse_Next_Char (Index, Char); if Str'Length /= 0 then Str (S_Index) := Char; end if; S_Index := S_Index + 1; end case; end loop; Index := Index + 1; Str_Last := S_Index - 1; end Parse_Cst_String; ----------------------- -- Skip_Simple_Value -- ----------------------- procedure Skip_Simple_Value (Type_Str : String; Index : in out Natural; Array_Item_Separator : Character := ','; End_Of_Array : Character := ')'; Repeat_Item_Start : Character := '<') is begin while Index <= Type_Str'Last and then Type_Str (Index) /= Array_Item_Separator and then Type_Str (Index) /= End_Of_Array and then Type_Str (Index) /= ASCII.LF -- always the end of a field and then Type_Str (Index) /= Repeat_Item_Start loop Index := Index + 1; end loop; end Skip_Simple_Value; --------------- -- Skip_Word -- --------------- procedure Skip_Word (Type_Str : String; Index : in out Natural; Step : Integer := 1) is Initial : constant Natural := Index; begin while Index <= Type_Str'Last and then Index >= Type_Str'First and then (Is_Alphanumeric (Type_Str (Index)) or else Type_Str (Index) = '_') loop Index := Index + Step; end loop; -- Move at least one character if Index = Initial then Index := Index + Step; end if; end Skip_Word; -------------------- -- Skip_CPP_Token -- -------------------- procedure Skip_CPP_Token (Type_Str : String; Index : in out Natural; Step : Integer := 1) is Initial : constant Natural := Index; begin while Index <= Type_Str'Last and then Index >= Type_Str'First and then (Is_Alphanumeric (Type_Str (Index)) or else Type_Str (Index) = '_' or else Type_Str (Index) = '.') loop Index := Index + Step; end loop; -- Move at least one character if Index = Initial then Index := Index + Step; end if; end Skip_CPP_Token; ------------ -- Reduce -- ------------ function Reduce (S : String; Max_Length : Positive := Positive'Last; Continuation : String := "...") return String is Result : String (S'Range); Len : Positive := Result'First; Blank : Boolean := False; Max : Natural; -- Max if the position of the last character to be returned Cut : Boolean := False; -- Cut set to true if string was cut before the end at Max characters Char : Natural := S'First; Next : Natural := Char; begin if Max_Length = Positive'Last then Max := Positive'Last; else Max := S'First + Max_Length - Continuation'Length - 1; end if; while Next <= S'Last loop Char := Next; Next := UTF8_Next_Char (S, Char); if Next > S'Last then Next := S'Last + 1; end if; if S (Char) = ASCII.LF or else S (Char) = ASCII.CR or else S (Char) = ASCII.HT or else S (Char) = ' ' then if not Blank then Result (Len) := ' '; Len := Len + 1; Blank := True; end if; else Blank := False; Result (Len .. Len + Next - Char - 1) := S (Char .. Next - 1); Len := Len + Next - Char; end if; if Len >= Max then Cut := True; exit; end if; end loop; if Cut then return Result (Result'First .. Len - 1) & Continuation; else return Result (Result'First .. Len - 1); end if; end Reduce; ------------ -- Krunch -- ------------ function Krunch (S : String; Max_String_Length : Positive := 20) return String is Ellipsis : constant Wide_Wide_Character := Wide_Wide_Character'Val (8230); -- UTF8 encoding for the ellipsis character (8230 in Decimal) Image : constant Wide_Wide_String := Decode (S); begin if Image'Length <= Max_String_Length then return S; end if; if Max_String_Length <= 3 then return Encode (Image (Image'First .. Image'First + Max_String_Length - 1)); else declare Half : constant Positive := (Max_String_Length - 1) / 2; Result : constant Wide_Wide_String := Image (Image'First .. Image'First + Half - 1) & Ellipsis & Image (Image'Last - Half + 1 .. Image'Last); begin return Encode (Result); end; end if; end Krunch; -------------- -- Strip_CR -- -------------- procedure Strip_CR (Text : in out String; Last : out Integer; CR_Found : out Boolean) is pragma Suppress (All_Checks); J : Natural := Text'First; begin CR_Found := False; if Text'Length = 0 then Last := 0; return; end if; loop -- Manual unrolling for efficiency exit when Text (J) = ASCII.CR or J = Text'Last; J := J + 1; exit when Text (J) = ASCII.CR or J = Text'Last; J := J + 1; exit when Text (J) = ASCII.CR or J = Text'Last; J := J + 1; end loop; if Text (J) /= ASCII.CR then Last := J; return; end if; CR_Found := True; Last := J - 1; for Index in J + 1 .. Text'Last loop if Text (Index) /= ASCII.CR then Last := Last + 1; Text (Last) := Text (Index); end if; end loop; end Strip_CR; ---------------------- -- Strip_CR_And_NUL -- ---------------------- procedure Strip_CR_And_NUL (Text : in out String; Last : out Integer; CR_Found : out Boolean; NUL_Found : out Boolean; Trailing_Space_Found : out Boolean) is pragma Suppress (All_Checks); Last_Is_Space : Boolean := False; J : Natural := Text'First; begin CR_Found := False; NUL_Found := False; Trailing_Space_Found := False; if Text'Length = 0 then Last := 0; return; end if; loop if Text (J) = ASCII.CR or else Text (J) = ASCII.NUL or else J = Text'Last then exit; elsif Text (J) = ASCII.LF then if Last_Is_Space then Trailing_Space_Found := True; Last_Is_Space := False; end if; elsif Text (J) = ASCII.HT or else Text (J) = ' ' then Last_Is_Space := True; else Last_Is_Space := False; end if; J := J + 1; end loop; case Text (J) is when ASCII.NUL | ASCII.CR => Last := J - 1; when others => Last := J; if Last_Is_Space then Trailing_Space_Found := True; end if; return; end case; for Index in J + 1 .. Text'Last loop case Text (Index) is when ASCII.NUL => NUL_Found := True; when ASCII.CR => CR_Found := True; when ASCII.HT | ' ' => Last_Is_Space := True; Last := Last + 1; Text (Last) := Text (Index); when ASCII.LF => if Last_Is_Space then Trailing_Space_Found := True; Last_Is_Space := False; end if; Last := Last + 1; Text (Last) := Text (Index); when others => Last_Is_Space := False; Last := Last + 1; Text (Last) := Text (Index); end case; end loop; if Last_Is_Space then Trailing_Space_Found := True; end if; end Strip_CR_And_NUL; ----------------------------- -- Strip_Ending_Linebreaks -- ----------------------------- function Strip_Ending_Linebreaks (Text : String) return String is begin -- Loop to make sure we have removed all of the ending CRs and LFs for J in reverse Text'Range loop if Text (J) /= ASCII.CR and then Text (J) /= ASCII.LF then return Text (Text'First .. J); end if; end loop; return ""; end Strip_Ending_Linebreaks; ---------------------- -- Do_Tab_Expansion -- ---------------------- function Do_Tab_Expansion (Text : String; Tab_Size : Integer) return String is Num_Tabs : Natural := 0; Col : Integer := 1; begin -- Count the number of tabs in the string for K in Text'Range loop if Text (K) = ASCII.HT then Num_Tabs := Num_Tabs + 1; end if; end loop; if Num_Tabs = 0 then return Text; else declare S : String (1 .. Num_Tabs * Tab_Size + Text'Length); S_Index : Integer := 1; Bound : Integer; begin for K in Text'Range loop case Text (K) is when ASCII.LF => S (S_Index) := Text (K); S_Index := S_Index + 1; Col := 1; when ASCII.HT => if Col mod Tab_Size /= 0 then Bound := (1 + Col / Tab_Size) * Tab_Size - Col + 1; S (S_Index .. S_Index + Bound - 1) := (others => ' '); S_Index := S_Index + Bound; Col := Col + Bound; else S (S_Index) := ' '; S_Index := S_Index + 1; Col := Col + 1; end if; when others => S (S_Index) := Text (K); S_Index := S_Index + 1; Col := Col + 1; end case; end loop; return S (S'First .. S_Index - 1); end; end if; end Do_Tab_Expansion; ------------------ -- Strip_Quotes -- ------------------ function Strip_Quotes (S : String) return String is S_First : Integer := S'First; S_Last : Integer := S'Last; begin if S = "" then return ""; end if; while S_First <= S'Last and then (S (S_First) = ' ' or else S (S_First) = '"') loop S_First := S_First + 1; end loop; while S_Last >= S'First and then (S (S_Last) = ' ' or else S (S_Last) = '"') loop S_Last := S_Last - 1; end loop; return S (S_First .. S_Last); end Strip_Quotes; ----------- -- Image -- ----------- function Image (N : Integer) return String is begin return GNATCOLL.Utils.Image (N, Min_Width => 1); end Image; ---------------------- -- Number_Of_Digits -- ---------------------- function Number_Of_Digits (N : Integer) return Natural is begin case N is when 0 .. 9 => return 1; when 10 .. 99 => return 2; when 100 .. 999 => return 3; when 1_000 .. 9_999 => return 4; when 10_000 .. 99_999 => return 5; when others => return Image (N)'Length; end case; end Number_Of_Digits; ---------------------- -- Is_Entity_Letter -- ---------------------- function Is_Entity_Letter (Char : Wide_Wide_Character) return Boolean is begin return Char = '_' or else Is_Alphanumeric (Char); end Is_Entity_Letter; ------------------------ -- Is_Operator_Letter -- ------------------------ function Is_Operator_Letter (Char : Wide_Wide_Character) return Boolean is begin case Char is when '<' | '=' | '>' | '+' | '-' | '*' | '/' => return True; when others => return False; end case; end Is_Operator_Letter; function Is_File_Letter (Char : Wide_Wide_Character) return Boolean is begin if Is_Control (Char) then return False; end if; case Char is when '<' | '/' | '\' | '>' | '"' | ' ' => return False; when others => return True; end case; end Is_File_Letter; ----------------- -- Copy_String -- ----------------- procedure Copy_String (Item : Interfaces.C.Strings.chars_ptr; Str : out String; Len : Natural) is procedure Strncpy (Dest : out String; Src : Interfaces.C.Strings.chars_ptr; Len : Interfaces.C.size_t); pragma Import (C, Strncpy, "strncpy"); begin Strncpy (Str, Item, Interfaces.C.size_t (Len)); end Copy_String; ----------- -- Clone -- ----------- function Clone (List : GNAT.Strings.String_List) return GNAT.Strings.String_List is L : String_List (List'Range); begin for J in List'Range loop L (J) := new String'(List (J).all); end loop; return L; end Clone; ------------ -- Append -- ------------ procedure Append (List : in out GNAT.Strings.String_List_Access; Item : String) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (String_List, String_List_Access); L : String_List_Access := List; begin if List = null then List := new String_List'(1 .. 1 => new String'(Item)); else List := new String_List (L'First .. L'Last + 1); List (L'Range) := L.all; List (List'Last) := new String'(Item); Unchecked_Free (L); end if; end Append; ------------ -- Append -- ------------ procedure Append (List : in out GNAT.Strings.String_List_Access; List2 : GNAT.Strings.String_List) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (String_List, String_List_Access); L : String_List_Access := List; begin if List = null then List := new String_List (1 .. List2'Length); else List := new String_List (L'First .. L'Last + List2'Length); List (L'Range) := L.all; Unchecked_Free (L); end if; List (List'Last - List2'Length + 1 .. List'Last) := List2; end Append; ---------------- -- Safe_Value -- ---------------- function Safe_Value (S : String; Default : Integer := 1) return Integer is begin if S = "" then return Default; else return Integer'Value (S); end if; exception when Constraint_Error => return Default; end Safe_Value; ------------- -- Protect -- ------------- function Protect (S : String; Protect_Quotes : Boolean := True; Protect_Spaces : Boolean := False; Protect_Backslashes : Boolean := True) return String is S2 : String (1 .. S'Length * 2); Index : Natural := 1; begin for J in S'Range loop if (Protect_Quotes and then S (J) = '"') or else (Protect_Backslashes and then S (J) = '\') or else (Protect_Spaces and then S (J) = ' ') then S2 (Index .. Index + 1) := '\' & S (J); Index := Index + 2; else S2 (Index) := S (J); Index := Index + 1; end if; end loop; return S2 (1 .. Index - 1); end Protect; --------------- -- Unprotect -- --------------- function Unprotect (S : String) return String is begin return GNATCOLL.Scripts.Utils.Unprotect (S); end Unprotect; ------------- -- Unquote -- ------------- function Unquote (S : String) return String is begin if S'Length > 1 and then S (S'First) = '"' and then S (S'Last) = '"' then return S (S'First + 1 .. S'Last - 1); else return S; end if; end Unquote; --------------- -- Hex_Value -- --------------- function Hex_Value (Hex : String) return Natural is begin return Integer'Value ("16#" & Hex & "#"); end Hex_Value; ------------ -- Decode -- ------------ function URL_Decode (URL : String) return String is Res : String (1 .. URL'Length); K : Natural := 0; J : Positive := URL'First; begin if URL = "" then return ""; end if; loop K := K + 1; if URL (J) = '%' and then J + 2 <= URL'Last and then Is_Hexadecimal_Digit (URL (J + 1)) and then Is_Hexadecimal_Digit (URL (J + 2)) then Res (K) := Character'Val (Hex_Value (URL (J + 1 .. J + 2))); J := J + 2; else Res (K) := URL (J); end if; J := J + 1; exit when J > URL'Last; end loop; return Res (1 .. K); end URL_Decode; ------------ -- Revert -- ------------ function Revert (S : String; Separator : String := ".") return String is Result : String (S'Range); Index : Natural := S'First; Last : Natural := S'Last; Len, J : Integer; First : constant Natural := S'First + Separator'Length - 1; begin J := S'Last; loop exit when J < First; if S (J - Separator'Length + 1 .. J) = Separator then Len := Last - J; Result (Index .. Index + Len - 1) := S (J + 1 .. Last); J := J - Separator'Length + 1; Last := J - 1; Index := Index + Len; Result (Index .. Index + Separator'Length - 1) := Separator; Index := Index + Separator'Length; end if; J := J - 1; end loop; if Last >= S'First then Result (Index .. Result'Last) := S (S'First .. Last); end if; return Result; end Revert; ------------------------------ -- Strip_Single_Underscores -- ------------------------------ function Strip_Single_Underscores (S : String) return String is S2 : String := S; J2 : Natural := S'First; begin for J in S'Range loop S2 (J2) := S (J); if S (J) /= '_' or else (J > S'First and then S (J - 1) = '_') then J2 := J2 + 1; end if; end loop; return S2 (S2'First .. J2 - 1); end Strip_Single_Underscores; ------------- -- Compare -- ------------- function Compare (A, B : String) return Integer is begin if A < B then return -1; elsif A > B then return 1; else return 0; end if; end Compare; function Compare (A, B : Integer) return Integer is begin if A < B then return -1; elsif A > B then return 1; else return 0; end if; end Compare; ---------- -- Hash -- ---------- function Hash (Key : String) return Header_Num is Tmp : constant Ada.Containers.Hash_Type := Ada.Strings.Hash (Key); begin return Header_Num'First + Header_Num'Base (Tmp mod Header_Num'Range_Length); end Hash; --------------------------- -- Case_Insensitive_Hash -- --------------------------- function Case_Insensitive_Hash (Key : String) return Header_Num is Tmp : constant Ada.Containers.Hash_Type := Ada.Strings.Hash_Case_Insensitive (Key); begin return Header_Num'First + Header_Num'Base (Tmp mod Header_Num'Range_Length); end Case_Insensitive_Hash; --------------------------- -- Has_Include_Directive -- --------------------------- function Has_Include_Directive (Str : String) return Boolean is begin return Str'Length > 11 and then Str (Str'First) = '#' and then Ada.Strings.Fixed.Index (Str (Str'First + 1 .. Str'Last), "include") /= 0; end Has_Include_Directive; end String_Utils;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Characters.Handling; -- with Ada.Characters.Latin_1; package body Support.Strings is package Real_IO is new Ada.Text_IO.Float_IO (Real); use Real_IO; package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); use Integer_IO; function str (source : Real; width : Integer := 10) return string is result : string (1..width) := (others => Ada.Characters.Latin_1.NUL); begin -- 4932 = largest exponent for 18 dec. digits -- so may need up to 4 digits in the exponent + 1 for the sign = 5 if source = 0.0 then Put (result,source,width-7,3); elsif abs (source) < 1.0 then if abs (source) >= 1.0e-99 then Put (result,source,width-7,3); elsif abs (source) >= 1.0e-999 then Put (result,source,width-8,4); else Put (result,source,width-9,5); end if; else if abs (source) < 1.0e100 then Put (result,source,width-7,3); elsif abs (source) < 1.0e1000 then Put (result,source,width-8,4); else Put (result,source,width-9,5); end if; end if; return result; end str; function str (source : Integer; width : Integer := 0) return string is result : string (1..width) := (others => Ada.Characters.Latin_1.NUL); wide_result : string (1..Integer'width) := (others => Ada.Characters.Latin_1.NUL); begin if width = 0 then Put (wide_result,source); return trim(wide_result,left); -- flush left, returns a string just large enough to contain the integer else Put (result,source); return result; end if; end str; function str (source : string; width : integer; pad : Character := Ada.Characters.Latin_1.NUL) return string is len_src : integer; tmp_out : string (1..width) := (others => pad); tmp_src : string := cut (source); begin len_src := get_strlen (tmp_src); if len_src <= width then -- source fits in the window tmp_out (1..len_src) := tmp_src (tmp_src'first..tmp_src'first+len_src-1); return tmp_out; else -- source too wide for the window return tmp_src (tmp_src'first..tmp_src'first+width-1); end if; end str; function str (source : character; width : integer := 1) return string is tmp_str : String (1..width) := (others => Ada.Characters.Latin_1.NUL); begin tmp_str (1) := source; return tmp_str; end str; function str (source : in string) return string is begin return cut(source); -- return the leading part of the string, trailing null's are tiresome end str; function fill_str (the_num : Integer; -- the number to print width : Integer; -- width of the printed number fill_chr : Character := ' ') -- the fill character return String is the_str : String (1 .. width); begin writestr (the_str, str (the_num, width)); for i in 1 .. width loop if the_str (i) = ' ' then the_str (i) := fill_chr; else exit; end if; end loop; return the_str; end fill_str; function spc (width : integer) return string is spaces : constant string (1..width) := (others => ' '); begin return spaces; end spc; function cut (the_line : string) return string is result : constant string := the_line; begin return result(result'first..result'first+get_strlen(result)-1); end cut; procedure null_string (source : in out string) is begin source := (others => Ada.Characters.Latin_1.NUL); end null_string; function get_strlen (source : in string) return integer is length : Integer := 0; begin for i in source'range loop exit when source(i) = Ada.Characters.Latin_1.NUL; length := i-source'first+1; end loop; return length; end get_strlen; procedure set_strlen (source : in out string; length : integer) is begin for i in source'first+length..source'last loop source(i) := Ada.Characters.Latin_1.NUL; end loop; end set_strlen; function make_str (n : Integer; m : Integer) return String is the_str : String (1 .. m); begin writestr (the_str, str (n, m)); for i in 1 .. m loop if the_str (i) = ' ' then the_str (i) := '0'; end if; end loop; return the_str; end make_str; procedure readstr (source : string; target : out integer) is last : integer; begin get (source,target,last); end readstr; procedure readstr (source : string; target : out real) is last : integer; begin get (source,target,last); end readstr; procedure writestr (target : out string; source : integer) is begin put (target,source); end writestr; procedure writestr (target : out string; source : real) is begin put (target,source); end writestr; procedure writestr (target : out string; source : string) is len_substr : Integer; len_source : Integer; len_target : Integer; beg_source : Integer; end_source : Integer; beg_target : Integer; end_target : Integer; begin null_string (target); len_source := get_strlen (source); -- source length minus trailing null chars len_target := target'length; -- target lenght, maximum lenght of final string len_substr := min (len_source,len_target); beg_source := source'first; end_source := source'first+len_substr-1; beg_target := target'first; end_target := target'first+len_substr-1; target (beg_target..end_target) := source (beg_source..end_source); end writestr; function centre (the_string : String; the_length : Integer; the_offset : Integer := 0) return String is the_string_length : Integer; the_result : String := spc(the_length); start, finish : Integer; left_space, right_space : Integer; begin the_string_length := get_strlen (the_string); left_space := max (0,(the_length-the_string_length)/2); right_space := max (0,the_length - left_space - the_string_length); left_space := max (0,min(left_space+the_offset,the_length-the_string_length)); right_space := max (0,min(right_space-the_offset,the_length-the_string_length)); start := max (1,min(the_length,left_space+1)); finish := max (1,min(the_length,the_length-right_space)); for i in start..finish loop the_result (i) := the_string (i-start+1); end loop; return the_result; end centre; ------------------------------------------------------------------------------ -- LCB: my code is faster than the Ada.Strings.Fixed.Trim code -- see the examples in tests/strings/lcb02.adb ------------------------------------------------------------------------------ procedure trim_head (the_string : in out String) is j : Integer; found : Boolean; the_string_len : Integer; the_beg, the_end : Integer; tmp_string : String := the_string; begin -- delete leading whitespace found := False; the_string_len := get_strlen(the_string); the_beg := the_string'first; the_end := the_beg + the_string_len-1; for i in the_beg .. the_end loop if the_string (i) /= ' ' then j := i; found := True; exit; end if; end loop; if found then writestr (tmp_string,the_string(j..the_end)); -- the_string has non-empty content else null_string (tmp_string); -- the_string consists entirely of white space end if; the_string := tmp_string; -- writestr(the_string,Ada.Strings.Fixed.trim (cut(the_string),left)); end trim_head; procedure trim_tail (the_string : in out String) is j : Integer; found : Boolean; the_string_len : Integer; the_beg, the_end : Integer; tmp_string : String := the_string; begin -- delete trailing whitespace found := False; null_string (tmp_string); the_string_len := get_strlen(the_string); the_beg := the_string'first; the_end := the_beg + the_string_len-1; for i in reverse the_beg .. the_end loop if the_string (i) /= ' ' then j := i; found := True; exit; end if; end loop; if found then set_strlen (the_string,j); -- the_string has non-empty content else null_string (the_string); -- the_string consists entirely of white space end if; -- writestr(the_string,Ada.Strings.Fixed.trim (cut(the_string),right)); end trim_tail; function trim_head (the_string : String) return String is tmp_string : String := the_string; begin trim_head (tmp_string); return cut (tmp_string); end trim_head; function trim_tail (the_string : String) return String is tmp_string : String := the_string; begin trim_tail (tmp_string); return cut (tmp_string); end trim_tail; procedure trim (the_string : in out String) is begin trim_head (the_string); trim_tail (the_string); -- writestr(the_string,Ada.Strings.Fixed.trim (cut(the_string),both)); end trim; function trim (the_string : String) return String is tmp_string : String := the_string; begin trim (tmp_string); return cut (tmp_string); end trim; function lower_case (source : String) return String is begin return Ada.Characters.Handling.To_Lower (source); end lower_case; function upper_case (source : String) return String is begin return Ada.Characters.Handling.To_Upper (source); end upper_case; end Support.Strings;
with Unicode_Strings; use Unicode_Strings; with Ada.Command_Line; with Ada.Task_Termination; with Ada.Task_Identification; with Configuration; with Logging; with Qweyboard.Emulation; with Input_Backend; with Output_Backend; procedure Main is use Logging; Settings : Configuration.Settings; begin Ada.Task_Termination.Set_Specific_Handler (Ada.Task_Identification.Current_Task, Logging.Logging_Termination_Handler.Log_Termination_Cause'Access); Ada.Task_Termination.Set_Dependents_Fallback_Handler (Logging.Logging_Termination_Handler.Log_Termination_Cause'Access); Configuration.Get_Settings (Settings); Log.Set_Verbosity (Settings.Log_Level); Log.Chat ("[Main] Got settings and set log verbosity"); Log.Chat ("[Main] Loading language"); Configuration.Load_Language (Settings); -- Then kick off the emulation! --Qweyboard.Emulation.Process.Ready_Wait; Log.Chat ("[Main] Emulation started"); -- Configure softboard --Qweyboard.Emulation.Process.Configure (Settings); Log.Chat ("[Main] Emulation configured"); -- First wait for the output backend to be ready Output_Backend.Output.Ready_Wait; Log.Chat ("[Main] Output backend ready"); -- Then wait for input backend to be ready Input_Backend.Input.Ready_Wait; Log.Chat ("[Main] Input backend ready"); exception when Configuration.ARGUMENTS_ERROR => Log.Error ("Usage: " & W (Ada.Command_Line.Command_Name) & " [OPTION]"); Log.Error (" "); Log.Error ("[OPTION] is any combination of the following options: "); Log.Error (" "); Log.Error (" -l <language file> : Modifies the standard layout with the "); Log.Error (" key mappings indicated in the specified "); Log.Error (" language file. "); Log.Error (" "); Log.Error (" -t <milliseconds> : Set the timeout for what counts as one "); Log.Error (" stroke. If you want 0, NKRO is strongly "); Log.Error (" recommended. Default value is 500, which "); Log.Error (" is probably way too high. "); Log.Error (" "); Log.Error (" -v,-vv,-vvv : Sets the log level of the software. If you "); Log.Error (" want to know what goes on inside, this is "); Log.Error (" where to poke... "); Ada.Command_Line.Set_Exit_Status (1); end Main;
package body Test_Unknown.Write is File_Name : constant String := "tmp/test-unknown-write.sf"; procedure Initialize (T : in out Test) is begin Set_Name (T, "Test_Unknown.Write"); Ahven.Framework.Add_Test_Routine (T, Check_Types'Access, "unknownSubtypes read written"); Ahven.Framework.Add_Test_Routine (T, Check_Fields_A'Access, "a: all fields are self-references"); Ahven.Framework.Add_Test_Routine (T, Check_Fields_C'Access, "c: all fields are self-references"); end Initialize; procedure Set_Up (T : in out Test) is State : access Skill_State := new Skill_State; begin Skill.Read (State, "resources/localBasePoolStartIndex.sf"); Skill.Write (State, File_Name); end Set_Up; procedure Tear_Down (T : in out Test) is begin Ada.Directories.Delete_File (File_Name); end Tear_Down; procedure Check_Types (T : in out Ahven.Framework.Test_Case'Class) is use Ada.Characters.Handling; use Ada.Strings.Fixed; use Ada.Tags; State : access Skill_State := new Skill_State; begin Skill.Read (State, File_Name); declare Types : constant String := "aaaaaaaaaaacc"; begin for I in Types'Range loop declare Object : Skill_Type'Class := Get_A (State, I).all; C : Character := To_Lower (Expanded_Name (Object'Tag)(9)); begin Ahven.Assert (Types (I) = C, "index " & Trim (I'Img, Ada.Strings.Left)); end; end loop; end; end Check_Types; procedure Check_Fields_A (T : in out Ahven.Framework.Test_Case'Class) is use Ada.Strings.Fixed; State : access Skill_State := new Skill_State; begin Skill.Read (State, File_Name); for I in 1 .. As_Size (State) loop declare X : A_Type_Access := Get_A (State, I); begin Ahven.Assert (X = X.Get_A, "index " & Trim (I'Img, Ada.Strings.Left)); end; end loop; end Check_Fields_A; procedure Check_Fields_C (T : in out Ahven.Framework.Test_Case'Class) is use Ada.Strings.Fixed; State : access Skill_State := new Skill_State; begin Skill.Read (State, File_Name); for I in 1 .. Cs_Size (State) loop declare X : C_Type_Access := Get_C (State, I); begin Ahven.Assert (X = X.Get_C, "index " & Trim (I'Img, Ada.Strings.Left)); end; end loop; end Check_Fields_C; end Test_Unknown.Write;
-- C47002C.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT VALUES BELONGING TO EACH CLASS OF TYPE CAN BE WRITTEN AS -- THE OPERANDS OF QUALIFIED EXPRESSIONS. -- THIS TEST IS FOR ARRAY, RECORD, AND ACCESS TYPES. -- RJW 7/23/86 WITH REPORT; USE REPORT; PROCEDURE C47002C IS BEGIN TEST( "C47002C", "CHECK THAT VALUES HAVING ARRAY, RECORD, AND " & "ACCESS TYPES CAN BE WRITTEN AS THE OPERANDS " & "OF QUALIFIED EXPRESSIONS" ); DECLARE -- ARRAY TYPES. TYPE ARR IS ARRAY (POSITIVE RANGE <>) OF INTEGER; SUBTYPE ARR1 IS ARR (1 .. 1); SUBTYPE ARR5 IS ARR (1 .. 5); TYPE NARR IS NEW ARR; SUBTYPE NARR2 IS NARR (2 .. 2); TYPE TARR IS ARRAY (NATURAL RANGE <>, NATURAL RANGE <>) OF INTEGER; SUBTYPE TARR15 IS TARR (1 .. 1, 1 .. 5); SUBTYPE TARR51 IS TARR (1 .. 5, 1 .. 1); TYPE NTARR IS NEW TARR; SUBTYPE NTARR26 IS NTARR (2 .. 6, 2 .. 6); FUNCTION F (X : ARR) RETURN ARR IS BEGIN RETURN X; END; FUNCTION F (X : NARR) RETURN NARR IS BEGIN RETURN X; END; FUNCTION F (X : TARR) RETURN TARR IS BEGIN RETURN X; END; FUNCTION F (X : NTARR) RETURN NTARR IS BEGIN RETURN X; END; BEGIN IF F (ARR1'(OTHERS => 0))'LAST /= 1 THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE ARR1" ); END IF; IF F (ARR5'(OTHERS => 0))'LAST /= 5 THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE ARR5" ); END IF; IF F (NARR2'(OTHERS => 0))'FIRST /= 2 OR F (NARR2'(OTHERS => 0))'LAST /= 2 THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE NARR2" ); END IF; IF F (TARR15'(OTHERS => (OTHERS => 0)))'LAST /= 1 OR F (TARR15'(OTHERS => (OTHERS => 0)))'LAST (2) /= 5 THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE TARR15" ); END IF; IF F (TARR51'(OTHERS => (OTHERS => 0)))'LAST /= 5 OR F (TARR51'(OTHERS => (OTHERS => 0)))'LAST (2) /= 1 THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE TARR51" ); END IF; IF F (NTARR26'(OTHERS => (OTHERS => 0)))'FIRST /= 2 OR F (NTARR26'(OTHERS => (OTHERS => 0)))'LAST /= 6 OR F (NTARR26'(OTHERS => (OTHERS => 0)))'FIRST (2) /= 2 OR F (NTARR26'(OTHERS => (OTHERS => 0)))'LAST (2) /= 6 THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE NTARR26" ); END IF; END; DECLARE -- RECORD TYPES. TYPE GENDER IS (MALE, FEMALE, NEUTER); TYPE MAN IS RECORD AGE : POSITIVE; END RECORD; TYPE WOMAN IS RECORD AGE : POSITIVE; END RECORD; TYPE ANDROID IS NEW MAN; FUNCTION F (X: WOMAN) RETURN GENDER IS BEGIN RETURN FEMALE; END F; FUNCTION F (X: MAN) RETURN GENDER IS BEGIN RETURN MALE; END F; FUNCTION F (X : ANDROID) RETURN GENDER IS BEGIN RETURN NEUTER; END F; BEGIN IF F (MAN'(AGE => 23)) /= MALE THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE MAN" ); END IF; IF F (WOMAN'(AGE => 38)) /= FEMALE THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE WOMAN" ); END IF; IF F (ANDROID'(AGE => 2001)) /= NEUTER THEN FAILED ( "INCORRECT RESULTS FOR TYPE ANDRIOD" ); END IF; END; DECLARE -- ACCESS TYPES. TYPE CODE IS (OLD, BRANDNEW, WRECK); TYPE CAR (D : CODE) IS RECORD NULL; END RECORD; TYPE KEY IS ACCESS CAR; TYPE KEY_OLD IS ACCESS CAR (OLD); KO : KEY_OLD := NEW CAR'(D => OLD); TYPE KEY_WRECK IS ACCESS CAR (WRECK); TYPE KEY_CARD IS NEW KEY; KC : KEY_CARD := NEW CAR'(D => BRANDNEW); FUNCTION F (X : KEY_OLD) RETURN CODE IS BEGIN RETURN OLD; END F; FUNCTION F (X : KEY_WRECK) RETURN CODE IS BEGIN RETURN WRECK; END F; FUNCTION F (X : KEY_CARD) RETURN CODE IS BEGIN RETURN BRANDNEW; END F; BEGIN IF KEY_OLD'(KO) /= KO THEN FAILED ( "INCORRECT RESULTS FOR TYPE KEY_OLD - 1" ); END IF; IF KEY_CARD'(KC) /= KC THEN FAILED ( "INCORRECT RESULTS FOR TYPE KEY_CARD - 1" ); END IF; IF F (KEY_OLD'(NULL)) /= OLD THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE KEY_OLD - 2" ); END IF; IF F (KEY_WRECK'(NULL)) /= WRECK THEN FAILED ( "INCORRECT RESULTS FOR SUBTYPE KEY_WRECK" ); END IF; IF F (KEY_CARD'(NULL)) /= BRANDNEW THEN FAILED ( "INCORRECT RESULTS FOR TYPE KEY_CARD - 2" ); END IF; END; RESULT; END C47002C;
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Directories; with Ada.Hierarchical_File_Names; with Ada.IO_Exceptions; with Ada.Streams.Stream_IO; with Tabula.Users.Load; with Tabula.Users.Save; package body Tabula.Users.Lists is use type Ada.Strings.Unbounded.Unbounded_String; procedure Load_Users_Log (List : in out User_List) is begin if not List.Log_Read then begin declare File : Ada.Streams.Stream_IO.File_Type := Ada.Streams.Stream_IO.Open ( Ada.Streams.Stream_IO.In_File, Name => List.Log_File_Name.all); begin Users_Log.Map'Read (Ada.Streams.Stream_IO.Stream (File), List.Log); Ada.Streams.Stream_IO.Close (File); end; exception when Ada.IO_Exceptions.Name_Error => null; end; List.Log_Read := True; end if; end Load_Users_Log; procedure Add_To_Users_Log ( List : in out User_List; Id : in String; Remote_Addr : in String; Remote_Host : in String; Now : in Ada.Calendar.Time) is Item : User_Log_Item := (+Id, +Remote_Addr, +Remote_Host); begin Load_Users_Log (List); Users_Log.Include (List.Log, Item, Now); -- create the directory declare Dir : constant String := Ada.Hierarchical_File_Names.Unchecked_Containing_Directory ( List.Log_File_Name.all); begin if Dir'Length /= 0 then Ada.Directories.Create_Path (Dir); end if; end; -- write the file declare File : Ada.Streams.Stream_IO.File_Type := Ada.Streams.Stream_IO.Create (Name => List.Log_File_Name.all); begin Users_Log.Map'Write (Ada.Streams.Stream_IO.Stream (File), List.Log); Ada.Streams.Stream_IO.Close (File); end; end Add_To_Users_Log; Upper_Subdirectory_Name : constant String := "+A"; function User_Full_Name ( Directory : String; Id : String; Only_Existing : Boolean := False) return String is Lower_Name : constant String := Ada.Hierarchical_File_Names.Compose ( Directory => Directory, Relative_Name => Id); begin if Ada.Directories.Exists (Lower_Name) then return Lower_Name; else declare Upper_Directory : constant String := Ada.Hierarchical_File_Names.Compose ( Directory => Directory, Relative_Name => Upper_Subdirectory_Name); Upper_Name : constant String := Ada.Hierarchical_File_Names.Compose ( Directory => Upper_Directory, Relative_Name => Id); begin if Ada.Directories.Exists (Upper_Name) then return Upper_Name; else if Only_Existing then raise Ada.IO_Exceptions.Name_Error; end if; if Id (Id'First) in 'A' .. 'Z' then return Upper_Name; else return Lower_Name; end if; end if; end; end if; end User_Full_Name; -- implementation function Create ( Directory : not null Static_String_Access; Log_File_Name : not null Static_String_Access) return User_List is begin return ( Directory => Directory, Log_File_Name => Log_File_Name, Log_Read => False, Log => Users_Log.Empty_Map); end Create; function Exists (List : User_List; Id : String) return Boolean is begin declare Dummy_File_Name : constant String := User_Full_Name (List.Directory.all, Id, Only_Existing => True); begin return True; end; exception when Ada.IO_Exceptions.Name_Error => return False; end Exists; procedure Query ( List : in out User_List; Id : in String; Password : in String; Remote_Addr : in String; Remote_Host : in String; Now : in Ada.Calendar.Time; Info : out User_Info; State : out User_State) is begin if Id'Length = 0 then State := Log_Off; elsif not Exists (List, Id) then State := Unknown; else Load (User_Full_Name (List.Directory.all, Id), Info); if Info.Password /= Digest (Password) or else not Info.Renamed.Is_Null then State := Invalid; else State := Valid; if Id /= Administrator then if not Info.No_Log then Add_To_Users_Log ( List, Id => Id, Remote_Addr => Remote_Addr, Remote_Host => Remote_Host, Now => Now); else Add_To_Users_Log ( List, Id => Id, Remote_Addr => "", Remote_Host => "", Now => Now); -- log only time end if; end if; end if; end if; end Query; procedure New_User ( List : in out User_List; Id : in String; Password : in String; Remote_Addr : in String; Remote_Host : in String; Now : in Ada.Calendar.Time; Result : out Boolean) is begin if Exists (List, Id) then Result := False; else declare Info : User_Info := ( Password => Digest (Password), Creation_Remote_Addr => +Remote_Addr, Creation_Remote_Host => +Remote_Host, Creation_Time => Now, Last_Remote_Addr => +Remote_Addr, Last_Remote_Host => +Remote_Host, Last_Time => Now, Ignore_Request => False, Disallow_New_Village => False, No_Log => False, Renamed => Ada.Strings.Unbounded.Null_Unbounded_String); Full_Name : constant String := User_Full_Name (List.Directory.all, Id); begin -- create the directory declare Dir : constant String := Ada.Hierarchical_File_Names.Unchecked_Containing_Directory (Full_Name); begin if Dir'Length /= 0 then Ada.Directories.Create_Path (Dir); end if; end; -- save the file Save (Full_Name, Info); Result := True; end; end if; exception when Ada.IO_Exceptions.Name_Error => Result := False; end New_User; procedure Update ( List : in out User_List; Id : in String; Remote_Addr : in String; Remote_Host : in String; Now : in Ada.Calendar.Time; Info : in out User_Info) is begin Info.Last_Remote_Addr := +Remote_Addr; Info.Last_Remote_Host := +Remote_Host; Info.Last_Time := Now; Save (User_Full_Name (List.Directory.all, Id), Info); end Update; function All_Users (List : User_List) return User_Info_Maps.Map is procedure Add (Result : in out User_Info_Maps.Map; Directory : in String) is Search : aliased Ada.Directories.Search_Type; begin Ada.Directories.Start_Search ( Search, Directory, "*", Filter => (Ada.Directories.Ordinary_File => True, others => False)); while Ada.Directories.More_Entries(Search) loop declare File : Ada.Directories.Directory_Entry_Type renames Ada.Directories.Look_Next_Entry (Search); Id : String := Ada.Directories.Simple_Name (File); begin if Id (Id'First) /= '.' then -- excluding dot file declare Info : User_Info; begin Load (User_Full_Name (List.Directory.all, Id), Info); User_Info_Maps.Include (Result, Id, Info); end; end if; end; Ada.Directories.Skip_Next_Entry (Search); end loop; Ada.Directories.End_Search(Search); end Add; begin return Result : User_Info_Maps.Map do Add (Result, List.Directory.all); declare Upper_Directory : constant String := Ada.Hierarchical_File_Names.Compose ( Directory => List.Directory.all, Relative_Name => Upper_Subdirectory_Name); begin if Ada.Directories.Exists (Upper_Directory) then Add (Result, Upper_Directory); end if; end; end return; end All_Users; procedure Muramura_Count ( List : in out User_List; Now : Ada.Calendar.Time; Muramura_Duration : Duration; Result : out Natural) is Muramura_Set : Users_Log.Map; begin Load_Users_Log (List); for I in List.Log.Iterate loop if Now - Users_Log.Element (I) <= Muramura_Duration then declare Item : User_Log_Item := (Users_Log.Key (I).Id, Ada.Strings.Unbounded.Null_Unbounded_String, Ada.Strings.Unbounded.Null_Unbounded_String); begin Users_Log.Include (Muramura_Set, Item, Now); end; end if; end loop; Result := Muramura_Set.Length; end Muramura_Count; function "<" (Left, Right : User_Log_Item) return Boolean is begin if Left.Id < Right.Id then return True; elsif Left.Id > Right.Id then return False; elsif Left.Remote_Addr < Right.Remote_Addr then return True; elsif Left.Remote_Addr > Right.Remote_Addr then return False; else return Left.Remote_Host < Right.Remote_Host; end if; end "<"; procedure Iterate_Log ( List : in out User_List; Process : not null access procedure ( Id : in String; Remote_Addr : in String; Remote_Host : in String; Time : in Ada.Calendar.Time)) is begin Load_Users_Log (List); for I in List.Log.Iterate loop declare Key : User_Log_Item renames Users_Log.Key (I); begin Process ( Id => Key.Id.Constant_Reference, Remote_Addr => Key.Remote_Addr.Constant_Reference, Remote_Host => Key.Remote_Host.Constant_Reference, Time => List.Log.Constant_Reference (I)); end; end loop; end Iterate_Log; end Tabula.Users.Lists;
with GESTE; package Player is procedure Move (Pt : GESTE.Pix_Point); function Position return GESTE.Pix_Point; procedure Update; procedure Jump; procedure Move_Left; procedure Move_Right; end Player;
with Interfaces.C.Strings; use Interfaces.C.Strings; package Animals is -- ----------------------------------------------------------------------- type Carnivore is limited interface; function Number_Of_Teeth (X : Carnivore) return Natural is abstract; pragma Convention (CPP, Number_Of_Teeth); -- Required by AI-430 -- ----------------------------------------------------------------------- type Domestic is limited interface; procedure Set_Owner (X : in out Domestic; Name : Chars_Ptr) is abstract; pragma Convention (CPP, Set_Owner); -- ----------------------------------------------------------------------- type Animal is tagged limited record Age : Natural := 0; end record; pragma CPP_Class (Animal); procedure Set_Age (X : in out Animal; Age : Natural); pragma Import (CPP, Set_Age); function Age (X : Animal) return Natural; pragma Import (CPP, Age); -- ----------------------------------------------------------------------- type Dog is new Animal and Carnivore and Domestic with record Tooth_Count : Natural; Owner : String (1 .. 30); end record; pragma CPP_Class (Dog); function Number_Of_Teeth (A : Dog) return Natural; pragma Import (CPP, Number_Of_Teeth); procedure Set_Owner (A : in out Dog; Name : Chars_Ptr); pragma Import (CPP, Set_Owner); function New_Dog return Dog'Class; pragma CPP_Constructor (New_Dog); pragma Import (CPP, New_Dog, "_ZN3DogC2Ev"); -- ----------------------------------------------------------------------- -- Example of a type derivation defined in the Ada side that inherites -- all the dispatching primitives of the ancestor from the C++ side. type Vaccinated_Dog is new Dog with null record; function Vaccination_Expired (A : Vaccinated_Dog) return Boolean; pragma Convention (CPP, Vaccination_Expired); end Animals;
-------------------------------------------------------------------------- -- ASnip Source Code Decorator -- Copyright (C) 2006, Georg Bauhaus -- -- 1. Permission is hereby granted to use, copy, modify and/or distribute -- this package, provided that: -- * copyright notices are retained unchanged, -- * any distribution of this package, whether modified or not, -- includes this license text. -- 2. Permission is hereby also granted to distribute binary programs which -- depend on this package. If the binary program depends on a modified -- version of this package, you are encouraged to publicly release the -- modified version of this package. -- -- THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. 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 AUTHORS BE LIABLE TO ANY PARTY FOR -- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -- DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE. -------------------------------------------------------------------------- -- eMail: bauhaus@arcor.de generic type INDEX is range <>; -- only integer types, for simplicity type ELEMENT is limited private; with function "<"(a, b: ELEMENT) return BOOLEAN is <>; with function "="(a, b: ELEMENT) return BOOLEAN is <>; type SORTED_LIST is array(INDEX range <>) of ELEMENT; function binary_search(container: SORTED_LIST; item: ELEMENT) return BOOLEAN; -- ! pre: items in `container` are ordered by "<", or otherwise "=" -- ! post: result = (`item` is present in `container`) -- ---------------------------------------------------------------- -- Three implementations of `binary_search`. They differ in execution -- speed. The differences also differ among compilers. -- ---------------------------------------------------------------- -- (1) --function binary_search -- (container: SORTED_LIST; item: ELEMENT) return BOOLEAN is -- -- recursion using array slices of decreasing lengths -- -- mid: constant INDEX := (container'first + container'last) / 2; -- begin -- if container'length = 0 then -- return False; -- elsif container'length = 1 then -- return container(container'last) = item; -- elsif container(mid) < item then -- return binary_search(container(INDEX'succ(mid) .. container'last), -- item); -- else -- return binary_search(container(container'first .. mid), item); -- end if; -- end binary_search; -- (2) function binary_search (container: SORTED_LIST; item: ELEMENT) return BOOLEAN is -- uses array indexing in recursive calls function search(j, k: INDEX) return BOOLEAN; -- increase `j` or decrease `k` in recursive calls -- ! pre: j <= k pragma inline(search); function search(j, k: INDEX) return BOOLEAN is mid: constant INDEX := (j + k) / 2; begin if j = k then return container(k) = item; elsif container(mid) < item then return search(INDEX'succ(mid), k); else return search(j, mid); end if; end search; begin if container'length = 0 then return False; else return search(container'first, container'last); end if; end binary_search; -- (3) The following version is like the above, but uses a loop and -- "manual inlining". Probably the fastest. --function binary_search -- (container: SORTED_LIST; item: ELEMENT) return BOOLEAN is -- -- array indexing and recursion replaced by a loop -- j: INDEX; -- k: INDEX; -- mid: INDEX; -- begin -- if container'length = 0 then -- return False; -- else -- j := container'first; -- k := container'last; -- -- ! assert j <= k -- mid := (j + k) / 2; -- while j < k loop -- if container(mid) < item then -- j := INDEX'succ(mid); -- else -- k := mid; -- end if; -- mid := (j + k) / 2; -- end loop; -- -- ! assert: j = k -- return container(k) = item; -- end if; -- end binary_search;
-- Package Scaliger -- This package defines extended duration and time types using the "julian day" -- as defined by Joseph Juste Scaliger in 1583. -- The duration is expressed as a number of 1/8 seconds. -- Two numeric conversion functions are definied -- exchanging a day expressed as a decimal figure from and to -- an integer number of 1/8 seconds. -- ---------------------------------------------------------------------------- -- Copyright Miletus 2015 -- 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 ------------------------------------------------------------------------------- -- In a draft version, two type definitions of -- the predefined Calendar package were used. -- this reference has been eliminated for language portability. package Scaliger is Time_Error : exception; -- same as in Calendar Day_unit : constant := 86_400.0; -- one day in real type seconds Horizon : Constant := 5_405_700 ; -- around 148 centuries in days, which covers years -4800 to 9999 subtype Historical_year_number is integer range -4800 .. 9999; -- Year of the "Common era", equivalent to Anno Domini when positive, -- with a zero year and using negative values for years Before Christus. -- The lower limit -4800 enables computations using the gregorian cycles -- of 400 years. subtype Month_Number is Integer range 1 .. 12; -- same as in Ada.Calendar subtype Day_Number is Integer range 1 .. 31; -- same as in Ada.Calendar subtype Julian_Day_Duration is Integer range -Horizon .. Horizon; subtype Julian_Day is Julian_Day_Duration range 0..Horizon; -- An integer Julian day represents any day on or after -- 1 January -4712 (Julian calendar). Duration_Horizon : Constant := Horizon * Day_unit; -- 148 centuries in seconds type Historical_Duration is delta 2#0.001# range -Duration_Horizon .. Duration_Horizon; -- Duration is stored and computed as an integer number of 1/8 seconds. -- This storage method is adequate because we express durations as -- a number of seconds (and minutes, hours and days). -- 1/8 second accuracy is suitable for computations involving the mean moon -- over a long period of time. -- Conversion method with durations expressed in fractional day is provided. subtype Historical_Time is Historical_Duration range 0.0 .. Duration_Horizon; -- Time counted from 1 Januray -4712 (Julian proleptic calendar) at 12:00 -- As Historical duration, this is stored in seconds. subtype H24_Historical_Duration is Historical_Duration range 0.0 .. 86_400.0; -- As in Ada.calendar, duration of one full day maximum. subtype Day_Historical_Duration is Historical_Duration range -43_200.0 .. 43_200.0; -- The Greenwich hour of the day expressed with respect to 12:00 noon. type Fractional_day_duration is delta 1.0E-6 range - Horizon * 1.0 .. Horizon * 1.0; -- This type enables conversion to and from Historical_Duration -- with the an accuracy of around 1/10 s. -- Do not use for computations, only for display. type General_date is record day : Day_Number; month : Month_Number; year : Historical_year_number; end record; -- a record for expression of most calendars. -- zodiacal calendar does not fit (certain month have more than 31 days). function Fractionnal_day_of (My_duration : Historical_Duration) return Fractional_day_duration; -- convert an historical duration (or time), in seconds, -- into a fractional day. function Convert_from_julian_day (Display : Fractional_day_duration) return Historical_Duration; -- used to convert manual entries in fractional day -- into usable time or duration expression. End Scaliger;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $: with Asis.Elements; with Asis.Expressions; with Asis.Gela.Lists; with Asis.Gela.Errors; with Asis.Gela.Classes; with Asis.Gela.Base_Lists; with Asis.Gela.Element_Utils; with Asis.Gela.Elements.Expr; with Asis.Gela.Elements.Assoc; with Asis.Gela.Elements.Decl; with Asis.Gela.Elements.Stmt; with Asis.Gela.Elements.Defs.Rng; with Asis.Gela.Elements.Defs.Const; with Asis.Gela.Elements.Clause.Rep; with Asis.Gela.Elements.Defs.Types; with Asis.Gela.Elements.Defs.Formal; package body Asis.Gela.Replace is procedure Function_To_Index_Constraint (Item : in out Asis.Element); procedure Function_To_Discriminant_Constraint (Item : in out Asis.Element); procedure Set_Enclosing_Element_In_List (List : access Asis.Gela.Base_Lists.Primary_Base_List_Node'Class; Parent : Asis.Element); procedure Set_Enclosing_Element_In_List (List : Asis.Element; Parent : Asis.Element); ----------------------------------------- -- Could_Be_Positional_Array_Aggregate -- ----------------------------------------- function Could_Be_Positional_Array_Aggregate (Item : Asis.Element) return Boolean is use Asis.Elements; use Asis.Expressions; List : Asis.Association_List := Record_Component_Associations (Item); begin if List'Length = 0 then -- null record return False; end if; for I in List'Range loop declare Choises : Asis.Expression_List := Record_Component_Choices (List (I)); begin if List'Length = 1 and then Choises'Length = 0 then return False; end if; if Choises'Length /= 0 then return False; end if; if Element_Kind (Component_Expression (List (I))) /= An_Expression then return False; end if; end; end loop; return True; end Could_Be_Positional_Array_Aggregate; --------------------------------- -- Expression_To_Function_Call -- --------------------------------- procedure Expression_To_Function_Call (Item : in out Asis.Element) is use Asis.Gela.Elements.Expr; Result : Function_Call_Ptr := new Function_Call_Node; begin Element_Utils.Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Prefix (Result.all, Item); Element_Utils.Set_Enclosing_Element (Item, Asis.Element (Result)); Set_Is_Prefix_Call (Result.all, True); Item := Asis.Element (Result); end Expression_To_Function_Call; ---------------------------- -- Function_To_Constraint -- ---------------------------- procedure Function_To_Constraint (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Errors; use Asis.Gela.Classes; Subtipe : Asis.Subtype_Mark := Prefix (Item); Info : Type_Info := Type_From_Subtype_Mark (Subtipe, Item); begin if Is_Not_Type (Info) or else Is_Definition (Info) then return; end if; if Is_Array (Info) then Function_To_Index_Constraint (Item); elsif Is_Composite (Info) then Function_To_Discriminant_Constraint (Item); else Report (Item, Error_Syntax_Bad_Constraints); end if; end Function_To_Constraint; ----------------------------------------- -- Function_To_Discriminant_Constraint -- ----------------------------------------- procedure Function_To_Discriminant_Constraint (Item : in out Asis.Element) is use Asis.Elements; use Asis.Gela.Lists; use Asis.Gela.Errors; use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Elements.Assoc; use Asis.Gela.Element_Utils; use Primary_Association_Lists; use Asis.Gela.Elements.Defs.Const; List : Asis.Association_List := Function_Call_Parameters (Item); List_I : Asis.Element; Result : Discriminant_Constraint_Ptr := new Discriminant_Constraint_Node; Assoc : Discriminant_Association_Ptr; Node : Record_Component_Association_Ptr; Child : Asis.Element; Funct : Function_Call_Node renames Function_Call_Node (Item.all); Aggr : constant Asis.Element := Record_Aggregate (Funct); Assoc_List : Primary_Association_Lists.List := new List_Node; Old_List : Primary_Choise_Lists.List; begin for I in List'Range loop List_I := List (I); Node := Record_Component_Association_Ptr (List_I); Child := Component_Expression (List_I); if Element_Kind (Child) = An_Expression then Assoc := new Discriminant_Association_Node; Copy_Element (List_I, Asis.Element (Assoc)); Set_Discriminant_Expression (Assoc.all, Child); Set_Enclosing_Element (Child, Asis.Element (Assoc)); Child := Record_Component_Choices_List (Node.all); Set_Discriminant_Selector_Names (Assoc.all, Child); Old_List := Primary_Choise_Lists.List (Child); if Assigned (Child) then Set_Enclosing_Element_In_List (Old_List, Asis.Element (Assoc)); end if; Add (Assoc_List.all, Asis.Element (Assoc)); Set_Enclosing_Element (Assoc.all, Asis.Element (Result)); else Report (Child, Error_Syntax_Bad_Constraints); end if; end loop; Copy_Element (Item, Asis.Element (Result)); Set_Discriminant_Associations (Result.all, Asis.Element (Assoc_List)); Set_Start_Position (Result.all, Start_Position (Aggr.all)); Set_End_Position (Result.all, End_Position (Aggr.all)); Item := Asis.Element (Result); end Function_To_Discriminant_Constraint; ----------------------------------- -- Function_To_Indexed_Component -- ----------------------------------- procedure Function_To_Indexed_Component (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; use Lists.Primary_Expression_Lists; Result : Indexed_Component_Ptr := new Indexed_Component_Node; Items : List := new List_Node; List : Asis.Association_List := Function_Call_Parameters (Item); Tmp : Asis.Element; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Prefix (Item); Set_Prefix (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); for I in List'Range loop Tmp := Component_Expression (List (I)); Add (Items.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); end loop; Set_Index_Expressions (Result.all, Asis.Element (Items)); Item := Asis.Element (Result); end Function_To_Indexed_Component; ---------------------------------- -- Function_To_Index_Constraint -- ---------------------------------- procedure Function_To_Index_Constraint (Item : in out Asis.Element) is use Asis.Elements; use Asis.Expressions; use Asis.Gela.Errors; use Asis.Gela.Elements.Defs; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; use Asis.Gela.Elements.Defs.Rng; use Asis.Gela.Elements.Defs.Const; use Lists.Primary_Definition_Lists; Result : Index_Constraint_Ptr := new Index_Constraint_Node; Ind : Discrete_Subtype_Indication_Ptr; Ranges : List := new List_Node; Child : Asis.Element; Funct : Function_Call_Node renames Function_Call_Node (Item.all); Aggr : constant Asis.Element := Record_Aggregate (Funct); List : Asis.Association_List := Function_Call_Parameters (Item); begin Copy_Element (Item, Asis.Element (Result)); for I in List'Range loop Child := Component_Expression (List (I)); if Element_Kind (Child) = An_Expression then Ind := new Discrete_Subtype_Indication_Node; Copy_Element (Child, Asis.Element (Ind)); Set_Subtype_Mark (Ind.all, Child); Set_Enclosing_Element (Child, Asis.Element (Ind)); Child := Asis.Element (Ind); end if; if Element_Kind (Child) = A_Definition then Add (Ranges.all, Child); Set_Enclosing_Element (Child, Asis.Element (Result)); else raise Internal_Error; end if; declare Choises : Asis.Expression_List := Record_Component_Choices (List (I)); begin if Choises'Length /= 0 then Report (Child, Error_Syntax_Bad_Constraints); end if; end; end loop; Set_Discrete_Ranges (Result.all, Asis.Element (Ranges)); Set_Start_Position (Result.all, Start_Position (Aggr.all)); Set_End_Position (Result.all, End_Position (Aggr.all)); Item := Asis.Element (Result); end Function_To_Index_Constraint; ----------------------- -- Function_To_Slice -- ----------------------- procedure Function_To_Slice (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : Slice_Ptr := new Slice_Node; List : Asis.Association_List := Function_Call_Parameters (Item); Tmp : Asis.Element; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Prefix (Item); Set_Prefix (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Tmp := Component_Expression (List (1)); Set_Slice_Range (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Item := Asis.Element (Result); end Function_To_Slice; --------------------------------- -- Function_To_Type_Conversion -- --------------------------------- procedure Function_To_Type_Conversion (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : Type_Conversion_Ptr := new Type_Conversion_Node; List : Asis.Association_List := Function_Call_Parameters (Item); Tmp : Asis.Element; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Prefix (Item); Set_Converted_Or_Qualified_Subtype_Mark (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Tmp := Component_Expression (List (1)); Set_Converted_Or_Qualified_Expression (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Item := Asis.Element (Result); end Function_To_Type_Conversion; --------------------------------------- -- Identifier_To_Enumeration_Literal -- --------------------------------------- procedure Identifier_To_Enumeration_Literal (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : Enumeration_Literal_Ptr := new Enumeration_Literal_Node; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Name_Image (Result.all, Name_Image (Item)); declare List : Element_List := Corresponding_Name_Definition_List (Item); begin for I in List'Range loop Add_Defining_Name (Asis.Element (Result), List (I)); Remove_Defining_Name (Item, List (I)); end loop; end; Set_Corresponding_Name_Declaration (Result.all, Corresponding_Name_Declaration (Item)); Item := Asis.Element (Result); end Identifier_To_Enumeration_Literal; ------------------------- -- Integer_Real_Number -- ------------------------- procedure Integer_Real_Number (Item : in out Asis.Element) is use Asis.Gela.Elements.Decl; Node : Integer_Number_Declaration_Node renames Integer_Number_Declaration_Node (Item.all); begin Set_Declaration_Kind (Node, A_Real_Number_Declaration); end Integer_Real_Number; ----------------------------------- -- Interface_To_Formal_Interface -- ----------------------------------- procedure Interface_To_Formal_Interface (Item : in out Asis.Statement) is use Asis.Gela.Elements.Defs.Types; use Asis.Gela.Elements.Defs.Formal; Node : Interface_Type_Node renames Interface_Type_Node (Item.all); Result : Formal_Interface_Type_Ptr := new Formal_Interface_Type_Node; begin Element_Utils.Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Interface_Kind (Result.all, Interface_Kind (Node)); Set_Progenitor_List (Result.all, Progenitor_List_List (Node)); Item := Asis.Element (Result); end Interface_To_Formal_Interface; --------------------------------------- -- Operator_Symbol_To_String_Literal -- --------------------------------------- procedure Operator_Symbol_To_String_Literal (Item : in out Asis.Element) is use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; Result : String_Literal_Ptr := new String_Literal_Node; begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Value_Image (Result.all, Asis.Expressions.Name_Image (Item)); Item := Asis.Element (Result); end Operator_Symbol_To_String_Literal; ----------------------------- -- Procedure_To_Entry_Call -- ----------------------------- procedure Procedure_To_Entry_Call (Item : in out Asis.Element) is use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; Result : Entry_Call_Statement_Ptr := new Entry_Call_Statement_Node; Node : Procedure_Call_Statement_Node renames Procedure_Call_Statement_Node (Item.all); Tmp : Asis.Element; begin Element_Utils.Copy_Element (Source => Item, Target => Asis.Element (Result)); Tmp := Called_Name (Node); Set_Called_Name (Result.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Result)); Tmp := Call_Statement_Parameters_List (Node); Set_Call_Statement_Parameters (Result.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Element (Result)); Tmp := Label_Names_List (Node); Set_Label_Names (Result.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Element (Result)); Item := Asis.Element (Result); end Procedure_To_Entry_Call; ------------------------------------- -- Procedure_To_Indexed_Entry_Call -- ------------------------------------- procedure Procedure_To_Indexed_Entry_Call (Element : in out Asis.Statement) is use Asis.Gela.Elements.Expr; use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; use Lists.Primary_Expression_Lists; Result : Entry_Call_Statement_Ptr := new Entry_Call_Statement_Node; Index : Indexed_Component_Ptr := new Indexed_Component_Node; Node : Procedure_Call_Statement_Node renames Procedure_Call_Statement_Node (Element.all); Tmp : Asis.Element; Items : List := new List_Node; List : Asis.Association_List := Call_Statement_Parameters (Element.all); begin Element_Utils.Copy_Element (Source => Element, Target => Asis.Element (Index)); Tmp := Called_Name (Node); Set_Prefix (Index.all, Tmp); Set_Enclosing_Element (Tmp, Asis.Element (Index)); Tmp := Component_Expression (List (1).all); Add (Items.all, Tmp); Set_Index_Expressions (Index.all, Asis.Element (Items)); Set_Enclosing_Element (Tmp, Asis.Element (Index)); Element_Utils.Copy_Element (Source => Element, Target => Asis.Element (Result)); Set_Called_Name (Result.all, Asis.Element (Index)); Set_Enclosing_Element (Index.all, Asis.Element (Result)); Tmp := Label_Names_List (Node); Set_Label_Names (Result.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Element (Result)); Element := Asis.Element (Result); end Procedure_To_Indexed_Entry_Call; ------------------------------- -- Record_To_Array_Aggregate -- ------------------------------- type Base_Array_Aggregate_Ptr is access all Asis.Gela.Elements.Expr.Base_Array_Aggregate_Node'Class; procedure Record_To_Array_Aggregate (Item : in out Asis.Element; Positional : in Boolean) is use Asis.Expressions; use Asis.Gela.Lists.Primary_Association_Lists; use Asis.Gela.Elements.Expr; use Asis.Gela.Element_Utils; -- Pos & Named ptr used for Storage_Pool works Pos : Positional_Array_Aggregate_Ptr; Named : Named_Array_Aggregate_Ptr; Result : Base_Array_Aggregate_Ptr; Items : List := List (Record_Component_Associations_List (Record_Aggregate_Node (Item.all))); begin if Positional then Pos := new Positional_Array_Aggregate_Node; Result := Base_Array_Aggregate_Ptr (Pos); else Named := new Named_Array_Aggregate_Node; Result := Base_Array_Aggregate_Ptr (Named); end if; Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Array_Component_Associations (Result.all, Asis.Element (Items)); Set_Enclosing_Element_In_List (Items, Asis.Element (Result)); Item := Asis.Element (Result); end Record_To_Array_Aggregate; --------------------------------- -- Record_To_Array_Association -- --------------------------------- procedure Record_To_Array_Association (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Lists.Primary_Choise_Lists; use Asis.Gela.Elements.Assoc; use Asis.Gela.Element_Utils; Result : Array_Component_Association_Ptr := new Array_Component_Association_Node; Items : List := List (Record_Component_Choices_List (Record_Component_Association_Node (Item.all))); begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Array_Component_Choices (Result.all, Asis.Element (Items)); if Items /= null then Set_Enclosing_Element_In_List (Items, Asis.Element (Result)); end if; Set_Component_Expression (Result.all, Component_Expression (Item)); Set_Enclosing_Element (Component_Expression (Item), Asis.Element (Result)); Item := Asis.Element (Result); end Record_To_Array_Association; -------------------------------------- -- Record_To_Parameter_Association -- -------------------------------------- procedure Record_To_Parameter_Association (Item : in out Asis.Element) is use Asis.Expressions; use Asis.Gela.Lists.Primary_Choise_Lists; use Asis.Gela.Elements.Assoc; use Asis.Gela.Element_Utils; Result : Parameter_Association_Ptr := new Parameter_Association_Node; Items : List := List (Record_Component_Choices_List (Record_Component_Association_Node (Item.all))); begin Copy_Element (Source => Item, Target => Asis.Element (Result)); Set_Actual_Parameter (Result.all, Component_Expression (Item)); Set_Enclosing_Element (Component_Expression (Item), Asis.Element (Result)); if Items /= null then Set_Formal_Parameter (Result.all, Get_Item (Items, 1)); Set_Enclosing_Element (Get_Item (Items, 1), Asis.Element (Result)); Destroy (Items); end if; Set_Is_Normalized (Result.all, False); Set_Is_Defaulted_Association (Result.all, False); Item := Asis.Element (Result); end Record_To_Parameter_Association; ----------------------------------- -- Set_Enclosing_Element_In_List -- ----------------------------------- procedure Set_Enclosing_Element_In_List (List : access Asis.Gela.Base_Lists.Primary_Base_List_Node'Class; Parent : Asis.Element) is use Asis.Gela.Base_Lists; begin for J in 1 .. Length (List.all) loop Element_Utils.Set_Enclosing_Element (Get_Item (List, J), Parent); end loop; end Set_Enclosing_Element_In_List; ----------------------------------- -- Set_Enclosing_Element_In_List -- ----------------------------------- procedure Set_Enclosing_Element_In_List (List : Asis.Element; Parent : Asis.Element) is begin if Assigned (List) then Set_Enclosing_Element_In_List (Asis.Gela.Base_Lists.Primary_Base_List (List), Parent); end if; end Set_Enclosing_Element_In_List; ------------------------- -- To_Timed_Entry_Call -- ------------------------- procedure To_Timed_Entry_Call (Element : in out Asis.Statement) is use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; Node : Selective_Accept_Statement_Node renames Selective_Accept_Statement_Node (Element.all); Statement : constant Timed_Entry_Call_Statement_Ptr := new Timed_Entry_Call_Statement_Node; Tmp : Asis.Element; begin Copy_Element (Element, Asis.Element (Statement)); Tmp := Label_Names_List (Node); Set_Label_Names (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Tmp := Statement_Paths_List (Node); Set_Statement_Paths (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Element := Asis.Statement (Statement); end To_Timed_Entry_Call; ------------------------------- -- To_Conditional_Entry_Call -- ------------------------------- procedure To_Conditional_Entry_Call (Element : in out Asis.Statement) is use Asis.Gela.Elements.Stmt; use Asis.Gela.Element_Utils; Node : Selective_Accept_Statement_Node renames Selective_Accept_Statement_Node (Element.all); Statement : constant Conditional_Entry_Call_Statement_Ptr := new Conditional_Entry_Call_Statement_Node; Tmp : Asis.Element; begin Copy_Element (Element, Asis.Element (Statement)); Tmp := Label_Names_List (Node); Set_Label_Names (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Tmp := Statement_Paths_List (Node); Set_Statement_Paths (Statement.all, Tmp); Set_Enclosing_Element_In_List (Tmp, Asis.Statement (Statement)); Element := Asis.Statement (Statement); end To_Conditional_Entry_Call; ------------------------------- -- To_Enumeration_Rep_Clause -- ------------------------------- procedure To_Enumeration_Rep_Clause (Element : in out Asis.Statement) is use Asis.Gela.Element_Utils; use Asis.Gela.Elements.Clause.Rep; Result : Enumeration_Representation_Clause_Ptr := new Enumeration_Representation_Clause_Node; Expr : Asis.Element := Representation_Clause_Expression (Element.all); Temp : Asis.Element; Positional : Boolean := Could_Be_Positional_Array_Aggregate (Expr); begin Record_To_Array_Aggregate (Expr, Positional); Copy_Element (Element, Asis.Element (Result)); Set_Representation_Clause_Expression (Result.all, Expr); Set_Enclosing_Element (Expr, Asis.Element (Result)); Temp := Representation_Clause_Name (Element.all); Set_Representation_Clause_Name (Result.all, Temp); Set_Enclosing_Element (Temp, Asis.Element (Result)); Element := Asis.Element (Result); end To_Enumeration_Rep_Clause; end Asis.Gela.Replace; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. ------------------------------------------------------------------------------
-- C61010A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT AN IN OR IN OUT FORMAL PARAMETER CAN BE DECLARED WITH A -- LIMITED PRIVATE TYPE OR A LIMITED COMPOSITE TYPE. -- DAS 1/22/81 -- JRK 1/20/84 TOTALLY REVISED. WITH REPORT; USE REPORT; PROCEDURE C61010A IS PACKAGE PKG IS TYPE ITYPE IS LIMITED PRIVATE; PROCEDURE LOOK_IN_I (X : IN ITYPE; V : INTEGER; M : STRING); PROCEDURE LOOK_INOUT_I (X : IN OUT ITYPE; V : INTEGER; M : STRING); PROCEDURE SET_I (X : IN OUT ITYPE; V : INTEGER); SUBTYPE INT_0_20 IS INTEGER RANGE 0 .. 20; TYPE VRTYPE (C : INT_0_20 := 20) IS LIMITED PRIVATE; PROCEDURE LOOK_IN_VR (X : IN VRTYPE; C : INTEGER; I : INTEGER; S : STRING; M : STRING); PROCEDURE LOOK_INOUT_VR (X : IN OUT VRTYPE; C : INTEGER; I : INTEGER; S : STRING; M : STRING); PROCEDURE SET_VR (X : IN OUT VRTYPE; C : INTEGER; I : INTEGER; S : STRING); PRIVATE TYPE ITYPE IS NEW INTEGER RANGE 0 .. 99; TYPE VRTYPE (C : INT_0_20 := 20) IS RECORD I : INTEGER; S : STRING (1 .. C); END RECORD; END PKG; USE PKG; I1 : ITYPE; TYPE ATYPE IS ARRAY (1 .. 3) OF ITYPE; A1 : ATYPE; VR1 : VRTYPE; D : CONSTANT INT_0_20 := 10; TYPE RTYPE IS RECORD J : ITYPE; R : VRTYPE (D); END RECORD; R1 : RTYPE; PACKAGE BODY PKG IS PROCEDURE LOOK_IN_I (X : IN ITYPE; V : INTEGER; M : STRING) IS BEGIN IF INTEGER (X) /= V THEN FAILED ("WRONG SCALAR VALUE - " & M); END IF; END LOOK_IN_I; PROCEDURE LOOK_INOUT_I (X : IN OUT ITYPE; V : INTEGER; M : STRING) IS BEGIN IF INTEGER (X) /= V THEN FAILED ("WRONG SCALAR VALUE - " & M); END IF; END LOOK_INOUT_I; PROCEDURE SET_I (X : IN OUT ITYPE; V : INTEGER) IS BEGIN X := ITYPE (IDENT_INT (V)); END SET_I; PROCEDURE LOOK_IN_VR (X : IN VRTYPE; C : INTEGER; I : INTEGER; S : STRING; M : STRING) IS BEGIN IF (X.C /= C OR X.I /= I) OR ELSE X.S /= S THEN FAILED ("WRONG COMPOSITE VALUE - " & M); END IF; END LOOK_IN_VR; PROCEDURE LOOK_INOUT_VR (X : IN OUT VRTYPE; C : INTEGER; I : INTEGER; S : STRING; M : STRING) IS BEGIN IF (X.C /= C OR X.I /= I) OR ELSE X.S /= S THEN FAILED ("WRONG COMPOSITE VALUE - " & M); END IF; END LOOK_INOUT_VR; PROCEDURE SET_VR (X : IN OUT VRTYPE; C : INTEGER; I : INTEGER; S : STRING) IS BEGIN X := (IDENT_INT(C), IDENT_INT(I), IDENT_STR(S)); END SET_VR; BEGIN I1 := ITYPE (IDENT_INT(2)); FOR I IN A1'RANGE LOOP A1 (I) := ITYPE (3 + IDENT_INT(I)); END LOOP; VR1 := (IDENT_INT(5), IDENT_INT(4), IDENT_STR("01234")); R1.J := ITYPE (IDENT_INT(6)); R1.R := (IDENT_INT(D), IDENT_INT(19), IDENT_STR("ABCDEFGHIJ")); END PKG; PROCEDURE CHECK_IN_I (X : IN ITYPE; V : INTEGER; M : STRING) IS BEGIN LOOK_IN_I (X, V, M); END CHECK_IN_I; PROCEDURE CHECK_INOUT_I (X : IN OUT ITYPE; OV : INTEGER; NV : INTEGER; M : STRING) IS BEGIN LOOK_INOUT_I (X, OV, M & " - A"); SET_I (X, NV); LOOK_INOUT_I (X, NV, M & " - B"); LOOK_IN_I (X, NV, M & " - C"); END CHECK_INOUT_I; PROCEDURE CHECK_IN_A (X : IN ATYPE; V : INTEGER; M : STRING) IS BEGIN FOR I IN X'RANGE LOOP LOOK_IN_I (X(I), V+I, M & " -" & INTEGER'IMAGE (I)); END LOOP; END CHECK_IN_A; PROCEDURE CHECK_INOUT_A (X : IN OUT ATYPE; OV : INTEGER; NV : INTEGER; M : STRING) IS BEGIN FOR I IN X'RANGE LOOP LOOK_INOUT_I (X(I), OV+I, M & " - A" & INTEGER'IMAGE (I)); SET_I (X(I), NV+I); LOOK_INOUT_I (X(I), NV+I, M & " - B" & INTEGER'IMAGE (I)); LOOK_IN_I (X(I), NV+I, M & " - C" & INTEGER'IMAGE (I)); END LOOP; END CHECK_INOUT_A; PROCEDURE CHECK_IN_VR (X : IN VRTYPE; C : INTEGER; I : INTEGER; S : STRING; M : STRING) IS BEGIN LOOK_IN_VR (X, C, I, S, M); END CHECK_IN_VR; PROCEDURE CHECK_INOUT_VR (X : IN OUT VRTYPE; OC : INTEGER; OI : INTEGER; OS : STRING; NC : INTEGER; NI : INTEGER; NS : STRING; M : STRING) IS BEGIN LOOK_INOUT_VR (X, OC, OI, OS, M & " - A"); SET_VR (X, NC, NI, NS); LOOK_INOUT_VR (X, NC, NI, NS, M & " - B"); LOOK_IN_VR (X, NC, NI, NS, M & " - C"); END CHECK_INOUT_VR; PROCEDURE CHECK_IN_R (X : IN RTYPE; J : INTEGER; C : INTEGER; I : INTEGER; S : STRING; M : STRING) IS BEGIN LOOK_IN_I (X.J, J, M & " - A"); LOOK_IN_VR (X.R, C, I, S, M & " - B"); END CHECK_IN_R; PROCEDURE CHECK_INOUT_R (X : IN OUT RTYPE; OJ : INTEGER; OC : INTEGER; OI : INTEGER; OS : STRING; NJ : INTEGER; NC : INTEGER; NI : INTEGER; NS : STRING; M : STRING) IS BEGIN LOOK_INOUT_I (X.J, OJ, M & " - A"); LOOK_INOUT_VR (X.R, OC, OI, OS, M & " - B"); SET_I (X.J, NJ); SET_VR (X.R, NC, NI, NS); LOOK_INOUT_I (X.J, NJ, M & " - C"); LOOK_INOUT_VR (X.R, NC, NI, NS, M & " - D"); LOOK_IN_I (X.J, NJ, M & " - E"); LOOK_IN_VR (X.R, NC, NI, NS, M & " - F"); END CHECK_INOUT_R; BEGIN TEST ("C61010A", "CHECK THAT LIMITED PRIVATE/COMPOSITE TYPES " & "CAN BE USED AS IN OR IN OUT FORMAL PARAMETERS"); CHECK_IN_I (I1, 2, "IN I"); CHECK_INOUT_I (I1, 2, 5, "INOUT I"); CHECK_IN_A (A1, 3, "IN A"); CHECK_INOUT_A (A1, 3, 17, "INOUT A"); CHECK_IN_VR (VR1, 5, 4, "01234", "IN VR"); CHECK_INOUT_VR (VR1, 5, 4, "01234", 10, 11, "9876543210", "INOUT VR"); CHECK_IN_R (R1, 6, D, 19, "ABCDEFGHIJ", "IN R"); CHECK_INOUT_R (R1, 6, D, 19, "ABCDEFGHIJ", 13, D, 5, "ZYXWVUTSRQ", "INOUT R"); RESULT; END C61010A;
with System.Long_Long_Float_Types; package body System.Formatting.Float is pragma Suppress (All_Checks); use type Long_Long_Integer_Types.Word_Unsigned; subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; function modfl (value : Long_Long_Float; iptr : access Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_modfl"; function roundl (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_roundl"; function truncl (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_truncl"; function isnanl (X : Long_Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isnanl"; function isinfl (X : Long_Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isinfl"; function signbitl (X : Long_Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_signbitl"; procedure Split ( X : Long_Long_Unsigned_Float; Fore : out Digit; -- Fore < Base Aft : out Long_Long_Unsigned_Float; Exponent : out Integer; Base : Number_Base := 10); procedure Split ( X : Long_Long_Unsigned_Float; Fore : out Digit; Aft : out Long_Long_Unsigned_Float; Exponent : out Integer; Base : Number_Base := 10) is begin if X > 0.0 then if X >= Long_Long_Unsigned_Float (Base) then declare B : Long_Long_Unsigned_Float := Long_Long_Unsigned_Float (Base); begin Exponent := 1; loop declare Next_B : constant Long_Long_Unsigned_Float := B * Long_Long_Unsigned_Float (Base); begin exit when Next_B > X; B := Next_B; end; Exponent := Exponent + 1; end loop; declare Scaled : constant Long_Long_Unsigned_Float := X / B; Fore_Float : constant Long_Long_Unsigned_Float := truncl (Scaled); begin Fore := Digit (Fore_Float); Aft := X - Fore_Float * B; end; end; else declare Scaled : Long_Long_Unsigned_Float := X; B : Long_Long_Unsigned_Float := 1.0; begin Exponent := 0; while Scaled < 1.0 loop Scaled := Scaled * Long_Long_Unsigned_Float (Base); B := B * Long_Long_Unsigned_Float (Base); Exponent := Exponent - 1; end loop; declare Fore_Float : constant Long_Long_Unsigned_Float := truncl (Scaled); begin Fore := Digit (Fore_Float); Aft := X - Fore_Float / B; end; end; end if; else Fore := 0; Aft := 0.0; Exponent := 0; end if; end Split; -- decimal part for floating-point format = Aft / Base ** Exponent procedure Aft_Scale ( Aft : Long_Long_Unsigned_Float; Scaled_Aft : out Long_Long_Unsigned_Float; Exponent : Integer; Round_Up : out Boolean; Base : Number_Base := 10; Aft_Width : Positive := Standard.Float'Digits - 1); procedure Aft_Scale ( Aft : Long_Long_Unsigned_Float; Scaled_Aft : out Long_Long_Unsigned_Float; Exponent : Integer; Round_Up : out Boolean; Base : Number_Base := 10; Aft_Width : Positive := Standard.Float'Digits - 1) is L : constant Long_Long_Unsigned_Float := Long_Long_Unsigned_Float (Base) ** Aft_Width; begin Scaled_Aft := roundl ( Aft * Long_Long_Unsigned_Float (Base) ** (Aft_Width - Exponent)); Round_Up := Scaled_Aft >= L; -- ".99"99.. would be rounded up to 1".00" end Aft_Scale; procedure Aft_Image ( Value : Long_Long_Unsigned_Float; -- scaled Aft Item : out String; -- Item'Length >= Width + 1 for '.' Last : out Natural; Base : Number_Base := 10; Set : Type_Set := Upper_Case; Aft_Width : Positive := Standard.Float'Digits - 1); procedure Aft_Image ( Value : Long_Long_Unsigned_Float; Item : out String; Last : out Natural; Base : Number_Base := 10; Set : Type_Set := Upper_Case; Aft_Width : Positive := Standard.Float'Digits - 1) is X : Long_Long_Unsigned_Float := Value; begin Last := Item'First + Aft_Width; Item (Item'First) := '.'; for I in reverse Item'First + 1 .. Last loop declare Q : Long_Long_Float; R : Long_Long_Float; begin Long_Long_Float_Types.Divide (X, Long_Long_Float (Base), Q, R); Image (Digit (R), Item (I), Set => Set); X := Q; end; end loop; pragma Assert (X = 0.0); end Aft_Image; -- implementation function Sign_Mark (Value : Long_Long_Float; Signs : Sign_Marks) return Character is begin if signbitl (Value) /= 0 then return Signs.Minus; elsif Value > 0.0 then return Signs.Plus; else return Signs.Zero; end if; end Sign_Mark; function Fore_Digits_Width ( Value : Long_Long_Unsigned_Float; Base : Number_Base := 10) return Positive is P : Long_Long_Float := Long_Long_Float (Base); Result : Positive := 1; begin while P <= Value loop -- Value is finite, so exit when isinfl (P) Result := Result + 1; P := P * Long_Long_Float (Base); end loop; return Result; end Fore_Digits_Width; function Fore_Digits_Width ( First, Last : Long_Long_Float; Base : Number_Base := 10) return Positive is Actual_First : Long_Long_Float := First; Actual_Last : Long_Long_Float := Last; Max_Abs : Long_Long_Float; begin if First > Last then Actual_First := Last; Actual_Last := First; end if; if Actual_Last <= 0.0 then Max_Abs := -Actual_First; elsif Actual_First >= 0.0 then Max_Abs := Actual_Last; else -- Actual_First < 0 and then Actual_Last > 0 Max_Abs := Long_Long_Float'Max (-Actual_First, Actual_Last); end if; return Fore_Digits_Width (Max_Abs, Base => Base); end Fore_Digits_Width; procedure Image_No_Sign_Nor_Exponent ( Value : Long_Long_Float; Item : out String; Fore_Last, Last : out Natural; Base : Number_Base := 10; Base_Form : Boolean := False; Set : Type_Set := Upper_Case; Fore_Digits_Width : Positive := 1; Fore_Digits_Fill : Character := '0'; Aft_Width : Positive) is Item_Fore : aliased Long_Long_Float; Aft : Long_Long_Float; Scaled_Aft : Long_Long_Float; Round_Up : Boolean; Required_Fore_Width : Positive; Error : Boolean; begin Last := Item'First - 1; -- opening '#' if Base_Form then Image ( Word_Unsigned (Base), Item (Last + 1 .. Item'Last), Last, Error => Error); pragma Assert (not Error); Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := '#'; end if; -- split Aft := modfl (abs Value, Item_Fore'Access); Float.Aft_Scale ( Aft, Scaled_Aft, 0, Round_Up, Base => Base, Aft_Width => Aft_Width); if Round_Up then Item_Fore := Item_Fore + 1.0; Scaled_Aft := 0.0; end if; -- integer part Required_Fore_Width := Float.Fore_Digits_Width (Item_Fore, Base => Base); if Fore_Digits_Width > Required_Fore_Width then pragma Assert ( Last + Fore_Digits_Width - Required_Fore_Width <= Item'Last); Fill_Padding ( Item (Last + 1 .. Last + Fore_Digits_Width - Required_Fore_Width), Fore_Digits_Fill); Last := Last + Fore_Digits_Width - Required_Fore_Width; end if; pragma Assert (Last + Required_Fore_Width <= Item'Last); for I in reverse Last + 1 .. Last + Required_Fore_Width loop declare Q : Long_Long_Float; R : Long_Long_Float; begin Long_Long_Float_Types.Divide ( Item_Fore, Long_Long_Float (Base), Q, R); Image (Digit (R), Item (I), Set => Set); Item_Fore := Q; end; end loop; Last := Last + Required_Fore_Width; Fore_Last := Last; -- '.' and decimal part pragma Assert (Last + Aft_Width <= Item'Last); Float.Aft_Image ( Scaled_Aft, Item (Last + 1 .. Item'Last), Last, Base => Base, Set => Set, Aft_Width => Aft_Width); -- closing '#' if Base_Form then Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := '#'; end if; end Image_No_Sign_Nor_Exponent; procedure Image_No_Exponent ( Value : Long_Long_Float; Item : out String; -- same as above except unnecessary width for exponent Fore_Last, Last : out Natural; Signs : Sign_Marks := ('-', ' ', ' '); Base : Number_Base := 10; Base_Form : Boolean := False; Set : Type_Set := Upper_Case; Fore_Digits_Width : Positive := 1; Fore_Digits_Fill : Character := '0'; Aft_Width : Positive; NaN : String := "NAN"; Infinity : String := "INF") is begin Last := Item'First - 1; declare Sign : constant Character := Sign_Mark (Value, Signs); begin if Sign /= No_Sign then Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := Sign; end if; end; if isnanl (Value) /= 0 then declare First : constant Positive := Last + 1; begin Last := Last + NaN'Length; pragma Assert (Last <= Item'Last); Item (First .. Last) := NaN; Fore_Last := Last; end; elsif isinfl (Value) /= 0 then declare First : constant Positive := Last + 1; begin Last := Last + Infinity'Length; pragma Assert (Last <= Item'Last); Item (First .. Last) := Infinity; Fore_Last := Last; end; else Image_No_Sign_Nor_Exponent ( Value, Item (Last + 1 .. Item'Last), Fore_Last, Last, Base => Base, Base_Form => Base_Form, Set => Set, Fore_Digits_Width => Fore_Digits_Width, Fore_Digits_Fill => Fore_Digits_Fill, Aft_Width => Aft_Width); end if; end Image_No_Exponent; procedure Image ( Value : Long_Long_Float; Item : out String; Fore_Last, Last : out Natural; Signs : Sign_Marks := ('-', ' ', ' '); Base : Number_Base := 10; Base_Form : Boolean := False; Set : Type_Set := Upper_Case; Fore_Digits_Width : Positive := 1; Fore_Digits_Fill : Character := '0'; Aft_Width : Positive; Exponent_Mark : Character := 'E'; Exponent_Signs : Sign_Marks := ('-', '+', '+'); Exponent_Digits_Width : Positive := 2; Exponent_Digits_Fill : Character := '0'; NaN : String := "NAN"; Infinity : String := "INF") is begin Last := Item'First - 1; declare Sign : constant Character := Sign_Mark (Value, Signs); begin if Sign /= No_Sign then Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := Sign; end if; end; if isnanl (Value) /= 0 then declare First : constant Positive := Last + 1; begin Last := Last + NaN'Length; pragma Assert (Last <= Item'Last); Item (First .. Last) := NaN; Fore_Last := Last; end; elsif isinfl (Value) /= 0 then declare First : constant Positive := Last + 1; begin Last := Last + Infinity'Length; pragma Assert (Last <= Item'Last); Item (First .. Last) := Infinity; Fore_Last := Last; end; else declare Fore : Digit; Aft : Long_Long_Float; Exponent : Integer; Abs_Exponent : Word_Unsigned; Scaled_Aft : Long_Long_Float; Rouned_Up : Boolean; Error : Boolean; begin Split ( abs Value, Fore, Aft, Exponent, Base => Base); Aft_Scale ( Aft, Scaled_Aft, Exponent, Rouned_Up, Base => Base, Aft_Width => Aft_Width); if Rouned_Up then Fore := Fore + 1; Scaled_Aft := 0.0; if Fore >= Base then Fore := 1; Exponent := Exponent + 1; end if; end if; -- opening '#' if Base_Form then Image ( Word_Unsigned (Base), Item (Last + 1 .. Item'Last), Last, Error => Error); pragma Assert (not Error); Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := '#'; end if; -- integer part pragma Assert (Last + Fore_Digits_Width <= Item'Last); Fill_Padding ( Item (Last + 1 .. Last + Fore_Digits_Width - 1), Fore_Digits_Fill); Last := Last + Fore_Digits_Width; -- including one digit Image (Fore, Item (Last), Set => Set); Fore_Last := Last; -- '.' and decimal part pragma Assert (Last + 1 + Aft_Width <= Item'Last); Aft_Image ( Scaled_Aft, Item (Last + 1 .. Item'Last), Last, Base => Base, Aft_Width => Aft_Width); -- closing # if Base_Form then Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := '#'; end if; -- exponent Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := Exponent_Mark; declare Exponent_Sign : Character; begin if Exponent < 0 then Abs_Exponent := -Word_Unsigned'Mod (Exponent); Exponent_Sign := Exponent_Signs.Minus; else Abs_Exponent := Word_Unsigned (Exponent); if Exponent > 0 then Exponent_Sign := Exponent_Signs.Plus; else Exponent_Sign := Exponent_Signs.Zero; end if; end if; if Exponent_Sign /= No_Sign then Last := Last + 1; pragma Assert (Last <= Item'Last); Item (Last) := Exponent_Sign; end if; end; Image ( Abs_Exponent, Item (Last + 1 .. Item'Last), Last, Width => Exponent_Digits_Width, Fill => Exponent_Digits_Fill, Error => Error); pragma Assert (not Error); end; end if; end Image; end System.Formatting.Float;
------------------------------------------------------------------------------ -- -- -- 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 System; use System; pragma Warnings (Off, "* is an internal GNAT unit"); with System.BB.Parameters; pragma Warnings (On, "* is an internal GNAT unit"); with STM32_SVD.RCC; use STM32_SVD.RCC; package body STM32.Device is HSE_VALUE : constant UInt32 := UInt32 (System.BB.Parameters.HSE_Clock); -- External oscillator in Hz HSI_VALUE : constant := 16_000_000; -- Internal oscillator in Hz HPRE_Presc_Table : constant array (UInt4) of UInt32 := (1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 8, 16, 64, 128, 256, 512); PPRE_Presc_Table : constant array (UInt3) of UInt32 := (1, 1, 1, 1, 2, 4, 8, 16); ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out GPIO_Port) is begin if This'Address = GPIOA_Base then RCC_Periph.AHB1ENR.GPIOAEN := True; elsif This'Address = GPIOB_Base then RCC_Periph.AHB1ENR.GPIOBEN := True; elsif This'Address = GPIOC_Base then RCC_Periph.AHB1ENR.GPIOCEN := True; elsif This'Address = GPIOD_Base then RCC_Periph.AHB1ENR.GPIODEN := True; elsif This'Address = GPIOE_Base then RCC_Periph.AHB1ENR.GPIOEEN := True; elsif This'Address = GPIOF_Base then RCC_Periph.AHB1ENR.GPIOFEN := True; elsif This'Address = GPIOG_Base then RCC_Periph.AHB1ENR.GPIOGEN := True; elsif This'Address = GPIOH_Base then RCC_Periph.AHB1ENR.GPIOHEN := True; elsif This'Address = GPIOI_Base then RCC_Periph.AHB1ENR.GPIOIEN := True; elsif This'Address = GPIOJ_Base then RCC_Periph.AHB1ENR.GPIOJEN := True; elsif This'Address = GPIOK_Base then RCC_Periph.AHB1ENR.GPIOKEN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (Point : GPIO_Point) is begin Enable_Clock (Point.Periph.all); end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (Points : GPIO_Points) is begin for Point of Points loop Enable_Clock (Point.Periph.all); end loop; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out GPIO_Port) is begin if This'Address = GPIOA_Base then RCC_Periph.AHB1RSTR.GPIOARST := True; RCC_Periph.AHB1RSTR.GPIOARST := False; elsif This'Address = GPIOB_Base then RCC_Periph.AHB1RSTR.GPIOBRST := True; RCC_Periph.AHB1RSTR.GPIOBRST := False; elsif This'Address = GPIOC_Base then RCC_Periph.AHB1RSTR.GPIOCRST := True; RCC_Periph.AHB1RSTR.GPIOCRST := False; elsif This'Address = GPIOD_Base then RCC_Periph.AHB1RSTR.GPIODRST := True; RCC_Periph.AHB1RSTR.GPIODRST := False; elsif This'Address = GPIOE_Base then RCC_Periph.AHB1RSTR.GPIOERST := True; RCC_Periph.AHB1RSTR.GPIOERST := False; elsif This'Address = GPIOF_Base then RCC_Periph.AHB1RSTR.GPIOFRST := True; RCC_Periph.AHB1RSTR.GPIOFRST := False; elsif This'Address = GPIOG_Base then RCC_Periph.AHB1RSTR.GPIOGRST := True; RCC_Periph.AHB1RSTR.GPIOGRST := False; elsif This'Address = GPIOH_Base then RCC_Periph.AHB1RSTR.GPIOHRST := True; RCC_Periph.AHB1RSTR.GPIOHRST := False; elsif This'Address = GPIOI_Base then RCC_Periph.AHB1RSTR.GPIOIRST := True; RCC_Periph.AHB1RSTR.GPIOIRST := False; elsif This'Address = GPIOJ_Base then RCC_Periph.AHB1RSTR.GPIOJRST := True; RCC_Periph.AHB1RSTR.GPIOJRST := False; elsif This'Address = GPIOK_Base then RCC_Periph.AHB1RSTR.GPIOKRST := True; RCC_Periph.AHB1RSTR.GPIOKRST := False; else raise Unknown_Device; end if; end Reset; ----------- -- Reset -- ----------- procedure Reset (Point : GPIO_Point) is begin Reset (Point.Periph.all); end Reset; ----------- -- Reset -- ----------- procedure Reset (Points : GPIO_Points) is Do_Reset : Boolean; begin for J in Points'Range loop Do_Reset := True; for K in Points'First .. J - 1 loop if Points (K).Periph = Points (J).Periph then Do_Reset := False; exit; end if; end loop; if Do_Reset then Reset (Points (J).Periph.all); end if; end loop; end Reset; ------------------------------ -- GPIO_Port_Representation -- ------------------------------ function GPIO_Port_Representation (Port : GPIO_Port) return UInt4 is begin -- TODO: rather ugly to have this board-specific range here if Port'Address = GPIOA_Base then return 0; elsif Port'Address = GPIOB_Base then return 1; elsif Port'Address = GPIOC_Base then return 2; elsif Port'Address = GPIOD_Base then return 3; elsif Port'Address = GPIOE_Base then return 4; elsif Port'Address = GPIOF_Base then return 5; elsif Port'Address = GPIOG_Base then return 6; elsif Port'Address = GPIOH_Base then return 7; elsif Port'Address = GPIOI_Base then return 8; elsif Port'Address = GPIOJ_Base then return 9; elsif Port'Address = GPIOK_Base then return 10; else raise Program_Error; end if; end GPIO_Port_Representation; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out Analog_To_Digital_Converter) is begin if This'Address = ADC1_Base then RCC_Periph.APB2ENR.ADC1EN := True; elsif This'Address = ADC2_Base then RCC_Periph.APB2ENR.ADC2EN := True; elsif This'Address = ADC3_Base then RCC_Periph.APB2ENR.ADC3EN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------------- -- Reset_All_ADC_Units -- ------------------------- procedure Reset_All_ADC_Units is begin RCC_Periph.APB2RSTR.ADCRST := True; RCC_Periph.APB2RSTR.ADCRST := False; end Reset_All_ADC_Units; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out Digital_To_Analog_Converter) is pragma Unreferenced (This); begin RCC_Periph.APB1ENR.DACEN := True; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out Digital_To_Analog_Converter) is pragma Unreferenced (This); begin RCC_Periph.APB1RSTR.DACRST := True; RCC_Periph.APB1RSTR.DACRST := False; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out USART) is begin if This.Periph.all'Address = USART1_Base then RCC_Periph.APB2ENR.USART1EN := True; elsif This.Periph.all'Address = USART2_Base then RCC_Periph.APB1ENR.USART2EN := True; elsif This.Periph.all'Address = USART3_Base then RCC_Periph.APB1ENR.USART3EN := True; elsif This.Periph.all'Address = UART4_Base then RCC_Periph.APB1ENR.UART4EN := True; elsif This.Periph.all'Address = UART5_Base then RCC_Periph.APB1ENR.UART5EN := True; elsif This.Periph.all'Address = USART6_Base then RCC_Periph.APB2ENR.USART6EN := True; elsif This.Periph.all'Address = UART7_Base then RCC_Periph.APB1ENR.UART7ENR := True; elsif This.Periph.all'Address = UART8_Base then RCC_Periph.APB1ENR.UART8ENR := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out USART) is begin if This.Periph.all'Address = USART1_Base then RCC_Periph.APB2RSTR.USART1RST := True; RCC_Periph.APB2RSTR.USART1RST := False; elsif This.Periph.all'Address = USART2_Base then RCC_Periph.APB1RSTR.UART2RST := True; RCC_Periph.APB1RSTR.UART2RST := False; elsif This.Periph.all'Address = USART3_Base then RCC_Periph.APB1RSTR.UART3RST := True; RCC_Periph.APB1RSTR.UART3RST := False; elsif This.Periph.all'Address = UART4_Base then RCC_Periph.APB1RSTR.UART4RST := True; RCC_Periph.APB1RSTR.UART4RST := False; elsif This.Periph.all'Address = UART5_Base then RCC_Periph.APB1RSTR.UART5RST := True; RCC_Periph.APB1RSTR.UART5RST := False; elsif This.Periph.all'Address = USART6_Base then RCC_Periph.APB2RSTR.USART6RST := True; RCC_Periph.APB2RSTR.USART6RST := False; elsif This.Periph.all'Address = UART7_Base then RCC_Periph.APB1RSTR.UART7RST := True; RCC_Periph.APB1RSTR.UART7RST := False; elsif This.Periph.all'Address = UART8_Base then RCC_Periph.APB1RSTR.UART8RST := True; RCC_Periph.APB1RSTR.UART8RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out DMA_Controller) is begin if This'Address = STM32_SVD.DMA1_Base then RCC_Periph.AHB1ENR.DMA1EN := True; elsif This'Address = STM32_SVD.DMA2_Base then RCC_Periph.AHB1ENR.DMA2EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out DMA_Controller) is begin if This'Address = STM32_SVD.DMA1_Base then RCC_Periph.AHB1RSTR.DMA1RST := True; RCC_Periph.AHB1RSTR.DMA1RST := False; elsif This'Address = STM32_SVD.DMA2_Base then RCC_Periph.AHB1RSTR.DMA2RST := True; RCC_Periph.AHB1RSTR.DMA2RST := False; else raise Unknown_Device; end if; end Reset; ---------------- -- As_Port_Id -- ---------------- function As_Port_Id (Port : I2C_Port) return I2C_Port_Id is begin if Port.Periph.all'Address = I2C1_Base then return I2C_Id_1; elsif Port.Periph.all'Address = I2C2_Base then return I2C_Id_2; elsif Port.Periph.all'Address = I2C3_Base then return I2C_Id_3; else raise Unknown_Device; end if; end As_Port_Id; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2C_Port) is begin Enable_Clock (As_Port_Id (This)); end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2C_Port_Id) is begin case This is when I2C_Id_1 => RCC_Periph.APB1ENR.I2C1EN := True; when I2C_Id_2 => RCC_Periph.APB1ENR.I2C2EN := True; when I2C_Id_3 => RCC_Periph.APB1ENR.I2C3EN := True; end case; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : I2C_Port) is begin Reset (As_Port_Id (This)); end Reset; ----------- -- Reset -- ----------- procedure Reset (This : I2C_Port_Id) is begin case This is when I2C_Id_1 => RCC_Periph.APB1RSTR.I2C1RST := True; RCC_Periph.APB1RSTR.I2C1RST := False; when I2C_Id_2 => RCC_Periph.APB1RSTR.I2C2RST := True; RCC_Periph.APB1RSTR.I2C2RST := False; when I2C_Id_3 => RCC_Periph.APB1RSTR.I2C3RST := True; RCC_Periph.APB1RSTR.I2C3RST := False; end case; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : SPI_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2ENR.SPI1EN := True; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1ENR.SPI2EN := True; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1ENR.SPI3EN := True; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2ENR.SPI4ENR := True; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2ENR.SPI5ENR := True; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB2ENR.SPI6ENR := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : SPI_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2RSTR.SPI1RST := True; RCC_Periph.APB2RSTR.SPI1RST := False; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1RSTR.SPI2RST := True; RCC_Periph.APB1RSTR.SPI2RST := False; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1RSTR.SPI3RST := True; RCC_Periph.APB1RSTR.SPI3RST := False; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2RSTR.SPI4RST := True; RCC_Periph.APB2RSTR.SPI4RST := False; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2RSTR.SPI5RST := True; RCC_Periph.APB2RSTR.SPI5RST := False; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB2RSTR.SPI6RST := True; RCC_Periph.APB2RSTR.SPI6RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2S_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2ENR.SPI1EN := True; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1ENR.SPI2EN := True; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1ENR.SPI3EN := True; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2ENR.SPI5ENR := True; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2ENR.SPI5ENR := True; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB2ENR.SPI6ENR := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out I2S_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2RSTR.SPI1RST := True; RCC_Periph.APB2RSTR.SPI1RST := False; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1RSTR.SPI2RST := True; RCC_Periph.APB1RSTR.SPI2RST := False; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1RSTR.SPI3RST := True; RCC_Periph.APB1RSTR.SPI3RST := False; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2RSTR.SPI4RST := True; RCC_Periph.APB2RSTR.SPI4RST := False; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2RSTR.SPI5RST := True; RCC_Periph.APB2RSTR.SPI5RST := False; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB2RSTR.SPI6RST := True; RCC_Periph.APB2RSTR.SPI6RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : in out Timer) is begin if This'Address = TIM1_Base then RCC_Periph.APB2ENR.TIM1EN := True; elsif This'Address = TIM2_Base then RCC_Periph.APB1ENR.TIM2EN := True; elsif This'Address = TIM3_Base then RCC_Periph.APB1ENR.TIM3EN := True; elsif This'Address = TIM4_Base then RCC_Periph.APB1ENR.TIM4EN := True; elsif This'Address = TIM5_Base then RCC_Periph.APB1ENR.TIM5EN := True; elsif This'Address = TIM6_Base then RCC_Periph.APB1ENR.TIM6EN := True; elsif This'Address = TIM7_Base then RCC_Periph.APB1ENR.TIM7EN := True; elsif This'Address = TIM8_Base then RCC_Periph.APB2ENR.TIM8EN := True; elsif This'Address = TIM9_Base then RCC_Periph.APB2ENR.TIM9EN := True; elsif This'Address = TIM10_Base then RCC_Periph.APB2ENR.TIM10EN := True; elsif This'Address = TIM11_Base then RCC_Periph.APB2ENR.TIM11EN := True; elsif This'Address = TIM12_Base then RCC_Periph.APB1ENR.TIM12EN := True; elsif This'Address = TIM13_Base then RCC_Periph.APB1ENR.TIM13EN := True; elsif This'Address = TIM14_Base then RCC_Periph.APB1ENR.TIM14EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out Timer) is begin if This'Address = TIM1_Base then RCC_Periph.APB2RSTR.TIM1RST := True; RCC_Periph.APB2RSTR.TIM1RST := False; elsif This'Address = TIM2_Base then RCC_Periph.APB1RSTR.TIM2RST := True; RCC_Periph.APB1RSTR.TIM2RST := False; elsif This'Address = TIM3_Base then RCC_Periph.APB1RSTR.TIM3RST := True; RCC_Periph.APB1RSTR.TIM3RST := False; elsif This'Address = TIM4_Base then RCC_Periph.APB1RSTR.TIM4RST := True; RCC_Periph.APB1RSTR.TIM4RST := False; elsif This'Address = TIM5_Base then RCC_Periph.APB1RSTR.TIM5RST := True; RCC_Periph.APB1RSTR.TIM5RST := False; elsif This'Address = TIM6_Base then RCC_Periph.APB1RSTR.TIM6RST := True; RCC_Periph.APB1RSTR.TIM6RST := False; elsif This'Address = TIM7_Base then RCC_Periph.APB1RSTR.TIM7RST := True; RCC_Periph.APB1RSTR.TIM7RST := False; elsif This'Address = TIM8_Base then RCC_Periph.APB2RSTR.TIM8RST := True; RCC_Periph.APB2RSTR.TIM8RST := False; elsif This'Address = TIM9_Base then RCC_Periph.APB2RSTR.TIM9RST := True; RCC_Periph.APB2RSTR.TIM9RST := False; elsif This'Address = TIM10_Base then RCC_Periph.APB2RSTR.TIM10RST := True; RCC_Periph.APB2RSTR.TIM10RST := False; elsif This'Address = TIM11_Base then RCC_Periph.APB2RSTR.TIM11RST := True; RCC_Periph.APB2RSTR.TIM11RST := False; elsif This'Address = TIM12_Base then RCC_Periph.APB1RSTR.TIM12RST := True; RCC_Periph.APB1RSTR.TIM12RST := False; elsif This'Address = TIM13_Base then RCC_Periph.APB1RSTR.TIM13RST := True; RCC_Periph.APB1RSTR.TIM13RST := False; elsif This'Address = TIM14_Base then RCC_Periph.APB1RSTR.TIM14RST := True; RCC_Periph.APB1RSTR.TIM14RST := False; else raise Unknown_Device; end if; end Reset; ------------------------------ -- System_Clock_Frequencies -- ------------------------------ function System_Clock_Frequencies return RCC_System_Clocks is Source : constant UInt2 := RCC_Periph.CFGR.SWS; Result : RCC_System_Clocks; begin Result.I2SCLK := 0; case Source is when 0 => -- HSI as source Result.SYSCLK := HSI_VALUE; when 1 => -- HSE as source Result.SYSCLK := HSE_VALUE; when 2 => -- PLL as source declare HSE_Source : constant Boolean := RCC_Periph.PLLCFGR.PLLSRC; Pllm : constant UInt32 := UInt32 (RCC_Periph.PLLCFGR.PLLM); Plln : constant UInt32 := UInt32 (RCC_Periph.PLLCFGR.PLLN); Pllp : constant UInt32 := (UInt32 (RCC_Periph.PLLCFGR.PLLP) + 1) * 2; Pllvco : UInt32; begin if not HSE_Source then Pllvco := HSI_VALUE; else Pllvco := HSE_VALUE; end if; Pllvco := Pllvco / Pllm; Result.I2SCLK := Pllvco; Pllvco := Pllvco * Plln; Result.SYSCLK := Pllvco / Pllp; end; when others => Result.SYSCLK := HSI_VALUE; end case; declare HPRE : constant UInt4 := RCC_Periph.CFGR.HPRE; PPRE1 : constant UInt3 := RCC_Periph.CFGR.PPRE.Arr (1); PPRE2 : constant UInt3 := RCC_Periph.CFGR.PPRE.Arr (2); begin Result.HCLK := Result.SYSCLK / HPRE_Presc_Table (HPRE); Result.PCLK1 := Result.HCLK / PPRE_Presc_Table (PPRE1); Result.PCLK2 := Result.HCLK / PPRE_Presc_Table (PPRE2); -- Timer clocks -- See Dedicated clock cfg register documentation. if not RCC_Periph.DCKCFGR.TIMPRE then -- Mode 0: -- If the APB prescaler (PPRE1, PPRE2 in the RCC_CFGR register) -- is configured to a division factor of 1, TIMxCLK = PCLKx. -- Otherwise, the timer clock frequencies are set to twice to the -- frequency of the APB domain to which the timers are connected : -- TIMxCLK = 2xPCLKx. if PPRE_Presc_Table (PPRE1) = 1 then Result.TIMCLK1 := Result.PCLK1; else Result.TIMCLK1 := Result.PCLK1 * 2; end if; if PPRE_Presc_Table (PPRE2) = 1 then Result.TIMCLK2 := Result.PCLK2; else Result.TIMCLK2 := Result.PCLK2 * 2; end if; else -- Mpde 1: -- If the APB prescaler (PPRE1, PPRE2 in the RCC_CFGR register) is -- configured to a division factor of 1, 2 or 4, TIMxCLK = HCLK. -- Otherwise, the timer clock frequencies are set to four times -- to the frequency of the APB domain to which the timers are -- connected : TIMxCLK = 4xPCLKx. if PPRE_Presc_Table (PPRE1) in 1 .. 4 then Result.TIMCLK1 := Result.HCLK; else Result.TIMCLK1 := Result.PCLK1 * 4; end if; if PPRE_Presc_Table (PPRE2) in 1 .. 4 then Result.TIMCLK2 := Result.HCLK; else Result.TIMCLK2 := Result.PCLK1 * 4; end if; end if; end; -- I2S Clock -- if RCC_Periph.CFGR.I2SSRC then -- External clock source Result.I2SCLK := 0; raise Program_Error with "External I2S clock value is unknown"; else -- Pll clock source declare Plli2sn : constant UInt32 := UInt32 (RCC_Periph.PLLI2SCFGR.PLLI2SN); Plli2sr : constant UInt32 := UInt32 (RCC_Periph.PLLI2SCFGR.PLLI2SR); begin Result.I2SCLK := (Result.I2SCLK * Plli2sn) / Plli2sr; end; end if; return Result; end System_Clock_Frequencies; -------------------- -- PLLI2S_Enabled -- -------------------- function PLLI2S_Enabled return Boolean is (RCC_Periph.CR.PLLI2SRDY); ------------------------ -- Set_PLLI2S_Factors -- ------------------------ procedure Set_PLLI2S_Factors (Pll_N : UInt9; Pll_R : UInt3) is begin RCC_Periph.PLLI2SCFGR.PLLI2SN := Pll_N; RCC_Periph.PLLI2SCFGR.PLLI2SR := Pll_R; end Set_PLLI2S_Factors; ------------------- -- Enable_PLLI2S -- ------------------- procedure Enable_PLLI2S is begin RCC_Periph.CR.PLLI2SON := True; loop exit when PLLI2S_Enabled; end loop; end Enable_PLLI2S; -------------------- -- Disable_PLLI2S -- -------------------- procedure Disable_PLLI2S is begin RCC_Periph.CR.PLLI2SON := False; loop exit when not PLLI2S_Enabled; end loop; end Disable_PLLI2S; ------------------ -- PLLSAI_Ready -- ------------------ function PLLSAI_Ready return Boolean is begin -- SHould be PLLSAIRDY, but not binded by the SVD file -- PLLSAIRDY: bit 29 return (RCC_Periph.CR.Reserved_28_31 and 2) /= 0; end PLLSAI_Ready; ------------------- -- Enable_PLLSAI -- ------------------- procedure Enable_PLLSAI is begin -- Should be PLLSAION, but not binded by the SVD file -- PLLSAION: bit 28 RCC_Periph.CR.Reserved_28_31 := RCC_Periph.CR.Reserved_28_31 or 1; -- Wait for PLLSAI activation loop exit when PLLSAI_Ready; end loop; end Enable_PLLSAI; ------------------- -- Enable_PLLSAI -- ------------------- procedure Disable_PLLSAI is begin -- Should be PLLSAION, but not binded by the SVD file -- PLLSAION: bit 28 RCC_Periph.CR.Reserved_28_31 := RCC_Periph.CR.Reserved_28_31 and not 1; end Disable_PLLSAI; ------------------------ -- Set_PLLSAI_Factors -- ------------------------ procedure Set_PLLSAI_Factors (LCD : UInt3; VCO : UInt9; DivR : PLLSAI_DivR) is PLLSAICFGR : PLLSAICFGR_Register; begin PLLSAICFGR.PLLSAIR := LCD; PLLSAICFGR.PLLSAIN := VCO; RCC_Periph.PLLSAICFGR := PLLSAICFGR; -- The exact bit name is device-specific RCC_Periph.DCKCFGR.PLLSAIDIVR := UInt2 (DivR); end Set_PLLSAI_Factors; ----------------------- -- Enable_DCMI_Clock -- ----------------------- procedure Enable_DCMI_Clock is begin RCC_Periph.AHB2ENR.DCMIEN := True; end Enable_DCMI_Clock; ---------------- -- Reset_DCMI -- ---------------- procedure Reset_DCMI is begin RCC_Periph.AHB2RSTR.DCMIRST := True; RCC_Periph.AHB2RSTR.DCMIRST := False; end Reset_DCMI; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : in out CRC_32) is pragma Unreferenced (This); begin RCC_Periph.AHB1ENR.CRCEN := True; end Enable_Clock; ------------------- -- Disable_Clock -- ------------------- procedure Disable_Clock (This : in out CRC_32) is pragma Unreferenced (This); begin RCC_Periph.AHB1ENR.CRCEN := False; end Disable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out CRC_32) is pragma Unreferenced (This); begin RCC_Periph.AHB1RSTR.CRCRST := True; RCC_Periph.AHB1RSTR.CRCRST := False; end Reset; end STM32.Device;
package body calc with SPARK_Mode is function calc (f1, f2: Float) return Float is begin return f1 * f2; -- Float overflow check proved, but it throws an exception because of underflow. end calc; end calc;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Containers.Hashed_Maps; with Program.Visibility; with Program.Symbol_Lists; package Program.Library_Environments is pragma Preelaborate; type Library_Environment is tagged limited private; function Public_View (Self : Library_Environment'Class; Name : Program.Symbol_Lists.Symbol_List) return Program.Visibility.Snapshot_Access; -- Return a library level view of a unit with given Name as it's visible -- from a public child unit. procedure Put_Public_View (Self : in out Library_Environment'Class; Name : Program.Symbol_Lists.Symbol_List; Value : Program.Visibility.Snapshot_Access); -- Remember a library level view of a unit with given Name as it's visible -- from a public child unit. private package Snapshot_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Program.Symbol_Lists.Symbol_List, Element_Type => Program.Visibility.Snapshot_Access, Hash => Program.Symbol_Lists.Hash, Equivalent_Keys => Program.Symbol_Lists."=", "=" => Program.Visibility."="); type Library_Environment is tagged limited record Public_Views : Snapshot_Maps.Map; end record; end Program.Library_Environments;
----------------------------------------------------------------------------- -- Delay provider for the write cycle for the EEPROM -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- package Delay_Provider is procedure Delay_MS (MS : Integer); end Delay_Provider;
------------------------------------------------------------------------------- -- 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.Util; package body Keccak.Generic_Parallel_Hash is --------------------------------------- -- Generic_Process_Parallel_Blocks -- --------------------------------------- generic with package SHAKE_Parallel_N is new Keccak.Generic_Parallel_XOF (<>); procedure Generic_Process_Parallel_Blocks (Ctx : in out Context; Data : in Types.Byte_Array) with Pre => (Data'Length = Ctx.Block_Size * SHAKE_Parallel_N.Num_Parallel_Instances and State_Of (Ctx) = Updating and Ctx.Partial_Block_Length = 0), Post => (State_Of (Ctx) = Updating and Ctx.Input_Len = Ctx'Old.Input_Len and Ctx.Partial_Block_Length = Ctx'Old.Partial_Block_Length and Ctx.Block_Size = Ctx'Old.Block_Size); -- Generic procedure to process N blocks in parallel. -- -- This procedure process N blocks in parallel to produce N chaining values -- (CV). The CVs are then processed in the outer (serial) cSHAKE. -- -- @param Ctx The KangarooTwelve context. -- -- @param Data Byte array containing N blocks. --------------------------------------- -- Generic_Process_Parallel_Blocks -- --------------------------------------- procedure Generic_Process_Parallel_Blocks (Ctx : in out Context; Data : in Types.Byte_Array) is N : constant Positive := SHAKE_Parallel_N.Num_Parallel_Instances; Parallel_Ctx : SHAKE_Parallel_N.Context; CV_N : Types.Byte_Array (1 .. CV_Size_Bytes * N); begin -- Process N blocks in parallel and produce N chaining values. SHAKE_Parallel_N.Init (Parallel_Ctx); SHAKE_Parallel_N.Update_Separate (Parallel_Ctx, Data); pragma Warnings (GNATprove, Off, "unused assignment to ""Parallel_Ctx""", Reason => "No further data needs to be extracted"); SHAKE_Parallel_N.Extract_Separate (Parallel_Ctx, CV_N); pragma Warnings (GNATprove, On); -- Process the chaining values with the outer CSHAKE. CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => CV_N); end Generic_Process_Parallel_Blocks; ------------------------------ -- Generic Instantiations -- ------------------------------ procedure Process_8_Parallel_Blocks is new Generic_Process_Parallel_Blocks (SHAKE_Parallel_8); procedure Process_4_Parallel_Blocks is new Generic_Process_Parallel_Blocks (SHAKE_Parallel_4); procedure Process_2_Parallel_Blocks is new Generic_Process_Parallel_Blocks (SHAKE_Parallel_2); ----------------------- -- Process_1_Block -- ----------------------- procedure Process_1_Block (Ctx : in out Context; Data : in Types.Byte_Array) with Pre => (Data'Length <= Ctx.Block_Size and State_Of (Ctx) = Updating and Ctx.Partial_Block_Length = 0), Post => (State_Of (Ctx) = Updating and Ctx.Input_Len = Ctx'Old.Input_Len and Ctx.Partial_Block_Length = Ctx'Old.Partial_Block_Length and Ctx.Block_Size = Ctx'Old.Block_Size); -- Processes a single block using a serial CSHAKE. ----------------------- -- Process_1_Block -- ----------------------- procedure Process_1_Block (Ctx : in out Context; Data : in Types.Byte_Array) is Serial_Ctx : SHAKE_Serial.Context; CV : Types.Byte_Array (1 .. CV_Size_Bytes); begin -- Process N blocks in parallel and produce N changing values. SHAKE_Serial.Init (Serial_Ctx); SHAKE_Serial.Update (Serial_Ctx, Data); pragma Warnings (GNATprove, Off, "unused assignment to ""Serial_Ctx""", Reason => "No further data needs to be extracted"); SHAKE_Serial.Extract (Serial_Ctx, CV); pragma Warnings (GNATprove, On); -- Process the chaining values with the outer CSHAKE. CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => CV); end Process_1_Block; ---------------------------- -- Add_To_Partial_Block -- ---------------------------- procedure Add_To_Partial_Block (Ctx : in out Context; Data : in Types.Byte_Array; Added : out Natural) with Pre => ((if Ctx.Partial_Block_Length > 0 then Max_Input_Length (Ctx) >= Data'Length) and State_Of (Ctx) = Updating), Post => (Added <= Ctx.Block_Size and Added <= Data'Length and (if Added < Data'Length then Ctx.Partial_Block_Length = 0) and State_Of (Ctx) = Updating and Num_Bytes_Processed (Ctx) = Num_Bytes_Processed (Ctx'Old) + Byte_Count (Added) and Ctx.Block_Size = Ctx'Old.Block_Size), Contract_Cases => (Ctx.Partial_Block_Length = 0 and Data'Length = 0 => Added = 0 and Ctx.Partial_Block_Length = 0, Ctx.Partial_Block_Length = 0 and Data'Length > 0 => Added = 0 and Ctx.Partial_Block_Length = 0, Ctx.Partial_Block_Length > 0 and Data'Length = 0 => Added = 0 and Ctx.Partial_Block_Length = Ctx'Old.Partial_Block_Length, Ctx.Partial_Block_Length > 0 and Data'Length > 0 => Added > 0); ---------------------------- -- Add_To_Partial_Block -- ---------------------------- procedure Add_To_Partial_Block (Ctx : in out Context; Data : in Types.Byte_Array; Added : out Natural) is Free_In_Block : Natural; CV : Types.Byte_Array (1 .. CV_Size_Bytes); begin if Ctx.Partial_Block_Length > 0 then Free_In_Block := Ctx.Block_Size - Ctx.Partial_Block_Length; if Data'Length >= Free_In_Block then SHAKE_Serial.Update (Ctx => Ctx.Partial_Block_CSHAKE, Message => Data (Data'First .. Data'First + (Free_In_Block - 1))); pragma Warnings (GNATprove, Off, "unused assignment", Reason => "No further data needs to be extracted before Init"); SHAKE_Serial.Extract (Ctx => Ctx.Partial_Block_CSHAKE, Digest => CV); pragma Warnings (GNATprove, On); CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => CV); SHAKE_Serial.Init (Ctx.Partial_Block_CSHAKE); Ctx.Partial_Block_Length := 0; Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Free_In_Block); Added := Free_In_Block; else SHAKE_Serial.Update (Ctx => Ctx.Partial_Block_CSHAKE, Message => Data); Ctx.Partial_Block_Length := Ctx.Partial_Block_Length + Data'Length; Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Data'Length); Added := Data'Length; end if; else Added := 0; end if; end Add_To_Partial_Block; ---------------------------------- -- Process_Last_Partial_Block -- ---------------------------------- procedure Process_Last_Partial_Block (Ctx : in out Context) with Global => null, Pre => State_Of (Ctx) = Updating, Post => (State_Of (Ctx) = Updating and Ctx.Partial_Block_Length = 0); ---------------------------------- -- Process_Last_Partial_Block -- ---------------------------------- procedure Process_Last_Partial_Block (Ctx : in out Context) is CV : Types.Byte_Array (0 .. CV_Size_Bytes - 1); begin if Ctx.Partial_Block_Length > 0 then SHAKE_Serial.Extract (Ctx.Partial_Block_CSHAKE, CV); CSHAKE_Serial.Update (Ctx.Outer_CSHAKE, CV); SHAKE_Serial.Init (Ctx.Partial_Block_CSHAKE); Ctx.Partial_Block_Length := 0; end if; end Process_Last_Partial_Block; ------------ -- Init -- ------------ procedure Init (Ctx : out Context; Block_Size : in Block_Size_Number; Customization : in String) is begin Ctx.Partial_Block_Length := 0; Ctx.Block_Size := Block_Size; Ctx.Input_Len := 0; Ctx.Finished := False; CSHAKE_Serial.Init (Ctx => Ctx.Outer_CSHAKE, Customization => Customization, Function_Name => "ParallelHash"); SHAKE_Serial.Init (Ctx.Partial_Block_CSHAKE); CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => Util.Left_Encode_NIST (Block_Size)); end Init; -------------- -- Update -- -------------- procedure Update (Ctx : in out Context; Data : in Types.Byte_Array) is Initial_Bytes_Processed : constant Byte_Count := Num_Bytes_Processed (Ctx); Initial_Block_Size : constant Positive := Ctx.Block_Size; Remaining : Natural; Offset : Natural; Pos : Types.Index_Number; begin Add_To_Partial_Block (Ctx, Data, Offset); Remaining := Data'Length - Offset; if Remaining > 0 then pragma Assert (Ctx.Partial_Block_Length = 0); pragma Assert (Num_Bytes_Processed (Ctx) = Initial_Bytes_Processed + Byte_Count (Offset)); pragma Assert (Byte_Count (Remaining) <= Max_Input_Length (Ctx)); -- Process blocks of 8 in parallel while Remaining >= Ctx.Block_Size * 8 loop pragma Loop_Invariant (Offset + Remaining = Data'Length); pragma Loop_Invariant (State_Of (Ctx) = Updating); pragma Loop_Invariant (Ctx.Input_Len = Initial_Bytes_Processed + Byte_Count (Offset)); pragma Loop_Invariant (Byte_Count (Remaining) <= Byte_Count'Last - Ctx.Input_Len); pragma Loop_Invariant (Ctx.Partial_Block_Length = 0); pragma Loop_Invariant (Ctx.Block_Size = Initial_Block_Size); Pos := Data'First + Offset; Process_8_Parallel_Blocks (Ctx => Ctx, Data => Data (Pos .. Pos + ((Ctx.Block_Size * 8) - 1))); Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Ctx.Block_Size * 8); Offset := Offset + (Ctx.Block_Size * 8); Remaining := Remaining - (Ctx.Block_Size * 8); end loop; pragma Assert_And_Cut (Offset + Remaining = Data'Length and State_Of (Ctx) = Updating and Num_Bytes_Processed (Ctx) = Initial_Bytes_Processed + Byte_Count (Offset) and Byte_Count (Remaining) <= Max_Input_Length (Ctx) and Ctx.Partial_Block_Length = 0 and Ctx.Block_Size = Initial_Block_Size and Remaining < Ctx.Block_Size * 8); -- Process blocks of 4 in parallel while Remaining >= Ctx.Block_Size * 4 loop pragma Loop_Invariant (Offset + Remaining = Data'Length); pragma Loop_Invariant (State_Of (Ctx) = Updating); pragma Loop_Invariant (Ctx.Input_Len = Initial_Bytes_Processed + Byte_Count (Offset)); pragma Loop_Invariant (Byte_Count (Remaining) <= Byte_Count'Last - Ctx.Input_Len); pragma Loop_Invariant (Ctx.Partial_Block_Length = 0); pragma Loop_Invariant (Ctx.Block_Size = Initial_Block_Size); Pos := Data'First + Offset; Process_4_Parallel_Blocks (Ctx => Ctx, Data => Data (Pos .. Pos + ((Ctx.Block_Size * 4) - 1))); Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Ctx.Block_Size * 4); Offset := Offset + (Ctx.Block_Size * 4); Remaining := Remaining - (Ctx.Block_Size * 4); end loop; pragma Assert_And_Cut (Offset + Remaining = Data'Length and State_Of (Ctx) = Updating and Num_Bytes_Processed (Ctx) = Initial_Bytes_Processed + Byte_Count (Offset) and Byte_Count (Remaining) <= Max_Input_Length (Ctx) and Ctx.Partial_Block_Length = 0 and Ctx.Block_Size = Initial_Block_Size and Remaining < Ctx.Block_Size * 4); -- Process blocks of 2 in parallel while Remaining >= Ctx.Block_Size * 2 loop pragma Loop_Invariant (Offset + Remaining = Data'Length); pragma Loop_Invariant (State_Of (Ctx) = Updating); pragma Loop_Invariant (Ctx.Input_Len = Initial_Bytes_Processed + Byte_Count (Offset)); pragma Loop_Invariant (Byte_Count (Remaining) <= Byte_Count'Last - Ctx.Input_Len); pragma Loop_Invariant (Ctx.Partial_Block_Length = 0); pragma Loop_Invariant (Ctx.Block_Size = Initial_Block_Size); Pos := Data'First + Offset; Process_2_Parallel_Blocks (Ctx => Ctx, Data => Data (Pos .. Pos + ((Ctx.Block_Size * 2) - 1))); Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Ctx.Block_Size * 2); Offset := Offset + (Ctx.Block_Size * 2); Remaining := Remaining - (Ctx.Block_Size * 2); end loop; pragma Assert_And_Cut (Offset + Remaining = Data'Length and State_Of (Ctx) = Updating and Num_Bytes_Processed (Ctx) = Initial_Bytes_Processed + Byte_Count (Offset) and Byte_Count (Remaining) <= Max_Input_Length (Ctx) and Ctx.Partial_Block_Length = 0 and Ctx.Block_Size = Initial_Block_Size and Remaining < Ctx.Block_Size * 2); -- Process single blocks if Remaining >= Ctx.Block_Size then Pos := Data'First + Offset; Process_1_Block (Ctx => Ctx, Data => Data (Pos .. Pos + (Ctx.Block_Size - 1))); Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Ctx.Block_Size); Offset := Offset + Ctx.Block_Size; Remaining := Remaining - Ctx.Block_Size; end if; pragma Assert (Offset + Remaining = Data'Length); pragma Assert (State_Of (Ctx) = Updating); pragma Assert (Num_Bytes_Processed (Ctx) = Initial_Bytes_Processed + Byte_Count (Offset)); pragma Assert (Remaining < Ctx.Block_Size); -- Process remaining data. if Remaining > 0 then SHAKE_Serial.Update (Ctx => Ctx.Partial_Block_CSHAKE, Message => Data (Data'First + Offset .. Data'Last)); Ctx.Partial_Block_Length := Remaining; Ctx.Input_Len := Ctx.Input_Len + Byte_Count (Remaining); end if; end if; end Update; -------------- -- Finish -- -------------- procedure Finish (Ctx : in out Context; Data : out Types.Byte_Array) is Nb_Blocks : Long_Long_Integer; begin Nb_Blocks := Long_Long_Integer (Ctx.Input_Len) / Long_Long_Integer (Ctx.Block_Size); if Ctx.Partial_Block_Length > 0 then pragma Assert (Ctx.Block_Size > 1); pragma Assert (Nb_Blocks < Long_Long_Integer'Last); Nb_Blocks := Nb_Blocks + 1; end if; Process_Last_Partial_Block (Ctx); Ctx.Finished := True; CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => Util.Right_Encode_NIST_Long_Long (Nb_Blocks)); CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => Util.Right_Encode_NIST_Bit_Length (Data'Length)); CSHAKE_Serial.Extract (Ctx => Ctx.Outer_CSHAKE, Digest => Data); end Finish; --------------- -- Extract -- --------------- procedure Extract (Ctx : in out Context; Data : out Types.Byte_Array) is Nb_Blocks : Long_Long_Integer; begin if State_Of (Ctx) = Updating then Nb_Blocks := Long_Long_Integer (Ctx.Input_Len) / Long_Long_Integer (Ctx.Block_Size); if Ctx.Partial_Block_Length > 0 then pragma Assert (Ctx.Block_Size > 1); pragma Assert (Nb_Blocks < Long_Long_Integer'Last); Nb_Blocks := Nb_Blocks + 1; end if; Process_Last_Partial_Block (Ctx); CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => Util.Right_Encode_NIST_Long_Long (Nb_Blocks)); CSHAKE_Serial.Update (Ctx => Ctx.Outer_CSHAKE, Message => Util.Right_Encode_NIST (0)); end if; CSHAKE_Serial.Extract (Ctx => Ctx.Outer_CSHAKE, Digest => Data); end Extract; end Keccak.Generic_Parallel_Hash;
with System; with Interfaces.C; with System.Address_To_Access_Conversions; package XEvent is package C renames Interfaces.C; type XKeyEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; root : aliased C.Unsigned_Long; subwindow : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; x_root : aliased C.Int; y_root : aliased C.Int; state : aliased C.Unsigned; keycode : aliased C.Unsigned; same_screen : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XKeyEvent); subtype XKeyPressedEvent is XKeyEvent; subtype XKeyReleasedEvent is XKeyEvent; type XButtonEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; root : aliased C.Unsigned_Long; subwindow : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; x_root : aliased C.Int; y_root : aliased C.Int; state : aliased C.Unsigned; button : aliased C.Unsigned; same_screen : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XButtonEvent); subtype XButtonPressedEvent is XButtonEvent; subtype XButtonReleasedEvent is XButtonEvent; type XMotionEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; root : aliased C.Unsigned_Long; subwindow : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; x_root : aliased C.Int; y_root : aliased C.Int; state : aliased C.Unsigned; is_hint : aliased C.char; same_screen : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XMotionEvent); subtype XPointerMovedEvent is XMotionEvent; type XCrossingEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; root : aliased C.Unsigned_Long; subwindow : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; x_root : aliased C.Int; y_root : aliased C.Int; mode : aliased C.Int; detail : aliased C.Int; same_screen : aliased C.Int; focus : aliased C.Int; state : aliased C.Unsigned; end record; pragma Convention (C_Pass_By_Copy, XCrossingEvent); subtype XEnterWindowEvent is XCrossingEvent; subtype XLeaveWindowEvent is XCrossingEvent; type XFocusChangeEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; mode : aliased C.Int; detail : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XFocusChangeEvent); subtype XFocusInEvent is XFocusChangeEvent; subtype XFocusOutEvent is XFocusChangeEvent; subtype XKeymapEvent_key_vector_array is Interfaces.C.char_array (0 .. 31); type XKeymapEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; key_vector : aliased XKeymapEvent_key_vector_array; end record; pragma Convention (C_Pass_By_Copy, XKeymapEvent); type XExposeEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; width : aliased C.Int; height : aliased C.Int; count : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XExposeEvent); type XGraphicsExposeEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_drawable : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; width : aliased C.Int; height : aliased C.Int; count : aliased C.Int; major_code : aliased C.Int; minor_code : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XGraphicsExposeEvent); type XNoExposeEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_drawable : aliased C.Unsigned_Long; major_code : aliased C.Int; minor_code : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XNoExposeEvent); type XVisibilityEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; state : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XVisibilityEvent); type XCreateWindowEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; parent : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; width : aliased C.Int; height : aliased C.Int; border_width : aliased C.Int; override_redirect : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XCreateWindowEvent); type XDestroyWindowEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XDestroyWindowEvent); type XUnmapEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; from_configure : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XUnmapEvent); type XMapEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; override_redirect : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XMapEvent); type XMapRequestEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; parent : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XMapRequestEvent); type XReparentEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; parent : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; override_redirect : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XReparentEvent); type XConfigureEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; width : aliased C.Int; height : aliased C.Int; border_width : aliased C.Int; above : aliased C.Unsigned_Long; override_redirect : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XConfigureEvent); type XGravityEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XGravityEvent); type XResizeRequestEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; width : aliased C.Int; height : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XResizeRequestEvent); type XConfigureRequestEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; parent : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; x : aliased C.Int; y : aliased C.Int; width : aliased C.Int; height : aliased C.Int; border_width : aliased C.Int; above : aliased C.Unsigned_Long; detail : aliased C.Int; value_mask : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XConfigureRequestEvent); type XCirculateEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; event : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; place : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XCirculateEvent); type XCirculateRequestEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; parent : aliased C.Unsigned_Long; the_window : aliased C.Unsigned_Long; place : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XCirculateRequestEvent); type XPropertyEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; the_atom : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; state : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XPropertyEvent); type XSelectionClearEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; selection : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XSelectionClearEvent); type XSelectionRequestEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; owner : aliased C.Unsigned_Long; requestor : aliased C.Unsigned_Long; selection : aliased C.Unsigned_Long; target : aliased C.Unsigned_Long; property : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XSelectionRequestEvent); type XSelectionEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; requestor : aliased C.Unsigned_Long; selection : aliased C.Unsigned_Long; target : aliased C.Unsigned_Long; property : aliased C.Unsigned_Long; the_time : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XSelectionEvent); type XColormapEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; the_colormap : aliased C.Unsigned_Long; c_new : aliased C.Int; state : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XColormapEvent); subtype anon1357_b_array is Interfaces.C.char_array (0 .. 19); type anon1357_s_array is array (0 .. 9) of aliased C.short; type anon1357_l_array is array (0 .. 4) of aliased C.long; type anon_1357 (discr : C.Unsigned := 0) is record case discr is when 0 => b : aliased anon1357_b_array; when 1 => s : aliased anon1357_s_array; when others => l : aliased anon1357_l_array; end case; end record; pragma Convention (C_Pass_By_Copy, anon_1357); pragma Unchecked_Union (anon_1357); subtype XClientMessageEvent_b_array is Interfaces.C.char_array (0 .. 19); type XClientMessageEvent_s_array is array (0 .. 9) of aliased C.short; type XClientMessageEvent_l_array is array (0 .. 4) of aliased C.long; type XClientMessageEvent_data_union (discr : C.Unsigned := 0) is record case discr is when 0 => b : aliased XClientMessageEvent_b_array; when 1 => s : aliased XClientMessageEvent_s_array; when others => l : aliased XClientMessageEvent_l_array; end case; end record; pragma Convention (C_Pass_By_Copy, XClientMessageEvent_data_union); pragma Unchecked_Union (XClientMessageEvent_data_union); type XClientMessageEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; message_type : aliased C.Unsigned_Long; format : aliased C.Int; data : XClientMessageEvent_data_union; end record; pragma Convention (C_Pass_By_Copy, XClientMessageEvent); type XMappingEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; request : aliased C.Int; first_keycode : aliased C.Int; count : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XMappingEvent); type XErrorEvent is record c_type : aliased C.Int; the_display : System.Address; resourceid : aliased C.Unsigned_Long; serial : aliased C.Unsigned_Long; error_code : aliased C.Unsigned_char; request_code : aliased C.Unsigned_char; minor_code : aliased C.Unsigned_char; end record; pragma Convention (C_Pass_By_Copy, XErrorEvent); type XAnyEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; the_window : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XAnyEvent); type XGenericEvent is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; extension : aliased C.Int; evtype : aliased C.Int; end record; pragma Convention (C_Pass_By_Copy, XGenericEvent); type XGenericEventCookie is record c_type : aliased C.Int; serial : aliased C.Unsigned_Long; send_event : aliased C.Int; the_display : System.Address; extension : aliased C.Int; evtype : aliased C.Int; cookie : aliased C.Unsigned; data : aliased System.Address; end record; pragma Convention (C_Pass_By_Copy, XGenericEventCookie); type anon1376_pad_array is array (0 .. 23) of aliased C.long; type u_XEvent (discr : C.Unsigned := 0) is record case discr is when 0 => c_type : aliased C.Int; when 1 => xany : aliased XAnyEvent; when 2 => xkey : aliased XKeyEvent; when 3 => xbutton : aliased XButtonEvent; when 4 => xmotion : aliased XMotionEvent; when 5 => xcrossing : aliased XCrossingEvent; when 6 => xfocus : aliased XFocusChangeEvent; when 7 => xexpose : aliased XExposeEvent; when 8 => xgraphicsexpose : aliased XGraphicsExposeEvent; when 9 => xnoexpose : aliased XNoExposeEvent; when 10 => xvisibility : aliased XVisibilityEvent; when 11 => xcreatewindow : aliased XCreateWindowEvent; when 12 => xdestroywindow : aliased XDestroyWindowEvent; when 13 => xunmap : aliased XUnmapEvent; when 14 => xmap : aliased XMapEvent; when 15 => xmaprequest : aliased XMapRequestEvent; when 16 => xreparent : aliased XReparentEvent; when 17 => xconfigure : aliased XConfigureEvent; when 18 => xgravity : aliased XGravityEvent; when 19 => xresizerequest : aliased XResizeRequestEvent; when 20 => xconfigurerequest : aliased XConfigureRequestEvent; when 21 => xcirculate : aliased XCirculateEvent; when 22 => xcirculaterequest : aliased XCirculateRequestEvent; when 23 => xproperty : aliased XPropertyEvent; when 24 => xselectionclear : aliased XSelectionClearEvent; when 25 => xselectionrequest : aliased XSelectionRequestEvent; when 26 => xselection : aliased XSelectionEvent; when 27 => xcolormap : aliased XColormapEvent; when 28 => xclient : aliased XClientMessageEvent; when 29 => xmapping : aliased XMappingEvent; when 30 => xerror : aliased XErrorEvent; when 31 => xkeymap : aliased XKeymapEvent; when 32 => xgeneric : aliased XGenericEvent; when 33 => xcookie : aliased XGenericEventCookie; when others => pad : aliased anon1376_pad_array; end case; end record; pragma Convention (C_Pass_By_Copy, u_XEvent); pragma Unchecked_Union (u_XEvent); subtype Event is U_XEvent; type XIEvent is record c_type : aliased C.int; serial : aliased C.unsigned_long; send_event : aliased C.int; the_display : System.Address; extension : aliased C.int; evtype : aliased C.int; the_time : aliased C.Unsigned_Long; end record; pragma Convention (C_Pass_By_Copy, XIEvent); type XIButtonState is record mask_len : aliased C.int; mask : access C.unsigned_char; end record; pragma Convention (C_Pass_By_Copy, XIButtonState); type XIValuatorState is record mask_len : aliased C.int; mask : access C.unsigned_char; values : access C.double; end record; pragma Convention (C_Pass_By_Copy, XIValuatorState); type XIModifierState is record base : aliased C.int; latched : aliased C.int; locked : aliased C.int; effective : aliased C.int; end record; pragma Convention (C_Pass_By_Copy, XIModifierState); type XIDeviceEvent is record c_type : aliased C.int; serial : aliased C.unsigned_long; send_event : aliased C.int; the_display : System.Address; extension : aliased C.int; evtype : aliased C.int; the_time : aliased C.Unsigned_Long; deviceid : aliased C.int; sourceid : aliased C.int; detail : aliased C.int; root : aliased C.Unsigned_Long; event : aliased C.Unsigned_Long; child : aliased C.Unsigned_Long; root_x : aliased C.double; root_y : aliased C.double; event_x : aliased C.double; event_y : aliased C.double; flags : aliased C.int; buttons : aliased XIButtonState; valuators : aliased XIValuatorState; mods : aliased XIModifierState; group : aliased XIModifierState; end record; pragma Convention (C_Pass_By_Copy, XIDeviceEvent); function XNextEvent (Display : System.Address; Any_Event : in out U_XEvent) return C.Int; pragma Import (C, XNextEvent, "XNextEvent"); function XGetEventData (Display : System.Address; Cookie : in out XGenericEventCookie) return C.Int; pragma Import (C, XGetEventData, "XGetEventData"); procedure XFreeEventData (Display : System.Address; Cookie : in out XGenericEventCookie); pragma Import (C, XFreeEventData, "XGetEventData"); package CastDeviceEvent is new System.Address_To_Access_Conversions (Object => XIDeviceEvent); subtype XIDeviceEvent_Access is CastDeviceEvent.Object_Pointer; end XEvent;
package Problem_71 is -- Consider the fraction, n/d, where n and d are positive integers. If n<d and HCF(n,d)=1, it is -- called a reduced proper fraction. -- If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size, we get: -- 1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8 -- It can be seen that 2/5 is the fraction immediately to the left of 3/7. -- By listing the set of reduced proper fractions for d ≤ 1,000,000 in ascending order of size, -- find the numerator of the fraction immediately to the left of 3/7. procedure Solve; end Problem_71;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . A R M _ G I C -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2006 The European Space Agency -- -- Copyright (C) 2003-2021, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ with Interfaces; use Interfaces; with System.BB.Parameters; with System.Machine_Code; package body System.ARM_GIC is use System.BB.Interrupts; subtype PRI is Unsigned_8; -- Type for GIC interrupt priorities. Note that 0 is the highest -- priority, which is reserved for the kernel and has no corresponding -- Interrupt_Priority value, and 255 is the lowest. We assume the -- PRIGROUP setting is such that the 4 most significant bits determine -- the priority group used for preemption. However, if less bits are -- implemented, this should still work. subtype Banked_Interrupt is Interrupt_ID range 0 .. 31; Interrupts_Enabled : array (Banked_Interrupt) of Boolean := (others => False); Interrupts_Priority : array (Banked_Interrupt) of PRI; subtype GIC_Interrupts is Interrupt_ID; -- Supports up to 192 interrupts, MaxIRQs need to be a aligned on 32 -- Number_of_IRQs = Interrupt_ID'Last + 1 -- Max_IRQs = (Number_Of_IRQs + 31) / 32 * 32 Max_IRQs : constant Natural := Natural'Min (192, ((Interrupt_ID'Last / 32 + 1) * 32)); function Reg_Num_32 (Intnum : GIC_Interrupts) return GIC_Interrupts is (Intnum / 32); -- 32-bit registers set -- Accessed by 32 bits chunks type Bits32_Register_Array is array (Natural range 0 .. Max_IRQs / 32 - 1) of Unsigned_32 with Pack, Volatile; -- Byte registers set -- Accessed by 8 bits chunks type Byte_Register_Array is array (Natural range 0 .. Max_IRQs - 1) of Unsigned_8 with Pack, Volatile; -- Byte registers set, accessed by 32-bit chunks type Byte_Register_Array32 is array (Natural range 0 .. Max_IRQs / 4 - 1) of Unsigned_32 with Pack, Volatile; type GICD_Peripheral is record CTLR : Unsigned_32; ISENABLER : Bits32_Register_Array; ICENABLER : Bits32_Register_Array; IPRIORITYR : Byte_Register_Array; ITARGETSR : Byte_Register_Array32; ICFGR : Byte_Register_Array32; SGIR : Unsigned_32; end record; for GICD_Peripheral use record CTLR at 16#000# range 0 .. 31; ISENABLER at 16#100# range 0 .. Max_IRQs - 1; ICENABLER at 16#180# range 0 .. Max_IRQs - 1; IPRIORITYR at 16#400# range 0 .. Max_IRQs * 8 - 1; ITARGETSR at 16#800# range 0 .. Max_IRQs * 8 - 1; ICFGR at 16#C00# range 0 .. Max_IRQs * 8 - 1; SGIR at 16#F00# range 0 .. 31; end record; type GICC_Peripheral is record CTLR : Unsigned_32; PMR : Unsigned_32; BPR : Unsigned_32; IAR : Unsigned_32; EOIR : Unsigned_32; end record; for GICC_Peripheral use record CTLR at 16#00# range 0 .. 31; PMR at 16#04# range 0 .. 31; BPR at 16#08# range 0 .. 31; IAR at 16#0C# range 0 .. 31; EOIR at 16#10# range 0 .. 31; end record; GICD : GICD_Peripheral with Volatile, Import, Address => BB.Parameters.GICD_Base_Address; GICC : GICC_Peripheral with Volatile, Import, Address => BB.Parameters.GICC_Base_Address; function To_PRI (P : Integer) return PRI with Inline; -- Return the PRI mask for the given Ada priority. Note that the zero -- value here means no mask, so no interrupts are masked. function To_Priority (P : PRI) return Interrupt_Priority with Inline; -- Given an ARM interrupt priority (PRI value), determine the Ada -- priority. -- While the value 0 is reserved for the kernel and has no Ada -- priority that represents it, Interrupt_Priority'Last is closest. ------------ -- To_PRI -- ------------ function To_PRI (P : Integer) return PRI is begin if P < Interrupt_Priority'First then -- Do not mask any interrupt return 255; else -- change range 240 .. 254 return PRI (Interrupt_Priority'Last - P) * 16; end if; end To_PRI; ----------------- -- To_Priority -- ----------------- function To_Priority (P : PRI) return Interrupt_Priority is begin if P = 0 then return Interrupt_Priority'Last; else return Interrupt_Priority'Last - Any_Priority'Base (P / 16); end if; end To_Priority; --------------------- -- Initialize_GICC -- --------------------- procedure Initialize_GICC is Int_Mask : Unsigned_32 := 0; begin -- Core-specific part of the GIC configuration: -- The GICC (CPU Interface) is banked for each CPU, so has to be -- configured each time. -- The PPI and SGI exceptions are also CPU-specific so are banked. -- see 4.1.4 in the ARM GIC Architecture Specification v2 document -- Mask all interrupts GICC.PMR := 0; -- Binary point register: -- The register defines the point at which the priority value fields -- split into two parts. GICC.BPR := 3; -- Disable banked interrupts by default GICD.ICENABLER (0) := 16#FFFF_FFFF#; -- Enable the CPU-specific interrupts that have a handler registered. -- -- On CPU0, no interrupt is registered for now so this has no effect. -- On the other CPUs, as interrupts are registered via a call to -- Interrupts.Install_Interrupt_Handler before the CPUs are started, -- the following properly takes care of initializing the interrupt mask -- and priorities for those. for J in Interrupts_Enabled'Range loop if Interrupts_Enabled (J) then Int_Mask := Int_Mask or 2 ** J; GICD.IPRIORITYR (J) := Interrupts_Priority (J); end if; end loop; if Int_Mask /= 0 then GICD.ISENABLER (0) := Int_Mask; end if; -- Set the Enable Group1 bit to the GICC CTLR register. -- The view we have here is a GICv1 or GICv2 version with Security -- extension, from a non-secure mode. GICC.CTLR := 1; end Initialize_GICC; --------------------- -- Initialize_GICD -- --------------------- procedure Initialize_GICD is begin GICD.CTLR := 0; -- default priority for J in GICD.IPRIORITYR'Range loop GICD.IPRIORITYR (J) := 0; end loop; -- Set the target cpu -- ITARGETSR(0) is read-only and redirects all IRQs to the currently -- running CPU. We initialize the shared interrupts targets to the -- same value so that we're sure to receive them. for Reg_Num in 8 .. GICD.ITARGETSR'Last loop GICD.ITARGETSR (Reg_Num) := GICD.ITARGETSR (0); end loop; -- Disable all shared Interrupts GICD.ICENABLER := (others => 16#FFFF_FFFF#); GICD.CTLR := 3; end Initialize_GICD; ------------------------- -- Define_IRQ_Triggers -- ------------------------- procedure Define_IRQ_Triggers (Config : ICFGR) is begin for J in Config'Range loop GICD.ICFGR (J) := Config (J); end loop; end Define_IRQ_Triggers; ----------------- -- IRQ_Handler -- ----------------- procedure IRQ_Handler is IAR : constant Unsigned_32 := GICC.IAR; Int_Id : constant Unsigned_32 := IAR and 16#3FF#; begin if Int_Id = 16#3FF# then -- Spurious interrupt return; end if; Interrupt_Wrapper (Interrupt_ID (Int_Id)); -- Clear interrupt request GICC.EOIR := IAR; end IRQ_Handler; ------------------------------- -- Install_Interrupt_Handler -- ------------------------------- procedure Install_Interrupt_Handler (Interrupt : Interrupt_ID; Prio : Interrupt_Priority) is begin GICD.IPRIORITYR (Interrupt) := To_PRI (Prio); GICD.ISENABLER (Reg_Num_32 (Interrupt)) := 2 ** (Interrupt mod 32); -- Handlers are registered before the CPUs are awaken (only the CPU 0 -- executes Install_Interrupt_Handler. -- So we save the registered interrupts to properly initialize the -- other CPUs for banked interrupts. if Interrupt in Banked_Interrupt then Interrupts_Priority (Interrupt) := To_PRI (Prio); Interrupts_Enabled (Interrupt) := True; end if; end Install_Interrupt_Handler; --------------------------- -- Priority_Of_Interrupt -- --------------------------- function Priority_Of_Interrupt (Interrupt : System.BB.Interrupts.Interrupt_ID) return System.Any_Priority is begin return To_Priority (GICD.IPRIORITYR (Interrupt)); end Priority_Of_Interrupt; -------------------------- -- Set_Current_Priority -- -------------------------- procedure Set_Current_Priority (Priority : Integer) is begin GICC.PMR := Unsigned_32 (To_PRI (Priority)); end Set_Current_Priority; ---------------- -- Power_Down -- ---------------- procedure Power_Down is begin System.Machine_Code.Asm ("wfi", Volatile => True); end Power_Down; -------------- -- Poke_CPU -- -------------- procedure Poke_CPU (CPU_Id : System.Multiprocessors.CPU; Poke_Interrupt : Interrupt_ID) is begin GICD.SGIR := 2 ** (15 + Natural (CPU_Id)) + Unsigned_32 (Poke_Interrupt); end Poke_CPU; end System.ARM_GIC;
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package Network.Managers.TCP_V4 is procedure Register (Manager : in out Network.Managers.Manager); private type Protocol is new Network.Managers.Protocol with record null; end record; overriding function Can_Listen (Self : Protocol; Address : Network.Addresses.Address) return Boolean; overriding function Can_Connect (Self : Protocol; Address : Network.Addresses.Address) return Boolean; overriding procedure Listen (Self : in out Protocol; List : Network.Addresses.Address_Array; Listener : Connection_Listener_Access; Poll : in out Network.Polls.Poll; Error : out League.Strings.Universal_String; Options : League.String_Vectors.Universal_String_Vector := League.String_Vectors.Empty_Universal_String_Vector); overriding procedure Connect (Self : in out Protocol; Address : Network.Addresses.Address; Poll : in out Network.Polls.Poll; Error : out League.Strings.Universal_String; Promise : out Network.Connection_Promises.Promise; Options : League.String_Vectors.Universal_String_Vector := League.String_Vectors.Empty_Universal_String_Vector); end Network.Managers.TCP_V4;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package xopintrin_h is -- Copyright (C) 2007-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC 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 3, or (at your option) -- any later version. -- GCC 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. -- 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/>. -- Integer multiply/add instructions. -- skipped func _mm_maccs_epi16 -- skipped func _mm_macc_epi16 -- skipped func _mm_maccsd_epi16 -- skipped func _mm_maccd_epi16 -- skipped func _mm_maccs_epi32 -- skipped func _mm_macc_epi32 -- skipped func _mm_maccslo_epi32 -- skipped func _mm_macclo_epi32 -- skipped func _mm_maccshi_epi32 -- skipped func _mm_macchi_epi32 -- skipped func _mm_maddsd_epi16 -- skipped func _mm_maddd_epi16 -- Packed Integer Horizontal Add and Subtract -- skipped func _mm_haddw_epi8 -- skipped func _mm_haddd_epi8 -- skipped func _mm_haddq_epi8 -- skipped func _mm_haddd_epi16 -- skipped func _mm_haddq_epi16 -- skipped func _mm_haddq_epi32 -- skipped func _mm_haddw_epu8 -- skipped func _mm_haddd_epu8 -- skipped func _mm_haddq_epu8 -- skipped func _mm_haddd_epu16 -- skipped func _mm_haddq_epu16 -- skipped func _mm_haddq_epu32 -- skipped func _mm_hsubw_epi8 -- skipped func _mm_hsubd_epi16 -- skipped func _mm_hsubq_epi32 -- Vector conditional move and permute -- skipped func _mm_cmov_si128 -- skipped func _mm_perm_epi8 -- Packed Integer Rotates and Shifts -- Rotates - Non-Immediate form -- skipped func _mm_rot_epi8 -- skipped func _mm_rot_epi16 -- skipped func _mm_rot_epi32 -- skipped func _mm_rot_epi64 -- Rotates - Immediate form -- Shifts -- skipped func _mm_shl_epi8 -- skipped func _mm_shl_epi16 -- skipped func _mm_shl_epi32 -- skipped func _mm_shl_epi64 -- skipped func _mm_sha_epi8 -- skipped func _mm_sha_epi16 -- skipped func _mm_sha_epi32 -- skipped func _mm_sha_epi64 -- Compare and Predicate Generation -- pcom (integer, unsigned bytes) -- skipped func _mm_comlt_epu8 -- skipped func _mm_comle_epu8 -- skipped func _mm_comgt_epu8 -- skipped func _mm_comge_epu8 -- skipped func _mm_comeq_epu8 -- skipped func _mm_comneq_epu8 -- skipped func _mm_comfalse_epu8 -- skipped func _mm_comtrue_epu8 --pcom (integer, unsigned words) -- skipped func _mm_comlt_epu16 -- skipped func _mm_comle_epu16 -- skipped func _mm_comgt_epu16 -- skipped func _mm_comge_epu16 -- skipped func _mm_comeq_epu16 -- skipped func _mm_comneq_epu16 -- skipped func _mm_comfalse_epu16 -- skipped func _mm_comtrue_epu16 --pcom (integer, unsigned double words) -- skipped func _mm_comlt_epu32 -- skipped func _mm_comle_epu32 -- skipped func _mm_comgt_epu32 -- skipped func _mm_comge_epu32 -- skipped func _mm_comeq_epu32 -- skipped func _mm_comneq_epu32 -- skipped func _mm_comfalse_epu32 -- skipped func _mm_comtrue_epu32 --pcom (integer, unsigned quad words) -- skipped func _mm_comlt_epu64 -- skipped func _mm_comle_epu64 -- skipped func _mm_comgt_epu64 -- skipped func _mm_comge_epu64 -- skipped func _mm_comeq_epu64 -- skipped func _mm_comneq_epu64 -- skipped func _mm_comfalse_epu64 -- skipped func _mm_comtrue_epu64 --pcom (integer, signed bytes) -- skipped func _mm_comlt_epi8 -- skipped func _mm_comle_epi8 -- skipped func _mm_comgt_epi8 -- skipped func _mm_comge_epi8 -- skipped func _mm_comeq_epi8 -- skipped func _mm_comneq_epi8 -- skipped func _mm_comfalse_epi8 -- skipped func _mm_comtrue_epi8 --pcom (integer, signed words) -- skipped func _mm_comlt_epi16 -- skipped func _mm_comle_epi16 -- skipped func _mm_comgt_epi16 -- skipped func _mm_comge_epi16 -- skipped func _mm_comeq_epi16 -- skipped func _mm_comneq_epi16 -- skipped func _mm_comfalse_epi16 -- skipped func _mm_comtrue_epi16 --pcom (integer, signed double words) -- skipped func _mm_comlt_epi32 -- skipped func _mm_comle_epi32 -- skipped func _mm_comgt_epi32 -- skipped func _mm_comge_epi32 -- skipped func _mm_comeq_epi32 -- skipped func _mm_comneq_epi32 -- skipped func _mm_comfalse_epi32 -- skipped func _mm_comtrue_epi32 --pcom (integer, signed quad words) -- skipped func _mm_comlt_epi64 -- skipped func _mm_comle_epi64 -- skipped func _mm_comgt_epi64 -- skipped func _mm_comge_epi64 -- skipped func _mm_comeq_epi64 -- skipped func _mm_comneq_epi64 -- skipped func _mm_comfalse_epi64 -- skipped func _mm_comtrue_epi64 -- FRCZ -- skipped func _mm_frcz_ps -- skipped func _mm_frcz_pd -- skipped func _mm_frcz_ss -- skipped func _mm_frcz_sd -- skipped func _mm256_frcz_ps -- skipped func _mm256_frcz_pd -- PERMIL2 end xopintrin_h;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Containers.Vectors; -- Misc functions for plugins development aid package Plugin is package Vectors is new Ada.Containers.Vectors (Positive, Unbounded_String); use Vectors; function Words (Str : Unbounded_String) return Vector; function Unwords (Words : Vector) return Unbounded_String; function Bold (Input : String) return String; function Link (Input : Unbounded_String) return Boolean; function GSub (Str : Unbounded_String; From : String; To : String) return Unbounded_String; end Plugin;
with Ada.Containers.Indefinite_Vectors; package GPR_Tools.Gprslaves.String_Vectors is new Ada.Containers.Indefinite_Vectors (Natural, String);
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- I N T E R F A C E S . P A C K E D _ D E C I M A L -- -- -- -- B o d y -- -- (Version for IBM Mainframe Packed Decimal Format) -- -- -- -- Copyright (C) 1992-2009, 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. -- -- -- ------------------------------------------------------------------------------ with System; use System; with Ada.Unchecked_Conversion; package body Interfaces.Packed_Decimal is type Packed is array (Byte_Length) of Unsigned_8; -- The type used internally to represent packed decimal type Packed_Ptr is access Packed; function To_Packed_Ptr is new Ada.Unchecked_Conversion (Address, Packed_Ptr); -- The following array is used to convert a value in the range 0-99 to -- a packed decimal format with two hexadecimal nibbles. It is worth -- using table look up in this direction because divides are expensive. Packed_Byte : constant array (00 .. 99) of Unsigned_8 := (16#00#, 16#01#, 16#02#, 16#03#, 16#04#, 16#05#, 16#06#, 16#07#, 16#08#, 16#09#, 16#10#, 16#11#, 16#12#, 16#13#, 16#14#, 16#15#, 16#16#, 16#17#, 16#18#, 16#19#, 16#20#, 16#21#, 16#22#, 16#23#, 16#24#, 16#25#, 16#26#, 16#27#, 16#28#, 16#29#, 16#30#, 16#31#, 16#32#, 16#33#, 16#34#, 16#35#, 16#36#, 16#37#, 16#38#, 16#39#, 16#40#, 16#41#, 16#42#, 16#43#, 16#44#, 16#45#, 16#46#, 16#47#, 16#48#, 16#49#, 16#50#, 16#51#, 16#52#, 16#53#, 16#54#, 16#55#, 16#56#, 16#57#, 16#58#, 16#59#, 16#60#, 16#61#, 16#62#, 16#63#, 16#64#, 16#65#, 16#66#, 16#67#, 16#68#, 16#69#, 16#70#, 16#71#, 16#72#, 16#73#, 16#74#, 16#75#, 16#76#, 16#77#, 16#78#, 16#79#, 16#80#, 16#81#, 16#82#, 16#83#, 16#84#, 16#85#, 16#86#, 16#87#, 16#88#, 16#89#, 16#90#, 16#91#, 16#92#, 16#93#, 16#94#, 16#95#, 16#96#, 16#97#, 16#98#, 16#99#); --------------------- -- Int32_To_Packed -- --------------------- procedure Int32_To_Packed (V : Integer_32; P : System.Address; D : D32) is PP : constant Packed_Ptr := To_Packed_Ptr (P); Empty_Nibble : constant Boolean := ((D rem 2) = 0); B : constant Byte_Length := (D / 2) + 1; VV : Integer_32 := V; begin -- Deal with sign byte first if VV >= 0 then PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#C#; VV := VV / 10; else VV := -VV; PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#D#; end if; for J in reverse B - 1 .. 2 loop if VV = 0 then for K in 1 .. J loop PP (K) := 16#00#; end loop; return; else PP (J) := Packed_Byte (Integer (VV rem 100)); VV := VV / 100; end if; end loop; -- Deal with leading byte if Empty_Nibble then if VV > 9 then raise Constraint_Error; else PP (1) := Unsigned_8 (VV); end if; else if VV > 99 then raise Constraint_Error; else PP (1) := Packed_Byte (Integer (VV)); end if; end if; end Int32_To_Packed; --------------------- -- Int64_To_Packed -- --------------------- procedure Int64_To_Packed (V : Integer_64; P : System.Address; D : D64) is PP : constant Packed_Ptr := To_Packed_Ptr (P); Empty_Nibble : constant Boolean := ((D rem 2) = 0); B : constant Byte_Length := (D / 2) + 1; VV : Integer_64 := V; begin -- Deal with sign byte first if VV >= 0 then PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#C#; VV := VV / 10; else VV := -VV; PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#D#; end if; for J in reverse B - 1 .. 2 loop if VV = 0 then for K in 1 .. J loop PP (K) := 16#00#; end loop; return; else PP (J) := Packed_Byte (Integer (VV rem 100)); VV := VV / 100; end if; end loop; -- Deal with leading byte if Empty_Nibble then if VV > 9 then raise Constraint_Error; else PP (1) := Unsigned_8 (VV); end if; else if VV > 99 then raise Constraint_Error; else PP (1) := Packed_Byte (Integer (VV)); end if; end if; end Int64_To_Packed; --------------------- -- Packed_To_Int32 -- --------------------- function Packed_To_Int32 (P : System.Address; D : D32) return Integer_32 is PP : constant Packed_Ptr := To_Packed_Ptr (P); Empty_Nibble : constant Boolean := ((D mod 2) = 0); B : constant Byte_Length := (D / 2) + 1; V : Integer_32; Dig : Unsigned_8; Sign : Unsigned_8; J : Positive; begin -- Cases where there is an unused (zero) nibble in the first byte. -- Deal with the single digit nibble at the right of this byte if Empty_Nibble then V := Integer_32 (PP (1)); J := 2; if V > 9 then raise Constraint_Error; end if; -- Cases where all nibbles are used else V := 0; J := 1; end if; -- Loop to process bytes containing two digit nibbles while J < B loop Dig := Shift_Right (PP (J), 4); if Dig > 9 then raise Constraint_Error; else V := V * 10 + Integer_32 (Dig); end if; Dig := PP (J) and 16#0F#; if Dig > 9 then raise Constraint_Error; else V := V * 10 + Integer_32 (Dig); end if; J := J + 1; end loop; -- Deal with digit nibble in sign byte Dig := Shift_Right (PP (J), 4); if Dig > 9 then raise Constraint_Error; else V := V * 10 + Integer_32 (Dig); end if; Sign := PP (J) and 16#0F#; -- Process sign nibble (deal with most common cases first) if Sign = 16#C# then return V; elsif Sign = 16#D# then return -V; elsif Sign = 16#B# then return -V; elsif Sign >= 16#A# then return V; else raise Constraint_Error; end if; end Packed_To_Int32; --------------------- -- Packed_To_Int64 -- --------------------- function Packed_To_Int64 (P : System.Address; D : D64) return Integer_64 is PP : constant Packed_Ptr := To_Packed_Ptr (P); Empty_Nibble : constant Boolean := ((D mod 2) = 0); B : constant Byte_Length := (D / 2) + 1; V : Integer_64; Dig : Unsigned_8; Sign : Unsigned_8; J : Positive; begin -- Cases where there is an unused (zero) nibble in the first byte. -- Deal with the single digit nibble at the right of this byte if Empty_Nibble then V := Integer_64 (PP (1)); J := 2; if V > 9 then raise Constraint_Error; end if; -- Cases where all nibbles are used else J := 1; V := 0; end if; -- Loop to process bytes containing two digit nibbles while J < B loop Dig := Shift_Right (PP (J), 4); if Dig > 9 then raise Constraint_Error; else V := V * 10 + Integer_64 (Dig); end if; Dig := PP (J) and 16#0F#; if Dig > 9 then raise Constraint_Error; else V := V * 10 + Integer_64 (Dig); end if; J := J + 1; end loop; -- Deal with digit nibble in sign byte Dig := Shift_Right (PP (J), 4); if Dig > 9 then raise Constraint_Error; else V := V * 10 + Integer_64 (Dig); end if; Sign := PP (J) and 16#0F#; -- Process sign nibble (deal with most common cases first) if Sign = 16#C# then return V; elsif Sign = 16#D# then return -V; elsif Sign = 16#B# then return -V; elsif Sign >= 16#A# then return V; else raise Constraint_Error; end if; end Packed_To_Int64; end Interfaces.Packed_Decimal;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . V C H E C K -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2010, Free Software Foundation, Inc. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Asis; use Asis; with Asis.Text; use Asis.Text; with Asis.Errors; use Asis.Errors; with A4G.A_Types; use A4G.A_Types; with A4G.Int_Knds; use A4G.Int_Knds; -- This package contains the routines for checking the validity of the -- arguments of the ASIS queries and for generating the diagnostic info. -- This package in its current state originated from the very beginning of -- the ASIS project and it definitely needs revising. package A4G.Vcheck is -- GNAT-style reformatting required!! Only formal compatibility with -gnatg -- is achieved by now. -- This package contains procedures for checking the validity of the -- Context, Compilation_Unit and Element values, raising the -- Asis-defined exceptions (with previous setting of the status -- value and forming the Diagnosis string) in some standard -- situations and utility subprograms to be used in the keeping to -- the "catch-all" policy defined in the subsection 3.6 of the -- ASIS: Detailed Semantics and Implementation Document (v. 1.1.1) -- -- The first prototype implementation uses rather roof approach -- to keep to the "catch-all" policy in respect to the -- non-Asis-defined exceptions and to handle the status and Diagnosis -- information. The main principles of this approach are: -- -- (a) all non-Asis exceptions are caught by -- -- when others => -- Raise_ASIS_Failed (Diagnosis => "Name of the routine in which" -- &" this handler is" ); -- -- exception handler, and as a rule no attempt is undertaken -- to recover from the error situation (Status is set as -- "Value_Error" and ASIS_Failed is raised); -- -- (b) Diagnosis string contains only general description of the failure -- and the indication of the Asis query or low-level implementation -- utility subprogram in which the Asis-defined exception was initially -- raised; -- -- (c) if Asis-defined exception propagates through the Asis implementation, -- then the information related to the dynamic context of the exception -- propagation is added to the Diagnosis (and separated by the -- Asis_Types_And_Limits.ASIS_Line_Terminator constant). -- -- (d) most of the routines in the Asis implementation should contain the -- exception handler with the "others" choice (as described in the -- paragraph (a) above. If it is known that the Asis_defined exception -- could be raised in the procedure or function body, then the body -- should contain two following exception handlers in the order given: -- -- when Asis_ASIS_Inappropriate_Context | -- ASIS_Inappropriate_Compilation_Unit | -- ASIS_Inappropriate_Element => -- -- raise; -- nothing should be done additionally; -- -- exception has been raised in the argument(s) -- -- validity/appropriation checks in the same -- -- frame -- -- when ASIS_Failed -- | other possible Asis-defined exceptions -- => -- Add_Call_Information (Outer_Call => "Name of the routine in which" -- &" this handler is" ); -- raise; ---???????? -- -- when others => -- Raise_ASIS_Failed (Diagnosis => "Name of the routine in which" -- &" this handler is" ); -- procedure Add (Phrase : String); -- Adds Phrase to Diagnosis_Buffer and resets Diagnosis_Len. Exits with no -- (further) change in Diagnosis_Buffer as soon as Diagnosis_Len attains -- Max_Diagnosis_Length. ------------------------------------------------------------ -- Checking the validity of Context, Compilation_Unit and -- Element ------------------------------------------------------------ ------------------------------------------------------------ procedure Check_Validity (Compilation_Unit : Asis.Compilation_Unit; Query : String); ------------------------------------------------------------ -- Compilation_Unit - Specifies the unit to check -- Query - Specifies the name of query in which the check -- is performed. The parameter value is used to -- form the Diagnosis string -- -- Performs the check if the unit does not belong to the closed library -- Sets the corresponding Status and forms the corresponding Diagnosis -- if the check fails -- -- BETTER DOCS NEEDED!! --------------------------------------------------------------- procedure Check_Validity (Element : Asis.Element; Query : String); ------------------------------------------------------------ -- Element - Specifies the element to check -- Query - Specifies the name of query in which the check is performed. -- The parameter value is used to form the Diagnosis string -- -- Performs the check if the element does not belong to the invalid -- element -- Sets the corresponding Status and forms the corresponding Diagnosis -- if the check fails -- -- BETTER DOCS NEEDED!! --------------------------------------------------------------- procedure Check_Validity (Line : Asis.Text.Line; Query : String); ------------------------------------------------------------ -- Line - Specifies the Line to check -- Query - Specifies the name of query in which the check is performed. -- The parameter value is used to form the Diagnosis string -- -- Performs the check if the line does not belong to the invalid -- Context -- Sets the corresponding Status and forms the corresponding Diagnosis -- if the check fails -- -- BETTER DOCS NEEDED!! ------------------------------------------------------------ procedure Check_Validity (Context : Asis.Context; Query : String); ------------------------------------------------------------ -- Context - Specifies the ASIS Context to check -- Query - Specifies the name of query in which the check is performed. -- The parameter value is used to form the Diagnosis string -- -- Performs the check if the Context is not in inassosiated or inopened -- state -- Sets the corresponding Status and forms the corresponding Diagnosis -- if the check fails -- -- BETTER DOCS NEEDED!! ------------------------------------- -- Raising Asis-defined exceptions -- ------------------------------------- procedure Raise_ASIS_Failed (Diagnosis : String; Argument : Asis.Element := Nil_Element; Stat : Asis.Errors.Error_Kinds := Internal_Error; Bool_Par : Boolean := False; Internal_Bug : Boolean := True); -- Raises ASIS_Failed with Stat as the value of ASIS Error Status. -- Usually expects the query name as Diagnosis. If the corresponding ASIS -- standard query has an optional boolean parameter, and if this parameter -- is set on for the given call to this query, then Bool_Par is expected to -- be set True. Internal_Bug specifies if the procedure is called for an -- internal implementation bug. -- This routine may be used to raise ASIS_Failed not only for the cases of -- internal implementation errors. In this case Internal_Bug should be set -- OFF, and Stat should specify the error kind. -- If Argument is not IS_Nil, adds the debug image of the argument to the -- diagnosis string. procedure Raise_ASIS_Failed_In_Traversing (Start_Element : Asis.Element; Failure_At : Asis.Element; Pre_Op : Boolean; Exception_Info : String); -- Raises ASIS_Failed with Stat as Unhandled_Exception_Error for the -- situation when some non-ASIS exception is raised in actual Pre- -- (Pre-Op is set ON) or Post-Operation (Pre_Op is set False). If forms the -- diagnostic message indicating the starting Element of the traversal -- (should be provided as the actual for Start_Element), the Element for -- which the failure took place (actual for Failure_At) and the information -- about the exception raised (passed as Exception_Info) -------------------------------------------------------------------- procedure Raise_ASIS_Inappropriate_Compilation_Unit (Diagnosis : String); -------------------------------------------------------------------- -- Diagnosis - Specifies the query to which the Compilation Unit -- with inappropriate kind was passed -- -- Raises ASIS_Inappropriate_Compilation_Unit with Value_Error status -- -- BETTER DOCS NEEDED!! -------------------------------------------------------------------- procedure Raise_ASIS_Inappropriate_Element (Diagnosis : String; Wrong_Kind : Internal_Element_Kinds; Status : Error_Kinds := Value_Error); -------------------------------------------------------------------- -- Diagnosis - Specifies the query to which the Element with -- inappropriate kind was passed -- -- Raises ASIS_Inappropriate_Element with Status error status -- -- BETTER DOCS NEEDED!! -- -------------------------------------------------------------------- procedure Raise_ASIS_Inappropriate_Line_Number (Diagnosis : String; Status : Error_Kinds := Value_Error); -------------------------------------------------------------------- procedure Not_Implemented_Yet (Diagnosis : String); -------------------------------------------------------------------- -- Diagnosis - Specifies the query which has not been implemented -- properly yet and has a placeholder as its body -- -- Raises ASIS_Failed with Not_Implemented_Error status -- -- This procedure is used in the placeholder bodies of the non-implemented -- queries -- -- BETTER DOCS NEEDED!! -------------------------------------------------------------------- ---------------------------------------------- -- Setting the Status and Diagnosis values -- ---------------------------------------------- -------------------------------------------------------------------- procedure Set_Error_Status (Status : Error_Kinds := Not_An_Error; Diagnosis : String := Nil_Asis_String); -------------------------------------------------------------------- -- -- This procedure is the full analog of the A4G.Set_Status -- procedure, it is intended to be used as the implementation of the -- A4G.Set_Status (by means of the renaming_as_a_body -- in the body of Asis_Environment) -------------------------------------------------------------------- ----------------------------- -- Adding Call Information -- ----------------------------- procedure Add_Call_Information (Outer_Call : String; Argument : Asis.Element := Nil_Element; Bool_Par : Boolean := False); -- Adds in the ASIS diagnosis the information about dynamically enclosing -- calls when an ASIS exception is propagated from some dynamically -- enclosed routine. If Argument is not Nil, adds its debug image in the -- Diagnosis, if needed (that is, if Argument_Postponed flag is set on, -- and resets this flag OFF after that) pragma No_Return (Raise_ASIS_Failed); pragma No_Return (Raise_ASIS_Inappropriate_Compilation_Unit); pragma No_Return (Raise_ASIS_Inappropriate_Element); pragma No_Return (Not_Implemented_Yet); ------------------------------------------- -- The revised code is below this header -- ------------------------------------------- --------------------------------------------------------------------- -- Data Objects for Handling the Diagnosis string and Error Status -- --------------------------------------------------------------------- Status_Indicator : Error_Kinds := Not_An_Error; Diagnosis_Buffer : String (1 .. Max_Diagnosis_Length); Diagnosis_Len : Natural range 0 .. Max_Diagnosis_Length := 0; -- The string buffer to form ASIS Diagnosis --------------------------- -- ASIS Error handling -- --------------------------- -- The following documentation item should be revised when the revising of -- the ASIS exception handling is completed (BB14-010) -- According to the ASIS Standard, only ASIS-defined exceptions are allowed -- to be raised by ASIS queries. -- -- The semantics of ASIS_Inappropriate_*** expectations well-defined and is -- supposed to be implemented in full conformance with ASIS Standard -- requirements. -- -- According to Asis.Exceptions, ASIS_Failed is "is a catch-all exception -- that may be raised for different reasons in different ASIS -- implementations". -- -- We are using the following approach to handing and reporting the -- internal implementation errors and to raising ASIS_Failed. -- -- 1. According to the (rather ill-defined) requirement of the ASIS -- Standard and other documents generated during the ASIS -- standardization process (in particular, "ASIS: Detailed Semantics and -- Implementation. Ada Semantic Interface Specification. ASIS version -- 1.1.1. April 26, 1994 by Gary E. Barnes), the body of every ASIS -- query contains 'when OTHERS' exception handler which does not allow -- any non-ASIS exception to propagate out of any ASIS query. (The -- exception is a set of rather trivial bodies of ASIS queries for which -- raising of non-ASIS exceptions is practically impossible). -- -- 2. By default any unexpected exception raise (that is, raising of any -- non-ASIS exception because of any reason) is treated as ASIS -- implementation error which should be immediately reported and which -- does not allow to continue the execution of any ASIS application. -- That is, detection of such an error should result in immediate exit -- to OS. This is implemented as the default behavior of all the ASIS -- and ASIS extensions queries. -- -- 3. An application may want to continue its execution even in case when -- an internal ASIS implementation error is detected. (The reason could -- be to try to use some workarounds for known ASIS implementation -- problems and to get the required information by some other ways). -- For this the application may set the Keep_Going flag ON by setting -- '-k' parameter of Asis.Implementation.Initialize. As a result, -- instead of generating the exit to OS, ASIS_Failed is raised with -- Unhandled_Exception_Error status. -- -- 4. We have some other reasons for raising ASIS_Failed. It can be raised -- in case when ASIS is initialized with "treat ASIS warnings as errors" -- mode as a part of generating of the ASIS warning. We have to use -- ASIS_Failed here, because the ASIS Standard does not give us any -- other choice. ASIS_Failed may also be raised by queries from -- Asis.Compilation_Units which are not supposed to be used for a -- dynamic Context. The important thing is that when ASIS_Failed is -- raised as a result of ASIS warning, the Error Status can never be -- Unhandled_Exception_Error -- -- 5. The general approach to exception handling in our ASIS implementation -- is: -- -- - For every standard ASIS query and for every ASIS Extensions query -- which is not trivial enough to conclude that raising of any -- non-ASIS exception is practically impossible, the body of this -- query should contain "when EX : OTHERS' handler, and the only -- statement in this handler should be the call to Report_ASIS_Bug -- procedure (see the documentation of this procedure below) -- -- - For every standard ASIS query and for every ASIS Extensions query -- which is not trivial enough to conclude that generating of the ASIS -- failure is practically impossible or for which we can not be sure -- that its implementation does not use any other ASIS queries, the -- body of this query should contain the handler for ASIS_Failed with -- the following code -- -- when ASIS_Failed => -- is Status_Indicator = Unhandled_Exception_Error then -- Add_Call_Information (...) -- end if; -- -- raise; -- -- The idea in behind is: if ASIS_Failed is the result of the internal -- ASIS implementation bug (that is, unexpected exception suppressed), -- we are collecting the information of enclosing calls, this may be -- useful if the call to one ASIS query is used in the implementation -- of some other ASIS query, the full "trace" of calls of the ASIS -- queries may be useful for an ASIS application programmer if (s)he -- would like to provide protections for ASIS bugs and to use some -- workarounds. And if ASIS_Failed is a result of ASIS warning, it -- should just propagated out of ASIS with the Diagnosis string formed -- as a part of error generation. ASIS_Failed raised when calling -- Asis.Compilation_Units queries which can not be used for a dynamic -- context could never be raised inside the call to an ASIS query -- enclosed into a call to some other ASIS query. procedure Report_ASIS_Bug (Query_Name : String; Ex : Exception_Occurrence; Arg_Element : Asis.Element := Nil_Element; Arg_Element_2 : Asis.Element := Nil_Element; Arg_CU : Asis.Compilation_Unit := Nil_Compilation_Unit; Arg_CU_2 : Asis.Compilation_Unit := Nil_Compilation_Unit; Arg_Line : Asis.Text.Line := Nil_Line; Arg_Span : Asis.Text.Span := Nil_Span; Bool_Par_ON : Boolean := False; Context_Par : Boolean := False -- What else??? ); pragma No_Return (Report_ASIS_Bug); -- This procedure is supposed to be called in "when OTHERS" exception -- handlers of an ASIS queries only. If we are in such an exception -- handler, then for sure we have detected some ASIS implementation bug. -- Depending on the ASIS initialization options, this procedure may -- perform the following options: -- -- - generates the ASIS bug box similar to the GNAT bug box generated by -- the GNAT Comperr.Compiler_Abort procedure. -- -- - raises ASIS_Failed with the summary of the information which should -- go into the ASIS bug box as the ASIS Diagnosis string -- -- - causes the exit to OS. -- -- Either exit to OS or raising ASIS_Failed should take place in any case. -- In case of exit to OS, the ASIS bug box should be generated. -- -- The call to this procedure should never result in exception raise (other -- then raising ASIS_Failed by purpose), the worst case is that the -- diagnostic information formed by this procedure is incomplete. -- -- Query_Name should be set to the full expanded Ada name of the query -- where this procedure is called -- -- Ex should be the exception name form enclosing "when Ex : others" -- handlers. -- -- All the other parameters are used to compose some debug information -- about the parameters of the call which fails. Some ASIS queries have -- two Element or Compilation Unit parameters, that's why we need -- Arg_Element_2 and Arg_CU_2. For queries having only one Element or CU -- parameter, Arg_Element or Arg_CU should be used to pass the argument of -- the call to form the diagnostic info. end A4G.Vcheck;
package Benchmark.Matrix is type Matrix_Type is abstract new Benchmark_Type with private; overriding procedure Set_Argument(benchmark : in out Matrix_Type; arg : in String); overriding procedure Run(benchmark : in Matrix_Type) is abstract; private type Matrix_Type is abstract new Benchmark_Type with record size : Positive := 256; iterations : Positive := 1; end record; function Get_Size(benchmark : Matrix_Type'Class) return Address_Type; procedure Read(benchmark : in Matrix_Type'Class; offset : in Address_Type; x, y : in Natural); procedure Write(benchmark : in Matrix_Type'Class; offset : in Address_Type; x, y : in Natural); end Benchmark.Matrix;
with Ada.Text_IO; use Ada.Text_IO; with Rejuvenation.Utils; use Rejuvenation.Utils; package body Rewriters is function Rewrite (R : Rewriter; Node : Ada_Node'Class; Top_Level : Boolean := True) return String is begin Put_Line ("Base function"); return Raw_Signature (Node); end Rewrite; -- Since we must provide an implementation, -- we have chosen the identity rewriter end Rewriters;
with INFLECTIONS_PACKAGE; use INFLECTIONS_PACKAGE; with DICTIONARY_PACKAGE; use DICTIONARY_PACKAGE; package UNIQUES_PACKAGE is type UNIQUE_ITEM; type UNIQUE_LIST is access UNIQUE_ITEM; type UNIQUE_ITEM is record STEM : STEM_TYPE := NULL_STEM_TYPE; QUAL : QUALITY_RECORD := NULL_QUALITY_RECORD; KIND : KIND_ENTRY := NULL_KIND_ENTRY; MNPC : DICT_IO.COUNT := NULL_MNPC; SUCC : UNIQUE_LIST; end record; type LATIN_UNIQUES is array (CHARACTER range 'a'..'z') of UNIQUE_LIST; NULL_LATIN_UNIQUES : LATIN_UNIQUES := (others => null); UNQ : LATIN_UNIQUES := NULL_LATIN_UNIQUES; type UNIQUES_DE_ARRAY is array (DICT_IO.POSITIVE_COUNT range <>) of DICTIONARY_ENTRY; UNIQUES_DE : UNIQUES_DE_ARRAY(1..100) := (others => NULL_DICTIONARY_ENTRY); end UNIQUES_PACKAGE;
------------------------------------------------------------------------------ -- -- -- Unicode Utilities -- -- -- -- Case Folding Utilities -- -- Simple Case Folding -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2019, 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. -- -- -- ------------------------------------------------------------------------------ -- Generated: 2019-08-15 -- CaseFolding.txt source -- https://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt -- ********** THIS FILE IS AUTOMATICALLY GENERATED ********* -- -- - See AURA.Unicode.UCD.Generate_Case_Folding.Simple - -- -- CaseFolding.txt: C+S maps loaded = 1411 function Unicode.Case_Folding.Simple (C: Wide_Wide_Character) return Wide_Wide_Character is type Codepoint is mod 2**24; type Key_Hash is mod 2**8; function Hash (C: Codepoint) return Key_Hash with Inline is T: Codepoint := C; begin return K: Key_Hash := 0 do for I in 1 .. 3 loop K := K xor Key_Hash (T and 16#FF#); T := T / 16#100#; end loop; end return; end Hash; function Bucket_00 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000202# => Wide_Wide_Character'Val (16#000203#), when 16#000404# => Wide_Wide_Character'Val (16#000454#), when 16#001E1E# => Wide_Wide_Character'Val (16#001E1F#), when 16#002C2C# => Wide_Wide_Character'Val (16#002C5C#), when 16#00ABAB# => Wide_Wide_Character'Val (16#0013DB#), when 16#010405# => Wide_Wide_Character'Val (16#01042D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_01 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000100# => Wide_Wide_Character'Val (16#000101#), when 16#000405# => Wide_Wide_Character'Val (16#000455#), when 16#000504# => Wide_Wide_Character'Val (16#000505#), when 16#002C2D# => Wide_Wide_Character'Val (16#002C5D#), when 16#00A7A6# => Wide_Wide_Character'Val (16#00A7A7#), when 16#00ABAA# => Wide_Wide_Character'Val (16#0013DA#), when 16#010404# => Wide_Wide_Character'Val (16#01042C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_02 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000200# => Wide_Wide_Character'Val (16#000201#), when 16#000406# => Wide_Wide_Character'Val (16#000456#), when 16#001E1C# => Wide_Wide_Character'Val (16#001E1D#), when 16#001F1D# => Wide_Wide_Character'Val (16#001F15#), when 16#002C2E# => Wide_Wide_Character'Val (16#002C5E#), when 16#00ABA9# => Wide_Wide_Character'Val (16#0013D9#), when 16#010407# => Wide_Wide_Character'Val (16#01042F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_03 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000102# => Wide_Wide_Character'Val (16#000103#), when 16#000407# => Wide_Wide_Character'Val (16#000457#), when 16#000506# => Wide_Wide_Character'Val (16#000507#), when 16#001F1C# => Wide_Wide_Character'Val (16#001F14#), when 16#00A7A4# => Wide_Wide_Character'Val (16#00A7A5#), when 16#00ABA8# => Wide_Wide_Character'Val (16#0013D8#), when 16#010406# => Wide_Wide_Character'Val (16#01042E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_04 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000206# => Wide_Wide_Character'Val (16#000207#), when 16#000400# => Wide_Wide_Character'Val (16#000450#), when 16#001E1A# => Wide_Wide_Character'Val (16#001E1B#), when 16#001F1B# => Wide_Wide_Character'Val (16#001F13#), when 16#002C28# => Wide_Wide_Character'Val (16#002C58#), when 16#00ABAF# => Wide_Wide_Character'Val (16#0013DF#), when 16#010401# => Wide_Wide_Character'Val (16#010429#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_05 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000104# => Wide_Wide_Character'Val (16#000105#), when 16#000401# => Wide_Wide_Character'Val (16#000451#), when 16#000500# => Wide_Wide_Character'Val (16#000501#), when 16#001F1A# => Wide_Wide_Character'Val (16#001F12#), when 16#002C29# => Wide_Wide_Character'Val (16#002C59#), when 16#00A7A2# => Wide_Wide_Character'Val (16#00A7A3#), when 16#00ABAE# => Wide_Wide_Character'Val (16#0013DE#), when 16#010400# => Wide_Wide_Character'Val (16#010428#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_06 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000204# => Wide_Wide_Character'Val (16#000205#), when 16#000402# => Wide_Wide_Character'Val (16#000452#), when 16#001E18# => Wide_Wide_Character'Val (16#001E19#), when 16#001F19# => Wide_Wide_Character'Val (16#001F11#), when 16#002C2A# => Wide_Wide_Character'Val (16#002C5A#), when 16#00ABAD# => Wide_Wide_Character'Val (16#0013DD#), when 16#010403# => Wide_Wide_Character'Val (16#01042B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_07 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000106# => Wide_Wide_Character'Val (16#000107#), when 16#000403# => Wide_Wide_Character'Val (16#000453#), when 16#000502# => Wide_Wide_Character'Val (16#000503#), when 16#001F18# => Wide_Wide_Character'Val (16#001F10#), when 16#002126# => Wide_Wide_Character'Val (16#0003C9#), when 16#002C2B# => Wide_Wide_Character'Val (16#002C5B#), when 16#00A7A0# => Wide_Wide_Character'Val (16#00A7A1#), when 16#00ABAC# => Wide_Wide_Character'Val (16#0013DC#), when 16#010402# => Wide_Wide_Character'Val (16#01042A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_08 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00020A# => Wide_Wide_Character'Val (16#00020B#), when 16#00040C# => Wide_Wide_Character'Val (16#00045C#), when 16#001E16# => Wide_Wide_Character'Val (16#001E17#), when 16#002C24# => Wide_Wide_Character'Val (16#002C54#), when 16#00ABA3# => Wide_Wide_Character'Val (16#0013D3#), when 16#01040D# => Wide_Wide_Character'Val (16#010435#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_09 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000108# => Wide_Wide_Character'Val (16#000109#), when 16#00040D# => Wide_Wide_Character'Val (16#00045D#), when 16#00050C# => Wide_Wide_Character'Val (16#00050D#), when 16#002C25# => Wide_Wide_Character'Val (16#002C55#), when 16#00A7AE# => Wide_Wide_Character'Val (16#00026A#), when 16#00ABA2# => Wide_Wide_Character'Val (16#0013D2#), when 16#01040C# => Wide_Wide_Character'Val (16#010434#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_0A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000208# => Wide_Wide_Character'Val (16#000209#), when 16#00040E# => Wide_Wide_Character'Val (16#00045E#), when 16#001E14# => Wide_Wide_Character'Val (16#001E15#), when 16#00212B# => Wide_Wide_Character'Val (16#0000E5#), when 16#002C26# => Wide_Wide_Character'Val (16#002C56#), when 16#00A7AD# => Wide_Wide_Character'Val (16#00026C#), when 16#00ABA1# => Wide_Wide_Character'Val (16#0013D1#), when 16#01040F# => Wide_Wide_Character'Val (16#010437#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_0B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00010A# => Wide_Wide_Character'Val (16#00010B#), when 16#00040F# => Wide_Wide_Character'Val (16#00045F#), when 16#00050E# => Wide_Wide_Character'Val (16#00050F#), when 16#00212A# => Wide_Wide_Character'Val (16#00006B#), when 16#002C27# => Wide_Wide_Character'Val (16#002C57#), when 16#00A7AC# => Wide_Wide_Character'Val (16#000261#), when 16#00ABA0# => Wide_Wide_Character'Val (16#0013D0#), when 16#01040E# => Wide_Wide_Character'Val (16#010436#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_0C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00020E# => Wide_Wide_Character'Val (16#00020F#), when 16#000408# => Wide_Wide_Character'Val (16#000458#), when 16#001E12# => Wide_Wide_Character'Val (16#001E13#), when 16#002C20# => Wide_Wide_Character'Val (16#002C50#), when 16#00A7AB# => Wide_Wide_Character'Val (16#00025C#), when 16#00ABA7# => Wide_Wide_Character'Val (16#0013D7#), when 16#010409# => Wide_Wide_Character'Val (16#010431#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_0D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00010C# => Wide_Wide_Character'Val (16#00010D#), when 16#000409# => Wide_Wide_Character'Val (16#000459#), when 16#000508# => Wide_Wide_Character'Val (16#000509#), when 16#002C21# => Wide_Wide_Character'Val (16#002C51#), when 16#00A7AA# => Wide_Wide_Character'Val (16#000266#), when 16#00ABA6# => Wide_Wide_Character'Val (16#0013D6#), when 16#010408# => Wide_Wide_Character'Val (16#010430#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_0E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00020C# => Wide_Wide_Character'Val (16#00020D#), when 16#00040A# => Wide_Wide_Character'Val (16#00045A#), when 16#001E10# => Wide_Wide_Character'Val (16#001E11#), when 16#002C22# => Wide_Wide_Character'Val (16#002C52#), when 16#00ABA5# => Wide_Wide_Character'Val (16#0013D5#), when 16#01040B# => Wide_Wide_Character'Val (16#010433#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_0F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00010E# => Wide_Wide_Character'Val (16#00010F#), when 16#00040B# => Wide_Wide_Character'Val (16#00045B#), when 16#00050A# => Wide_Wide_Character'Val (16#00050B#), when 16#002C23# => Wide_Wide_Character'Val (16#002C53#), when 16#00A7A8# => Wide_Wide_Character'Val (16#00A7A9#), when 16#00ABA4# => Wide_Wide_Character'Val (16#0013D4#), when 16#01040A# => Wide_Wide_Character'Val (16#010432#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_10 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000212# => Wide_Wide_Character'Val (16#000213#), when 16#000414# => Wide_Wide_Character'Val (16#000434#), when 16#001E0E# => Wide_Wide_Character'Val (16#001E0F#), when 16#001F0F# => Wide_Wide_Character'Val (16#001F07#), when 16#00ABBB# => Wide_Wide_Character'Val (16#0013EB#), when 16#010415# => Wide_Wide_Character'Val (16#01043D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_11 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000110# => Wide_Wide_Character'Val (16#000111#), when 16#000415# => Wide_Wide_Character'Val (16#000435#), when 16#000514# => Wide_Wide_Character'Val (16#000515#), when 16#001F0E# => Wide_Wide_Character'Val (16#001F06#), when 16#00A7B6# => Wide_Wide_Character'Val (16#00A7B7#), when 16#00ABBA# => Wide_Wide_Character'Val (16#0013EA#), when 16#010414# => Wide_Wide_Character'Val (16#01043C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_12 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000210# => Wide_Wide_Character'Val (16#000211#), when 16#000416# => Wide_Wide_Character'Val (16#000436#), when 16#001E0C# => Wide_Wide_Character'Val (16#001E0D#), when 16#001F0D# => Wide_Wide_Character'Val (16#001F05#), when 16#00ABB9# => Wide_Wide_Character'Val (16#0013E9#), when 16#010417# => Wide_Wide_Character'Val (16#01043F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_13 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000112# => Wide_Wide_Character'Val (16#000113#), when 16#000417# => Wide_Wide_Character'Val (16#000437#), when 16#000516# => Wide_Wide_Character'Val (16#000517#), when 16#001F0C# => Wide_Wide_Character'Val (16#001F04#), when 16#002132# => Wide_Wide_Character'Val (16#00214E#), when 16#00A7B4# => Wide_Wide_Character'Val (16#00A7B5#), when 16#00ABB8# => Wide_Wide_Character'Val (16#0013E8#), when 16#010416# => Wide_Wide_Character'Val (16#01043E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_14 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000216# => Wide_Wide_Character'Val (16#000217#), when 16#000410# => Wide_Wide_Character'Val (16#000430#), when 16#001E0A# => Wide_Wide_Character'Val (16#001E0B#), when 16#001F0B# => Wide_Wide_Character'Val (16#001F03#), when 16#00A7B3# => Wide_Wide_Character'Val (16#00AB53#), when 16#00ABBF# => Wide_Wide_Character'Val (16#0013EF#), when 16#010411# => Wide_Wide_Character'Val (16#010439#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_15 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000114# => Wide_Wide_Character'Val (16#000115#), when 16#000411# => Wide_Wide_Character'Val (16#000431#), when 16#000510# => Wide_Wide_Character'Val (16#000511#), when 16#001F0A# => Wide_Wide_Character'Val (16#001F02#), when 16#00A7B2# => Wide_Wide_Character'Val (16#00029D#), when 16#00ABBE# => Wide_Wide_Character'Val (16#0013EE#), when 16#010410# => Wide_Wide_Character'Val (16#010438#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_16 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000214# => Wide_Wide_Character'Val (16#000215#), when 16#000412# => Wide_Wide_Character'Val (16#000432#), when 16#001E08# => Wide_Wide_Character'Val (16#001E09#), when 16#001F09# => Wide_Wide_Character'Val (16#001F01#), when 16#00A7B1# => Wide_Wide_Character'Val (16#000287#), when 16#00ABBD# => Wide_Wide_Character'Val (16#0013ED#), when 16#010413# => Wide_Wide_Character'Val (16#01043B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_17 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000116# => Wide_Wide_Character'Val (16#000117#), when 16#000413# => Wide_Wide_Character'Val (16#000433#), when 16#000512# => Wide_Wide_Character'Val (16#000513#), when 16#001F08# => Wide_Wide_Character'Val (16#001F00#), when 16#00A7B0# => Wide_Wide_Character'Val (16#00029E#), when 16#00ABBC# => Wide_Wide_Character'Val (16#0013EC#), when 16#010412# => Wide_Wide_Character'Val (16#01043A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_18 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00021A# => Wide_Wide_Character'Val (16#00021B#), when 16#00041C# => Wide_Wide_Character'Val (16#00043C#), when 16#001E06# => Wide_Wide_Character'Val (16#001E07#), when 16#00ABB3# => Wide_Wide_Character'Val (16#0013E3#), when 16#01041D# => Wide_Wide_Character'Val (16#010445#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_19 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000118# => Wide_Wide_Character'Val (16#000119#), when 16#00041D# => Wide_Wide_Character'Val (16#00043D#), when 16#00051C# => Wide_Wide_Character'Val (16#00051D#), when 16#00A7BE# => Wide_Wide_Character'Val (16#00A7BF#), when 16#00ABB2# => Wide_Wide_Character'Val (16#0013E2#), when 16#01041C# => Wide_Wide_Character'Val (16#010444#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_1A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000218# => Wide_Wide_Character'Val (16#000219#), when 16#00041E# => Wide_Wide_Character'Val (16#00043E#), when 16#001E04# => Wide_Wide_Character'Val (16#001E05#), when 16#00ABB1# => Wide_Wide_Character'Val (16#0013E1#), when 16#01041F# => Wide_Wide_Character'Val (16#010447#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_1B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00011A# => Wide_Wide_Character'Val (16#00011B#), when 16#00041F# => Wide_Wide_Character'Val (16#00043F#), when 16#00051E# => Wide_Wide_Character'Val (16#00051F#), when 16#00A7BC# => Wide_Wide_Character'Val (16#00A7BD#), when 16#00ABB0# => Wide_Wide_Character'Val (16#0013E0#), when 16#01041E# => Wide_Wide_Character'Val (16#010446#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_1C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00021E# => Wide_Wide_Character'Val (16#00021F#), when 16#000418# => Wide_Wide_Character'Val (16#000438#), when 16#001E02# => Wide_Wide_Character'Val (16#001E03#), when 16#00ABB7# => Wide_Wide_Character'Val (16#0013E7#), when 16#010419# => Wide_Wide_Character'Val (16#010441#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_1D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00011C# => Wide_Wide_Character'Val (16#00011D#), when 16#000419# => Wide_Wide_Character'Val (16#000439#), when 16#000518# => Wide_Wide_Character'Val (16#000519#), when 16#00A7BA# => Wide_Wide_Character'Val (16#00A7BB#), when 16#00ABB6# => Wide_Wide_Character'Val (16#0013E6#), when 16#010418# => Wide_Wide_Character'Val (16#010440#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_1E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00021C# => Wide_Wide_Character'Val (16#00021D#), when 16#00041A# => Wide_Wide_Character'Val (16#00043A#), when 16#001E00# => Wide_Wide_Character'Val (16#001E01#), when 16#00ABB5# => Wide_Wide_Character'Val (16#0013E5#), when 16#01041B# => Wide_Wide_Character'Val (16#010443#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_1F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00011E# => Wide_Wide_Character'Val (16#00011F#), when 16#00041B# => Wide_Wide_Character'Val (16#00043B#), when 16#00051A# => Wide_Wide_Character'Val (16#00051B#), when 16#00A7B8# => Wide_Wide_Character'Val (16#00A7B9#), when 16#00ABB4# => Wide_Wide_Character'Val (16#0013E4#), when 16#01041A# => Wide_Wide_Character'Val (16#010442#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_20 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000222# => Wide_Wide_Character'Val (16#000223#), when 16#000424# => Wide_Wide_Character'Val (16#000444#), when 16#001E3E# => Wide_Wide_Character'Val (16#001E3F#), when 16#001F3F# => Wide_Wide_Character'Val (16#001F37#), when 16#002C0C# => Wide_Wide_Character'Val (16#002C3C#), when 16#00A686# => Wide_Wide_Character'Val (16#00A687#), when 16#00AB8B# => Wide_Wide_Character'Val (16#0013BB#), when 16#010425# => Wide_Wide_Character'Val (16#01044D#), when 16#016E4F# => Wide_Wide_Character'Val (16#016E6F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_21 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000120# => Wide_Wide_Character'Val (16#000121#), when 16#000425# => Wide_Wide_Character'Val (16#000445#), when 16#000524# => Wide_Wide_Character'Val (16#000525#), when 16#001F3E# => Wide_Wide_Character'Val (16#001F36#), when 16#002C0D# => Wide_Wide_Character'Val (16#002C3D#), when 16#00A786# => Wide_Wide_Character'Val (16#00A787#), when 16#00AB8A# => Wide_Wide_Character'Val (16#0013BA#), when 16#010424# => Wide_Wide_Character'Val (16#01044C#), when 16#016E4E# => Wide_Wide_Character'Val (16#016E6E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_22 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000220# => Wide_Wide_Character'Val (16#00019E#), when 16#000426# => Wide_Wide_Character'Val (16#000446#), when 16#001E3C# => Wide_Wide_Character'Val (16#001E3D#), when 16#001F3D# => Wide_Wide_Character'Val (16#001F35#), when 16#002C0E# => Wide_Wide_Character'Val (16#002C3E#), when 16#00A684# => Wide_Wide_Character'Val (16#00A685#), when 16#00AB89# => Wide_Wide_Character'Val (16#0013B9#), when 16#010427# => Wide_Wide_Character'Val (16#01044F#), when 16#016E4D# => Wide_Wide_Character'Val (16#016E6D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_23 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000122# => Wide_Wide_Character'Val (16#000123#), when 16#000427# => Wide_Wide_Character'Val (16#000447#), when 16#000526# => Wide_Wide_Character'Val (16#000527#), when 16#001F3C# => Wide_Wide_Character'Val (16#001F34#), when 16#002C0F# => Wide_Wide_Character'Val (16#002C3F#), when 16#00A784# => Wide_Wide_Character'Val (16#00A785#), when 16#00AB88# => Wide_Wide_Character'Val (16#0013B8#), when 16#010426# => Wide_Wide_Character'Val (16#01044E#), when 16#016E4C# => Wide_Wide_Character'Val (16#016E6C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_24 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000226# => Wide_Wide_Character'Val (16#000227#), when 16#000420# => Wide_Wide_Character'Val (16#000440#), when 16#001E3A# => Wide_Wide_Character'Val (16#001E3B#), when 16#001F3B# => Wide_Wide_Character'Val (16#001F33#), when 16#002C08# => Wide_Wide_Character'Val (16#002C38#), when 16#00A682# => Wide_Wide_Character'Val (16#00A683#), when 16#00AB8F# => Wide_Wide_Character'Val (16#0013BF#), when 16#010421# => Wide_Wide_Character'Val (16#010449#), when 16#016E4B# => Wide_Wide_Character'Val (16#016E6B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_25 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000124# => Wide_Wide_Character'Val (16#000125#), when 16#000421# => Wide_Wide_Character'Val (16#000441#), when 16#000520# => Wide_Wide_Character'Val (16#000521#), when 16#001F3A# => Wide_Wide_Character'Val (16#001F32#), when 16#002C09# => Wide_Wide_Character'Val (16#002C39#), when 16#00A782# => Wide_Wide_Character'Val (16#00A783#), when 16#00AB8E# => Wide_Wide_Character'Val (16#0013BE#), when 16#010420# => Wide_Wide_Character'Val (16#010448#), when 16#016E4A# => Wide_Wide_Character'Val (16#016E6A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_26 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000224# => Wide_Wide_Character'Val (16#000225#), when 16#000422# => Wide_Wide_Character'Val (16#000442#), when 16#001E38# => Wide_Wide_Character'Val (16#001E39#), when 16#001F39# => Wide_Wide_Character'Val (16#001F31#), when 16#002C0A# => Wide_Wide_Character'Val (16#002C3A#), when 16#00A680# => Wide_Wide_Character'Val (16#00A681#), when 16#00AB8D# => Wide_Wide_Character'Val (16#0013BD#), when 16#010423# => Wide_Wide_Character'Val (16#01044B#), when 16#016E49# => Wide_Wide_Character'Val (16#016E69#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_27 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000126# => Wide_Wide_Character'Val (16#000127#), when 16#000423# => Wide_Wide_Character'Val (16#000443#), when 16#000522# => Wide_Wide_Character'Val (16#000523#), when 16#001F38# => Wide_Wide_Character'Val (16#001F30#), when 16#002C0B# => Wide_Wide_Character'Val (16#002C3B#), when 16#00A780# => Wide_Wide_Character'Val (16#00A781#), when 16#00AB8C# => Wide_Wide_Character'Val (16#0013BC#), when 16#010422# => Wide_Wide_Character'Val (16#01044A#), when 16#016E48# => Wide_Wide_Character'Val (16#016E68#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_28 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00022A# => Wide_Wide_Character'Val (16#00022B#), when 16#00042C# => Wide_Wide_Character'Val (16#00044C#), when 16#001E36# => Wide_Wide_Character'Val (16#001E37#), when 16#002C04# => Wide_Wide_Character'Val (16#002C34#), when 16#00A68E# => Wide_Wide_Character'Val (16#00A68F#), when 16#00AB83# => Wide_Wide_Character'Val (16#0013B3#), when 16#016E47# => Wide_Wide_Character'Val (16#016E67#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_29 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000128# => Wide_Wide_Character'Val (16#000129#), when 16#00042D# => Wide_Wide_Character'Val (16#00044D#), when 16#00052C# => Wide_Wide_Character'Val (16#00052D#), when 16#002C05# => Wide_Wide_Character'Val (16#002C35#), when 16#00AB82# => Wide_Wide_Character'Val (16#0013B2#), when 16#016E46# => Wide_Wide_Character'Val (16#016E66#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_2A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000228# => Wide_Wide_Character'Val (16#000229#), when 16#00042E# => Wide_Wide_Character'Val (16#00044E#), when 16#001E34# => Wide_Wide_Character'Val (16#001E35#), when 16#002C06# => Wide_Wide_Character'Val (16#002C36#), when 16#00A68C# => Wide_Wide_Character'Val (16#00A68D#), when 16#00A78D# => Wide_Wide_Character'Val (16#000265#), when 16#00AB81# => Wide_Wide_Character'Val (16#0013B1#), when 16#016E45# => Wide_Wide_Character'Val (16#016E65#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_2B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00012A# => Wide_Wide_Character'Val (16#00012B#), when 16#00042F# => Wide_Wide_Character'Val (16#00044F#), when 16#00052E# => Wide_Wide_Character'Val (16#00052F#), when 16#002C07# => Wide_Wide_Character'Val (16#002C37#), when 16#00AB80# => Wide_Wide_Character'Val (16#0013B0#), when 16#016E44# => Wide_Wide_Character'Val (16#016E64#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_2C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00022E# => Wide_Wide_Character'Val (16#00022F#), when 16#000428# => Wide_Wide_Character'Val (16#000448#), when 16#001E32# => Wide_Wide_Character'Val (16#001E33#), when 16#002C00# => Wide_Wide_Character'Val (16#002C30#), when 16#00A68A# => Wide_Wide_Character'Val (16#00A68B#), when 16#00A78B# => Wide_Wide_Character'Val (16#00A78C#), when 16#00AB87# => Wide_Wide_Character'Val (16#0013B7#), when 16#016E43# => Wide_Wide_Character'Val (16#016E63#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_2D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00012C# => Wide_Wide_Character'Val (16#00012D#), when 16#000429# => Wide_Wide_Character'Val (16#000449#), when 16#000528# => Wide_Wide_Character'Val (16#000529#), when 16#002C01# => Wide_Wide_Character'Val (16#002C31#), when 16#00AB86# => Wide_Wide_Character'Val (16#0013B6#), when 16#016E42# => Wide_Wide_Character'Val (16#016E62#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_2E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00022C# => Wide_Wide_Character'Val (16#00022D#), when 16#00042A# => Wide_Wide_Character'Val (16#00044A#), when 16#001E30# => Wide_Wide_Character'Val (16#001E31#), when 16#002C02# => Wide_Wide_Character'Val (16#002C32#), when 16#00A688# => Wide_Wide_Character'Val (16#00A689#), when 16#00AB85# => Wide_Wide_Character'Val (16#0013B5#), when 16#016E41# => Wide_Wide_Character'Val (16#016E61#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_2F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00012E# => Wide_Wide_Character'Val (16#00012F#), when 16#00042B# => Wide_Wide_Character'Val (16#00044B#), when 16#00052A# => Wide_Wide_Character'Val (16#00052B#), when 16#002C03# => Wide_Wide_Character'Val (16#002C33#), when 16#00AB84# => Wide_Wide_Character'Val (16#0013B4#), when 16#016E40# => Wide_Wide_Character'Val (16#016E60#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_30 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000232# => Wide_Wide_Character'Val (16#000233#), when 16#000535# => Wide_Wide_Character'Val (16#000565#), when 16#001E2E# => Wide_Wide_Character'Val (16#001E2F#), when 16#001F2F# => Wide_Wide_Character'Val (16#001F27#), when 16#002C1C# => Wide_Wide_Character'Val (16#002C4C#), when 16#00A696# => Wide_Wide_Character'Val (16#00A697#), when 16#00AB9B# => Wide_Wide_Character'Val (16#0013CB#), when 16#016E5F# => Wide_Wide_Character'Val (16#016E7F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_31 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000534# => Wide_Wide_Character'Val (16#000564#), when 16#001F2E# => Wide_Wide_Character'Val (16#001F26#), when 16#002C1D# => Wide_Wide_Character'Val (16#002C4D#), when 16#00A796# => Wide_Wide_Character'Val (16#00A797#), when 16#00AB9A# => Wide_Wide_Character'Val (16#0013CA#), when 16#016E5E# => Wide_Wide_Character'Val (16#016E7E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_32 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000230# => Wide_Wide_Character'Val (16#000231#), when 16#000537# => Wide_Wide_Character'Val (16#000567#), when 16#001E2C# => Wide_Wide_Character'Val (16#001E2D#), when 16#001F2D# => Wide_Wide_Character'Val (16#001F25#), when 16#002C1E# => Wide_Wide_Character'Val (16#002C4E#), when 16#00A694# => Wide_Wide_Character'Val (16#00A695#), when 16#00AB99# => Wide_Wide_Character'Val (16#0013C9#), when 16#016E5D# => Wide_Wide_Character'Val (16#016E7D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_33 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000132# => Wide_Wide_Character'Val (16#000133#), when 16#000536# => Wide_Wide_Character'Val (16#000566#), when 16#001F2C# => Wide_Wide_Character'Val (16#001F24#), when 16#002C1F# => Wide_Wide_Character'Val (16#002C4F#), when 16#00AB98# => Wide_Wide_Character'Val (16#0013C8#), when 16#016E5C# => Wide_Wide_Character'Val (16#016E7C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_34 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000531# => Wide_Wide_Character'Val (16#000561#), when 16#001E2A# => Wide_Wide_Character'Val (16#001E2B#), when 16#001F2B# => Wide_Wide_Character'Val (16#001F23#), when 16#002C18# => Wide_Wide_Character'Val (16#002C48#), when 16#00A692# => Wide_Wide_Character'Val (16#00A693#), when 16#00AB9F# => Wide_Wide_Character'Val (16#0013CF#), when 16#016E5B# => Wide_Wide_Character'Val (16#016E7B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_35 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000134# => Wide_Wide_Character'Val (16#000135#), when 16#001F2A# => Wide_Wide_Character'Val (16#001F22#), when 16#002C19# => Wide_Wide_Character'Val (16#002C49#), when 16#00A792# => Wide_Wide_Character'Val (16#00A793#), when 16#00AB9E# => Wide_Wide_Character'Val (16#0013CE#), when 16#016E5A# => Wide_Wide_Character'Val (16#016E7A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_36 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000533# => Wide_Wide_Character'Val (16#000563#), when 16#001E28# => Wide_Wide_Character'Val (16#001E29#), when 16#001F29# => Wide_Wide_Character'Val (16#001F21#), when 16#002C1A# => Wide_Wide_Character'Val (16#002C4A#), when 16#00A690# => Wide_Wide_Character'Val (16#00A691#), when 16#00AB9D# => Wide_Wide_Character'Val (16#0013CD#), when 16#016E59# => Wide_Wide_Character'Val (16#016E79#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_37 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000136# => Wide_Wide_Character'Val (16#000137#), when 16#000532# => Wide_Wide_Character'Val (16#000562#), when 16#001F28# => Wide_Wide_Character'Val (16#001F20#), when 16#002C1B# => Wide_Wide_Character'Val (16#002C4B#), when 16#00A790# => Wide_Wide_Character'Val (16#00A791#), when 16#00AB9C# => Wide_Wide_Character'Val (16#0013CC#), when 16#016E58# => Wide_Wide_Character'Val (16#016E78#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_38 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000139# => Wide_Wide_Character'Val (16#00013A#), when 16#00023A# => Wide_Wide_Character'Val (16#002C65#), when 16#00053D# => Wide_Wide_Character'Val (16#00056D#), when 16#001E26# => Wide_Wide_Character'Val (16#001E27#), when 16#002C14# => Wide_Wide_Character'Val (16#002C44#), when 16#00AB93# => Wide_Wide_Character'Val (16#0013C3#), when 16#016E57# => Wide_Wide_Character'Val (16#016E77#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_39 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00023B# => Wide_Wide_Character'Val (16#00023C#), when 16#00053C# => Wide_Wide_Character'Val (16#00056C#), when 16#002C15# => Wide_Wide_Character'Val (16#002C45#), when 16#00A79E# => Wide_Wide_Character'Val (16#00A79F#), when 16#00AB92# => Wide_Wide_Character'Val (16#0013C2#), when 16#016E56# => Wide_Wide_Character'Val (16#016E76#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_3A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00013B# => Wide_Wide_Character'Val (16#00013C#), when 16#00053F# => Wide_Wide_Character'Val (16#00056F#), when 16#001E24# => Wide_Wide_Character'Val (16#001E25#), when 16#002C16# => Wide_Wide_Character'Val (16#002C46#), when 16#00AB91# => Wide_Wide_Character'Val (16#0013C1#), when 16#016E55# => Wide_Wide_Character'Val (16#016E75#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_3B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00053E# => Wide_Wide_Character'Val (16#00056E#), when 16#002C17# => Wide_Wide_Character'Val (16#002C47#), when 16#00A79C# => Wide_Wide_Character'Val (16#00A79D#), when 16#00AB90# => Wide_Wide_Character'Val (16#0013C0#), when 16#016E54# => Wide_Wide_Character'Val (16#016E74#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_3C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00013D# => Wide_Wide_Character'Val (16#00013E#), when 16#00023E# => Wide_Wide_Character'Val (16#002C66#), when 16#000539# => Wide_Wide_Character'Val (16#000569#), when 16#001E22# => Wide_Wide_Character'Val (16#001E23#), when 16#002C10# => Wide_Wide_Character'Val (16#002C40#), when 16#00A69A# => Wide_Wide_Character'Val (16#00A69B#), when 16#00AB97# => Wide_Wide_Character'Val (16#0013C7#), when 16#016E53# => Wide_Wide_Character'Val (16#016E73#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_3D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000538# => Wide_Wide_Character'Val (16#000568#), when 16#002C11# => Wide_Wide_Character'Val (16#002C41#), when 16#00A79A# => Wide_Wide_Character'Val (16#00A79B#), when 16#00AB96# => Wide_Wide_Character'Val (16#0013C6#), when 16#016E52# => Wide_Wide_Character'Val (16#016E72#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_3E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00013F# => Wide_Wide_Character'Val (16#000140#), when 16#00053B# => Wide_Wide_Character'Val (16#00056B#), when 16#001E20# => Wide_Wide_Character'Val (16#001E21#), when 16#002C12# => Wide_Wide_Character'Val (16#002C42#), when 16#00A698# => Wide_Wide_Character'Val (16#00A699#), when 16#00AB95# => Wide_Wide_Character'Val (16#0013C5#), when 16#016E51# => Wide_Wide_Character'Val (16#016E71#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_3F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00023D# => Wide_Wide_Character'Val (16#00019A#), when 16#00053A# => Wide_Wide_Character'Val (16#00056A#), when 16#002C13# => Wide_Wide_Character'Val (16#002C43#), when 16#00A798# => Wide_Wide_Character'Val (16#00A799#), when 16#00AB94# => Wide_Wide_Character'Val (16#0013C4#), when 16#016E50# => Wide_Wide_Character'Val (16#016E70#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_40 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000141# => Wide_Wide_Character'Val (16#000142#), when 16#000545# => Wide_Wide_Character'Val (16#000575#), when 16#001E5E# => Wide_Wide_Character'Val (16#001E5F#), when 16#001F5F# => Wide_Wide_Character'Val (16#001F57#), when 16#002161# => Wide_Wide_Character'Val (16#002171#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_41 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000041# => Wide_Wide_Character'Val (16#000061#), when 16#000243# => Wide_Wide_Character'Val (16#000180#), when 16#000544# => Wide_Wide_Character'Val (16#000574#), when 16#002160# => Wide_Wide_Character'Val (16#002170#), when 16#002C6D# => Wide_Wide_Character'Val (16#000251#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_42 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000042# => Wide_Wide_Character'Val (16#000062#), when 16#000143# => Wide_Wide_Character'Val (16#000144#), when 16#000547# => Wide_Wide_Character'Val (16#000577#), when 16#001E5C# => Wide_Wide_Character'Val (16#001E5D#), when 16#001F5D# => Wide_Wide_Character'Val (16#001F55#), when 16#002163# => Wide_Wide_Character'Val (16#002173#), when 16#002C6E# => Wide_Wide_Character'Val (16#000271#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_43 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000043# => Wide_Wide_Character'Val (16#000063#), when 16#000241# => Wide_Wide_Character'Val (16#000242#), when 16#000546# => Wide_Wide_Character'Val (16#000576#), when 16#002162# => Wide_Wide_Character'Val (16#002172#), when 16#002C6F# => Wide_Wide_Character'Val (16#000250#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_44 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000044# => Wide_Wide_Character'Val (16#000064#), when 16#000145# => Wide_Wide_Character'Val (16#000146#), when 16#000246# => Wide_Wide_Character'Val (16#000247#), when 16#000541# => Wide_Wide_Character'Val (16#000571#), when 16#001E5A# => Wide_Wide_Character'Val (16#001E5B#), when 16#001F5B# => Wide_Wide_Character'Val (16#001F53#), when 16#002165# => Wide_Wide_Character'Val (16#002175#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_45 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000045# => Wide_Wide_Character'Val (16#000065#), when 16#000540# => Wide_Wide_Character'Val (16#000570#), when 16#002164# => Wide_Wide_Character'Val (16#002174#), when 16#002C69# => Wide_Wide_Character'Val (16#002C6A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_46 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000046# => Wide_Wide_Character'Val (16#000066#), when 16#000147# => Wide_Wide_Character'Val (16#000148#), when 16#000244# => Wide_Wide_Character'Val (16#000289#), when 16#000345# => Wide_Wide_Character'Val (16#0003B9#), when 16#000543# => Wide_Wide_Character'Val (16#000573#), when 16#001E58# => Wide_Wide_Character'Val (16#001E59#), when 16#001F59# => Wide_Wide_Character'Val (16#001F51#), when 16#002167# => Wide_Wide_Character'Val (16#002177#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_47 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000047# => Wide_Wide_Character'Val (16#000067#), when 16#000245# => Wide_Wide_Character'Val (16#00028C#), when 16#000542# => Wide_Wide_Character'Val (16#000572#), when 16#002166# => Wide_Wide_Character'Val (16#002176#), when 16#002C6B# => Wide_Wide_Character'Val (16#002C6C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_48 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000048# => Wide_Wide_Character'Val (16#000068#), when 16#00024A# => Wide_Wide_Character'Val (16#00024B#), when 16#00054D# => Wide_Wide_Character'Val (16#00057D#), when 16#001E56# => Wide_Wide_Character'Val (16#001E57#), when 16#002169# => Wide_Wide_Character'Val (16#002179#), when 16#002C64# => Wide_Wide_Character'Val (16#00027D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_49 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000049# => Wide_Wide_Character'Val (16#000069#), when 16#00054C# => Wide_Wide_Character'Val (16#00057C#), when 16#002168# => Wide_Wide_Character'Val (16#002178#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_4A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00004A# => Wide_Wide_Character'Val (16#00006A#), when 16#000248# => Wide_Wide_Character'Val (16#000249#), when 16#00054F# => Wide_Wide_Character'Val (16#00057F#), when 16#001E54# => Wide_Wide_Character'Val (16#001E55#), when 16#00216B# => Wide_Wide_Character'Val (16#00217B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_4B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00004B# => Wide_Wide_Character'Val (16#00006B#), when 16#00014A# => Wide_Wide_Character'Val (16#00014B#), when 16#00054E# => Wide_Wide_Character'Val (16#00057E#), when 16#00216A# => Wide_Wide_Character'Val (16#00217A#), when 16#002C67# => Wide_Wide_Character'Val (16#002C68#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_4C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00004C# => Wide_Wide_Character'Val (16#00006C#), when 16#00024E# => Wide_Wide_Character'Val (16#00024F#), when 16#000549# => Wide_Wide_Character'Val (16#000579#), when 16#001E52# => Wide_Wide_Character'Val (16#001E53#), when 16#00216D# => Wide_Wide_Character'Val (16#00217D#), when 16#002C60# => Wide_Wide_Character'Val (16#002C61#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_4D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00004D# => Wide_Wide_Character'Val (16#00006D#), when 16#00014C# => Wide_Wide_Character'Val (16#00014D#), when 16#000548# => Wide_Wide_Character'Val (16#000578#), when 16#00216C# => Wide_Wide_Character'Val (16#00217C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_4E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00004E# => Wide_Wide_Character'Val (16#00006E#), when 16#00024C# => Wide_Wide_Character'Val (16#00024D#), when 16#00054B# => Wide_Wide_Character'Val (16#00057B#), when 16#001E50# => Wide_Wide_Character'Val (16#001E51#), when 16#00216F# => Wide_Wide_Character'Val (16#00217F#), when 16#002C62# => Wide_Wide_Character'Val (16#00026B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_4F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00004F# => Wide_Wide_Character'Val (16#00006F#), when 16#00014E# => Wide_Wide_Character'Val (16#00014F#), when 16#00054A# => Wide_Wide_Character'Val (16#00057A#), when 16#00216E# => Wide_Wide_Character'Val (16#00217E#), when 16#002C63# => Wide_Wide_Character'Val (16#001D7D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_50 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000050# => Wide_Wide_Character'Val (16#000070#), when 16#000555# => Wide_Wide_Character'Val (16#000585#), when 16#001E4E# => Wide_Wide_Character'Val (16#001E4F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_51 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000051# => Wide_Wide_Character'Val (16#000071#), when 16#000150# => Wide_Wide_Character'Val (16#000151#), when 16#000554# => Wide_Wide_Character'Val (16#000584#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_52 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000052# => Wide_Wide_Character'Val (16#000072#), when 16#001E4C# => Wide_Wide_Character'Val (16#001E4D#), when 16#001F4D# => Wide_Wide_Character'Val (16#001F45#), when 16#002C7E# => Wide_Wide_Character'Val (16#00023F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_53 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000053# => Wide_Wide_Character'Val (16#000073#), when 16#000152# => Wide_Wide_Character'Val (16#000153#), when 16#000556# => Wide_Wide_Character'Val (16#000586#), when 16#001F4C# => Wide_Wide_Character'Val (16#001F44#), when 16#002C7F# => Wide_Wide_Character'Val (16#000240#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_54 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000054# => Wide_Wide_Character'Val (16#000074#), when 16#000551# => Wide_Wide_Character'Val (16#000581#), when 16#001E4A# => Wide_Wide_Character'Val (16#001E4B#), when 16#001F4B# => Wide_Wide_Character'Val (16#001F43#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_55 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000055# => Wide_Wide_Character'Val (16#000075#), when 16#000154# => Wide_Wide_Character'Val (16#000155#), when 16#000550# => Wide_Wide_Character'Val (16#000580#), when 16#001F4A# => Wide_Wide_Character'Val (16#001F42#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_56 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000056# => Wide_Wide_Character'Val (16#000076#), when 16#000553# => Wide_Wide_Character'Val (16#000583#), when 16#001E48# => Wide_Wide_Character'Val (16#001E49#), when 16#001F49# => Wide_Wide_Character'Val (16#001F41#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_57 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000057# => Wide_Wide_Character'Val (16#000077#), when 16#000156# => Wide_Wide_Character'Val (16#000157#), when 16#000552# => Wide_Wide_Character'Val (16#000582#), when 16#001F48# => Wide_Wide_Character'Val (16#001F40#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_58 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000058# => Wide_Wide_Character'Val (16#000078#), when 16#001E46# => Wide_Wide_Character'Val (16#001E47#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_59 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000059# => Wide_Wide_Character'Val (16#000079#), when 16#000158# => Wide_Wide_Character'Val (16#000159#), when 16#002C75# => Wide_Wide_Character'Val (16#002C76#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_5A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00005A# => Wide_Wide_Character'Val (16#00007A#), when 16#001E44# => Wide_Wide_Character'Val (16#001E45#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_5B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00015A# => Wide_Wide_Character'Val (16#00015B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_5C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#001E42# => Wide_Wide_Character'Val (16#001E43#), when 16#002C70# => Wide_Wide_Character'Val (16#000252#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_5D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00015C# => Wide_Wide_Character'Val (16#00015D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_5E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#001E40# => Wide_Wide_Character'Val (16#001E41#), when 16#002C72# => Wide_Wide_Character'Val (16#002C73#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_5F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00015E# => Wide_Wide_Character'Val (16#00015F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_60 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000464# => Wide_Wide_Character'Val (16#000465#), when 16#001E7E# => Wide_Wide_Character'Val (16#001E7F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_61 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000160# => Wide_Wide_Character'Val (16#000161#), when 16#00A7C6# => Wide_Wide_Character'Val (16#001D8E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_62 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000466# => Wide_Wide_Character'Val (16#000467#), when 16#001E7C# => Wide_Wide_Character'Val (16#001E7D#), when 16#00A7C5# => Wide_Wide_Character'Val (16#000282#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_63 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000162# => Wide_Wide_Character'Val (16#000163#), when 16#00A7C4# => Wide_Wide_Character'Val (16#00A794#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_64 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000460# => Wide_Wide_Character'Val (16#000461#), when 16#001E7A# => Wide_Wide_Character'Val (16#001E7B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_65 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000164# => Wide_Wide_Character'Val (16#000165#), when 16#00A7C2# => Wide_Wide_Character'Val (16#00A7C3#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_66 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000462# => Wide_Wide_Character'Val (16#000463#), when 16#001E78# => Wide_Wide_Character'Val (16#001E79#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_67 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000166# => Wide_Wide_Character'Val (16#000167#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_68 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00046C# => Wide_Wide_Character'Val (16#00046D#), when 16#001E76# => Wide_Wide_Character'Val (16#001E77#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_69 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000168# => Wide_Wide_Character'Val (16#000169#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_6A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00046E# => Wide_Wide_Character'Val (16#00046F#), when 16#001E74# => Wide_Wide_Character'Val (16#001E75#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_6B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00016A# => Wide_Wide_Character'Val (16#00016B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_6C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000468# => Wide_Wide_Character'Val (16#000469#), when 16#001E72# => Wide_Wide_Character'Val (16#001E73#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_6D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00016C# => Wide_Wide_Character'Val (16#00016D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_6E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00046A# => Wide_Wide_Character'Val (16#00046B#), when 16#001E70# => Wide_Wide_Character'Val (16#001E71#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_6F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00016E# => Wide_Wide_Character'Val (16#00016F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_70 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000474# => Wide_Wide_Character'Val (16#000475#), when 16#001E6E# => Wide_Wide_Character'Val (16#001E6F#), when 16#001F6F# => Wide_Wide_Character'Val (16#001F67#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_71 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000170# => Wide_Wide_Character'Val (16#000171#), when 16#000372# => Wide_Wide_Character'Val (16#000373#), when 16#001F6E# => Wide_Wide_Character'Val (16#001F66#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_72 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000476# => Wide_Wide_Character'Val (16#000477#), when 16#001E6C# => Wide_Wide_Character'Val (16#001E6D#), when 16#001F6D# => Wide_Wide_Character'Val (16#001F65#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_73 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000172# => Wide_Wide_Character'Val (16#000173#), when 16#000370# => Wide_Wide_Character'Val (16#000371#), when 16#001F6C# => Wide_Wide_Character'Val (16#001F64#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_74 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000470# => Wide_Wide_Character'Val (16#000471#), when 16#001E6A# => Wide_Wide_Character'Val (16#001E6B#), when 16#001F6B# => Wide_Wide_Character'Val (16#001F63#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_75 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000174# => Wide_Wide_Character'Val (16#000175#), when 16#000376# => Wide_Wide_Character'Val (16#000377#), when 16#001F6A# => Wide_Wide_Character'Val (16#001F62#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_76 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000472# => Wide_Wide_Character'Val (16#000473#), when 16#001E68# => Wide_Wide_Character'Val (16#001E69#), when 16#001F69# => Wide_Wide_Character'Val (16#001F61#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_77 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000176# => Wide_Wide_Character'Val (16#000177#), when 16#001F68# => Wide_Wide_Character'Val (16#001F60#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_78 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000179# => Wide_Wide_Character'Val (16#00017A#), when 16#00047C# => Wide_Wide_Character'Val (16#00047D#), when 16#001E66# => Wide_Wide_Character'Val (16#001E67#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_79 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000178# => Wide_Wide_Character'Val (16#0000FF#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_7A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00017B# => Wide_Wide_Character'Val (16#00017C#), when 16#00047E# => Wide_Wide_Character'Val (16#00047F#), when 16#001E64# => Wide_Wide_Character'Val (16#001E65#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_7B (C: Codepoint) return Wide_Wide_Character is (Wide_Wide_Character'Val (C)) with Inline; function Bucket_7C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00017D# => Wide_Wide_Character'Val (16#00017E#), when 16#00037F# => Wide_Wide_Character'Val (16#0003F3#), when 16#000478# => Wide_Wide_Character'Val (16#000479#), when 16#001E62# => Wide_Wide_Character'Val (16#001E63#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_7D (C: Codepoint) return Wide_Wide_Character is (Wide_Wide_Character'Val (C)) with Inline; function Bucket_7E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00017F# => Wide_Wide_Character'Val (16#000073#), when 16#00047A# => Wide_Wide_Character'Val (16#00047B#), when 16#001E60# => Wide_Wide_Character'Val (16#001E61#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_7F (C: Codepoint) return Wide_Wide_Character is (Wide_Wide_Character'Val (C)) with Inline; function Bucket_80 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000181# => Wide_Wide_Character'Val (16#000253#), when 16#001C9C# => Wide_Wide_Character'Val (16#0010DC#), when 16#001E9E# => Wide_Wide_Character'Val (16#0000DF#), when 16#001F9F# => Wide_Wide_Character'Val (16#001F97#), when 16#002CAC# => Wide_Wide_Character'Val (16#002CAD#), when 16#010C8D# => Wide_Wide_Character'Val (16#010CCD#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_81 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#001C9D# => Wide_Wide_Character'Val (16#0010DD#), when 16#001F9E# => Wide_Wide_Character'Val (16#001F96#), when 16#00A726# => Wide_Wide_Character'Val (16#00A727#), when 16#010C8C# => Wide_Wide_Character'Val (16#010CCC#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_82 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#001C9E# => Wide_Wide_Character'Val (16#0010DE#), when 16#001F9D# => Wide_Wide_Character'Val (16#001F95#), when 16#002CAE# => Wide_Wide_Character'Val (16#002CAF#), when 16#010C8F# => Wide_Wide_Character'Val (16#010CCF#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_83 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000182# => Wide_Wide_Character'Val (16#000183#), when 16#001C9F# => Wide_Wide_Character'Val (16#0010DF#), when 16#001F9C# => Wide_Wide_Character'Val (16#001F94#), when 16#00A724# => Wide_Wide_Character'Val (16#00A725#), when 16#010C8E# => Wide_Wide_Character'Val (16#010CCE#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_84 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000480# => Wide_Wide_Character'Val (16#000481#), when 16#001C98# => Wide_Wide_Character'Val (16#0010D8#), when 16#001F9B# => Wide_Wide_Character'Val (16#001F93#), when 16#002CA8# => Wide_Wide_Character'Val (16#002CA9#), when 16#010C89# => Wide_Wide_Character'Val (16#010CC9#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_85 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000184# => Wide_Wide_Character'Val (16#000185#), when 16#000386# => Wide_Wide_Character'Val (16#0003AC#), when 16#001C99# => Wide_Wide_Character'Val (16#0010D9#), when 16#001E9B# => Wide_Wide_Character'Val (16#001E61#), when 16#001F9A# => Wide_Wide_Character'Val (16#001F92#), when 16#00A722# => Wide_Wide_Character'Val (16#00A723#), when 16#010C88# => Wide_Wide_Character'Val (16#010CC8#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_86 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000187# => Wide_Wide_Character'Val (16#000188#), when 16#001C9A# => Wide_Wide_Character'Val (16#0010DA#), when 16#001F99# => Wide_Wide_Character'Val (16#001F91#), when 16#002CAA# => Wide_Wide_Character'Val (16#002CAB#), when 16#010C8B# => Wide_Wide_Character'Val (16#010CCB#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_87 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000186# => Wide_Wide_Character'Val (16#000254#), when 16#001C9B# => Wide_Wide_Character'Val (16#0010DB#), when 16#001F98# => Wide_Wide_Character'Val (16#001F90#), when 16#010C8A# => Wide_Wide_Character'Val (16#010CCA#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_88 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000189# => Wide_Wide_Character'Val (16#000256#), when 16#00048C# => Wide_Wide_Character'Val (16#00048D#), when 16#001C94# => Wide_Wide_Character'Val (16#0010D4#), when 16#002CA4# => Wide_Wide_Character'Val (16#002CA5#), when 16#010C85# => Wide_Wide_Character'Val (16#010CC5#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_89 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00038A# => Wide_Wide_Character'Val (16#0003AF#), when 16#001C95# => Wide_Wide_Character'Val (16#0010D5#), when 16#00A72E# => Wide_Wide_Character'Val (16#00A72F#), when 16#010C84# => Wide_Wide_Character'Val (16#010CC4#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_8A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00018B# => Wide_Wide_Character'Val (16#00018C#), when 16#000389# => Wide_Wide_Character'Val (16#0003AE#), when 16#00048E# => Wide_Wide_Character'Val (16#00048F#), when 16#001C96# => Wide_Wide_Character'Val (16#0010D6#), when 16#001E94# => Wide_Wide_Character'Val (16#001E95#), when 16#002CA6# => Wide_Wide_Character'Val (16#002CA7#), when 16#010C87# => Wide_Wide_Character'Val (16#010CC7#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_8B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00018A# => Wide_Wide_Character'Val (16#000257#), when 16#000388# => Wide_Wide_Character'Val (16#0003AD#), when 16#001C97# => Wide_Wide_Character'Val (16#0010D7#), when 16#00A72C# => Wide_Wide_Character'Val (16#00A72D#), when 16#010C86# => Wide_Wide_Character'Val (16#010CC6#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_8C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00038F# => Wide_Wide_Character'Val (16#0003CE#), when 16#001C90# => Wide_Wide_Character'Val (16#0010D0#), when 16#001E92# => Wide_Wide_Character'Val (16#001E93#), when 16#002CA0# => Wide_Wide_Character'Val (16#002CA1#), when 16#010C81# => Wide_Wide_Character'Val (16#010CC1#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_8D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00038E# => Wide_Wide_Character'Val (16#0003CD#), when 16#001C91# => Wide_Wide_Character'Val (16#0010D1#), when 16#00A72A# => Wide_Wide_Character'Val (16#00A72B#), when 16#010C80# => Wide_Wide_Character'Val (16#010CC0#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_8E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00018F# => Wide_Wide_Character'Val (16#000259#), when 16#00048A# => Wide_Wide_Character'Val (16#00048B#), when 16#001C92# => Wide_Wide_Character'Val (16#0010D2#), when 16#001E90# => Wide_Wide_Character'Val (16#001E91#), when 16#002CA2# => Wide_Wide_Character'Val (16#002CA3#), when 16#010C83# => Wide_Wide_Character'Val (16#010CC3#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_8F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00018E# => Wide_Wide_Character'Val (16#0001DD#), when 16#00038C# => Wide_Wide_Character'Val (16#0003CC#), when 16#001C93# => Wide_Wide_Character'Val (16#0010D3#), when 16#00A728# => Wide_Wide_Character'Val (16#00A729#), when 16#010C82# => Wide_Wide_Character'Val (16#010CC2#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_90 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000191# => Wide_Wide_Character'Val (16#000192#), when 16#000393# => Wide_Wide_Character'Val (16#0003B3#), when 16#000494# => Wide_Wide_Character'Val (16#000495#), when 16#001E8E# => Wide_Wide_Character'Val (16#001E8F#), when 16#001F8F# => Wide_Wide_Character'Val (16#001F87#), when 16#002CBC# => Wide_Wide_Character'Val (16#002CBD#), when 16#010C9D# => Wide_Wide_Character'Val (16#010CDD#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_91 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000190# => Wide_Wide_Character'Val (16#00025B#), when 16#000392# => Wide_Wide_Character'Val (16#0003B2#), when 16#001F8E# => Wide_Wide_Character'Val (16#001F86#), when 16#00A736# => Wide_Wide_Character'Val (16#00A737#), when 16#010C9C# => Wide_Wide_Character'Val (16#010CDC#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_92 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000193# => Wide_Wide_Character'Val (16#000260#), when 16#000391# => Wide_Wide_Character'Val (16#0003B1#), when 16#000496# => Wide_Wide_Character'Val (16#000497#), when 16#001E8C# => Wide_Wide_Character'Val (16#001E8D#), when 16#001F8D# => Wide_Wide_Character'Val (16#001F85#), when 16#0024B6# => Wide_Wide_Character'Val (16#0024D0#), when 16#002CBE# => Wide_Wide_Character'Val (16#002CBF#), when 16#010C9F# => Wide_Wide_Character'Val (16#010CDF#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_93 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#001F8C# => Wide_Wide_Character'Val (16#001F84#), when 16#0024B7# => Wide_Wide_Character'Val (16#0024D1#), when 16#00A734# => Wide_Wide_Character'Val (16#00A735#), when 16#010C9E# => Wide_Wide_Character'Val (16#010CDE#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_94 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000397# => Wide_Wide_Character'Val (16#0003B7#), when 16#000490# => Wide_Wide_Character'Val (16#000491#), when 16#001C88# => Wide_Wide_Character'Val (16#00A64B#), when 16#001E8A# => Wide_Wide_Character'Val (16#001E8B#), when 16#001F8B# => Wide_Wide_Character'Val (16#001F83#), when 16#002CB8# => Wide_Wide_Character'Val (16#002CB9#), when 16#010C99# => Wide_Wide_Character'Val (16#010CD9#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_95 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000194# => Wide_Wide_Character'Val (16#000263#), when 16#000396# => Wide_Wide_Character'Val (16#0003B6#), when 16#001F8A# => Wide_Wide_Character'Val (16#001F82#), when 16#00A732# => Wide_Wide_Character'Val (16#00A733#), when 16#010C98# => Wide_Wide_Character'Val (16#010CD8#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_96 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000197# => Wide_Wide_Character'Val (16#000268#), when 16#000395# => Wide_Wide_Character'Val (16#0003B5#), when 16#000492# => Wide_Wide_Character'Val (16#000493#), when 16#001E88# => Wide_Wide_Character'Val (16#001E89#), when 16#001F89# => Wide_Wide_Character'Val (16#001F81#), when 16#002CBA# => Wide_Wide_Character'Val (16#002CBB#), when 16#010C9B# => Wide_Wide_Character'Val (16#010CDB#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_97 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000196# => Wide_Wide_Character'Val (16#000269#), when 16#000394# => Wide_Wide_Character'Val (16#0003B4#), when 16#001F88# => Wide_Wide_Character'Val (16#001F80#), when 16#010C9A# => Wide_Wide_Character'Val (16#010CDA#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_98 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00039B# => Wide_Wide_Character'Val (16#0003BB#), when 16#00049C# => Wide_Wide_Character'Val (16#00049D#), when 16#001C84# => Wide_Wide_Character'Val (16#000442#), when 16#001E86# => Wide_Wide_Character'Val (16#001E87#), when 16#0024BC# => Wide_Wide_Character'Val (16#0024D6#), when 16#002CB4# => Wide_Wide_Character'Val (16#002CB5#), when 16#010C95# => Wide_Wide_Character'Val (16#010CD5#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_99 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000198# => Wide_Wide_Character'Val (16#000199#), when 16#00039A# => Wide_Wide_Character'Val (16#0003BA#), when 16#001C85# => Wide_Wide_Character'Val (16#000442#), when 16#0024BD# => Wide_Wide_Character'Val (16#0024D7#), when 16#00A73E# => Wide_Wide_Character'Val (16#00A73F#), when 16#010C94# => Wide_Wide_Character'Val (16#010CD4#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_9A (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000399# => Wide_Wide_Character'Val (16#0003B9#), when 16#00049E# => Wide_Wide_Character'Val (16#00049F#), when 16#001C86# => Wide_Wide_Character'Val (16#00044A#), when 16#001E84# => Wide_Wide_Character'Val (16#001E85#), when 16#0024BE# => Wide_Wide_Character'Val (16#0024D8#), when 16#002CB6# => Wide_Wide_Character'Val (16#002CB7#), when 16#010C97# => Wide_Wide_Character'Val (16#010CD7#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_9B (C: Codepoint) return Wide_Wide_Character is (case C is when 16#000398# => Wide_Wide_Character'Val (16#0003B8#), when 16#001C87# => Wide_Wide_Character'Val (16#000463#), when 16#0024BF# => Wide_Wide_Character'Val (16#0024D9#), when 16#00A73C# => Wide_Wide_Character'Val (16#00A73D#), when 16#010C96# => Wide_Wide_Character'Val (16#010CD6#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_9C (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00019D# => Wide_Wide_Character'Val (16#000272#), when 16#00039F# => Wide_Wide_Character'Val (16#0003BF#), when 16#000498# => Wide_Wide_Character'Val (16#000499#), when 16#001C80# => Wide_Wide_Character'Val (16#000432#), when 16#001E82# => Wide_Wide_Character'Val (16#001E83#), when 16#0024B8# => Wide_Wide_Character'Val (16#0024D2#), when 16#002CB0# => Wide_Wide_Character'Val (16#002CB1#), when 16#010C91# => Wide_Wide_Character'Val (16#010CD1#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_9D (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00019C# => Wide_Wide_Character'Val (16#00026F#), when 16#00039E# => Wide_Wide_Character'Val (16#0003BE#), when 16#001C81# => Wide_Wide_Character'Val (16#000434#), when 16#0024B9# => Wide_Wide_Character'Val (16#0024D3#), when 16#00A73A# => Wide_Wide_Character'Val (16#00A73B#), when 16#010C90# => Wide_Wide_Character'Val (16#010CD0#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_9E (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00019F# => Wide_Wide_Character'Val (16#000275#), when 16#00039D# => Wide_Wide_Character'Val (16#0003BD#), when 16#00049A# => Wide_Wide_Character'Val (16#00049B#), when 16#001C82# => Wide_Wide_Character'Val (16#00043E#), when 16#001E80# => Wide_Wide_Character'Val (16#001E81#), when 16#0024BA# => Wide_Wide_Character'Val (16#0024D4#), when 16#002CB2# => Wide_Wide_Character'Val (16#002CB3#), when 16#010C93# => Wide_Wide_Character'Val (16#010CD3#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_9F (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00039C# => Wide_Wide_Character'Val (16#0003BC#), when 16#001C83# => Wide_Wide_Character'Val (16#000441#), when 16#0024BB# => Wide_Wide_Character'Val (16#0024D5#), when 16#00A738# => Wide_Wide_Character'Val (16#00A739#), when 16#010C92# => Wide_Wide_Character'Val (16#010CD2#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A0 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003A3# => Wide_Wide_Character'Val (16#0003C3#), when 16#0004A4# => Wide_Wide_Character'Val (16#0004A5#), when 16#0010B0# => Wide_Wide_Character'Val (16#002D10#), when 16#001EBE# => Wide_Wide_Character'Val (16#001EBF#), when 16#002C8C# => Wide_Wide_Character'Val (16#002C8D#), when 16#010CAD# => Wide_Wide_Character'Val (16#010CED#), when 16#0118B9# => Wide_Wide_Character'Val (16#0118D9#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A1 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001A0# => Wide_Wide_Character'Val (16#0001A1#), when 16#0010B1# => Wide_Wide_Character'Val (16#002D11#), when 16#001CBD# => Wide_Wide_Character'Val (16#0010FD#), when 16#001FBE# => Wide_Wide_Character'Val (16#0003B9#), when 16#010CAC# => Wide_Wide_Character'Val (16#010CEC#), when 16#0118B8# => Wide_Wide_Character'Val (16#0118D8#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A2 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003A1# => Wide_Wide_Character'Val (16#0003C1#), when 16#0004A6# => Wide_Wide_Character'Val (16#0004A7#), when 16#0010B2# => Wide_Wide_Character'Val (16#002D12#), when 16#001CBE# => Wide_Wide_Character'Val (16#0010FE#), when 16#001EBC# => Wide_Wide_Character'Val (16#001EBD#), when 16#002183# => Wide_Wide_Character'Val (16#002184#), when 16#002C8E# => Wide_Wide_Character'Val (16#002C8F#), when 16#010CAF# => Wide_Wide_Character'Val (16#010CEF#), when 16#0118BB# => Wide_Wide_Character'Val (16#0118DB#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A3 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001A2# => Wide_Wide_Character'Val (16#0001A3#), when 16#0003A0# => Wide_Wide_Character'Val (16#0003C0#), when 16#0010B3# => Wide_Wide_Character'Val (16#002D13#), when 16#001CBF# => Wide_Wide_Character'Val (16#0010FF#), when 16#001FBC# => Wide_Wide_Character'Val (16#001FB3#), when 16#010CAE# => Wide_Wide_Character'Val (16#010CEE#), when 16#0118BA# => Wide_Wide_Character'Val (16#0118DA#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A4 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003A7# => Wide_Wide_Character'Val (16#0003C7#), when 16#0004A0# => Wide_Wide_Character'Val (16#0004A1#), when 16#0010B4# => Wide_Wide_Character'Val (16#002D14#), when 16#001CB8# => Wide_Wide_Character'Val (16#0010F8#), when 16#001EBA# => Wide_Wide_Character'Val (16#001EBB#), when 16#001FBB# => Wide_Wide_Character'Val (16#001F71#), when 16#002C88# => Wide_Wide_Character'Val (16#002C89#), when 16#010CA9# => Wide_Wide_Character'Val (16#010CE9#), when 16#0118BD# => Wide_Wide_Character'Val (16#0118DD#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A5 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001A4# => Wide_Wide_Character'Val (16#0001A5#), when 16#0003A6# => Wide_Wide_Character'Val (16#0003C6#), when 16#0010B5# => Wide_Wide_Character'Val (16#002D15#), when 16#001CB9# => Wide_Wide_Character'Val (16#0010F9#), when 16#001FBA# => Wide_Wide_Character'Val (16#001F70#), when 16#010CA8# => Wide_Wide_Character'Val (16#010CE8#), when 16#0118BC# => Wide_Wide_Character'Val (16#0118DC#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A6 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001A7# => Wide_Wide_Character'Val (16#0001A8#), when 16#0003A5# => Wide_Wide_Character'Val (16#0003C5#), when 16#0004A2# => Wide_Wide_Character'Val (16#0004A3#), when 16#0010B6# => Wide_Wide_Character'Val (16#002D16#), when 16#001CBA# => Wide_Wide_Character'Val (16#0010FA#), when 16#001EB8# => Wide_Wide_Character'Val (16#001EB9#), when 16#001FB9# => Wide_Wide_Character'Val (16#001FB1#), when 16#002C8A# => Wide_Wide_Character'Val (16#002C8B#), when 16#010CAB# => Wide_Wide_Character'Val (16#010CEB#), when 16#0118BF# => Wide_Wide_Character'Val (16#0118DF#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A7 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001A6# => Wide_Wide_Character'Val (16#000280#), when 16#0003A4# => Wide_Wide_Character'Val (16#0003C4#), when 16#0010B7# => Wide_Wide_Character'Val (16#002D17#), when 16#001FB8# => Wide_Wide_Character'Val (16#001FB0#), when 16#010CAA# => Wide_Wide_Character'Val (16#010CEA#), when 16#0118BE# => Wide_Wide_Character'Val (16#0118DE#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A8 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001A9# => Wide_Wide_Character'Val (16#000283#), when 16#0003AB# => Wide_Wide_Character'Val (16#0003CB#), when 16#0004AC# => Wide_Wide_Character'Val (16#0004AD#), when 16#0010B8# => Wide_Wide_Character'Val (16#002D18#), when 16#001CB4# => Wide_Wide_Character'Val (16#0010F4#), when 16#001EB6# => Wide_Wide_Character'Val (16#001EB7#), when 16#002C84# => Wide_Wide_Character'Val (16#002C85#), when 16#010CA5# => Wide_Wide_Character'Val (16#010CE5#), when 16#0118B1# => Wide_Wide_Character'Val (16#0118D1#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_A9 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003AA# => Wide_Wide_Character'Val (16#0003CA#), when 16#0010B9# => Wide_Wide_Character'Val (16#002D19#), when 16#001CB5# => Wide_Wide_Character'Val (16#0010F5#), when 16#010CA4# => Wide_Wide_Character'Val (16#010CE4#), when 16#0118B0# => Wide_Wide_Character'Val (16#0118D0#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_AA (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003A9# => Wide_Wide_Character'Val (16#0003C9#), when 16#0004AE# => Wide_Wide_Character'Val (16#0004AF#), when 16#0010BA# => Wide_Wide_Character'Val (16#002D1A#), when 16#001CB6# => Wide_Wide_Character'Val (16#0010F6#), when 16#001EB4# => Wide_Wide_Character'Val (16#001EB5#), when 16#002C86# => Wide_Wide_Character'Val (16#002C87#), when 16#010CA7# => Wide_Wide_Character'Val (16#010CE7#), when 16#0118B3# => Wide_Wide_Character'Val (16#0118D3#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_AB (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003A8# => Wide_Wide_Character'Val (16#0003C8#), when 16#0010BB# => Wide_Wide_Character'Val (16#002D1B#), when 16#001CB7# => Wide_Wide_Character'Val (16#0010F7#), when 16#010CA6# => Wide_Wide_Character'Val (16#010CE6#), when 16#0118B2# => Wide_Wide_Character'Val (16#0118D2#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_AC (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004A8# => Wide_Wide_Character'Val (16#0004A9#), when 16#0010BC# => Wide_Wide_Character'Val (16#002D1C#), when 16#001CB0# => Wide_Wide_Character'Val (16#0010F0#), when 16#001EB2# => Wide_Wide_Character'Val (16#001EB3#), when 16#002C80# => Wide_Wide_Character'Val (16#002C81#), when 16#010CA1# => Wide_Wide_Character'Val (16#010CE1#), when 16#0118B5# => Wide_Wide_Character'Val (16#0118D5#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_AD (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001AC# => Wide_Wide_Character'Val (16#0001AD#), when 16#0010BD# => Wide_Wide_Character'Val (16#002D1D#), when 16#001CB1# => Wide_Wide_Character'Val (16#0010F1#), when 16#010CA0# => Wide_Wide_Character'Val (16#010CE0#), when 16#0118B4# => Wide_Wide_Character'Val (16#0118D4#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_AE (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001AF# => Wide_Wide_Character'Val (16#0001B0#), when 16#0004AA# => Wide_Wide_Character'Val (16#0004AB#), when 16#0010BE# => Wide_Wide_Character'Val (16#002D1E#), when 16#001CB2# => Wide_Wide_Character'Val (16#0010F2#), when 16#001EB0# => Wide_Wide_Character'Val (16#001EB1#), when 16#002C82# => Wide_Wide_Character'Val (16#002C83#), when 16#010CA3# => Wide_Wide_Character'Val (16#010CE3#), when 16#0118B7# => Wide_Wide_Character'Val (16#0118D7#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_AF (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001AE# => Wide_Wide_Character'Val (16#000288#), when 16#0010BF# => Wide_Wide_Character'Val (16#002D1F#), when 16#001CB3# => Wide_Wide_Character'Val (16#0010F3#), when 16#010CA2# => Wide_Wide_Character'Val (16#010CE2#), when 16#0118B6# => Wide_Wide_Character'Val (16#0118D6#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B0 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001B1# => Wide_Wide_Character'Val (16#00028A#), when 16#0004B4# => Wide_Wide_Character'Val (16#0004B5#), when 16#0010A0# => Wide_Wide_Character'Val (16#002D00#), when 16#001CAC# => Wide_Wide_Character'Val (16#0010EC#), when 16#001EAE# => Wide_Wide_Character'Val (16#001EAF#), when 16#001FAF# => Wide_Wide_Character'Val (16#001FA7#), when 16#002C9C# => Wide_Wide_Character'Val (16#002C9D#), when 16#0104B5# => Wide_Wide_Character'Val (16#0104DD#), when 16#0118A9# => Wide_Wide_Character'Val (16#0118C9#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B1 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0010A1# => Wide_Wide_Character'Val (16#002D01#), when 16#001CAD# => Wide_Wide_Character'Val (16#0010ED#), when 16#001FAE# => Wide_Wide_Character'Val (16#001FA6#), when 16#0104B4# => Wide_Wide_Character'Val (16#0104DC#), when 16#0118A8# => Wide_Wide_Character'Val (16#0118C8#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B2 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001B3# => Wide_Wide_Character'Val (16#0001B4#), when 16#0004B6# => Wide_Wide_Character'Val (16#0004B7#), when 16#0010A2# => Wide_Wide_Character'Val (16#002D02#), when 16#001CAE# => Wide_Wide_Character'Val (16#0010EE#), when 16#001EAC# => Wide_Wide_Character'Val (16#001EAD#), when 16#001FAD# => Wide_Wide_Character'Val (16#001FA5#), when 16#002C9E# => Wide_Wide_Character'Val (16#002C9F#), when 16#0104B7# => Wide_Wide_Character'Val (16#0104DF#), when 16#0118AB# => Wide_Wide_Character'Val (16#0118CB#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B3 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001B2# => Wide_Wide_Character'Val (16#00028B#), when 16#0010A3# => Wide_Wide_Character'Val (16#002D03#), when 16#001CAF# => Wide_Wide_Character'Val (16#0010EF#), when 16#001FAC# => Wide_Wide_Character'Val (16#001FA4#), when 16#0104B6# => Wide_Wide_Character'Val (16#0104DE#), when 16#0118AA# => Wide_Wide_Character'Val (16#0118CA#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B4 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001B5# => Wide_Wide_Character'Val (16#0001B6#), when 16#0004B0# => Wide_Wide_Character'Val (16#0004B1#), when 16#0010A4# => Wide_Wide_Character'Val (16#002D04#), when 16#001CA8# => Wide_Wide_Character'Val (16#0010E8#), when 16#001EAA# => Wide_Wide_Character'Val (16#001EAB#), when 16#001FAB# => Wide_Wide_Character'Val (16#001FA3#), when 16#002C98# => Wide_Wide_Character'Val (16#002C99#), when 16#0104B1# => Wide_Wide_Character'Val (16#0104D9#), when 16#0118AD# => Wide_Wide_Character'Val (16#0118CD#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B5 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000B5# => Wide_Wide_Character'Val (16#0003BC#), when 16#0010A5# => Wide_Wide_Character'Val (16#002D05#), when 16#001CA9# => Wide_Wide_Character'Val (16#0010E9#), when 16#001FAA# => Wide_Wide_Character'Val (16#001FA2#), when 16#0104B0# => Wide_Wide_Character'Val (16#0104D8#), when 16#0118AC# => Wide_Wide_Character'Val (16#0118CC#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B6 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001B7# => Wide_Wide_Character'Val (16#000292#), when 16#0004B2# => Wide_Wide_Character'Val (16#0004B3#), when 16#0010A6# => Wide_Wide_Character'Val (16#002D06#), when 16#001CAA# => Wide_Wide_Character'Val (16#0010EA#), when 16#001EA8# => Wide_Wide_Character'Val (16#001EA9#), when 16#001FA9# => Wide_Wide_Character'Val (16#001FA1#), when 16#002C9A# => Wide_Wide_Character'Val (16#002C9B#), when 16#0104B3# => Wide_Wide_Character'Val (16#0104DB#), when 16#0118AF# => Wide_Wide_Character'Val (16#0118CF#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B7 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0010A7# => Wide_Wide_Character'Val (16#002D07#), when 16#001CAB# => Wide_Wide_Character'Val (16#0010EB#), when 16#001FA8# => Wide_Wide_Character'Val (16#001FA0#), when 16#0104B2# => Wide_Wide_Character'Val (16#0104DA#), when 16#0118AE# => Wide_Wide_Character'Val (16#0118CE#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B8 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004BC# => Wide_Wide_Character'Val (16#0004BD#), when 16#0010A8# => Wide_Wide_Character'Val (16#002D08#), when 16#001CA4# => Wide_Wide_Character'Val (16#0010E4#), when 16#001EA6# => Wide_Wide_Character'Val (16#001EA7#), when 16#002C94# => Wide_Wide_Character'Val (16#002C95#), when 16#0104BD# => Wide_Wide_Character'Val (16#0104E5#), when 16#0118A1# => Wide_Wide_Character'Val (16#0118C1#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_B9 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001B8# => Wide_Wide_Character'Val (16#0001B9#), when 16#0010A9# => Wide_Wide_Character'Val (16#002D09#), when 16#001CA5# => Wide_Wide_Character'Val (16#0010E5#), when 16#0104BC# => Wide_Wide_Character'Val (16#0104E4#), when 16#0118A0# => Wide_Wide_Character'Val (16#0118C0#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_BA (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004BE# => Wide_Wide_Character'Val (16#0004BF#), when 16#0010AA# => Wide_Wide_Character'Val (16#002D0A#), when 16#001CA6# => Wide_Wide_Character'Val (16#0010E6#), when 16#001EA4# => Wide_Wide_Character'Val (16#001EA5#), when 16#002C96# => Wide_Wide_Character'Val (16#002C97#), when 16#0104BF# => Wide_Wide_Character'Val (16#0104E7#), when 16#0118A3# => Wide_Wide_Character'Val (16#0118C3#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_BB (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0010AB# => Wide_Wide_Character'Val (16#002D0B#), when 16#001CA7# => Wide_Wide_Character'Val (16#0010E7#), when 16#0104BE# => Wide_Wide_Character'Val (16#0104E6#), when 16#0118A2# => Wide_Wide_Character'Val (16#0118C2#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_BC (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004B8# => Wide_Wide_Character'Val (16#0004B9#), when 16#0010AC# => Wide_Wide_Character'Val (16#002D0C#), when 16#001CA0# => Wide_Wide_Character'Val (16#0010E0#), when 16#001EA2# => Wide_Wide_Character'Val (16#001EA3#), when 16#002C90# => Wide_Wide_Character'Val (16#002C91#), when 16#0104B9# => Wide_Wide_Character'Val (16#0104E1#), when 16#010CB1# => Wide_Wide_Character'Val (16#010CF1#), when 16#0118A5# => Wide_Wide_Character'Val (16#0118C5#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_BD (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001BC# => Wide_Wide_Character'Val (16#0001BD#), when 16#0010AD# => Wide_Wide_Character'Val (16#002D0D#), when 16#001CA1# => Wide_Wide_Character'Val (16#0010E1#), when 16#0104B8# => Wide_Wide_Character'Val (16#0104E0#), when 16#010CB0# => Wide_Wide_Character'Val (16#010CF0#), when 16#0118A4# => Wide_Wide_Character'Val (16#0118C4#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_BE (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004BA# => Wide_Wide_Character'Val (16#0004BB#), when 16#0010AE# => Wide_Wide_Character'Val (16#002D0E#), when 16#001CA2# => Wide_Wide_Character'Val (16#0010E2#), when 16#001EA0# => Wide_Wide_Character'Val (16#001EA1#), when 16#002C92# => Wide_Wide_Character'Val (16#002C93#), when 16#0104BB# => Wide_Wide_Character'Val (16#0104E3#), when 16#0118A7# => Wide_Wide_Character'Val (16#0118C7#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_BF (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0010AF# => Wide_Wide_Character'Val (16#002D0F#), when 16#001CA3# => Wide_Wide_Character'Val (16#0010E3#), when 16#0104BA# => Wide_Wide_Character'Val (16#0104E2#), when 16#010CB2# => Wide_Wide_Character'Val (16#010CF2#), when 16#0118A6# => Wide_Wide_Character'Val (16#0118C6#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C0 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C0# => Wide_Wide_Character'Val (16#0000E0#), when 16#001EDE# => Wide_Wide_Character'Val (16#001EDF#), when 16#00A666# => Wide_Wide_Character'Val (16#00A667#), when 16#0104C5# => Wide_Wide_Character'Val (16#0104ED#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C1 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C1# => Wide_Wide_Character'Val (16#0000E1#), when 16#0003C2# => Wide_Wide_Character'Val (16#0003C3#), when 16#0004C5# => Wide_Wide_Character'Val (16#0004C6#), when 16#002CED# => Wide_Wide_Character'Val (16#002CEE#), when 16#00A766# => Wide_Wide_Character'Val (16#00A767#), when 16#0104C4# => Wide_Wide_Character'Val (16#0104EC#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C2 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C2# => Wide_Wide_Character'Val (16#0000E2#), when 16#001EDC# => Wide_Wide_Character'Val (16#001EDD#), when 16#00A664# => Wide_Wide_Character'Val (16#00A665#), when 16#0104C7# => Wide_Wide_Character'Val (16#0104EF#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C3 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C3# => Wide_Wide_Character'Val (16#0000E3#), when 16#0004C7# => Wide_Wide_Character'Val (16#0004C8#), when 16#00A764# => Wide_Wide_Character'Val (16#00A765#), when 16#0104C6# => Wide_Wide_Character'Val (16#0104EE#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C4 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C4# => Wide_Wide_Character'Val (16#0000E4#), when 16#0001C5# => Wide_Wide_Character'Val (16#0001C6#), when 16#0004C0# => Wide_Wide_Character'Val (16#0004CF#), when 16#001EDA# => Wide_Wide_Character'Val (16#001EDB#), when 16#001FDB# => Wide_Wide_Character'Val (16#001F77#), when 16#00A662# => Wide_Wide_Character'Val (16#00A663#), when 16#0104C1# => Wide_Wide_Character'Val (16#0104E9#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C5 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C5# => Wide_Wide_Character'Val (16#0000E5#), when 16#0001C4# => Wide_Wide_Character'Val (16#0001C6#), when 16#0004C1# => Wide_Wide_Character'Val (16#0004C2#), when 16#001FDA# => Wide_Wide_Character'Val (16#001F76#), when 16#00A762# => Wide_Wide_Character'Val (16#00A763#), when 16#00FF3A# => Wide_Wide_Character'Val (16#00FF5A#), when 16#0104C0# => Wide_Wide_Character'Val (16#0104E8#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C6 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C6# => Wide_Wide_Character'Val (16#0000E6#), when 16#0001C7# => Wide_Wide_Character'Val (16#0001C9#), when 16#001ED8# => Wide_Wide_Character'Val (16#001ED9#), when 16#001FD9# => Wide_Wide_Character'Val (16#001FD1#), when 16#00A660# => Wide_Wide_Character'Val (16#00A661#), when 16#00FF39# => Wide_Wide_Character'Val (16#00FF59#), when 16#0104C3# => Wide_Wide_Character'Val (16#0104EB#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C7 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C7# => Wide_Wide_Character'Val (16#0000E7#), when 16#0004C3# => Wide_Wide_Character'Val (16#0004C4#), when 16#001FD8# => Wide_Wide_Character'Val (16#001FD0#), when 16#002CEB# => Wide_Wide_Character'Val (16#002CEC#), when 16#00A760# => Wide_Wide_Character'Val (16#00A761#), when 16#00FF38# => Wide_Wide_Character'Val (16#00FF58#), when 16#0104C2# => Wide_Wide_Character'Val (16#0104EA#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C8 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C8# => Wide_Wide_Character'Val (16#0000E8#), when 16#001ED6# => Wide_Wide_Character'Val (16#001ED7#), when 16#00FF37# => Wide_Wide_Character'Val (16#00FF57#), when 16#0104CD# => Wide_Wide_Character'Val (16#0104F5#), when 16#01E920# => Wide_Wide_Character'Val (16#01E942#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_C9 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000C9# => Wide_Wide_Character'Val (16#0000E9#), when 16#0001C8# => Wide_Wide_Character'Val (16#0001C9#), when 16#0004CD# => Wide_Wide_Character'Val (16#0004CE#), when 16#00A76E# => Wide_Wide_Character'Val (16#00A76F#), when 16#00FF36# => Wide_Wide_Character'Val (16#00FF56#), when 16#0104CC# => Wide_Wide_Character'Val (16#0104F4#), when 16#01E921# => Wide_Wide_Character'Val (16#01E943#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_CA (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000CA# => Wide_Wide_Character'Val (16#0000EA#), when 16#0001CB# => Wide_Wide_Character'Val (16#0001CC#), when 16#001ED4# => Wide_Wide_Character'Val (16#001ED5#), when 16#00A66C# => Wide_Wide_Character'Val (16#00A66D#), when 16#00FF35# => Wide_Wide_Character'Val (16#00FF55#), when 16#0104CF# => Wide_Wide_Character'Val (16#0104F7#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_CB (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000CB# => Wide_Wide_Character'Val (16#0000EB#), when 16#0001CA# => Wide_Wide_Character'Val (16#0001CC#), when 16#00A76C# => Wide_Wide_Character'Val (16#00A76D#), when 16#00FF34# => Wide_Wide_Character'Val (16#00FF54#), when 16#0104CE# => Wide_Wide_Character'Val (16#0104F6#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_CC (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000CC# => Wide_Wide_Character'Val (16#0000EC#), when 16#0001CD# => Wide_Wide_Character'Val (16#0001CE#), when 16#0003CF# => Wide_Wide_Character'Val (16#0003D7#), when 16#001ED2# => Wide_Wide_Character'Val (16#001ED3#), when 16#002CE0# => Wide_Wide_Character'Val (16#002CE1#), when 16#00A66A# => Wide_Wide_Character'Val (16#00A66B#), when 16#00FF33# => Wide_Wide_Character'Val (16#00FF53#), when 16#0104C9# => Wide_Wide_Character'Val (16#0104F1#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_CD (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000CD# => Wide_Wide_Character'Val (16#0000ED#), when 16#0004C9# => Wide_Wide_Character'Val (16#0004CA#), when 16#00A76A# => Wide_Wide_Character'Val (16#00A76B#), when 16#00FF32# => Wide_Wide_Character'Val (16#00FF52#), when 16#0104C8# => Wide_Wide_Character'Val (16#0104F0#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_CE (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000CE# => Wide_Wide_Character'Val (16#0000EE#), when 16#0001CF# => Wide_Wide_Character'Val (16#0001D0#), when 16#001ED0# => Wide_Wide_Character'Val (16#001ED1#), when 16#002CE2# => Wide_Wide_Character'Val (16#002CE3#), when 16#00A668# => Wide_Wide_Character'Val (16#00A669#), when 16#00FF31# => Wide_Wide_Character'Val (16#00FF51#), when 16#0104CB# => Wide_Wide_Character'Val (16#0104F3#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_CF (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000CF# => Wide_Wide_Character'Val (16#0000EF#), when 16#0004CB# => Wide_Wide_Character'Val (16#0004CC#), when 16#00A768# => Wide_Wide_Character'Val (16#00A769#), when 16#00FF30# => Wide_Wide_Character'Val (16#00FF50#), when 16#0104CA# => Wide_Wide_Character'Val (16#0104F2#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D0 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D0# => Wide_Wide_Character'Val (16#0000F0#), when 16#0001D1# => Wide_Wide_Character'Val (16#0001D2#), when 16#0004D4# => Wide_Wide_Character'Val (16#0004D5#), when 16#0010C0# => Wide_Wide_Character'Val (16#002D20#), when 16#001ECE# => Wide_Wide_Character'Val (16#001ECF#), when 16#00AB7B# => Wide_Wide_Character'Val (16#0013AB#), when 16#00FF2F# => Wide_Wide_Character'Val (16#00FF4F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D1 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D1# => Wide_Wide_Character'Val (16#0000F1#), when 16#0010C1# => Wide_Wide_Character'Val (16#002D21#), when 16#00AB7A# => Wide_Wide_Character'Val (16#0013AA#), when 16#00FF2E# => Wide_Wide_Character'Val (16#00FF4E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D2 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D2# => Wide_Wide_Character'Val (16#0000F2#), when 16#0001D3# => Wide_Wide_Character'Val (16#0001D4#), when 16#0003D1# => Wide_Wide_Character'Val (16#0003B8#), when 16#0004D6# => Wide_Wide_Character'Val (16#0004D7#), when 16#0010C2# => Wide_Wide_Character'Val (16#002D22#), when 16#001ECC# => Wide_Wide_Character'Val (16#001ECD#), when 16#00AB79# => Wide_Wide_Character'Val (16#0013A9#), when 16#00FF2D# => Wide_Wide_Character'Val (16#00FF4D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D3 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D3# => Wide_Wide_Character'Val (16#0000F3#), when 16#0003D0# => Wide_Wide_Character'Val (16#0003B2#), when 16#0010C3# => Wide_Wide_Character'Val (16#002D23#), when 16#001FCC# => Wide_Wide_Character'Val (16#001FC3#), when 16#00AB78# => Wide_Wide_Character'Val (16#0013A8#), when 16#00FF2C# => Wide_Wide_Character'Val (16#00FF4C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D4 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D4# => Wide_Wide_Character'Val (16#0000F4#), when 16#0001D5# => Wide_Wide_Character'Val (16#0001D6#), when 16#0004D0# => Wide_Wide_Character'Val (16#0004D1#), when 16#0010C4# => Wide_Wide_Character'Val (16#002D24#), when 16#001ECA# => Wide_Wide_Character'Val (16#001ECB#), when 16#001FCB# => Wide_Wide_Character'Val (16#001F75#), when 16#00AB7F# => Wide_Wide_Character'Val (16#0013AF#), when 16#00FF2B# => Wide_Wide_Character'Val (16#00FF4B#), when 16#0104D1# => Wide_Wide_Character'Val (16#0104F9#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D5 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D5# => Wide_Wide_Character'Val (16#0000F5#), when 16#0003D6# => Wide_Wide_Character'Val (16#0003C0#), when 16#0010C5# => Wide_Wide_Character'Val (16#002D25#), when 16#001FCA# => Wide_Wide_Character'Val (16#001F74#), when 16#00AB7E# => Wide_Wide_Character'Val (16#0013AE#), when 16#00FF2A# => Wide_Wide_Character'Val (16#00FF4A#), when 16#0104D0# => Wide_Wide_Character'Val (16#0104F8#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D6 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D6# => Wide_Wide_Character'Val (16#0000F6#), when 16#0001D7# => Wide_Wide_Character'Val (16#0001D8#), when 16#0003D5# => Wide_Wide_Character'Val (16#0003C6#), when 16#0004D2# => Wide_Wide_Character'Val (16#0004D3#), when 16#001EC8# => Wide_Wide_Character'Val (16#001EC9#), when 16#001FC9# => Wide_Wide_Character'Val (16#001F73#), when 16#00AB7D# => Wide_Wide_Character'Val (16#0013AD#), when 16#00FF29# => Wide_Wide_Character'Val (16#00FF49#), when 16#0104D3# => Wide_Wide_Character'Val (16#0104FB#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D7 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0010C7# => Wide_Wide_Character'Val (16#002D27#), when 16#001FC8# => Wide_Wide_Character'Val (16#001F72#), when 16#00AB7C# => Wide_Wide_Character'Val (16#0013AC#), when 16#00FF28# => Wide_Wide_Character'Val (16#00FF48#), when 16#0104D2# => Wide_Wide_Character'Val (16#0104FA#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D8 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D8# => Wide_Wide_Character'Val (16#0000F8#), when 16#0001D9# => Wide_Wide_Character'Val (16#0001DA#), when 16#0004DC# => Wide_Wide_Character'Val (16#0004DD#), when 16#001EC6# => Wide_Wide_Character'Val (16#001EC7#), when 16#00AB73# => Wide_Wide_Character'Val (16#0013A3#), when 16#00FF27# => Wide_Wide_Character'Val (16#00FF47#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_D9 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000D9# => Wide_Wide_Character'Val (16#0000F9#), when 16#0003DA# => Wide_Wide_Character'Val (16#0003DB#), when 16#00A77E# => Wide_Wide_Character'Val (16#00A77F#), when 16#00AB72# => Wide_Wide_Character'Val (16#0013A2#), when 16#00FF26# => Wide_Wide_Character'Val (16#00FF46#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_DA (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000DA# => Wide_Wide_Character'Val (16#0000FA#), when 16#0001DB# => Wide_Wide_Character'Val (16#0001DC#), when 16#0004DE# => Wide_Wide_Character'Val (16#0004DF#), when 16#001EC4# => Wide_Wide_Character'Val (16#001EC5#), when 16#00A77D# => Wide_Wide_Character'Val (16#001D79#), when 16#00AB71# => Wide_Wide_Character'Val (16#0013A1#), when 16#00FF25# => Wide_Wide_Character'Val (16#00FF45#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_DB (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000DB# => Wide_Wide_Character'Val (16#0000FB#), when 16#0003D8# => Wide_Wide_Character'Val (16#0003D9#), when 16#00AB70# => Wide_Wide_Character'Val (16#0013A0#), when 16#00FF24# => Wide_Wide_Character'Val (16#00FF44#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_DC (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000DC# => Wide_Wide_Character'Val (16#0000FC#), when 16#0004D8# => Wide_Wide_Character'Val (16#0004D9#), when 16#001EC2# => Wide_Wide_Character'Val (16#001EC3#), when 16#00A77B# => Wide_Wide_Character'Val (16#00A77C#), when 16#00AB77# => Wide_Wide_Character'Val (16#0013A7#), when 16#00FF23# => Wide_Wide_Character'Val (16#00FF43#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_DD (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000DD# => Wide_Wide_Character'Val (16#0000FD#), when 16#0003DE# => Wide_Wide_Character'Val (16#0003DF#), when 16#0010CD# => Wide_Wide_Character'Val (16#002D2D#), when 16#00AB76# => Wide_Wide_Character'Val (16#0013A6#), when 16#00FF22# => Wide_Wide_Character'Val (16#00FF42#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_DE (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0000DE# => Wide_Wide_Character'Val (16#0000FE#), when 16#0004DA# => Wide_Wide_Character'Val (16#0004DB#), when 16#001EC0# => Wide_Wide_Character'Val (16#001EC1#), when 16#002CF2# => Wide_Wide_Character'Val (16#002CF3#), when 16#00A779# => Wide_Wide_Character'Val (16#00A77A#), when 16#00AB75# => Wide_Wide_Character'Val (16#0013A5#), when 16#00FF21# => Wide_Wide_Character'Val (16#00FF41#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_DF (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001DE# => Wide_Wide_Character'Val (16#0001DF#), when 16#0003DC# => Wide_Wide_Character'Val (16#0003DD#), when 16#00AB74# => Wide_Wide_Character'Val (16#0013A4#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E0 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004E4# => Wide_Wide_Character'Val (16#0004E5#), when 16#001EFE# => Wide_Wide_Character'Val (16#001EFF#), when 16#0024C4# => Wide_Wide_Character'Val (16#0024DE#), when 16#002CCC# => Wide_Wide_Character'Val (16#002CCD#), when 16#00A646# => Wide_Wide_Character'Val (16#00A647#), when 16#01E908# => Wide_Wide_Character'Val (16#01E92A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E1 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001E0# => Wide_Wide_Character'Val (16#0001E1#), when 16#0003E2# => Wide_Wide_Character'Val (16#0003E3#), when 16#0024C5# => Wide_Wide_Character'Val (16#0024DF#), when 16#00A746# => Wide_Wide_Character'Val (16#00A747#), when 16#01E909# => Wide_Wide_Character'Val (16#01E92B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E2 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004E6# => Wide_Wide_Character'Val (16#0004E7#), when 16#001EFC# => Wide_Wide_Character'Val (16#001EFD#), when 16#0024C6# => Wide_Wide_Character'Val (16#0024E0#), when 16#002CCE# => Wide_Wide_Character'Val (16#002CCF#), when 16#00A644# => Wide_Wide_Character'Val (16#00A645#), when 16#01E90A# => Wide_Wide_Character'Val (16#01E92C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E3 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001E2# => Wide_Wide_Character'Val (16#0001E3#), when 16#0003E0# => Wide_Wide_Character'Val (16#0003E1#), when 16#001FFC# => Wide_Wide_Character'Val (16#001FF3#), when 16#0024C7# => Wide_Wide_Character'Val (16#0024E1#), when 16#00A744# => Wide_Wide_Character'Val (16#00A745#), when 16#01E90B# => Wide_Wide_Character'Val (16#01E92D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E4 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004E0# => Wide_Wide_Character'Val (16#0004E1#), when 16#001EFA# => Wide_Wide_Character'Val (16#001EFB#), when 16#001FFB# => Wide_Wide_Character'Val (16#001F7D#), when 16#0024C0# => Wide_Wide_Character'Val (16#0024DA#), when 16#002CC8# => Wide_Wide_Character'Val (16#002CC9#), when 16#00A642# => Wide_Wide_Character'Val (16#00A643#), when 16#01E90C# => Wide_Wide_Character'Val (16#01E92E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E5 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001E4# => Wide_Wide_Character'Val (16#0001E5#), when 16#0003E6# => Wide_Wide_Character'Val (16#0003E7#), when 16#001FFA# => Wide_Wide_Character'Val (16#001F7C#), when 16#0024C1# => Wide_Wide_Character'Val (16#0024DB#), when 16#00A742# => Wide_Wide_Character'Val (16#00A743#), when 16#01E90D# => Wide_Wide_Character'Val (16#01E92F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E6 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004E2# => Wide_Wide_Character'Val (16#0004E3#), when 16#001EF8# => Wide_Wide_Character'Val (16#001EF9#), when 16#001FF9# => Wide_Wide_Character'Val (16#001F79#), when 16#0024C2# => Wide_Wide_Character'Val (16#0024DC#), when 16#002CCA# => Wide_Wide_Character'Val (16#002CCB#), when 16#00A640# => Wide_Wide_Character'Val (16#00A641#), when 16#01E90E# => Wide_Wide_Character'Val (16#01E930#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E7 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001E6# => Wide_Wide_Character'Val (16#0001E7#), when 16#0003E4# => Wide_Wide_Character'Val (16#0003E5#), when 16#001FF8# => Wide_Wide_Character'Val (16#001F78#), when 16#0024C3# => Wide_Wide_Character'Val (16#0024DD#), when 16#00A740# => Wide_Wide_Character'Val (16#00A741#), when 16#01E90F# => Wide_Wide_Character'Val (16#01E931#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E8 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004EC# => Wide_Wide_Character'Val (16#0004ED#), when 16#0013FB# => Wide_Wide_Character'Val (16#0013F3#), when 16#001EF6# => Wide_Wide_Character'Val (16#001EF7#), when 16#0024CC# => Wide_Wide_Character'Val (16#0024E6#), when 16#002CC4# => Wide_Wide_Character'Val (16#002CC5#), when 16#00A64E# => Wide_Wide_Character'Val (16#00A64F#), when 16#01E900# => Wide_Wide_Character'Val (16#01E922#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_E9 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001E8# => Wide_Wide_Character'Val (16#0001E9#), when 16#0003EA# => Wide_Wide_Character'Val (16#0003EB#), when 16#0013FA# => Wide_Wide_Character'Val (16#0013F2#), when 16#0024CD# => Wide_Wide_Character'Val (16#0024E7#), when 16#00A74E# => Wide_Wide_Character'Val (16#00A74F#), when 16#01E901# => Wide_Wide_Character'Val (16#01E923#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_EA (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004EE# => Wide_Wide_Character'Val (16#0004EF#), when 16#0013F9# => Wide_Wide_Character'Val (16#0013F1#), when 16#001EF4# => Wide_Wide_Character'Val (16#001EF5#), when 16#0024CE# => Wide_Wide_Character'Val (16#0024E8#), when 16#002CC6# => Wide_Wide_Character'Val (16#002CC7#), when 16#00A64C# => Wide_Wide_Character'Val (16#00A64D#), when 16#01E902# => Wide_Wide_Character'Val (16#01E924#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_EB (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001EA# => Wide_Wide_Character'Val (16#0001EB#), when 16#0003E8# => Wide_Wide_Character'Val (16#0003E9#), when 16#0013F8# => Wide_Wide_Character'Val (16#0013F0#), when 16#0024CF# => Wide_Wide_Character'Val (16#0024E9#), when 16#00A74C# => Wide_Wide_Character'Val (16#00A74D#), when 16#01E903# => Wide_Wide_Character'Val (16#01E925#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_EC (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004E8# => Wide_Wide_Character'Val (16#0004E9#), when 16#001EF2# => Wide_Wide_Character'Val (16#001EF3#), when 16#0024C8# => Wide_Wide_Character'Val (16#0024E2#), when 16#002CC0# => Wide_Wide_Character'Val (16#002CC1#), when 16#00A64A# => Wide_Wide_Character'Val (16#00A64B#), when 16#01E904# => Wide_Wide_Character'Val (16#01E926#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_ED (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001EC# => Wide_Wide_Character'Val (16#0001ED#), when 16#0003EE# => Wide_Wide_Character'Val (16#0003EF#), when 16#0024C9# => Wide_Wide_Character'Val (16#0024E3#), when 16#00A74A# => Wide_Wide_Character'Val (16#00A74B#), when 16#01E905# => Wide_Wide_Character'Val (16#01E927#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_EE (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004EA# => Wide_Wide_Character'Val (16#0004EB#), when 16#0013FD# => Wide_Wide_Character'Val (16#0013F5#), when 16#001EF0# => Wide_Wide_Character'Val (16#001EF1#), when 16#0024CA# => Wide_Wide_Character'Val (16#0024E4#), when 16#002CC2# => Wide_Wide_Character'Val (16#002CC3#), when 16#00A648# => Wide_Wide_Character'Val (16#00A649#), when 16#01E906# => Wide_Wide_Character'Val (16#01E928#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_EF (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001EE# => Wide_Wide_Character'Val (16#0001EF#), when 16#0003EC# => Wide_Wide_Character'Val (16#0003ED#), when 16#0013FC# => Wide_Wide_Character'Val (16#0013F4#), when 16#0024CB# => Wide_Wide_Character'Val (16#0024E5#), when 16#00A748# => Wide_Wide_Character'Val (16#00A749#), when 16#01E907# => Wide_Wide_Character'Val (16#01E929#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F0 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001F1# => Wide_Wide_Character'Val (16#0001F3#), when 16#0004F4# => Wide_Wide_Character'Val (16#0004F5#), when 16#001EEE# => Wide_Wide_Character'Val (16#001EEF#), when 16#002CDC# => Wide_Wide_Character'Val (16#002CDD#), when 16#00A656# => Wide_Wide_Character'Val (16#00A657#), when 16#01E918# => Wide_Wide_Character'Val (16#01E93A#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F1 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#00A756# => Wide_Wide_Character'Val (16#00A757#), when 16#01E919# => Wide_Wide_Character'Val (16#01E93B#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F2 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003F1# => Wide_Wide_Character'Val (16#0003C1#), when 16#0004F6# => Wide_Wide_Character'Val (16#0004F7#), when 16#001EEC# => Wide_Wide_Character'Val (16#001EED#), when 16#002CDE# => Wide_Wide_Character'Val (16#002CDF#), when 16#00A654# => Wide_Wide_Character'Val (16#00A655#), when 16#01E91A# => Wide_Wide_Character'Val (16#01E93C#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F3 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001F2# => Wide_Wide_Character'Val (16#0001F3#), when 16#0003F0# => Wide_Wide_Character'Val (16#0003BA#), when 16#001FEC# => Wide_Wide_Character'Val (16#001FE5#), when 16#00A754# => Wide_Wide_Character'Val (16#00A755#), when 16#01E91B# => Wide_Wide_Character'Val (16#01E93D#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F4 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003F7# => Wide_Wide_Character'Val (16#0003F8#), when 16#0004F0# => Wide_Wide_Character'Val (16#0004F1#), when 16#001EEA# => Wide_Wide_Character'Val (16#001EEB#), when 16#001FEB# => Wide_Wide_Character'Val (16#001F7B#), when 16#002CD8# => Wide_Wide_Character'Val (16#002CD9#), when 16#00A652# => Wide_Wide_Character'Val (16#00A653#), when 16#01E91C# => Wide_Wide_Character'Val (16#01E93E#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F5 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001F4# => Wide_Wide_Character'Val (16#0001F5#), when 16#001FEA# => Wide_Wide_Character'Val (16#001F7A#), when 16#00A752# => Wide_Wide_Character'Val (16#00A753#), when 16#01E91D# => Wide_Wide_Character'Val (16#01E93F#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F6 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001F7# => Wide_Wide_Character'Val (16#0001BF#), when 16#0003F5# => Wide_Wide_Character'Val (16#0003B5#), when 16#0004F2# => Wide_Wide_Character'Val (16#0004F3#), when 16#001EE8# => Wide_Wide_Character'Val (16#001EE9#), when 16#001FE9# => Wide_Wide_Character'Val (16#001FE1#), when 16#002CDA# => Wide_Wide_Character'Val (16#002CDB#), when 16#00A650# => Wide_Wide_Character'Val (16#00A651#), when 16#01E91E# => Wide_Wide_Character'Val (16#01E940#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F7 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001F6# => Wide_Wide_Character'Val (16#000195#), when 16#0003F4# => Wide_Wide_Character'Val (16#0003B8#), when 16#001FE8# => Wide_Wide_Character'Val (16#001FE0#), when 16#00A750# => Wide_Wide_Character'Val (16#00A751#), when 16#01E91F# => Wide_Wide_Character'Val (16#01E941#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F8 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0004FC# => Wide_Wide_Character'Val (16#0004FD#), when 16#001EE6# => Wide_Wide_Character'Val (16#001EE7#), when 16#002CD4# => Wide_Wide_Character'Val (16#002CD5#), when 16#00A65E# => Wide_Wide_Character'Val (16#00A65F#), when 16#01E910# => Wide_Wide_Character'Val (16#01E932#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_F9 (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001F8# => Wide_Wide_Character'Val (16#0001F9#), when 16#0003FA# => Wide_Wide_Character'Val (16#0003FB#), when 16#00A75E# => Wide_Wide_Character'Val (16#00A75F#), when 16#01E911# => Wide_Wide_Character'Val (16#01E933#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_FA (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003F9# => Wide_Wide_Character'Val (16#0003F2#), when 16#0004FE# => Wide_Wide_Character'Val (16#0004FF#), when 16#001EE4# => Wide_Wide_Character'Val (16#001EE5#), when 16#002CD6# => Wide_Wide_Character'Val (16#002CD7#), when 16#00A65C# => Wide_Wide_Character'Val (16#00A65D#), when 16#01E912# => Wide_Wide_Character'Val (16#01E934#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_FB (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001FA# => Wide_Wide_Character'Val (16#0001FB#), when 16#00A75C# => Wide_Wide_Character'Val (16#00A75D#), when 16#01E913# => Wide_Wide_Character'Val (16#01E935#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_FC (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003FF# => Wide_Wide_Character'Val (16#00037D#), when 16#0004F8# => Wide_Wide_Character'Val (16#0004F9#), when 16#001EE2# => Wide_Wide_Character'Val (16#001EE3#), when 16#002CD0# => Wide_Wide_Character'Val (16#002CD1#), when 16#00A65A# => Wide_Wide_Character'Val (16#00A65B#), when 16#01E914# => Wide_Wide_Character'Val (16#01E936#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_FD (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001FC# => Wide_Wide_Character'Val (16#0001FD#), when 16#0003FE# => Wide_Wide_Character'Val (16#00037C#), when 16#00A75A# => Wide_Wide_Character'Val (16#00A75B#), when 16#01E915# => Wide_Wide_Character'Val (16#01E937#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_FE (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0003FD# => Wide_Wide_Character'Val (16#00037B#), when 16#0004FA# => Wide_Wide_Character'Val (16#0004FB#), when 16#001EE0# => Wide_Wide_Character'Val (16#001EE1#), when 16#002CD2# => Wide_Wide_Character'Val (16#002CD3#), when 16#00A658# => Wide_Wide_Character'Val (16#00A659#), when 16#01E916# => Wide_Wide_Character'Val (16#01E938#), when others => Wide_Wide_Character'Val (C)) with Inline; function Bucket_FF (C: Codepoint) return Wide_Wide_Character is (case C is when 16#0001FE# => Wide_Wide_Character'Val (16#0001FF#), when 16#00A758# => Wide_Wide_Character'Val (16#00A759#), when 16#01E917# => Wide_Wide_Character'Val (16#01E939#), when others => Wide_Wide_Character'Val (C)) with Inline; begin -- This shouldn't happen.. if Wide_Wide_Character'Pos(C) > 16#10FFFF# then return C; end if; declare CP: constant Codepoint := Codepoint (Wide_Wide_Character'Pos (C)); K: constant Key_Hash := Hash (CP); begin case K is when 16#00# => return Bucket_00 (CP); when 16#01# => return Bucket_01 (CP); when 16#02# => return Bucket_02 (CP); when 16#03# => return Bucket_03 (CP); when 16#04# => return Bucket_04 (CP); when 16#05# => return Bucket_05 (CP); when 16#06# => return Bucket_06 (CP); when 16#07# => return Bucket_07 (CP); when 16#08# => return Bucket_08 (CP); when 16#09# => return Bucket_09 (CP); when 16#0A# => return Bucket_0A (CP); when 16#0B# => return Bucket_0B (CP); when 16#0C# => return Bucket_0C (CP); when 16#0D# => return Bucket_0D (CP); when 16#0E# => return Bucket_0E (CP); when 16#0F# => return Bucket_0F (CP); when 16#10# => return Bucket_10 (CP); when 16#11# => return Bucket_11 (CP); when 16#12# => return Bucket_12 (CP); when 16#13# => return Bucket_13 (CP); when 16#14# => return Bucket_14 (CP); when 16#15# => return Bucket_15 (CP); when 16#16# => return Bucket_16 (CP); when 16#17# => return Bucket_17 (CP); when 16#18# => return Bucket_18 (CP); when 16#19# => return Bucket_19 (CP); when 16#1A# => return Bucket_1A (CP); when 16#1B# => return Bucket_1B (CP); when 16#1C# => return Bucket_1C (CP); when 16#1D# => return Bucket_1D (CP); when 16#1E# => return Bucket_1E (CP); when 16#1F# => return Bucket_1F (CP); when 16#20# => return Bucket_20 (CP); when 16#21# => return Bucket_21 (CP); when 16#22# => return Bucket_22 (CP); when 16#23# => return Bucket_23 (CP); when 16#24# => return Bucket_24 (CP); when 16#25# => return Bucket_25 (CP); when 16#26# => return Bucket_26 (CP); when 16#27# => return Bucket_27 (CP); when 16#28# => return Bucket_28 (CP); when 16#29# => return Bucket_29 (CP); when 16#2A# => return Bucket_2A (CP); when 16#2B# => return Bucket_2B (CP); when 16#2C# => return Bucket_2C (CP); when 16#2D# => return Bucket_2D (CP); when 16#2E# => return Bucket_2E (CP); when 16#2F# => return Bucket_2F (CP); when 16#30# => return Bucket_30 (CP); when 16#31# => return Bucket_31 (CP); when 16#32# => return Bucket_32 (CP); when 16#33# => return Bucket_33 (CP); when 16#34# => return Bucket_34 (CP); when 16#35# => return Bucket_35 (CP); when 16#36# => return Bucket_36 (CP); when 16#37# => return Bucket_37 (CP); when 16#38# => return Bucket_38 (CP); when 16#39# => return Bucket_39 (CP); when 16#3A# => return Bucket_3A (CP); when 16#3B# => return Bucket_3B (CP); when 16#3C# => return Bucket_3C (CP); when 16#3D# => return Bucket_3D (CP); when 16#3E# => return Bucket_3E (CP); when 16#3F# => return Bucket_3F (CP); when 16#40# => return Bucket_40 (CP); when 16#41# => return Bucket_41 (CP); when 16#42# => return Bucket_42 (CP); when 16#43# => return Bucket_43 (CP); when 16#44# => return Bucket_44 (CP); when 16#45# => return Bucket_45 (CP); when 16#46# => return Bucket_46 (CP); when 16#47# => return Bucket_47 (CP); when 16#48# => return Bucket_48 (CP); when 16#49# => return Bucket_49 (CP); when 16#4A# => return Bucket_4A (CP); when 16#4B# => return Bucket_4B (CP); when 16#4C# => return Bucket_4C (CP); when 16#4D# => return Bucket_4D (CP); when 16#4E# => return Bucket_4E (CP); when 16#4F# => return Bucket_4F (CP); when 16#50# => return Bucket_50 (CP); when 16#51# => return Bucket_51 (CP); when 16#52# => return Bucket_52 (CP); when 16#53# => return Bucket_53 (CP); when 16#54# => return Bucket_54 (CP); when 16#55# => return Bucket_55 (CP); when 16#56# => return Bucket_56 (CP); when 16#57# => return Bucket_57 (CP); when 16#58# => return Bucket_58 (CP); when 16#59# => return Bucket_59 (CP); when 16#5A# => return Bucket_5A (CP); when 16#5B# => return Bucket_5B (CP); when 16#5C# => return Bucket_5C (CP); when 16#5D# => return Bucket_5D (CP); when 16#5E# => return Bucket_5E (CP); when 16#5F# => return Bucket_5F (CP); when 16#60# => return Bucket_60 (CP); when 16#61# => return Bucket_61 (CP); when 16#62# => return Bucket_62 (CP); when 16#63# => return Bucket_63 (CP); when 16#64# => return Bucket_64 (CP); when 16#65# => return Bucket_65 (CP); when 16#66# => return Bucket_66 (CP); when 16#67# => return Bucket_67 (CP); when 16#68# => return Bucket_68 (CP); when 16#69# => return Bucket_69 (CP); when 16#6A# => return Bucket_6A (CP); when 16#6B# => return Bucket_6B (CP); when 16#6C# => return Bucket_6C (CP); when 16#6D# => return Bucket_6D (CP); when 16#6E# => return Bucket_6E (CP); when 16#6F# => return Bucket_6F (CP); when 16#70# => return Bucket_70 (CP); when 16#71# => return Bucket_71 (CP); when 16#72# => return Bucket_72 (CP); when 16#73# => return Bucket_73 (CP); when 16#74# => return Bucket_74 (CP); when 16#75# => return Bucket_75 (CP); when 16#76# => return Bucket_76 (CP); when 16#77# => return Bucket_77 (CP); when 16#78# => return Bucket_78 (CP); when 16#79# => return Bucket_79 (CP); when 16#7A# => return Bucket_7A (CP); when 16#7B# => return Bucket_7B (CP); when 16#7C# => return Bucket_7C (CP); when 16#7D# => return Bucket_7D (CP); when 16#7E# => return Bucket_7E (CP); when 16#7F# => return Bucket_7F (CP); when 16#80# => return Bucket_80 (CP); when 16#81# => return Bucket_81 (CP); when 16#82# => return Bucket_82 (CP); when 16#83# => return Bucket_83 (CP); when 16#84# => return Bucket_84 (CP); when 16#85# => return Bucket_85 (CP); when 16#86# => return Bucket_86 (CP); when 16#87# => return Bucket_87 (CP); when 16#88# => return Bucket_88 (CP); when 16#89# => return Bucket_89 (CP); when 16#8A# => return Bucket_8A (CP); when 16#8B# => return Bucket_8B (CP); when 16#8C# => return Bucket_8C (CP); when 16#8D# => return Bucket_8D (CP); when 16#8E# => return Bucket_8E (CP); when 16#8F# => return Bucket_8F (CP); when 16#90# => return Bucket_90 (CP); when 16#91# => return Bucket_91 (CP); when 16#92# => return Bucket_92 (CP); when 16#93# => return Bucket_93 (CP); when 16#94# => return Bucket_94 (CP); when 16#95# => return Bucket_95 (CP); when 16#96# => return Bucket_96 (CP); when 16#97# => return Bucket_97 (CP); when 16#98# => return Bucket_98 (CP); when 16#99# => return Bucket_99 (CP); when 16#9A# => return Bucket_9A (CP); when 16#9B# => return Bucket_9B (CP); when 16#9C# => return Bucket_9C (CP); when 16#9D# => return Bucket_9D (CP); when 16#9E# => return Bucket_9E (CP); when 16#9F# => return Bucket_9F (CP); when 16#A0# => return Bucket_A0 (CP); when 16#A1# => return Bucket_A1 (CP); when 16#A2# => return Bucket_A2 (CP); when 16#A3# => return Bucket_A3 (CP); when 16#A4# => return Bucket_A4 (CP); when 16#A5# => return Bucket_A5 (CP); when 16#A6# => return Bucket_A6 (CP); when 16#A7# => return Bucket_A7 (CP); when 16#A8# => return Bucket_A8 (CP); when 16#A9# => return Bucket_A9 (CP); when 16#AA# => return Bucket_AA (CP); when 16#AB# => return Bucket_AB (CP); when 16#AC# => return Bucket_AC (CP); when 16#AD# => return Bucket_AD (CP); when 16#AE# => return Bucket_AE (CP); when 16#AF# => return Bucket_AF (CP); when 16#B0# => return Bucket_B0 (CP); when 16#B1# => return Bucket_B1 (CP); when 16#B2# => return Bucket_B2 (CP); when 16#B3# => return Bucket_B3 (CP); when 16#B4# => return Bucket_B4 (CP); when 16#B5# => return Bucket_B5 (CP); when 16#B6# => return Bucket_B6 (CP); when 16#B7# => return Bucket_B7 (CP); when 16#B8# => return Bucket_B8 (CP); when 16#B9# => return Bucket_B9 (CP); when 16#BA# => return Bucket_BA (CP); when 16#BB# => return Bucket_BB (CP); when 16#BC# => return Bucket_BC (CP); when 16#BD# => return Bucket_BD (CP); when 16#BE# => return Bucket_BE (CP); when 16#BF# => return Bucket_BF (CP); when 16#C0# => return Bucket_C0 (CP); when 16#C1# => return Bucket_C1 (CP); when 16#C2# => return Bucket_C2 (CP); when 16#C3# => return Bucket_C3 (CP); when 16#C4# => return Bucket_C4 (CP); when 16#C5# => return Bucket_C5 (CP); when 16#C6# => return Bucket_C6 (CP); when 16#C7# => return Bucket_C7 (CP); when 16#C8# => return Bucket_C8 (CP); when 16#C9# => return Bucket_C9 (CP); when 16#CA# => return Bucket_CA (CP); when 16#CB# => return Bucket_CB (CP); when 16#CC# => return Bucket_CC (CP); when 16#CD# => return Bucket_CD (CP); when 16#CE# => return Bucket_CE (CP); when 16#CF# => return Bucket_CF (CP); when 16#D0# => return Bucket_D0 (CP); when 16#D1# => return Bucket_D1 (CP); when 16#D2# => return Bucket_D2 (CP); when 16#D3# => return Bucket_D3 (CP); when 16#D4# => return Bucket_D4 (CP); when 16#D5# => return Bucket_D5 (CP); when 16#D6# => return Bucket_D6 (CP); when 16#D7# => return Bucket_D7 (CP); when 16#D8# => return Bucket_D8 (CP); when 16#D9# => return Bucket_D9 (CP); when 16#DA# => return Bucket_DA (CP); when 16#DB# => return Bucket_DB (CP); when 16#DC# => return Bucket_DC (CP); when 16#DD# => return Bucket_DD (CP); when 16#DE# => return Bucket_DE (CP); when 16#DF# => return Bucket_DF (CP); when 16#E0# => return Bucket_E0 (CP); when 16#E1# => return Bucket_E1 (CP); when 16#E2# => return Bucket_E2 (CP); when 16#E3# => return Bucket_E3 (CP); when 16#E4# => return Bucket_E4 (CP); when 16#E5# => return Bucket_E5 (CP); when 16#E6# => return Bucket_E6 (CP); when 16#E7# => return Bucket_E7 (CP); when 16#E8# => return Bucket_E8 (CP); when 16#E9# => return Bucket_E9 (CP); when 16#EA# => return Bucket_EA (CP); when 16#EB# => return Bucket_EB (CP); when 16#EC# => return Bucket_EC (CP); when 16#ED# => return Bucket_ED (CP); when 16#EE# => return Bucket_EE (CP); when 16#EF# => return Bucket_EF (CP); when 16#F0# => return Bucket_F0 (CP); when 16#F1# => return Bucket_F1 (CP); when 16#F2# => return Bucket_F2 (CP); when 16#F3# => return Bucket_F3 (CP); when 16#F4# => return Bucket_F4 (CP); when 16#F5# => return Bucket_F5 (CP); when 16#F6# => return Bucket_F6 (CP); when 16#F7# => return Bucket_F7 (CP); when 16#F8# => return Bucket_F8 (CP); when 16#F9# => return Bucket_F9 (CP); when 16#FA# => return Bucket_FA (CP); when 16#FB# => return Bucket_FB (CP); when 16#FC# => return Bucket_FC (CP); when 16#FD# => return Bucket_FD (CP); when 16#FE# => return Bucket_FE (CP); when 16#FF# => return Bucket_FF (CP); end case; end; end Unicode.Case_Folding.Simple;
with Ada.Unchecked_Conversion; with System.Address_To_Constant_Access_Conversions; with System.Address_To_Named_Access_Conversions; with System.Stack; with System.Unwind.Raising; with System.Unwind.Standard; with C.string; with C.sys.ucontext; package body System.Unwind.Mapping is pragma Suppress (All_Checks); use type C.signed_int; use type C.signed_long; use type C.unsigned_int; use type C.unsigned_long; function strlen (s : not null access constant C.char) return C.size_t with Import, Convention => Intrinsic, External_Name => "__builtin_strlen"; package char_ptr_Conv is new Address_To_Named_Access_Conversions (C.char, C.char_ptr); procedure sigaction_Handler ( Signal_Number : C.signed_int; Info : access C.signal.siginfo_t; Context : C.void_ptr) with Convention => C; pragma No_Return (sigaction_Handler); procedure sigaction_Handler ( Signal_Number : C.signed_int; Info : access C.signal.siginfo_t; Context : C.void_ptr) is -- allow to inspect the parameters with debugger. type ucontext_t_ptr is access constant C.sys.ucontext.ucontext_t with Convention => C; for ucontext_t_ptr'Storage_Size use 0; package ucontext_t_ptr_Conv is new Address_To_Constant_Access_Conversions ( C.sys.ucontext.ucontext_t, ucontext_t_ptr); uap : constant ucontext_t_ptr := ucontext_t_ptr_Conv.To_Pointer (Address (Context)); pragma Inspection_Point (Signal_Number); pragma Inspection_Point (Info); pragma Inspection_Point (uap); -- space for overflow detection, decided for CB1010C Stack_Overflow_Space : constant := (Standard'Address_Size / Standard'Storage_Unit) * 8 * 1024 * 1024; -- the components of the exception. Message : constant C.char_ptr := C.string.strsignal (Signal_Number); Message_Length : constant C.size_t := strlen (Message); Eexception_Id : Exception_Data_Access; Stack_Guard : Address := Null_Address; begin case Signal_Number is when C.signal.SIGFPE => Eexception_Id := Standard.Constraint_Error'Access; when C.signal.SIGBUS | C.signal.SIGSEGV => declare Top, Bottom : Address; Fault : Address; begin Stack.Get (Top => Top, Bottom => Bottom); Stack.Fake_Return_From_Signal_Handler; if Info /= null then Fault := Stack.Fault_Address (Info.all); else Fault := Null_Address; end if; if Fault /= Null_Address and then Fault >= Top - Stack_Overflow_Space and then Fault < Bottom then -- stack overflow Stack_Guard := Top + C.signal.MINSIGSTKSZ; Eexception_Id := Standard.Storage_Error'Access; else Eexception_Id := Standard.Program_Error'Access; end if; end; when others => Eexception_Id := Standard.Program_Error'Access; end case; declare Message_All : String (1 .. Integer (Message_Length)); for Message_All'Address use char_ptr_Conv.To_Address (Message); begin Raising.Raise_From_Signal_Handler ( Eexception_Id, Message => Message_All, Stack_Guard => Stack_Guard); end; end sigaction_Handler; procedure Set_Signal_Stack (S : access Signal_Stack_Type); procedure Set_Signal_Stack (S : access Signal_Stack_Type) is function Cast is new Ada.Unchecked_Conversion (C.char_ptr, C.void_ptr); -- OSX function Cast is new Ada.Unchecked_Conversion (C.char_ptr, C.char_ptr); -- FreeBSD pragma Warnings (Off, Cast); stack : aliased C.signal.stack_t := ( ss_sp => Cast (S (S'First)'Access), ss_size => Signal_Stack_Type'Size / Standard'Storage_Unit, ss_flags => 0); Dummy : C.signed_int; begin Dummy := C.signal.sigaltstack (stack'Access, null); end Set_Signal_Stack; Signal_Stack : aliased Signal_Stack_Type; -- implementation procedure Install_Exception_Handler (SEH : Address) is pragma Unreferenced (SEH); act : aliased C.signal.struct_sigaction := ( (Unchecked_Tag => 1, sa_sigaction => sigaction_Handler'Access), others => <>); Dummy : C.signed_int; begin act.sa_flags := C.signed_int ( C.unsigned_int'(C.signal.SA_NODEFER or C.signal.SA_SIGINFO)); Dummy := C.signal.sigemptyset (act.sa_mask'Access); -- illegal instruction Dummy := C.signal.sigaction (C.signal.SIGILL, act'Access, null); -- floating-point exception Dummy := C.signal.sigaction (C.signal.SIGFPE, act'Access, null); -- bus error Set_Signal_Stack (Signal_Stack'Access); act.sa_flags := C.signed_int (C.unsigned_int (act.sa_flags) or C.signal.SA_ONSTACK); Dummy := C.signal.sigaction (C.signal.SIGBUS, act'Access, null); -- segmentation violation Dummy := C.signal.sigaction (C.signal.SIGSEGV, act'Access, null); end Install_Exception_Handler; procedure Install_Task_Exception_Handler ( SEH : Address; Signal_Stack : not null access Signal_Stack_Type) is pragma Unreferenced (SEH); begin -- sigaction setting would be inherited from environment task. Set_Signal_Stack (Signal_Stack); end Install_Task_Exception_Handler; end System.Unwind.Mapping;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ T Y P E -- -- -- -- 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 Atree; use Atree; with Debug; use Debug; with Einfo; use Einfo; with Errout; use Errout; with Lib; use Lib; with Opt; use Opt; with Output; use Output; with Sem; use Sem; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; with Sem_Util; use Sem_Util; with Stand; use Stand; with Sinfo; use Sinfo; with Snames; use Snames; with Uintp; use Uintp; package body Sem_Type is ------------------------------------- -- Handling of Overload Resolution -- ------------------------------------- -- Overload resolution uses two passes over the syntax tree of a complete -- context. In the first, bottom-up pass, the types of actuals in calls -- are used to resolve possibly overloaded subprogram and operator names. -- In the second top-down pass, the type of the context (for example the -- condition in a while statement) is used to resolve a possibly ambiguous -- call, and the unique subprogram name in turn imposes a specific context -- on each of its actuals. -- Most expressions are in fact unambiguous, and the bottom-up pass is -- sufficient to resolve most everything. To simplify the common case, -- names and expressions carry a flag Is_Overloaded to indicate whether -- they have more than one interpretation. If the flag is off, then each -- name has already a unique meaning and type, and the bottom-up pass is -- sufficient (and much simpler). -------------------------- -- Operator Overloading -- -------------------------- -- The visibility of operators is handled differently from that of -- other entities. We do not introduce explicit versions of primitive -- operators for each type definition. As a result, there is only one -- entity corresponding to predefined addition on all numeric types, etc. -- The back-end resolves predefined operators according to their type. -- The visibility of primitive operations then reduces to the visibility -- of the resulting type: (a + b) is a legal interpretation of some -- primitive operator + if the type of the result (which must also be -- the type of a and b) is directly visible (i.e. either immediately -- visible or use-visible.) -- User-defined operators are treated like other functions, but the -- visibility of these user-defined operations must be special-cased -- to determine whether they hide or are hidden by predefined operators. -- The form P."+" (x, y) requires additional handling. -- -- Concatenation is treated more conventionally: for every one-dimensional -- array type we introduce a explicit concatenation operator. This is -- necessary to handle the case of (element & element => array) which -- cannot be handled conveniently if there is no explicit instance of -- resulting type of the operation. ----------------------- -- Local Subprograms -- ----------------------- procedure All_Overloads; pragma Warnings (Off, All_Overloads); -- Debugging procedure: list full contents of Overloads table. function Universal_Interpretation (Opnd : Node_Id) return Entity_Id; -- Yields universal_Integer or Universal_Real if this is a candidate. function Specific_Type (T1, T2 : Entity_Id) return Entity_Id; -- If T1 and T2 are compatible, return the one that is not -- universal or is not a "class" type (any_character, etc). -------------------- -- Add_One_Interp -- -------------------- procedure Add_One_Interp (N : Node_Id; E : Entity_Id; T : Entity_Id; Opnd_Type : Entity_Id := Empty) is Vis_Type : Entity_Id; procedure Add_Entry (Name : Entity_Id; Typ : Entity_Id); -- Add one interpretation to node. Node is already known to be -- overloaded. Add new interpretation if not hidden by previous -- one, and remove previous one if hidden by new one. function Is_Universal_Operation (Op : Entity_Id) return Boolean; -- True if the entity is a predefined operator and the operands have -- a universal Interpretation. --------------- -- Add_Entry -- --------------- procedure Add_Entry (Name : Entity_Id; Typ : Entity_Id) is Index : Interp_Index; It : Interp; begin Get_First_Interp (N, Index, It); while Present (It.Nam) loop -- A user-defined subprogram hides another declared at an outer -- level, or one that is use-visible. So return if previous -- definition hides new one (which is either in an outer -- scope, or use-visible). Note that for functions use-visible -- is the same as potentially use-visible. If new one hides -- previous one, replace entry in table of interpretations. -- If this is a universal operation, retain the operator in case -- preference rule applies. if (((Ekind (Name) = E_Function or else Ekind (Name) = E_Procedure) and then Ekind (Name) = Ekind (It.Nam)) or else (Ekind (Name) = E_Operator and then Ekind (It.Nam) = E_Function)) and then Is_Immediately_Visible (It.Nam) and then Type_Conformant (Name, It.Nam) and then Base_Type (It.Typ) = Base_Type (T) then if Is_Universal_Operation (Name) then exit; -- If node is an operator symbol, we have no actuals with -- which to check hiding, and this is done in full in the -- caller (Analyze_Subprogram_Renaming) so we include the -- predefined operator in any case. elsif Nkind (N) = N_Operator_Symbol or else (Nkind (N) = N_Expanded_Name and then Nkind (Selector_Name (N)) = N_Operator_Symbol) then exit; elsif not In_Open_Scopes (Scope (Name)) or else Scope_Depth (Scope (Name)) <= Scope_Depth (Scope (It.Nam)) then -- If ambiguity within instance, and entity is not an -- implicit operation, save for later disambiguation. if Scope (Name) = Scope (It.Nam) and then not Is_Inherited_Operation (Name) and then In_Instance then exit; else return; end if; else All_Interp.Table (Index).Nam := Name; return; end if; -- Avoid making duplicate entries in overloads elsif Name = It.Nam and then Base_Type (It.Typ) = Base_Type (T) then return; -- Otherwise keep going else Get_Next_Interp (Index, It); end if; end loop; -- On exit, enter new interpretation. The context, or a preference -- rule, will resolve the ambiguity on the second pass. All_Interp.Table (All_Interp.Last) := (Name, Typ); All_Interp.Increment_Last; All_Interp.Table (All_Interp.Last) := No_Interp; end Add_Entry; ---------------------------- -- Is_Universal_Operation -- ---------------------------- function Is_Universal_Operation (Op : Entity_Id) return Boolean is Arg : Node_Id; begin if Ekind (Op) /= E_Operator then return False; elsif Nkind (N) in N_Binary_Op then return Present (Universal_Interpretation (Left_Opnd (N))) and then Present (Universal_Interpretation (Right_Opnd (N))); elsif Nkind (N) in N_Unary_Op then return Present (Universal_Interpretation (Right_Opnd (N))); elsif Nkind (N) = N_Function_Call then Arg := First_Actual (N); while Present (Arg) loop if No (Universal_Interpretation (Arg)) then return False; end if; Next_Actual (Arg); end loop; return True; else return False; end if; end Is_Universal_Operation; -- Start of processing for Add_One_Interp begin -- If the interpretation is a predefined operator, verify that the -- result type is visible, or that the entity has already been -- resolved (case of an instantiation node that refers to a predefined -- operation, or an internally generated operator node, or an operator -- given as an expanded name). If the operator is a comparison or -- equality, it is the type of the operand that matters to determine -- whether the operator is visible. In an instance, the check is not -- performed, given that the operator was visible in the generic. if Ekind (E) = E_Operator then if Present (Opnd_Type) then Vis_Type := Opnd_Type; else Vis_Type := Base_Type (T); end if; if In_Open_Scopes (Scope (Vis_Type)) or else Is_Potentially_Use_Visible (Vis_Type) or else In_Use (Vis_Type) or else (In_Use (Scope (Vis_Type)) and then not Is_Hidden (Vis_Type)) or else Nkind (N) = N_Expanded_Name or else (Nkind (N) in N_Op and then E = Entity (N)) or else In_Instance then null; -- If the node is given in functional notation and the prefix -- is an expanded name, then the operator is visible if the -- prefix is the scope of the result type as well. If the -- operator is (implicitly) defined in an extension of system, -- it is know to be valid (see Defined_In_Scope, sem_ch4.adb). elsif Nkind (N) = N_Function_Call and then Nkind (Name (N)) = N_Expanded_Name and then (Entity (Prefix (Name (N))) = Scope (Base_Type (T)) or else Entity (Prefix (Name (N))) = Scope (Vis_Type) or else Scope (Vis_Type) = System_Aux_Id) then null; -- Save type for subsequent error message, in case no other -- interpretation is found. else Candidate_Type := Vis_Type; return; end if; -- In an instance, an abstract non-dispatching operation cannot -- be a candidate interpretation, because it could not have been -- one in the generic (it may be a spurious overloading in the -- instance). elsif In_Instance and then Is_Abstract (E) and then not Is_Dispatching_Operation (E) then return; end if; -- If this is the first interpretation of N, N has type Any_Type. -- In that case place the new type on the node. If one interpretation -- already exists, indicate that the node is overloaded, and store -- both the previous and the new interpretation in All_Interp. If -- this is a later interpretation, just add it to the set. if Etype (N) = Any_Type then if Is_Type (E) then Set_Etype (N, T); else -- Record both the operator or subprogram name, and its type. if Nkind (N) in N_Op or else Is_Entity_Name (N) then Set_Entity (N, E); end if; Set_Etype (N, T); end if; -- Either there is no current interpretation in the table for any -- node or the interpretation that is present is for a different -- node. In both cases add a new interpretation to the table. elsif Interp_Map.Last < 0 or else Interp_Map.Table (Interp_Map.Last).Node /= N then New_Interps (N); if (Nkind (N) in N_Op or else Is_Entity_Name (N)) and then Present (Entity (N)) then Add_Entry (Entity (N), Etype (N)); elsif (Nkind (N) = N_Function_Call or else Nkind (N) = N_Procedure_Call_Statement) and then (Nkind (Name (N)) = N_Operator_Symbol or else Is_Entity_Name (Name (N))) then Add_Entry (Entity (Name (N)), Etype (N)); else -- Overloaded prefix in indexed or selected component, -- or call whose name is an expression or another call. Add_Entry (Etype (N), Etype (N)); end if; Add_Entry (E, T); else Add_Entry (E, T); end if; end Add_One_Interp; ------------------- -- All_Overloads -- ------------------- procedure All_Overloads is begin for J in All_Interp.First .. All_Interp.Last loop if Present (All_Interp.Table (J).Nam) then Write_Entity_Info (All_Interp.Table (J). Nam, " "); else Write_Str ("No Interp"); end if; Write_Str ("================="); Write_Eol; end loop; end All_Overloads; --------------------- -- Collect_Interps -- --------------------- procedure Collect_Interps (N : Node_Id) is Ent : constant Entity_Id := Entity (N); H : Entity_Id; First_Interp : Interp_Index; begin New_Interps (N); -- Unconditionally add the entity that was initially matched First_Interp := All_Interp.Last; Add_One_Interp (N, Ent, Etype (N)); -- For expanded name, pick up all additional entities from the -- same scope, since these are obviously also visible. Note that -- these are not necessarily contiguous on the homonym chain. if Nkind (N) = N_Expanded_Name then H := Homonym (Ent); while Present (H) loop if Scope (H) = Scope (Entity (N)) then Add_One_Interp (N, H, Etype (H)); end if; H := Homonym (H); end loop; -- Case of direct name else -- First, search the homonym chain for directly visible entities H := Current_Entity (Ent); while Present (H) loop exit when (not Is_Overloadable (H)) and then Is_Immediately_Visible (H); if Is_Immediately_Visible (H) and then H /= Ent then -- Only add interpretation if not hidden by an inner -- immediately visible one. for J in First_Interp .. All_Interp.Last - 1 loop -- Current homograph is not hidden. Add to overloads. if not Is_Immediately_Visible (All_Interp.Table (J).Nam) then exit; -- Homograph is hidden, unless it is a predefined operator. elsif Type_Conformant (H, All_Interp.Table (J).Nam) then -- A homograph in the same scope can occur within an -- instantiation, the resulting ambiguity has to be -- resolved later. if Scope (H) = Scope (Ent) and then In_Instance and then not Is_Inherited_Operation (H) then All_Interp.Table (All_Interp.Last) := (H, Etype (H)); All_Interp.Increment_Last; All_Interp.Table (All_Interp.Last) := No_Interp; goto Next_Homograph; elsif Scope (H) /= Standard_Standard then goto Next_Homograph; end if; end if; end loop; -- On exit, we know that current homograph is not hidden. Add_One_Interp (N, H, Etype (H)); if Debug_Flag_E then Write_Str ("Add overloaded Interpretation "); Write_Int (Int (H)); Write_Eol; end if; end if; <<Next_Homograph>> H := Homonym (H); end loop; -- Scan list of homographs for use-visible entities only. H := Current_Entity (Ent); while Present (H) loop if Is_Potentially_Use_Visible (H) and then H /= Ent and then Is_Overloadable (H) then for J in First_Interp .. All_Interp.Last - 1 loop if not Is_Immediately_Visible (All_Interp.Table (J).Nam) then exit; elsif Type_Conformant (H, All_Interp.Table (J).Nam) then goto Next_Use_Homograph; end if; end loop; Add_One_Interp (N, H, Etype (H)); end if; <<Next_Use_Homograph>> H := Homonym (H); end loop; end if; if All_Interp.Last = First_Interp + 1 then -- The original interpretation is in fact not overloaded. Set_Is_Overloaded (N, False); end if; end Collect_Interps; ------------ -- Covers -- ------------ function Covers (T1, T2 : Entity_Id) return Boolean is begin pragma Assert (Present (T1) and Present (T2)); -- Simplest case: same types are compatible, and types that have the -- same base type and are not generic actuals are compatible. Generic -- actuals belong to their class but are not compatible with other -- types of their class, and in particular with other generic actuals. -- They are however compatible with their own subtypes, and itypes -- with the same base are compatible as well. Similary, constrained -- subtypes obtained from expressions of an unconstrained nominal type -- are compatible with the base type (may lead to spurious ambiguities -- in obscure cases ???) -- Generic actuals require special treatment to avoid spurious ambi- -- guities in an instance, when two formal types are instantiated with -- the same actual, so that different subprograms end up with the same -- signature in the instance. if T1 = T2 then return True; elsif Base_Type (T1) = Base_Type (T2) then if not Is_Generic_Actual_Type (T1) then return True; else return (not Is_Generic_Actual_Type (T2) or else Is_Itype (T1) or else Is_Itype (T2) or else Is_Constr_Subt_For_U_Nominal (T1) or else Is_Constr_Subt_For_U_Nominal (T2) or else Scope (T1) /= Scope (T2)); end if; -- Literals are compatible with types in a given "class" elsif (T2 = Universal_Integer and then Is_Integer_Type (T1)) or else (T2 = Universal_Real and then Is_Real_Type (T1)) or else (T2 = Universal_Fixed and then Is_Fixed_Point_Type (T1)) or else (T2 = Any_Fixed and then Is_Fixed_Point_Type (T1)) or else (T2 = Any_String and then Is_String_Type (T1)) or else (T2 = Any_Character and then Is_Character_Type (T1)) or else (T2 = Any_Access and then Is_Access_Type (T1)) then return True; -- The context may be class wide. elsif Is_Class_Wide_Type (T1) and then Is_Ancestor (Root_Type (T1), T2) then return True; elsif Is_Class_Wide_Type (T1) and then Is_Class_Wide_Type (T2) and then Base_Type (Etype (T1)) = Base_Type (Etype (T2)) then return True; -- In a dispatching call the actual may be class-wide elsif Is_Class_Wide_Type (T2) and then Base_Type (Root_Type (T2)) = Base_Type (T1) then return True; -- Some contexts require a class of types rather than a specific type elsif (T1 = Any_Integer and then Is_Integer_Type (T2)) or else (T1 = Any_Boolean and then Is_Boolean_Type (T2)) or else (T1 = Any_Real and then Is_Real_Type (T2)) or else (T1 = Any_Fixed and then Is_Fixed_Point_Type (T2)) or else (T1 = Any_Discrete and then Is_Discrete_Type (T2)) then return True; -- An aggregate is compatible with an array or record type elsif T2 = Any_Composite and then Ekind (T1) in E_Array_Type .. E_Record_Subtype then return True; -- If the expected type is an anonymous access, the designated -- type must cover that of the expression. elsif Ekind (T1) = E_Anonymous_Access_Type and then Is_Access_Type (T2) and then Covers (Designated_Type (T1), Designated_Type (T2)) then return True; -- An Access_To_Subprogram is compatible with itself, or with an -- anonymous type created for an attribute reference Access. elsif (Ekind (Base_Type (T1)) = E_Access_Subprogram_Type or else Ekind (Base_Type (T1)) = E_Access_Protected_Subprogram_Type) and then Is_Access_Type (T2) and then (not Comes_From_Source (T1) or else not Comes_From_Source (T2)) and then (Is_Overloadable (Designated_Type (T2)) or else Ekind (Designated_Type (T2)) = E_Subprogram_Type) and then Type_Conformant (Designated_Type (T1), Designated_Type (T2)) and then Mode_Conformant (Designated_Type (T1), Designated_Type (T2)) then return True; elsif Is_Record_Type (T1) and then (Is_Remote_Call_Interface (T1) or else Is_Remote_Types (T1)) and then Present (Corresponding_Remote_Type (T1)) then return Covers (Corresponding_Remote_Type (T1), T2); elsif Ekind (T2) = E_Access_Attribute_Type and then (Ekind (Base_Type (T1)) = E_General_Access_Type or else Ekind (Base_Type (T1)) = E_Access_Type) and then Covers (Designated_Type (T1), Designated_Type (T2)) then -- If the target type is a RACW type while the source is an access -- attribute type, we are building a RACW that may be exported. if Is_Remote_Access_To_Class_Wide_Type (Base_Type (T1)) then Set_Has_RACW (Current_Sem_Unit); end if; return True; elsif Ekind (T2) = E_Allocator_Type and then Is_Access_Type (T1) and then Covers (Designated_Type (T1), Designated_Type (T2)) then return True; -- A boolean operation on integer literals is compatible with a -- modular context. elsif T2 = Any_Modular and then Is_Modular_Integer_Type (T1) then return True; -- The actual type may be the result of a previous error elsif Base_Type (T2) = Any_Type then return True; -- A packed array type covers its corresponding non-packed type. -- This is not legitimate Ada, but allows the omission of a number -- of otherwise useless unchecked conversions, and since this can -- only arise in (known correct) expanded code, no harm is done elsif Is_Array_Type (T2) and then Is_Packed (T2) and then T1 = Packed_Array_Type (T2) then return True; -- Similarly an array type covers its corresponding packed array type elsif Is_Array_Type (T1) and then Is_Packed (T1) and then T2 = Packed_Array_Type (T1) then return True; -- In an instance the proper view may not always be correct for -- private types, but private and full view are compatible. This -- removes spurious errors from nested instantiations that involve, -- among other things, types derived from privated types. elsif In_Instance and then Is_Private_Type (T1) and then ((Present (Full_View (T1)) and then Covers (Full_View (T1), T2)) or else Base_Type (T1) = T2 or else Base_Type (T2) = T1) then return True; -- In the expansion of inlined bodies, types are compatible if they -- are structurally equivalent. elsif In_Inlined_Body and then (Underlying_Type (T1) = Underlying_Type (T2) or else (Is_Access_Type (T1) and then Is_Access_Type (T2) and then Designated_Type (T1) = Designated_Type (T2)) or else (T1 = Any_Access and then Is_Access_Type (Underlying_Type (T2)))) then return True; -- Otherwise it doesn't cover! else return False; end if; end Covers; ------------------ -- Disambiguate -- ------------------ function Disambiguate (N : Node_Id; I1, I2 : Interp_Index; Typ : Entity_Id) return Interp is I : Interp_Index; It : Interp; It1, It2 : Interp; Nam1, Nam2 : Entity_Id; Predef_Subp : Entity_Id; User_Subp : Entity_Id; function Matches (Actual, Formal : Node_Id) return Boolean; -- Look for exact type match in an instance, to remove spurious -- ambiguities when two formal types have the same actual. function Standard_Operator return Boolean; function Remove_Conversions return Interp; -- Last chance for pathological cases involving comparisons on -- literals, and user overloadings of the same operator. Such -- pathologies have been removed from the ACVC, but still appear in -- two DEC tests, with the following notable quote from Ben Brosgol: -- -- [Note: I disclaim all credit/responsibility/blame for coming up with -- this example; Robert Dewar brought it to our attention, since it -- is apparently found in the ACVC 1.5. I did not attempt to find -- the reason in the Reference Manual that makes the example legal, -- since I was too nauseated by it to want to pursue it further.] -- -- Accordingly, this is not a fully recursive solution, but it handles -- DEC tests c460vsa, c460vsb. It also handles ai00136a, which pushes -- pathology in the other direction with calls whose multiple overloaded -- actuals make them truly unresolvable. ------------- -- Matches -- ------------- function Matches (Actual, Formal : Node_Id) return Boolean is T1 : constant Entity_Id := Etype (Actual); T2 : constant Entity_Id := Etype (Formal); begin return T1 = T2 or else (Is_Numeric_Type (T2) and then (T1 = Universal_Real or else T1 = Universal_Integer)); end Matches; ------------------------ -- Remove_Conversions -- ------------------------ function Remove_Conversions return Interp is I : Interp_Index; It : Interp; It1 : Interp; F1 : Entity_Id; Act1 : Node_Id; Act2 : Node_Id; begin It1 := No_Interp; Get_First_Interp (N, I, It); while Present (It.Typ) loop if not Is_Overloadable (It.Nam) then return No_Interp; end if; F1 := First_Formal (It.Nam); if No (F1) then return It1; else if Nkind (N) = N_Function_Call or else Nkind (N) = N_Procedure_Call_Statement then Act1 := First_Actual (N); if Present (Act1) then Act2 := Next_Actual (Act1); else Act2 := Empty; end if; elsif Nkind (N) in N_Unary_Op then Act1 := Right_Opnd (N); Act2 := Empty; elsif Nkind (N) in N_Binary_Op then Act1 := Left_Opnd (N); Act2 := Right_Opnd (N); else return It1; end if; if Nkind (Act1) in N_Op and then Is_Overloaded (Act1) and then (Nkind (Right_Opnd (Act1)) = N_Integer_Literal or else Nkind (Right_Opnd (Act1)) = N_Real_Literal) and then Has_Compatible_Type (Act1, Standard_Boolean) and then Etype (F1) = Standard_Boolean then if It1 /= No_Interp then return No_Interp; elsif Present (Act2) and then Nkind (Act2) in N_Op and then Is_Overloaded (Act2) and then (Nkind (Right_Opnd (Act1)) = N_Integer_Literal or else Nkind (Right_Opnd (Act1)) = N_Real_Literal) and then Has_Compatible_Type (Act2, Standard_Boolean) then -- The preference rule on the first actual is not -- sufficient to disambiguate. goto Next_Interp; else It1 := It; end if; end if; end if; <<Next_Interp>> Get_Next_Interp (I, It); end loop; if Errors_Detected > 0 then -- After some error, a formal may have Any_Type and yield -- a spurious match. To avoid cascaded errors if possible, -- check for such a formal in either candidate. declare Formal : Entity_Id; begin Formal := First_Formal (Nam1); while Present (Formal) loop if Etype (Formal) = Any_Type then return Disambiguate.It2; end if; Next_Formal (Formal); end loop; Formal := First_Formal (Nam2); while Present (Formal) loop if Etype (Formal) = Any_Type then return Disambiguate.It1; end if; Next_Formal (Formal); end loop; end; end if; return It1; end Remove_Conversions; ----------------------- -- Standard_Operator -- ----------------------- function Standard_Operator return Boolean is Nam : Node_Id; begin if Nkind (N) in N_Op then return True; elsif Nkind (N) = N_Function_Call then Nam := Name (N); if Nkind (Nam) /= N_Expanded_Name then return True; else return Entity (Prefix (Nam)) = Standard_Standard; end if; else return False; end if; end Standard_Operator; -- Start of processing for Disambiguate begin -- Recover the two legal interpretations. Get_First_Interp (N, I, It); while I /= I1 loop Get_Next_Interp (I, It); end loop; It1 := It; Nam1 := It.Nam; while I /= I2 loop Get_Next_Interp (I, It); end loop; It2 := It; Nam2 := It.Nam; -- If the context is universal, the predefined operator is preferred. -- This includes bounds in numeric type declarations, and expressions -- in type conversions. If no interpretation yields a universal type, -- then we must check whether the user-defined entity hides the prede- -- fined one. if Chars (Nam1) in Any_Operator_Name and then Standard_Operator then if Typ = Universal_Integer or else Typ = Universal_Real or else Typ = Any_Integer or else Typ = Any_Discrete or else Typ = Any_Real or else Typ = Any_Type then -- Find an interpretation that yields the universal type, or else -- a predefined operator that yields a predefined numeric type. declare Candidate : Interp := No_Interp; begin Get_First_Interp (N, I, It); while Present (It.Typ) loop if (Covers (Typ, It.Typ) or else Typ = Any_Type) and then (It.Typ = Universal_Integer or else It.Typ = Universal_Real) then return It; elsif Covers (Typ, It.Typ) and then Scope (It.Typ) = Standard_Standard and then Scope (It.Nam) = Standard_Standard and then Is_Numeric_Type (It.Typ) then Candidate := It; end if; Get_Next_Interp (I, It); end loop; if Candidate /= No_Interp then return Candidate; end if; end; elsif Chars (Nam1) /= Name_Op_Not and then (Typ = Standard_Boolean or else Typ = Any_Boolean) then -- Equality or comparison operation. Choose predefined operator -- if arguments are universal. The node may be an operator, a -- name, or a function call, so unpack arguments accordingly. declare Arg1, Arg2 : Node_Id; begin if Nkind (N) in N_Op then Arg1 := Left_Opnd (N); Arg2 := Right_Opnd (N); elsif Is_Entity_Name (N) or else Nkind (N) = N_Operator_Symbol then Arg1 := First_Entity (Entity (N)); Arg2 := Next_Entity (Arg1); else Arg1 := First_Actual (N); Arg2 := Next_Actual (Arg1); end if; if Present (Arg2) and then Present (Universal_Interpretation (Arg1)) and then Universal_Interpretation (Arg2) = Universal_Interpretation (Arg1) then Get_First_Interp (N, I, It); while Scope (It.Nam) /= Standard_Standard loop Get_Next_Interp (I, It); end loop; return It; end if; end; end if; end if; -- If no universal interpretation, check whether user-defined operator -- hides predefined one, as well as other special cases. If the node -- is a range, then one or both bounds are ambiguous. Each will have -- to be disambiguated w.r.t. the context type. The type of the range -- itself is imposed by the context, so we can return either legal -- interpretation. if Ekind (Nam1) = E_Operator then Predef_Subp := Nam1; User_Subp := Nam2; elsif Ekind (Nam2) = E_Operator then Predef_Subp := Nam2; User_Subp := Nam1; elsif Nkind (N) = N_Range then return It1; -- If two user defined-subprograms are visible, it is a true ambiguity, -- unless one of them is an entry and the context is a conditional or -- timed entry call, or unless we are within an instance and this is -- results from two formals types with the same actual. else if Nkind (N) = N_Procedure_Call_Statement and then Nkind (Parent (N)) = N_Entry_Call_Alternative and then N = Entry_Call_Statement (Parent (N)) then if Ekind (Nam2) = E_Entry then return It2; elsif Ekind (Nam1) = E_Entry then return It1; else return No_Interp; end if; -- If the ambiguity occurs within an instance, it is due to several -- formal types with the same actual. Look for an exact match -- between the types of the formals of the overloadable entities, -- and the actuals in the call, to recover the unambiguous match -- in the original generic. elsif In_Instance then if (Nkind (N) = N_Function_Call or else Nkind (N) = N_Procedure_Call_Statement) then declare Actual : Node_Id; Formal : Entity_Id; begin Actual := First_Actual (N); Formal := First_Formal (Nam1); while Present (Actual) loop if Etype (Actual) /= Etype (Formal) then return It2; end if; Next_Actual (Actual); Next_Formal (Formal); end loop; return It1; end; elsif Nkind (N) in N_Binary_Op then if Matches (Left_Opnd (N), First_Formal (Nam1)) and then Matches (Right_Opnd (N), Next_Formal (First_Formal (Nam1))) then return It1; else return It2; end if; elsif Nkind (N) in N_Unary_Op then if Etype (Right_Opnd (N)) = Etype (First_Formal (Nam1)) then return It1; else return It2; end if; else return Remove_Conversions; end if; else return Remove_Conversions; end if; end if; -- an implicit concatenation operator on a string type cannot be -- disambiguated from the predefined concatenation. This can only -- happen with concatenation of string literals. if Chars (User_Subp) = Name_Op_Concat and then Ekind (User_Subp) = E_Operator and then Is_String_Type (Etype (First_Formal (User_Subp))) then return No_Interp; -- If the user-defined operator is in an open scope, or in the scope -- of the resulting type, or given by an expanded name that names its -- scope, it hides the predefined operator for the type. Exponentiation -- has to be special-cased because the implicit operator does not have -- a symmetric signature, and may not be hidden by the explicit one. elsif (Nkind (N) = N_Function_Call and then Nkind (Name (N)) = N_Expanded_Name and then (Chars (Predef_Subp) /= Name_Op_Expon or else Hides_Op (User_Subp, Predef_Subp)) and then Scope (User_Subp) = Entity (Prefix (Name (N)))) or else Hides_Op (User_Subp, Predef_Subp) then if It1.Nam = User_Subp then return It1; else return It2; end if; -- Otherwise, the predefined operator has precedence, or if the -- user-defined operation is directly visible we have a true ambiguity. -- If this is a fixed-point multiplication and division in Ada83 mode, -- exclude the universal_fixed operator, which often causes ambiguities -- in legacy code. else if (In_Open_Scopes (Scope (User_Subp)) or else Is_Potentially_Use_Visible (User_Subp)) and then not In_Instance then if Is_Fixed_Point_Type (Typ) and then (Chars (Nam1) = Name_Op_Multiply or else Chars (Nam1) = Name_Op_Divide) and then Ada_83 then if It2.Nam = Predef_Subp then return It1; else return It2; end if; else return No_Interp; end if; elsif It1.Nam = Predef_Subp then return It1; else return It2; end if; end if; end Disambiguate; --------------------- -- End_Interp_List -- --------------------- procedure End_Interp_List is begin All_Interp.Table (All_Interp.Last) := No_Interp; All_Interp.Increment_Last; end End_Interp_List; ------------------------- -- Entity_Matches_Spec -- ------------------------- function Entity_Matches_Spec (Old_S, New_S : Entity_Id) return Boolean is begin -- Simple case: same entity kinds, type conformance is required. -- A parameterless function can also rename a literal. if Ekind (Old_S) = Ekind (New_S) or else (Ekind (New_S) = E_Function and then Ekind (Old_S) = E_Enumeration_Literal) then return Type_Conformant (New_S, Old_S); elsif Ekind (New_S) = E_Function and then Ekind (Old_S) = E_Operator then return Operator_Matches_Spec (Old_S, New_S); elsif Ekind (New_S) = E_Procedure and then Is_Entry (Old_S) then return Type_Conformant (New_S, Old_S); else return False; end if; end Entity_Matches_Spec; ---------------------- -- Find_Unique_Type -- ---------------------- function Find_Unique_Type (L : Node_Id; R : Node_Id) return Entity_Id is I : Interp_Index; It : Interp; T : Entity_Id := Etype (L); TR : Entity_Id := Any_Type; begin if Is_Overloaded (R) then Get_First_Interp (R, I, It); while Present (It.Typ) loop if Covers (T, It.Typ) or else Covers (It.Typ, T) then -- If several interpretations are possible and L is universal, -- apply preference rule. if TR /= Any_Type then if (T = Universal_Integer or else T = Universal_Real) and then It.Typ = T then TR := It.Typ; end if; else TR := It.Typ; end if; end if; Get_Next_Interp (I, It); end loop; Set_Etype (R, TR); -- In the non-overloaded case, the Etype of R is already set -- correctly. else null; end if; -- If one of the operands is Universal_Fixed, the type of the -- other operand provides the context. if Etype (R) = Universal_Fixed then return T; elsif T = Universal_Fixed then return Etype (R); else return Specific_Type (T, Etype (R)); end if; end Find_Unique_Type; ---------------------- -- Get_First_Interp -- ---------------------- procedure Get_First_Interp (N : Node_Id; I : out Interp_Index; It : out Interp) is Int_Ind : Interp_Index; O_N : Node_Id; begin -- If a selected component is overloaded because the selector has -- multiple interpretations, the node is a call to a protected -- operation or an indirect call. Retrieve the interpretation from -- the selector name. The selected component may be overloaded as well -- if the prefix is overloaded. That case is unchanged. if Nkind (N) = N_Selected_Component and then Is_Overloaded (Selector_Name (N)) then O_N := Selector_Name (N); else O_N := N; end if; for Index in 0 .. Interp_Map.Last loop if Interp_Map.Table (Index).Node = O_N then Int_Ind := Interp_Map.Table (Index).Index; It := All_Interp.Table (Int_Ind); I := Int_Ind; return; end if; end loop; -- Procedure should never be called if the node has no interpretations raise Program_Error; end Get_First_Interp; ---------------------- -- Get_Next_Interp -- ---------------------- procedure Get_Next_Interp (I : in out Interp_Index; It : out Interp) is begin I := I + 1; It := All_Interp.Table (I); end Get_Next_Interp; ------------------------- -- Has_Compatible_Type -- ------------------------- function Has_Compatible_Type (N : Node_Id; Typ : Entity_Id) return Boolean is I : Interp_Index; It : Interp; begin if N = Error then return False; end if; if Nkind (N) = N_Subtype_Indication or else not Is_Overloaded (N) then return Covers (Typ, Etype (N)) or else (not Is_Tagged_Type (Typ) and then Ekind (Typ) /= E_Anonymous_Access_Type and then Covers (Etype (N), Typ)); else Get_First_Interp (N, I, It); while Present (It.Typ) loop if Covers (Typ, It.Typ) or else (not Is_Tagged_Type (Typ) and then Ekind (Typ) /= E_Anonymous_Access_Type and then Covers (It.Typ, Typ)) then return True; end if; Get_Next_Interp (I, It); end loop; return False; end if; end Has_Compatible_Type; -------------- -- Hides_Op -- -------------- function Hides_Op (F : Entity_Id; Op : Entity_Id) return Boolean is Btyp : constant Entity_Id := Base_Type (Etype (First_Formal (F))); begin return Operator_Matches_Spec (Op, F) and then (In_Open_Scopes (Scope (F)) or else Scope (F) = Scope (Btyp) or else (not In_Open_Scopes (Scope (Btyp)) and then not In_Use (Btyp) and then not In_Use (Scope (Btyp)))); end Hides_Op; ------------------------ -- Init_Interp_Tables -- ------------------------ procedure Init_Interp_Tables is begin All_Interp.Init; Interp_Map.Init; end Init_Interp_Tables; --------------------- -- Intersect_Types -- --------------------- function Intersect_Types (L, R : Node_Id) return Entity_Id is Index : Interp_Index; It : Interp; Typ : Entity_Id; function Check_Right_Argument (T : Entity_Id) return Entity_Id; -- Find interpretation of right arg that has type compatible with T -------------------------- -- Check_Right_Argument -- -------------------------- function Check_Right_Argument (T : Entity_Id) return Entity_Id is Index : Interp_Index; It : Interp; T2 : Entity_Id; begin if not Is_Overloaded (R) then return Specific_Type (T, Etype (R)); else Get_First_Interp (R, Index, It); loop T2 := Specific_Type (T, It.Typ); if T2 /= Any_Type then return T2; end if; Get_Next_Interp (Index, It); exit when No (It.Typ); end loop; return Any_Type; end if; end Check_Right_Argument; -- Start processing for Intersect_Types begin if Etype (L) = Any_Type or else Etype (R) = Any_Type then return Any_Type; end if; if not Is_Overloaded (L) then Typ := Check_Right_Argument (Etype (L)); else Typ := Any_Type; Get_First_Interp (L, Index, It); while Present (It.Typ) loop Typ := Check_Right_Argument (It.Typ); exit when Typ /= Any_Type; Get_Next_Interp (Index, It); end loop; end if; -- If Typ is Any_Type, it means no compatible pair of types was found if Typ = Any_Type then if Nkind (Parent (L)) in N_Op then Error_Msg_N ("incompatible types for operator", Parent (L)); elsif Nkind (Parent (L)) = N_Range then Error_Msg_N ("incompatible types given in constraint", Parent (L)); else Error_Msg_N ("incompatible types", Parent (L)); end if; end if; return Typ; end Intersect_Types; ----------------- -- Is_Ancestor -- ----------------- function Is_Ancestor (T1, T2 : Entity_Id) return Boolean is Par : Entity_Id; begin if Base_Type (T1) = Base_Type (T2) then return True; elsif Is_Private_Type (T1) and then Present (Full_View (T1)) and then Base_Type (T2) = Base_Type (Full_View (T1)) then return True; else Par := Etype (T2); loop if Base_Type (T1) = Base_Type (Par) or else (Is_Private_Type (T1) and then Present (Full_View (T1)) and then Base_Type (Par) = Base_Type (Full_View (T1))) then return True; elsif Is_Private_Type (Par) and then Present (Full_View (Par)) and then Full_View (Par) = Base_Type (T1) then return True; elsif Etype (Par) /= Par then Par := Etype (Par); else return False; end if; end loop; end if; end Is_Ancestor; ------------------- -- Is_Subtype_Of -- ------------------- function Is_Subtype_Of (T1 : Entity_Id; T2 : Entity_Id) return Boolean is S : Entity_Id; begin S := Ancestor_Subtype (T1); while Present (S) loop if S = T2 then return True; else S := Ancestor_Subtype (S); end if; end loop; return False; end Is_Subtype_Of; ----------------- -- New_Interps -- ----------------- procedure New_Interps (N : Node_Id) is begin Interp_Map.Increment_Last; All_Interp.Increment_Last; Interp_Map.Table (Interp_Map.Last) := (N, All_Interp.Last); All_Interp.Table (All_Interp.Last) := No_Interp; Set_Is_Overloaded (N, True); end New_Interps; --------------------------- -- Operator_Matches_Spec -- --------------------------- function Operator_Matches_Spec (Op, New_S : Entity_Id) return Boolean is Op_Name : constant Name_Id := Chars (Op); T : constant Entity_Id := Etype (New_S); New_F : Entity_Id; Old_F : Entity_Id; Num : Int; T1 : Entity_Id; T2 : Entity_Id; begin -- To verify that a predefined operator matches a given signature, -- do a case analysis of the operator classes. Function can have one -- or two formals and must have the proper result type. New_F := First_Formal (New_S); Old_F := First_Formal (Op); Num := 0; while Present (New_F) and then Present (Old_F) loop Num := Num + 1; Next_Formal (New_F); Next_Formal (Old_F); end loop; -- Definite mismatch if different number of parameters if Present (Old_F) or else Present (New_F) then return False; -- Unary operators elsif Num = 1 then T1 := Etype (First_Formal (New_S)); if Op_Name = Name_Op_Subtract or else Op_Name = Name_Op_Add or else Op_Name = Name_Op_Abs then return Base_Type (T1) = Base_Type (T) and then Is_Numeric_Type (T); elsif Op_Name = Name_Op_Not then return Base_Type (T1) = Base_Type (T) and then Valid_Boolean_Arg (Base_Type (T)); else return False; end if; -- Binary operators else T1 := Etype (First_Formal (New_S)); T2 := Etype (Next_Formal (First_Formal (New_S))); if Op_Name = Name_Op_And or else Op_Name = Name_Op_Or or else Op_Name = Name_Op_Xor then return Base_Type (T1) = Base_Type (T2) and then Base_Type (T1) = Base_Type (T) and then Valid_Boolean_Arg (Base_Type (T)); elsif Op_Name = Name_Op_Eq or else Op_Name = Name_Op_Ne then return Base_Type (T1) = Base_Type (T2) and then not Is_Limited_Type (T1) and then Is_Boolean_Type (T); elsif Op_Name = Name_Op_Lt or else Op_Name = Name_Op_Le or else Op_Name = Name_Op_Gt or else Op_Name = Name_Op_Ge then return Base_Type (T1) = Base_Type (T2) and then Valid_Comparison_Arg (T1) and then Is_Boolean_Type (T); elsif Op_Name = Name_Op_Add or else Op_Name = Name_Op_Subtract then return Base_Type (T1) = Base_Type (T2) and then Base_Type (T1) = Base_Type (T) and then Is_Numeric_Type (T); -- for division and multiplication, a user-defined function does -- not match the predefined universal_fixed operation, except in -- Ada83 mode. elsif Op_Name = Name_Op_Divide then return (Base_Type (T1) = Base_Type (T2) and then Base_Type (T1) = Base_Type (T) and then Is_Numeric_Type (T) and then (not Is_Fixed_Point_Type (T) or else Ada_83)) -- Mixed_Mode operations on fixed-point types. or else (Base_Type (T1) = Base_Type (T) and then Base_Type (T2) = Base_Type (Standard_Integer) and then Is_Fixed_Point_Type (T)) -- A user defined operator can also match (and hide) a mixed -- operation on universal literals. or else (Is_Integer_Type (T2) and then Is_Floating_Point_Type (T1) and then Base_Type (T1) = Base_Type (T)); elsif Op_Name = Name_Op_Multiply then return (Base_Type (T1) = Base_Type (T2) and then Base_Type (T1) = Base_Type (T) and then Is_Numeric_Type (T) and then (not Is_Fixed_Point_Type (T) or else Ada_83)) -- Mixed_Mode operations on fixed-point types. or else (Base_Type (T1) = Base_Type (T) and then Base_Type (T2) = Base_Type (Standard_Integer) and then Is_Fixed_Point_Type (T)) or else (Base_Type (T2) = Base_Type (T) and then Base_Type (T1) = Base_Type (Standard_Integer) and then Is_Fixed_Point_Type (T)) or else (Is_Integer_Type (T2) and then Is_Floating_Point_Type (T1) and then Base_Type (T1) = Base_Type (T)) or else (Is_Integer_Type (T1) and then Is_Floating_Point_Type (T2) and then Base_Type (T2) = Base_Type (T)); elsif Op_Name = Name_Op_Mod or else Op_Name = Name_Op_Rem then return Base_Type (T1) = Base_Type (T2) and then Base_Type (T1) = Base_Type (T) and then Is_Integer_Type (T); elsif Op_Name = Name_Op_Expon then return Base_Type (T1) = Base_Type (T) and then Is_Numeric_Type (T) and then Base_Type (T2) = Base_Type (Standard_Integer); elsif Op_Name = Name_Op_Concat then return Is_Array_Type (T) and then (Base_Type (T) = Base_Type (Etype (Op))) and then (Base_Type (T1) = Base_Type (T) or else Base_Type (T1) = Base_Type (Component_Type (T))) and then (Base_Type (T2) = Base_Type (T) or else Base_Type (T2) = Base_Type (Component_Type (T))); else return False; end if; end if; end Operator_Matches_Spec; ------------------- -- Remove_Interp -- ------------------- procedure Remove_Interp (I : in out Interp_Index) is II : Interp_Index; begin -- Find end of Interp list and copy downward to erase the discarded one II := I + 1; while Present (All_Interp.Table (II).Typ) loop II := II + 1; end loop; for J in I + 1 .. II loop All_Interp.Table (J - 1) := All_Interp.Table (J); end loop; -- Back up interp. index to insure that iterator will pick up next -- available interpretation. I := I - 1; end Remove_Interp; ------------------ -- Save_Interps -- ------------------ procedure Save_Interps (Old_N : Node_Id; New_N : Node_Id) is begin if Is_Overloaded (Old_N) then for Index in 0 .. Interp_Map.Last loop if Interp_Map.Table (Index).Node = Old_N then Interp_Map.Table (Index).Node := New_N; exit; end if; end loop; end if; end Save_Interps; ------------------- -- Specific_Type -- ------------------- function Specific_Type (T1, T2 : Entity_Id) return Entity_Id is B1 : constant Entity_Id := Base_Type (T1); B2 : constant Entity_Id := Base_Type (T2); function Is_Remote_Access (T : Entity_Id) return Boolean; -- Check whether T is the equivalent type of a remote access type. -- If distribution is enabled, T is a legal context for Null. ---------------------- -- Is_Remote_Access -- ---------------------- function Is_Remote_Access (T : Entity_Id) return Boolean is begin return Is_Record_Type (T) and then (Is_Remote_Call_Interface (T) or else Is_Remote_Types (T)) and then Present (Corresponding_Remote_Type (T)) and then Is_Access_Type (Corresponding_Remote_Type (T)); end Is_Remote_Access; -- Start of processing for Specific_Type begin if (T1 = Any_Type or else T2 = Any_Type) then return Any_Type; end if; if B1 = B2 then return B1; elsif (T1 = Universal_Integer and then Is_Integer_Type (T2)) or else (T1 = Universal_Real and then Is_Real_Type (T2)) or else (T1 = Any_Fixed and then Is_Fixed_Point_Type (T2)) then return B2; elsif (T2 = Universal_Integer and then Is_Integer_Type (T1)) or else (T2 = Universal_Real and then Is_Real_Type (T1)) or else (T2 = Any_Fixed and then Is_Fixed_Point_Type (T1)) then return B1; elsif (T2 = Any_String and then Is_String_Type (T1)) then return B1; elsif (T1 = Any_String and then Is_String_Type (T2)) then return B2; elsif (T2 = Any_Character and then Is_Character_Type (T1)) then return B1; elsif (T1 = Any_Character and then Is_Character_Type (T2)) then return B2; elsif (T1 = Any_Access and then (Is_Access_Type (T2) or else Is_Remote_Access (T2))) then return T2; elsif (T2 = Any_Access and then (Is_Access_Type (T1) or else Is_Remote_Access (T1))) then return T1; elsif (T2 = Any_Composite and then Ekind (T1) in E_Array_Type .. E_Record_Subtype) then return T1; elsif (T1 = Any_Composite and then Ekind (T2) in E_Array_Type .. E_Record_Subtype) then return T2; elsif (T1 = Any_Modular and then Is_Modular_Integer_Type (T2)) then return T2; elsif (T2 = Any_Modular and then Is_Modular_Integer_Type (T1)) then return T1; -- Special cases for equality operators (all other predefined -- operators can never apply to tagged types) elsif Is_Class_Wide_Type (T1) and then Is_Ancestor (Root_Type (T1), T2) then return T1; elsif Is_Class_Wide_Type (T2) and then Is_Ancestor (Root_Type (T2), T1) then return T2; elsif (Ekind (B1) = E_Access_Subprogram_Type or else Ekind (B1) = E_Access_Protected_Subprogram_Type) and then Ekind (Designated_Type (B1)) /= E_Subprogram_Type and then Is_Access_Type (T2) then return T2; elsif (Ekind (B2) = E_Access_Subprogram_Type or else Ekind (B2) = E_Access_Protected_Subprogram_Type) and then Ekind (Designated_Type (B2)) /= E_Subprogram_Type and then Is_Access_Type (T1) then return T1; elsif (Ekind (T1) = E_Allocator_Type or else Ekind (T1) = E_Access_Attribute_Type or else Ekind (T1) = E_Anonymous_Access_Type) and then Is_Access_Type (T2) then return T2; elsif (Ekind (T2) = E_Allocator_Type or else Ekind (T2) = E_Access_Attribute_Type or else Ekind (T2) = E_Anonymous_Access_Type) and then Is_Access_Type (T1) then return T1; -- If none of the above cases applies, types are not compatible. else return Any_Type; end if; end Specific_Type; ------------------------------ -- Universal_Interpretation -- ------------------------------ function Universal_Interpretation (Opnd : Node_Id) return Entity_Id is Index : Interp_Index; It : Interp; begin -- The argument may be a formal parameter of an operator or subprogram -- with multiple interpretations, or else an expression for an actual. if Nkind (Opnd) = N_Defining_Identifier or else not Is_Overloaded (Opnd) then if Etype (Opnd) = Universal_Integer or else Etype (Opnd) = Universal_Real then return Etype (Opnd); else return Empty; end if; else Get_First_Interp (Opnd, Index, It); while Present (It.Typ) loop if It.Typ = Universal_Integer or else It.Typ = Universal_Real then return It.Typ; end if; Get_Next_Interp (Index, It); end loop; return Empty; end if; end Universal_Interpretation; ----------------------- -- Valid_Boolean_Arg -- ----------------------- -- In addition to booleans and arrays of booleans, we must include -- aggregates as valid boolean arguments, because in the first pass -- of resolution their components are not examined. If it turns out not -- to be an aggregate of booleans, this will be diagnosed in Resolve. -- Any_Composite must be checked for prior to the array type checks -- because Any_Composite does not have any associated indexes. function Valid_Boolean_Arg (T : Entity_Id) return Boolean is begin return Is_Boolean_Type (T) or else T = Any_Composite or else (Is_Array_Type (T) and then T /= Any_String and then Number_Dimensions (T) = 1 and then Is_Boolean_Type (Component_Type (T)) and then (not Is_Private_Composite (T) or else In_Instance) and then (not Is_Limited_Composite (T) or else In_Instance)) or else Is_Modular_Integer_Type (T) or else T = Universal_Integer; end Valid_Boolean_Arg; -------------------------- -- Valid_Comparison_Arg -- -------------------------- function Valid_Comparison_Arg (T : Entity_Id) return Boolean is begin return Is_Discrete_Type (T) or else Is_Real_Type (T) or else (Is_Array_Type (T) and then Number_Dimensions (T) = 1 and then Is_Discrete_Type (Component_Type (T)) and then (not Is_Private_Composite (T) or else In_Instance) and then (not Is_Limited_Composite (T) or else In_Instance)) or else Is_String_Type (T); end Valid_Comparison_Arg; --------------------- -- Write_Overloads -- --------------------- procedure Write_Overloads (N : Node_Id) is I : Interp_Index; It : Interp; Nam : Entity_Id; begin if not Is_Overloaded (N) then Write_Str ("Non-overloaded entity "); Write_Eol; Write_Entity_Info (Entity (N), " "); else Get_First_Interp (N, I, It); Write_Str ("Overloaded entity "); Write_Eol; Nam := It.Nam; while Present (Nam) loop Write_Entity_Info (Nam, " "); Write_Str ("================="); Write_Eol; Get_Next_Interp (I, It); Nam := It.Nam; end loop; end if; end Write_Overloads; end Sem_Type;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . B O A R D _ P A R A M E T E R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2016-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. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ -- This package defines board parameters for the nRF52840-DK board package System.BB.Board_Parameters is pragma No_Elaboration_Code_All; pragma Pure; -------------------- -- Hardware clock -- -------------------- RTC_Tick_Scaling_Factor : constant := 32; -- 32.768 kHz * 32 = 1.048576 MHz -- Use a fairly high scaling factor so that Ada.Real_Time.Time_Unit is -- at least 1 microsecond. This improves the long-running accuracy of -- periodic tasks where the period is not integer divisible by 32.768 kHz. -- -- The maximum permitted scaling factor is 255, otherwise the 24-bit RTC -- period (@ 32 kHz) cannot be scaled to the 32-bit range of -- Timer_Interval. Main_Clock_Frequency : constant := 32_768 * RTC_Tick_Scaling_Factor; -- On the nRF52 we use the RTC peripheral as the system tick, instead of -- the Cortex-M4 SysTick because the SysTick is powered down when the CPU -- enters sleep mode (via the "wfi" instruction). Since we still want to -- be able to put the CPU to sleep (to save power) we instead use the -- low-power RTC peripheral, which runs at 32.768 kHz. -- -- In this runtime, the minimum allowed frequency is 50_000 Hz so that -- Ada.Real_Time.Time_Unit does not exceed 20 us as required by -- Ada RM D.8 (30). Since the RTC's actual period is 30.518 us we multiply -- the RTC frequency by RTC_Tick_Scaling_Factor so that Time_Unit meets the -- requirement in Ada RM D.8 (30). end System.BB.Board_Parameters;
pragma Warnings (Off); pragma Ada_95; with System; with System.Parameters; with System.Secondary_Stack; package ada_main is GNAT_Version : constant String := "GNAT Version: Community 2019 (20190517-74)" & ASCII.NUL; pragma Export (C, GNAT_Version, "__gnat_version"); Ada_Main_Program_Name : constant String := "_ada_digital_blood_pressure_monitor" & ASCII.NUL; pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name"); procedure adainit; pragma Export (C, adainit, "adainit"); procedure adafinal; pragma Export (C, adafinal, "adafinal"); procedure main; pragma Export (C, main, "main"); -- BEGIN ELABORATION ORDER -- ada%s -- interfaces%s -- system%s -- ada.io_exceptions%s -- gnat%s -- interfaces.stm32%s -- interfaces.stm32.pwr%s -- system.bb%s -- system.bb.board_parameters%s -- system.bb.cpu_specific%s -- system.bb.mcu_parameters%s -- system.bb.mcu_parameters%b -- system.exceptions%s -- system.exceptions%b -- system.img_bool%s -- system.img_bool%b -- system.img_int%s -- system.img_int%b -- system.machine_code%s -- system.parameters%s -- system.parameters%b -- system.restrictions%s -- system.restrictions%b -- system.semihosting%s -- system.semihosting%b -- system.storage_elements%s -- system.storage_elements%b -- system.secondary_stack%s -- system.secondary_stack%b -- gnat.debug_utilities%s -- gnat.debug_utilities%b -- system.case_util%s -- system.case_util%b -- system.string_hash%s -- system.string_hash%b -- system.htable%s -- system.htable%b -- system.task_info%s -- system.task_info%b -- system.text_io%s -- system.text_io%b -- system.io%s -- system.io%b -- system.traceback_entries%s -- system.traceback_entries%b -- system.unsigned_types%s -- interfaces.stm32.rcc%s -- system.img_uns%s -- system.img_uns%b -- system.stm32%s -- system.bb.parameters%s -- system.stm32%b -- system.wch_con%s -- system.wch_con%b -- system.wch_jis%s -- system.wch_jis%b -- system.wch_cnv%s -- system.wch_cnv%b -- system.address_image%s -- system.address_image%b -- system.traceback%s -- system.traceback%b -- ada.tags%s -- system.bb.cpu_primitives%s -- system.bb.cpu_primitives.context_switch_trigger%s -- system.bb.cpu_primitives.context_switch_trigger%b -- system.bb.interrupts%s -- system.bb.protection%s -- system.multiprocessors%s -- system.bb.time%s -- system.bb.board_support%s -- system.bb.board_support%b -- system.bb.threads%s -- system.bb.threads.queues%s -- system.bb.threads.queues%b -- system.bb.timing_events%s -- system.bb.timing_events%b -- system.multiprocessors.spin_locks%s -- system.multiprocessors.spin_locks%b -- system.multiprocessors.fair_locks%s -- system.os_interface%s -- system.standard_library%s -- ada.exceptions%s -- system.exceptions.machine%s -- system.exceptions.machine%b -- system.exceptions_debug%s -- system.exceptions_debug%b -- system.soft_links%s -- system.task_primitives%s -- system.tasking%s -- system.task_primitives.operations%s -- system.tasking.debug%s -- system.tasking.debug%b -- system.val_uns%s -- system.val_util%s -- system.val_util%b -- system.wch_stw%s -- system.wch_stw%b -- ada.exceptions.last_chance_handler%s -- ada.exceptions.last_chance_handler%b -- ada.exceptions.traceback%s -- ada.exceptions.traceback%b -- ada.tags%b -- system.bb.cpu_primitives%b -- system.bb.interrupts%b -- system.bb.protection%b -- system.bb.threads%b -- system.bb.time%b -- system.exception_table%s -- system.exception_table%b -- system.memory%s -- system.memory%b -- system.multiprocessors%b -- system.multiprocessors.fair_locks%b -- system.soft_links%b -- system.standard_library%b -- system.task_primitives.operations%b -- system.tasking%b -- system.traceback.symbolic%s -- system.traceback.symbolic%b -- ada.exceptions%b -- system.val_uns%b -- ada.streams%s -- ada.streams%b -- system.finalization_root%s -- system.finalization_root%b -- ada.finalization%s -- system.storage_pools%s -- system.storage_pools%b -- system.finalization_masters%s -- system.finalization_masters%b -- system.stream_attributes%s -- system.stream_attributes%b -- ada.real_time%s -- ada.real_time%b -- ada.real_time.delays%s -- ada.real_time.delays%b -- system.assertions%s -- system.assertions%b -- system.pool_global%s -- system.pool_global%b -- system.tasking.protected_objects%s -- system.tasking.protected_objects%b -- system.tasking.protected_objects.entries%s -- system.tasking.protected_objects.entries%b -- system.tasking.protected_objects.multiprocessors%s -- system.tasking.protected_objects.multiprocessors%b -- system.tasking.queuing%s -- system.tasking.queuing%b -- system.tasking.protected_objects.operations%s -- system.tasking.protected_objects.operations%b -- system.tasking.restricted%s -- system.tasking.restricted.stages%s -- system.tasking.restricted.stages%b -- ada.task_identification%s -- ada.task_identification%b -- system.interrupts%s -- system.interrupts%b -- ada.interrupts%s -- ada.interrupts%b -- ada.interrupts.names%s -- cortex_m%s -- cortex_m_svd%s -- hal%s -- cortex_m_svd.scb%s -- stm32%s -- stm32_svd%s -- stm32_svd.adc%s -- stm32_svd.crc%s -- stm32_svd.dac%s -- stm32_svd.dma%s -- stm32_svd.dma2d%s -- stm32_svd.exti%s -- stm32_svd.fsmc%s -- stm32_svd.gpio%s -- stm32_svd.i2c%s -- stm32_svd.ltdc%s -- stm32_svd.pwr%s -- stm32_svd.rcc%s -- stm32_svd.rtc%s -- stm32_svd.sdio%s -- sdmmc_svd%s -- stm32_svd.spi%s -- stm32_svd.syscfg%s -- stm32_svd.usart%s -- adl_config%s -- bmp_fonts%s -- bmp_fonts%b -- cortex_m.cache%s -- cortex_m.cache%b -- hal.audio%s -- hal.bitmap%s -- bitmap_color_conversion%s -- bitmap_color_conversion%b -- hal.block_drivers%s -- hal.framebuffer%s -- hal.gpio%s -- hal.i2c%s -- hal.real_time_clock%s -- hal.sdmmc%s -- hal.sdmmc%b -- hal.spi%s -- hal.time%s -- hal.touch_panel%s -- hal.uart%s -- hershey_fonts%s -- hershey_fonts%b -- bitmapped_drawing%s -- bitmapped_drawing%b -- ili9341_regs%s -- ili9341%s -- ili9341%b -- l3gd20%s -- l3gd20%b -- ravenscar_time%s -- ravenscar_time%b -- sdmmc_init%s -- sdmmc_init%b -- sdmmc_svd_periph%s -- soft_drawing_bitmap%s -- soft_drawing_bitmap%b -- memory_mapped_bitmap%s -- memory_mapped_bitmap%b -- stm32.adc%s -- stm32.adc%b -- stm32.crc%s -- stm32.crc%b -- stm32.dac%s -- stm32.dac%b -- stm32.dma%s -- stm32.dma%b -- stm32.dma.interrupts%s -- stm32.dma.interrupts%b -- stm32.dma2d%s -- stm32.dma2d%b -- stm32.dma2d.interrupt%s -- stm32.dma2d.interrupt%b -- stm32.dma2d.polling%s -- stm32.dma2d.polling%b -- stm32.dma2d_bitmap%s -- stm32.dma2d_bitmap%b -- stm32.exti%s -- stm32.exti%b -- stm32.fmc%s -- stm32.fmc%b -- stm32.power_control%s -- stm32.power_control%b -- stm32.rtc%s -- stm32.rtc%b -- stm32.spi%s -- stm32.spi%b -- stm32.spi.dma%s -- stm32.spi.dma%b -- stm32.timers%s -- stm32.timers%b -- stm32.gpio%s -- stm32.i2c%s -- stm32.i2c.dma%s -- stm32.i2s%s -- stm32.rcc%s -- stm32.sdmmc_interrupt%s -- stm32.sdmmc%s -- stm32.sdmmc_interrupt%b -- stm32.syscfg%s -- stm32.gpio%b -- stm32.usarts%s -- stm32.device%s -- stm32.device%b -- stm32.i2c%b -- stm32.i2c.dma%b -- stm32.i2s%b -- stm32.rcc%b -- stm32.sdmmc%b -- stm32.syscfg%b -- stm32.usarts%b -- stm32.ltdc%s -- stm32.ltdc%b -- stm32.setup%s -- stm32.setup%b -- stmpe811%s -- stmpe811%b -- framebuffer_ltdc%s -- framebuffer_ili9341%s -- stm32.sdram%s -- framebuffer_ltdc%b -- touch_panel_stmpe811%s -- stm32.board%s -- stm32.board%b -- framebuffer_ili9341%b -- stm32.sdram%b -- touch_panel_stmpe811%b -- last_chance_handler%s -- last_chance_handler%b -- lcd_std_out%s -- lcd_std_out%b -- stm32.user_button%s -- stm32.user_button%b -- digital_blood_pressure_monitor%b -- END ELABORATION ORDER end ada_main;
------------------------------------------------------------------------------ -- -- -- Unicode Utilities -- -- -- -- Normalization Form Utilities -- -- Quick Check Query Facilities -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2019, 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. -- -- -- ------------------------------------------------------------------------------ -- Generated: 2019-08-18 -- DerivedNormalizationProps.txt source -- https://www.unicode.org/Public/UCD/latest/ucd/DerivedNormalizationProps.txt -- **************** THIS FILE IS AUTOMATICALLY GENERATED **************** -- -- - See Unicode.UCD.Generate_Normalization_Quick_Check_Body.adb - -- -- DerivedNormalizationProps.txt -- -- Records loaded (NFC_QC) = 116 function Unicode.Normalization.Quick_Check.C (C: Wide_Wide_Character) return Quick_Check_Result is type Codepoint is mod 2**24; function Plane_00_Lookup (C: Codepoint) return Quick_Check_Result is (case C is when 16#000340# .. 16#000341# => NO, when 16#000343# .. 16#000344# => NO, when 16#000374# => NO, when 16#00037E# => NO, when 16#000387# => NO, when 16#000958# .. 16#00095F# => NO, when 16#0009DC# .. 16#0009DD# => NO, when 16#0009DF# => NO, when 16#000A33# => NO, when 16#000A36# => NO, when 16#000A59# .. 16#000A5B# => NO, when 16#000A5E# => NO, when 16#000B5C# .. 16#000B5D# => NO, when 16#000F43# => NO, when 16#000F4D# => NO, when 16#000F52# => NO, when 16#000F57# => NO, when 16#000F5C# => NO, when 16#000F69# => NO, when 16#000F73# => NO, when 16#000F75# .. 16#000F76# => NO, when 16#000F78# => NO, when 16#000F81# => NO, when 16#000F93# => NO, when 16#000F9D# => NO, when 16#000FA2# => NO, when 16#000FA7# => NO, when 16#000FAC# => NO, when 16#000FB9# => NO, when 16#001F71# => NO, when 16#001F73# => NO, when 16#001F75# => NO, when 16#001F77# => NO, when 16#001F79# => NO, when 16#001F7B# => NO, when 16#001F7D# => NO, when 16#001FBB# => NO, when 16#001FBE# => NO, when 16#001FC9# => NO, when 16#001FCB# => NO, when 16#001FD3# => NO, when 16#001FDB# => NO, when 16#001FE3# => NO, when 16#001FEB# => NO, when 16#001FEE# .. 16#001FEF# => NO, when 16#001FF9# => NO, when 16#001FFB# => NO, when 16#001FFD# => NO, when 16#002000# .. 16#002001# => NO, when 16#002126# => NO, when 16#00212A# .. 16#00212B# => NO, when 16#002329# => NO, when 16#00232A# => NO, when 16#002ADC# => NO, when 16#00F900# .. 16#00FA0D# => NO, when 16#00FA10# => NO, when 16#00FA12# => NO, when 16#00FA15# .. 16#00FA1E# => NO, when 16#00FA20# => NO, when 16#00FA22# => NO, when 16#00FA25# .. 16#00FA26# => NO, when 16#00FA2A# .. 16#00FA6D# => NO, when 16#00FA70# .. 16#00FAD9# => NO, when 16#00FB1D# => NO, when 16#00FB1F# => NO, when 16#00FB2A# .. 16#00FB36# => NO, when 16#00FB38# .. 16#00FB3C# => NO, when 16#00FB3E# => NO, when 16#00FB40# .. 16#00FB41# => NO, when 16#00FB43# .. 16#00FB44# => NO, when 16#00FB46# .. 16#00FB4E# => NO, when 16#000300# .. 16#000304# => MAYBE, when 16#000306# .. 16#00030C# => MAYBE, when 16#00030F# => MAYBE, when 16#000311# => MAYBE, when 16#000313# .. 16#000314# => MAYBE, when 16#00031B# => MAYBE, when 16#000323# .. 16#000328# => MAYBE, when 16#00032D# .. 16#00032E# => MAYBE, when 16#000330# .. 16#000331# => MAYBE, when 16#000338# => MAYBE, when 16#000342# => MAYBE, when 16#000345# => MAYBE, when 16#000653# .. 16#000655# => MAYBE, when 16#00093C# => MAYBE, when 16#0009BE# => MAYBE, when 16#0009D7# => MAYBE, when 16#000B3E# => MAYBE, when 16#000B56# => MAYBE, when 16#000B57# => MAYBE, when 16#000BBE# => MAYBE, when 16#000BD7# => MAYBE, when 16#000C56# => MAYBE, when 16#000CC2# => MAYBE, when 16#000CD5# .. 16#000CD6# => MAYBE, when 16#000D3E# => MAYBE, when 16#000D57# => MAYBE, when 16#000DCA# => MAYBE, when 16#000DCF# => MAYBE, when 16#000DDF# => MAYBE, when 16#00102E# => MAYBE, when 16#001161# .. 16#001175# => MAYBE, when 16#0011A8# .. 16#0011C2# => MAYBE, when 16#001B35# => MAYBE, when 16#003099# .. 16#00309A# => MAYBE, when others => YES) with Inline; function Plane_01_Lookup (C: Codepoint) return Quick_Check_Result is (case C is when 16#01D15E# .. 16#01D164# => NO, when 16#01D1BB# .. 16#01D1C0# => NO, when 16#0110BA# => MAYBE, when 16#011127# => MAYBE, when 16#01133E# => MAYBE, when 16#011357# => MAYBE, when 16#0114B0# => MAYBE, when 16#0114BA# => MAYBE, when 16#0114BD# => MAYBE, when 16#0115AF# => MAYBE, when others => YES) with Inline; function Plane_02_Lookup (C: Codepoint) return Quick_Check_Result is (case C is when 16#02F800# .. 16#02FA1D# => NO, when others => YES) with Inline; function Plane_03_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_04_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_05_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_06_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_07_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_08_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_09_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_0A_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_0B_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_0C_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_0D_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_0E_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_0F_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; function Plane_10_Lookup (C: Codepoint) return Quick_Check_Result is (YES) with Inline; CP: constant Codepoint := Codepoint (Wide_Wide_Character'Pos(C)); begin return (case CP is when 16#000000# .. 16#00FFFF# => Plane_00_Lookup (CP), when 16#010000# .. 16#01FFFF# => Plane_01_Lookup (CP), when 16#020000# .. 16#02FFFF# => Plane_02_Lookup (CP), when 16#030000# .. 16#03FFFF# => Plane_03_Lookup (CP), when 16#040000# .. 16#04FFFF# => Plane_04_Lookup (CP), when 16#050000# .. 16#05FFFF# => Plane_05_Lookup (CP), when 16#060000# .. 16#06FFFF# => Plane_06_Lookup (CP), when 16#070000# .. 16#07FFFF# => Plane_07_Lookup (CP), when 16#080000# .. 16#08FFFF# => Plane_08_Lookup (CP), when 16#090000# .. 16#09FFFF# => Plane_09_Lookup (CP), when 16#0A0000# .. 16#0AFFFF# => Plane_0A_Lookup (CP), when 16#0B0000# .. 16#0BFFFF# => Plane_0B_Lookup (CP), when 16#0C0000# .. 16#0CFFFF# => Plane_0C_Lookup (CP), when 16#0D0000# .. 16#0DFFFF# => Plane_0D_Lookup (CP), when 16#0E0000# .. 16#0EFFFF# => Plane_0E_Lookup (CP), when 16#0F0000# .. 16#0FFFFF# => Plane_0F_Lookup (CP), when 16#100000# .. 16#10FFFF# => Plane_10_Lookup (CP), when others => YES); end Unicode.Normalization.Quick_Check.C;
with GNAT.String_Split; with Ada.Strings.Fixed; package body UxAS.Comms.Data.Addressed is ---------------------- -- Is_Valid_Address -- ---------------------- function Is_Valid_Address (Address : String) return Boolean is Delimiter_Pos : Natural; use Ada.Strings.Fixed; begin if Address'Length = 0 then return False; end if; Delimiter_Pos := Index (Source => Address, Pattern => Address_Attributes_Delimiter); if Delimiter_Pos /= 0 then -- found a delimiter return False; end if; return True; end Is_Valid_Address; ----------------------------- -- Set_Address_And_Payload -- ----------------------------- procedure Set_Address_And_Payload (This : in out Addressed_Message; Address : String; Payload : String; Result : out Boolean) is begin if not Is_Valid_Address (Address) or Payload'Length = 0 then This.Is_Valid := False; Result := False; return; end if; Copy (Address, To => This.Address); Copy (Payload, To => This.Payload); Copy (Address & Address_Attributes_Delimiter & Payload, To => This.Content_String); This.Is_Valid := True; Result := True; end Set_Address_And_Payload; --------------------------------------------------- -- Set_Address_And_Payload_From_Delimited_String -- --------------------------------------------------- procedure Set_Address_And_Payload_From_Delimited_String (This : in out Addressed_Message; Delimited_String : String; Result : out Boolean) is begin if Delimited_String'Length >= Minimum_Delimited_Address_Message_String_Length then Parse_Addressed_Message_String_And_Set_Fields (This, Delimited_String, Result); else This.Is_Valid := False; Result := False; end if; end Set_Address_And_Payload_From_Delimited_String; -------------- -- Is_Valid -- -------------- function Is_Valid (This : Addressed_Message) return Boolean is (This.Is_Valid); ------------- -- Address -- ------------- function Address (This : Addressed_Message) return String is (Value (This.Address)); ------------- -- Payload -- ------------- function Payload (This : Addressed_Message) return String is (Value (This.Payload)); -------------------- -- Content_String -- -------------------- function Content_String (This : Addressed_Message) return String is (Value (This.Content_String)); --------------------------------------------------- -- Parse_Addressed_Message_String_And_Set_Fields -- --------------------------------------------------- procedure Parse_Addressed_Message_String_And_Set_Fields (This : in out Addressed_Message; Delimited_String : String; Result : out Boolean) is use GNAT.String_Split; Parts : Slice_Set; begin Create (Parts, From => Delimited_String, Separators => Address_Attributes_Delimiter, Mode => Single); -- contiguous delimiters are NOT treated as a single delimiter; This.Is_Valid := False; Result := False; if Slice_Count (Parts) /= 2 then return; elsif Slice (Parts, 1) = "" or Slice (Parts, 2) = "" then return; else Set_Address_And_Payload (This, Address => Slice (Parts, 1), Payload => Slice (Parts, 2), Result => Result); end if; end Parse_Addressed_Message_String_And_Set_Fields; end UxAS.Comms.Data.Addressed;
with eGL.Binding, eGL.Pointers, System; package body openGL.Display is use eGL, eGL.Binding, eGL.Pointers; function Default return Item is use type System.Address, eGL.EGLBoolean; the_Display : Display.item; Success : EGLBoolean; Status : EGLBoolean; begin the_Display.Thin := eglGetDisplay (Display_Pointer (EGL_DEFAULT_DISPLAY)); if the_Display.Thin = egl_NO_DISPLAY then raise openGL.Error with "Failed to open the default Display with eGL."; end if; Success := eglInitialize (the_Display.Thin, the_Display.Version_major'Unchecked_Access, the_Display.Version_minor'Unchecked_Access); if Success = egl_False then raise openGL.Error with "Failed to initialise eGL using the default Display."; end if; Status := eglBindAPI (EGL_OPENGL_ES_API); return the_Display; end Default; end openGL.Display;
package body Lights is function Create_Light(Position: Vector; Color: Color_Type) return Light_Type is ( ( Position => Position, Color => Color ) ); function Position_Of(Light: Light_Type) return Vector is ( Light.Position ); function Color_Of(Light: Light_Type) return Color_Type is ( Light.Color ); end Lights;
-- SipHash24_C -- an Ada specification for the reference C implementation of SipHash and -- Half Siphash -- Copyright (c) 2015-2016, James Humphry - see LICENSE file for details with Ada.Unchecked_Conversion; with Interfaces, Interfaces.C, Interfaces.C.Strings; use Interfaces; package SipHash24_c is subtype U8 is Interfaces.Unsigned_8; type U8_Access is access all U8; subtype U32 is Interfaces.Unsigned_32; subtype U64 is Interfaces.Unsigned_64; type U8_Array is array (Natural range <>) of aliased U8; subtype U8_Array4 is U8_Array(0..3); subtype U8_Array8 is U8_Array(0..7); function chars_ptr_to_U8_Access is new Ada.Unchecked_Conversion(Source => Interfaces.C.Strings.chars_ptr, Target => U8_Access); function C_SipHash24 ( c_in : access Interfaces.Unsigned_8; inlen : Interfaces.C.size_t; k : access Interfaces.Unsigned_8; c_out : access Interfaces.Unsigned_8; outlen : Interfaces.C.size_t ) return C.int; pragma Import (C, C_SipHash24, "siphash"); function C_HalfSipHash24 ( c_in : access Interfaces.Unsigned_8; inlen : Interfaces.C.size_t; k : access Interfaces.Unsigned_8; c_out : access Interfaces.Unsigned_8; outlen : Interfaces.C.size_t ) return C.int; pragma Import (C, C_HalfSipHash24, "halfsiphash"); function U8_Array4_to_U32 (c : U8_Array4) return U32 is (U32(c(0)) or Shift_Left(U32(c(1)), 8) or Shift_Left(U32(c(2)), 16) or Shift_Left(U32(c(3)), 24)); function U8_Array8_to_U64 (c : U8_Array8) return U64 is (U64(c(0)) or Shift_Left(U64(c(1)), 8) or Shift_Left(U64(c(2)), 16) or Shift_Left(U64(c(3)), 24) or Shift_Left(U64(c(4)), 32) or Shift_Left(U64(c(5)), 40) or Shift_Left(U64(c(6)), 48) or Shift_Left(U64(c(7)), 56)); end SipHash24_c;
package openGL.Screen -- -- Models an openGL screen. -- is type Item is tagged limited private; private type Item is tagged limited record null; end record; end openGL.Screen;
----------------------------------------------------------------------- -- decompress -- Decompress file using Util.Streams.Buffered.LZMA -- Copyright (C) 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.Text_IO; with Ada.Command_Line; with Ada.Streams.Stream_IO; with Util.Streams.Files; with Util.Streams.Buffered.Lzma; procedure Decompress is procedure Decompress_File (Source : in String; Destination : in String); procedure Decompress_File (Source : in String; Destination : in String) is In_Stream : aliased Util.Streams.Files.File_Stream; Out_Stream : aliased Util.Streams.Files.File_Stream; Decompressor : aliased Util.Streams.Buffered.Lzma.Decompress_Stream; begin In_Stream.Open (Mode => Ada.Streams.Stream_IO.In_File, Name => Source); Out_Stream.Create (Mode => Ada.Streams.Stream_IO.Out_File, Name => Destination); Decompressor.Initialize (Input => In_Stream'Access, Size => 32768); Util.Streams.Copy (From => Decompressor, Into => Out_Stream); end Decompress_File; begin if Ada.Command_Line.Argument_Count /= 2 then Ada.Text_IO.Put_Line ("Usage: decompress source destination"); return; end if; Decompress_File (Source => Ada.Command_Line.Argument (1), Destination => Ada.Command_Line.Argument (2)); end Decompress;
----------------------------------------------------------------------- -- mat-readers-files -- Reader for files -- Copyright (C) 2014, 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.Streams.Stream_IO; with Util.Log.Loggers; package body MAT.Readers.Streams.Files is -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Readers.Files"); BUFFER_SIZE : constant Natural := 100 * 1024; -- ------------------------------ -- Open the file. -- ------------------------------ procedure Open (Reader : in out File_Reader_Type; Path : in String) is Stream : constant access Util.Streams.Input_Stream'Class := Reader.File'Access; begin Log.Info ("Reading data stream {0}", Path); Reader.Stream.Initialize (Size => BUFFER_SIZE, Input => Stream); Reader.File.Open (Mode => Ada.Streams.Stream_IO.In_File, Name => Path); end Open; end MAT.Readers.Streams.Files;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt with AdaBase.Interfaces.Driver; with AdaBase.Statement.Base.PostgreSQL; with AdaBase.Connection.Base.PostgreSQL; with Ada.Containers.Vectors; package AdaBase.Driver.Base.PostgreSQL is package AID renames AdaBase.Interfaces.Driver; package SMT renames AdaBase.Statement.Base.PostgreSQL; package CON renames AdaBase.Connection.Base.PostgreSQL; type PostgreSQL_Driver is new Base_Driver and AID.iDriver with private; overriding function execute (driver : PostgreSQL_Driver; sql : String) return Affected_Rows; function query (driver : PostgreSQL_Driver; sql : String) return SMT.PostgreSQL_statement; function prepare (driver : PostgreSQL_Driver; sql : String) return SMT.PostgreSQL_statement; function query_select (driver : PostgreSQL_Driver; distinct : Boolean := False; tables : String; columns : String; conditions : String := blankstring; groupby : String := blankstring; having : String := blankstring; order : String := blankstring; null_sort : Null_Priority := native; limit : Trax_ID := 0; offset : Trax_ID := 0) return SMT.PostgreSQL_statement; function prepare_select (driver : PostgreSQL_Driver; distinct : Boolean := False; tables : String; columns : String; conditions : String := blankstring; groupby : String := blankstring; having : String := blankstring; order : String := blankstring; null_sort : Null_Priority := native; limit : Trax_ID := 0; offset : Trax_ID := 0) return SMT.PostgreSQL_statement; function call_stored_procedure (driver : PostgreSQL_Driver; stored_procedure : String; proc_arguments : String) return SMT.PostgreSQL_statement; function trait_query_buffers_used (driver : PostgreSQL_Driver) return Boolean; procedure set_trait_query_buffers_used (driver : PostgreSQL_Driver; trait : Boolean); private global_statement_counter : Trax_ID := 0; type PostgreSQL_Driver is new Base_Driver and AID.iDriver with record local_connection : aliased CON.PostgreSQL_Connection; async_cmd_mode : Boolean := False; end record; overriding procedure private_connect (driver : out PostgreSQL_Driver; database : String; username : String; password : String; hostname : String := blankstring; socket : String := blankstring; port : Posix_Port := portless); function sql_assemble (distinct : Boolean := False; tables : String; columns : String; conditions : String := blankstring; groupby : String := blankstring; having : String := blankstring; order : String := blankstring; null_sort : Null_Priority := native; limit : Trax_ID := 0; offset : Trax_ID := 0) return String; function private_statement (driver : PostgreSQL_Driver; sql : String; nextsets : String := ""; prepared : Boolean) return SMT.PostgreSQL_statement; overriding procedure initialize (Object : in out PostgreSQL_Driver); end AdaBase.Driver.Base.PostgreSQL;
pragma License (Unrestricted); -- implementation unit specialized for Darwin with System.Storage_Elements; private with C.malloc.malloc; package System.Unbounded_Allocators is -- Separated storage pool for local scope. pragma Preelaborate; type Unbounded_Allocator is limited private; procedure Initialize (Object : in out Unbounded_Allocator); procedure Finalize (Object : in out Unbounded_Allocator); procedure Allocate ( Allocator : Unbounded_Allocator; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); procedure Deallocate ( Allocator : Unbounded_Allocator; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); function Allocator_Of (Storage_Address : Address) return Unbounded_Allocator; private type Unbounded_Allocator is new C.malloc.malloc.malloc_zone_t_ptr; end System.Unbounded_Allocators;
----------------------------------------------------------------------- -- net-dhcp -- DHCP client -- Copyright (C) 2016, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Real_Time; with Net.Interfaces; with Net.Buffers; with Net.Sockets.Udp; -- == DHCP Client == -- The DHCP client can be used to configure the IPv4 network stack by using -- the DHCP protocol (RFC 2131). The DHCP client uses a UDP socket on port 68 -- to send and receive DHCP messages. The DHCP client state is maintained by -- two procedures which are called asynchronously: the <tt>Process</tt> -- and <tt>Receive</tt> procedures. The <tt>Process</tt> procedure is responsible -- for sending requests to the DHCP server and to manage the timeouts used for -- the retransmissions, renewal and lease expiration. On its hand, the <tt>Receive</tt> -- procedure is called by the UDP socket layer when a DHCP packet is received. -- These two procedures are typically called from different tasks. -- -- To make the implementation simple and ready to use, the DHCP client uses a pre-defined -- configuration that should meet most requirements. The DHCP client asks for the following -- DHCP options: -- -- * Option 1: Subnetmask -- * Option 3: Router -- * Option 6: Domain name server -- * Option 12: Hostname -- * Option 15: Domain name -- * Option 26: Interface MTU size -- * Option 28: Brodcast address -- * Option 42: NTP server -- * Option 72: WWW server -- * Option 51: Lease time -- * Option 58: Renew time -- * Option 59: Rebind time -- -- It sends the following options to help the server identify the client: -- -- * Option 60: Vendor class identifier, the string "Ada Embedded Network" is sent. -- * Option 61: Client identifier, the Ethernet address is used as identifier. -- -- === Initialization === -- To use the client, one will have to declare a global aliased DHCP client instance -- (the aliased is necessary as the UDP socket layer needs to get an access to it): -- -- C : aliased Net.DHCP.Client; -- -- The DHCP client instance must then be initialized after the network interface -- is initialized. The <tt>Initialize</tt> procedure needs an access to the interface -- instance. -- -- C.Initialize (Ifnet'Access); -- -- The initialization only binds the UDP socket to the port 68 and prepares the DHCP -- state machine. At this stage, no DHCP packet is sent yet but the UDP socket is now -- able to receive them. -- -- === Processing === -- The <tt>Process</tt> procedure must be called either by a main task or by a dedicated -- task to send the DHCP requests and maintain the DHCP state machine. Each time this -- procedure is called, it looks whether some DHCP processing must be done and it computes -- a deadline that indicates the time for the next call. It is safe -- to call the <tt>Process</tt> procedure more often than required. The operation will -- perform different operations depending on the DHCP state: -- -- In the <tt>STATE_INIT</tt> state, it records the begining of the DHCP discovering state, -- switches to the <tt>STATE_SELECTING</tt> and sends the first DHCP discover packet. -- -- When the DHCP state machine is in the <tt>STATE_SELECTING</tt> state, it continues to -- send the DHCP discover packet taking into account the backoff timeout. -- -- In the <tt>STATE_REQUESTING</tt> state, it sends the DHCP request packet to the server. -- -- In the <tt>STATE_BOUND</tt> state, it configures the interface if it is not yet configured -- and it then waits for the DHCP lease renewal. If the DHCP lease must be renewed, it -- switches to the <tt>STATE_RENEWING</tt> state. -- -- [images/ada-net-dhcp.png] -- -- The DHCP client does not use any task to give you the freedom on how you want to integrate -- the DHCP client in your application. The <tt>Process</tt> procedure may be integrated in -- a loop similar to the loop below: -- -- declare -- Dhcp_Deadline : Ada.Real_Time.Time; -- begin -- loop -- C.Process (Dhcp_Deadline); -- delay until Dhcp_Deadline; -- end loop; -- end; -- -- This loop may be part of a dedicated task for the DHCP client but it may also be part -- of another task that could also handle other network house keeping (such as ARP management). -- -- === Interface Configuration === -- Once in the <tt>STATE_BOUND</tt>, the interface configuration is done by the <tt>Process</tt> -- procedure that calls the <tt>Bind</tt> procedure with the DHCP received options. -- This procedure configures the interface IP, netmask, gateway, MTU and DNS. It is possible -- to override this procedure in an application to be notified and extract other information -- from the received DHCP options. In that case, it is still important to call the overriden -- procedure so that the interface and network stack is correctly configured. -- package Net.DHCP is -- The <tt>State_Type</tt> defines the DHCP client finite state machine. type State_Type is (STATE_INIT, STATE_INIT_REBOOT, STATE_SELECTING, STATE_REQUESTING, STATE_DAD, STATE_BOUND, STATE_RENEWING, STATE_REBINDING, STATE_REBOOTING); -- Options extracted from the server response. type Options_Type is record Msg_Type : Net.Uint8; Hostname : String (1 .. 255); Hostname_Len : Natural := 0; Domain : String (1 .. 255); Domain_Len : Natural := 0; Ip : Net.Ip_Addr := (0, 0, 0, 0); Broadcast : Net.Ip_Addr := (255, 255, 255, 255); Router : Net.Ip_Addr := (0, 0, 0, 0); Netmask : Net.Ip_Addr := (255, 255, 255, 0); Server : Net.Ip_Addr := (0, 0, 0, 0); Ntp : Net.Ip_Addr := (0, 0, 0, 0); Www : Net.Ip_Addr := (0, 0, 0, 0); Dns1 : Net.Ip_Addr := (0, 0, 0, 0); Dns2 : Net.Ip_Addr := (0, 0, 0, 0); Lease_Time : Natural := 0; Renew_Time : Natural := 0; Rebind_Time : Natural := 0; Mtu : Ip_Length := 1500; end record; type Client is new Net.Sockets.Udp.Raw_Socket with private; -- Get the current DHCP client state. function Get_State (Request : in Client) return State_Type; -- Get the DHCP options that were configured during the bind process. function Get_Config (Request : in Client) return Options_Type; -- Initialize the DHCP request. procedure Initialize (Request : in out Client; Ifnet : access Net.Interfaces.Ifnet_Type'Class); -- Process the DHCP client. Depending on the DHCP state machine, proceed to the -- discover, request, renew, rebind operations. Return in <tt>Next_Call</tt> the -- deadline time before the next call. procedure Process (Request : in out Client; Next_Call : out Ada.Real_Time.Time); -- Send the DHCP discover packet to initiate the DHCP discovery process. procedure Discover (Request : in out Client) with Pre => Request.Get_State = STATE_SELECTING; -- Send the DHCP request packet after we received an offer. procedure Request (Request : in out Client) with Pre => Request.Get_State = STATE_REQUESTING; -- Check for duplicate address on the network. If we find someone else using -- the IP, send a DHCPDECLINE to the server. At the end of the DAD process, -- switch to the STATE_BOUND state. procedure Check_Address (Request : in out Client); -- Configure the IP stack and the interface after the DHCP ACK is received. -- The interface is configured to use the IP address, the ARP cache is flushed -- so that the duplicate address check can be made. procedure Configure (Request : in out Client; Ifnet : in out Net.Interfaces.Ifnet_Type'Class; Config : in Options_Type) with Pre => Request.Get_State in STATE_DAD | STATE_RENEWING | STATE_REBINDING, Post => Request.Get_State in STATE_DAD | STATE_RENEWING | STATE_REBINDING; -- Bind the interface with the DHCP configuration that was recieved by the DHCP ACK. -- This operation is called by the <tt>Process</tt> procedure when the BOUND state -- is entered. It can be overriden to perform specific actions. procedure Bind (Request : in out Client; Ifnet : in out Net.Interfaces.Ifnet_Type'Class; Config : in Options_Type) with Pre => Request.Get_State = STATE_BOUND; -- Send the DHCPDECLINE message to notify the DHCP server that we refuse the IP -- because the DAD discovered that the address is used. procedure Decline (Request : in out Client) with Pre => Request.Get_State = STATE_DAD, Post => Request.Get_State = STATE_INIT; -- Send the DHCPREQUEST in unicast to the DHCP server to renew the DHCP lease. procedure Renew (Request : in out Client) with Pre => Request.Get_State = STATE_RENEWING; -- Fill the DHCP options in the request. procedure Fill_Options (Request : in Client; Packet : in out Net.Buffers.Buffer_Type; Kind : in Net.Uint8; Mac : in Net.Ether_Addr); -- Receive the DHCP offer/ack/nak from the DHCP server and update the DHCP state machine. -- It only updates the DHCP state machine (the DHCP request are only sent by -- <tt>Process</tt>). overriding procedure Receive (Request : in out Client; From : in Net.Sockets.Sockaddr_In; Packet : in out Net.Buffers.Buffer_Type); -- Extract the DHCP options from the DHCP packet. procedure Extract_Options (Packet : in out Net.Buffers.Buffer_Type; Options : out Options_Type); -- Update the UDP header for the packet and send it. overriding procedure Send (Request : in out Client; Packet : in out Net.Buffers.Buffer_Type) with Pre => not Packet.Is_Null, Post => Packet.Is_Null; private -- Compute the next timeout according to the DHCP state. procedure Next_Timeout (Request : in out Client); type Retry_Type is new Net.Uint8 range 0 .. 5; type Backoff_Array is array (Retry_Type) of Integer; -- Timeout table used for the DHCP backoff algorithm during for DHCP DISCOVER. Backoff : constant Backoff_Array := (0, 4, 8, 16, 32, 64); -- Wait 30 seconds before starting again a DHCP discovery process after a NAK/DECLINE. DEFAULT_PAUSE_DELAY : constant Natural := 30; -- The DHCP state machine is accessed by the <tt>Process</tt> procedure to proceed to -- the DHCP discovery and re-new process. In parallel, the <tt>Receive</tt> procedure -- handles the DHCP packets received by the DHCP server and it changes the state according -- to the received packet. protected type Machine is -- Get the current state. function Get_State return State_Type; -- Set the new DHCP state. procedure Set_State (New_State : in State_Type); -- Set the DHCP options and the DHCP state to the STATE_BOUND. procedure Bind (Options : in Options_Type); -- Get the DHCP options that were configured during the bind process. function Get_Config return Options_Type; private State : State_Type := STATE_INIT; Config : Options_Type; end Machine; type Client is new Net.Sockets.Udp.Raw_Socket with record Ifnet : access Net.Interfaces.Ifnet_Type'Class; State : Machine; Current : State_Type := STATE_INIT; Mac : Net.Ether_Addr := (others => 0); Timeout : Ada.Real_Time.Time; Start_Time : Ada.Real_Time.Time; Renew_Time : Ada.Real_Time.Time; Rebind_Time : Ada.Real_Time.Time; Expire_Time : Ada.Real_Time.Time; Pause_Delay : Natural := DEFAULT_PAUSE_DELAY; Xid : Net.Uint32; Secs : Net.Uint16 := 0; Ip : Net.Ip_Addr := (others => 0); Server_Ip : Net.Ip_Addr := (others => 0); Retry : Retry_Type := 0; Configured : Boolean := False; end record; end Net.DHCP;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- I N T E R F A C E S . L E O N 3 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2006 The European Space Agency -- -- Copyright (C) 2003-2017, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ -- This package provides the appropriate mapping for the system registers. -- This is a LEON3 specific package, based on the UT699 LEON 3FT/SPARC V8 -- Micro-Processor Advanced Users Manual, dated March 2, 2009 from -- www.aeroflex.com/LEON, referenced hereafter as AUM. package Interfaces.Leon3 is pragma No_Elaboration_Code_All; pragma Preelaborate; -- Pragma Suppress_Initialization (register_type) must be used in order -- to keep eficiency. Otherwise, initialization procedures are always -- generated for objects of packed boolean array types and of record types -- that have components of these types. ---------------------------- -- Local type definitions -- ---------------------------- type Reserved_2 is array (0 .. 1) of Boolean; for Reserved_2'Size use 2; pragma Pack (Reserved_2); type Reserved_3 is array (0 .. 2) of Boolean; for Reserved_3'Size use 3; pragma Pack (Reserved_3); type Reserved_8 is array (0 .. 7) of Boolean; for Reserved_8'Size use 8; pragma Pack (Reserved_8); type Reserved_9 is array (0 .. 8) of Boolean; for Reserved_9'Size use 9; pragma Pack (Reserved_9); type Reserved_16 is array (0 .. 15) of Boolean; for Reserved_16'Size use 16; pragma Pack (Reserved_16); type Reserved_20 is array (0 .. 19) of Boolean; for Reserved_20'Size use 20; pragma Pack (Reserved_20); type Reserved_21 is array (0 .. 20) of Boolean; for Reserved_21'Size use 21; pragma Pack (Reserved_21); type Reserved_22 is array (0 .. 21) of Boolean; for Reserved_22'Size use 22; pragma Pack (Reserved_22); type Reserved_23 is array (0 .. 22) of Boolean; for Reserved_23'Size use 23; pragma Pack (Reserved_23); type Reserved_24 is array (0 .. 23) of Boolean; for Reserved_24'Size use 24; pragma Pack (Reserved_24); type Reserved_25 is array (0 .. 24) of Boolean; for Reserved_25'Size use 25; pragma Pack (Reserved_25); type Reserved_27 is array (0 .. 26) of Boolean; for Reserved_27'Size use 27; pragma Pack (Reserved_27); -- Mapping between bits in a 32-bit register as used in the hardware -- documentation and bit order as used by Ada. -- This makes it easier to verify correctness against the AUM. Ranges will -- need to be reversed, but the compiler will check this. Bit00 : constant := 31; Bit01 : constant := 30; Bit02 : constant := 29; Bit03 : constant := 28; Bit04 : constant := 27; Bit05 : constant := 26; Bit06 : constant := 25; Bit07 : constant := 24; Bit08 : constant := 23; Bit09 : constant := 22; Bit10 : constant := 21; Bit11 : constant := 20; Bit12 : constant := 19; Bit13 : constant := 18; Bit14 : constant := 17; Bit15 : constant := 16; Bit16 : constant := 15; Bit17 : constant := 14; Bit18 : constant := 13; Bit19 : constant := 12; Bit20 : constant := 11; Bit21 : constant := 10; Bit22 : constant := 09; Bit23 : constant := 08; Bit24 : constant := 7; Bit25 : constant := 06; Bit26 : constant := 05; Bit27 : constant := 4; Bit28 : constant := 03; Bit29 : constant := 02; Bit30 : constant := 1; Bit31 : constant := 00; end Interfaces.Leon3;
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Events.Controllers -- -- Game controller specific events. -------------------------------------------------------------------------------------------------------------------- with SDL.Events.Joysticks; package SDL.Events.Controllers is -- Game controller events. Axis_Motion : constant Event_Types := 16#0000_0650#; Button_Down : constant Event_Types := Axis_Motion + 1; Button_Up : constant Event_Types := Axis_Motion + 2; Device_Added : constant Event_Types := Axis_Motion + 3; Device_Removed : constant Event_Types := Axis_Motion + 4; Device_Remapped : constant Event_Types := Axis_Motion + 5; type Axes is (Invalid, Left_X, Left_Y, Right_X, Right_Y, Left_Trigger, Right_Trigger) with Convention => C; for Axes use (Invalid => -1, Left_X => 0, Left_Y => 1, Right_X => 2, Right_Y => 3, Left_Trigger => 4, Right_Trigger => 5); type Axes_Values is range -32768 .. 32767 with Convention => C, Size => 16; type Axis_Events is record Event_Type : Event_Types; -- Will be set to Axis_Motion. Time_Stamp : Time_Stamps; Which : SDL.Events.Joysticks.IDs; Axis : Axes; Padding_1 : Padding_8; Padding_2 : Padding_8; Padding_3 : Padding_8; Value : Axes_Values; Padding_4 : Padding_16; end record with Convention => C; type Buttons is (Invalid, A, B, X, Y, Back, Guide, Start, Left_Stick, Right_Stick, Left_Shoulder, Right_Shoulder, Pad_Up, -- Direction pad buttons. Pad_Down, Pad_Left, Pad_Right) with Convention => C; for Buttons use (Invalid => -1, A => 0, B => 1, X => 2, Y => 3, Back => 4, Guide => 5, Start => 6, Left_Stick => 7, Right_Stick => 8, Left_Shoulder => 9, Right_Shoulder => 10, Pad_Up => 11, Pad_Down => 12, Pad_Left => 13, Pad_Right => 14); type Button_Events is record Event_Type : Event_Types; -- Will be set to Button_Down or Button_Up. Time_Stamp : Time_Stamps; Which : SDL.Events.Joysticks.IDs; Button : Buttons; State : Button_State; Padding_1 : Padding_8; Padding_2 : Padding_8; end record with Convention => C; type Device_Events is record Event_Type : Event_Types; -- Will be set to Device_Added, Device_Removed or Device_Remapped. Time_Stamp : Time_Stamps; Which : SDL.Events.Joysticks.IDs; end record with Convention => C; private for Axis_Events use record Event_Type at 0 * SDL.Word range 0 .. 31; Time_Stamp at 1 * SDL.Word range 0 .. 31; Which at 2 * SDL.Word range 0 .. 31; Axis at 3 * SDL.Word range 0 .. 7; Padding_1 at 3 * SDL.Word range 8 .. 15; Padding_2 at 3 * SDL.Word range 16 .. 23; Padding_3 at 3 * SDL.Word range 24 .. 31; Value at 4 * SDL.Word range 0 .. 15; Padding_4 at 4 * SDL.Word range 16 .. 31; end record; for Button_Events use record Event_Type at 0 * SDL.Word range 0 .. 31; Time_Stamp at 1 * SDL.Word range 0 .. 31; Which at 2 * SDL.Word range 0 .. 31; Button at 3 * SDL.Word range 0 .. 7; State at 3 * SDL.Word range 8 .. 15; Padding_1 at 3 * SDL.Word range 16 .. 23; Padding_2 at 3 * SDL.Word range 24 .. 31; end record; for Device_Events use record Event_Type at 0 * SDL.Word range 0 .. 31; Time_Stamp at 1 * SDL.Word range 0 .. 31; Which at 2 * SDL.Word range 0 .. 31; end record; end SDL.Events.Controllers;
-- find circular dependency with Ada.Command_Line; with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Directories; with Ada.Strings.Functions; with Ada.Strings.Unbounded; with Ada.Text_IO.Iterators; procedure cirdep is use type Ada.Strings.Unbounded.Unbounded_String; procedure Usage is begin Ada.Text_IO.Put_Line ("usage: cirdep --RTS=dir"); end Usage; RTS_Dir : Ada.Strings.Unbounded.Unbounded_String; begin -- arguments for I in Ada.Command_Line.Iterate loop declare Item : constant String := Ada.Command_Line.Argument (I); begin if Item'Length > 6 and then Item (Item'First .. Item'First + 5) = "--RTS=" then RTS_Dir := +Item (Item'First + 6 .. Item'Last); else Usage; return; end if; end; end loop; if RTS_Dir = Ada.Strings.Unbounded.Null_Unbounded_String then Usage; return; end if; declare package Unit_Sets is new Ada.Containers.Indefinite_Ordered_Sets (String); use type Unit_Sets.Set; package Unit_To_Unit_Sets_Maps is new Ada.Containers.Indefinite_Ordered_Maps (String, Unit_Sets.Set); Table : Unit_To_Unit_Sets_Maps.Map; begin -- reading for E of Ada.Directories.Entries ( Ada.Directories.Compose (RTS_Dir.Constant_Reference, "adalib"), "*.ali") loop declare Name : constant String := Ada.Directories.Base_Name (Ada.Directories.Simple_Name (E)); The_Set : Unit_Sets.Set; File : Ada.Text_IO.File_Type := Ada.Text_IO.Open (Ada.Text_IO.In_File, Ada.Directories.Full_Name (E)); begin for Line of Ada.Text_IO.Iterators.Lines (File) loop if Line'Length >= 2 and then Line (Line'First .. Line'First + 1) = "D " then declare Dep_Name : constant String := Line ( Line'First + 2 .. Ada.Strings.Functions.Index_Element (Line (Line'First + 2 .. Line'Last), '.') - 1); begin if Dep_Name /= Name then Unit_Sets.Include (The_Set, Dep_Name); end if; end; end if; end loop; Ada.Text_IO.Close (File); Unit_To_Unit_Sets_Maps.Insert (Table, Name, The_Set); end; end loop; -- removing separated units for I in Table.Iterate loop declare The_Set : Unit_Sets.Set renames Table.Reference (I); J : Unit_Sets.Cursor := The_Set.First; begin while Unit_Sets.Has_Element (J) loop declare Next : constant Unit_Sets.Cursor := Unit_Sets.Next (J); Dep_Name : constant String := The_Set.Constant_Reference (J); begin if not Unit_To_Unit_Sets_Maps.Contains (Table, Dep_Name) then Unit_Sets.Delete (The_Set, J); end if; J := Next; end; end loop; end; end loop; -- searching loop declare Changed : Boolean := False; begin for I in Table.Iterate loop declare Name : constant String := Unit_To_Unit_Sets_Maps.Key (I); The_Set : Unit_Sets.Set renames Table.Reference (I); begin for J in The_Set.Iterate loop declare Dep_Name : constant String := The_Set.Constant_Reference (J); The_Grandchildren : Unit_Sets.Set renames Table.Constant_Reference (Dep_Name); begin for K in The_Grandchildren.Iterate loop declare G_Dep_Name : constant String := The_Grandchildren.Constant_Reference (K); begin if G_Dep_Name /= Name and then not The_Set.Contains (G_Dep_Name) then Unit_Sets.Include (The_Set, G_Dep_Name); Changed := True; end if; end; end loop; end; end loop; end; end loop; exit when not Changed; end; end loop; -- detecting for I in Table.Iterate loop declare Name : constant String := Unit_To_Unit_Sets_Maps.Key (I); The_Set : Unit_Sets.Set renames Table.Constant_Reference (I); begin for J in The_Set.Iterate loop declare Dep_Name : constant String := The_Set.Constant_Reference (J); begin if Unit_Sets.Contains (Table.Constant_Reference (Dep_Name), Name) then Ada.Text_IO.Put (Name); Ada.Text_IO.Put (" <=> "); Ada.Text_IO.Put (The_Set.Constant_Reference (J)); Ada.Text_IO.New_Line; end if; end; end loop; end; end loop; end; end cirdep;
-- { dg-do compile } with Renaming2_Pkg1; package Renaming2 is type T is null record; package Iter is new Renaming2_Pkg1.GP.Inner (T); end Renaming2;
-- A83009B.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 DERIVED TYPE DECLARATION IN A GENERIC -- UNIT MAY DERIVE TWO OR MORE SUBPROGRAM HOMOGRAPHS. -- CHECK THE CASES WHERE: -- 1) THE DERIVED SUBPROGRAMS BECOME HOMOGRAPHS BECAUSE OF THE -- SUBSTITUTION OF THE DERIVED TYPE FOR THE PARENT TYPE IN -- THE IMPLICIT SUBPROGRAM SPECIFICATIONS. -- 2) THE PARENT TYPE IS DECLARED IN A GENERIC INSTANCE AND -- THE INSTANCE INCLUDES TWO OR MORE DERIVABLE SUBPROGRAMS -- THAT ARE HOMOGRAPHS AS A RESULT OF THE ARGUMENTS GIVEN -- FOR THE GENERIC FORMAL-TYPE PARAMETERS. -- TEST CASES WHERE THE DERIVED TYPE DECLARATIONS ARE GIVEN IN: -- . THE VISIBLE PART OF A GENERIC PACKAGE SPECIFICATION, -- . THE PRIVATE PART OF A GENERIC PACKAGE SPECIFICATION, -- . A GENERIC PACKAGE BODY, -- . A GENERIC SUBPROGRAM BODY. -- -- HISTORY: -- DHH 09/20/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE A83009B IS TYPE ENUM IS (E1, E2, E3); GENERIC TYPE T1 IS (<>); TYPE T2 IS (<>); PACKAGE G_PACK IS TYPE PARENT IS (E1, E2, E3); PROCEDURE HP (P1 : PARENT; P2 : T1); PROCEDURE HP (P3 : PARENT; P4 : T2); FUNCTION HF (P1 : T1) RETURN PARENT; FUNCTION HF (P2 : T2) RETURN PARENT; END G_PACK; PACKAGE BODY G_PACK IS PROCEDURE HP (P1 : PARENT; P2 : T1) IS BEGIN NULL; END HP; PROCEDURE HP (P3 : PARENT; P4 : T2) IS BEGIN NULL; END HP; FUNCTION HF (P1 : T1) RETURN PARENT IS BEGIN RETURN E1; END HF; FUNCTION HF (P2 : T2) RETURN PARENT IS BEGIN RETURN E2; END HF; END G_PACK; BEGIN TEST ("A83009B", "A DERIVED TYPE DECLARATION IN A GENERIC " & "UNIT MAY DERIVE TWO OR MORE SUBPROGRAM " & "HOMOGRAPHS"); DECLARE -- SUBPROGRAMS BECOME HOMOGRAPHS BECAUSE OF SUBSTITUTION. GENERIC PACKAGE PACK2 IS TYPE CHILD1 IS PRIVATE; PACKAGE IN_PACK2 IS TYPE PARENT IS (E1, E2, E3); PROCEDURE HP (P1 : PARENT; P2 : CHILD1); PROCEDURE HP (P3 : CHILD1; P4 : PARENT); FUNCTION HF (P1 : CHILD1; P2 : PARENT) RETURN PARENT; FUNCTION HF (P3 : PARENT; P4 : CHILD1) RETURN PARENT; END IN_PACK2; USE IN_PACK2; PRIVATE TYPE CHILD1 IS NEW IN_PACK2.PARENT; -- PRIVATE PART END PACK2; -- OF SPEC. PACKAGE BODY PACK2 IS TYPE CHILD2 IS NEW CHILD1; -- VISIBLE PART OF BODY. GENERIC PACKAGE IN_BODY IS TYPE CHILD3 IS NEW CHILD1; -- VISIBLE PART OF SPEC. END IN_BODY; GENERIC PROCEDURE P; PROCEDURE P IS TYPE CHILD4 IS NEW CHILD1; -- SUBPROGRAM BODY. BEGIN NULL; END; PACKAGE BODY IN_PACK2 IS PROCEDURE HP (P1 : PARENT; P2 : CHILD1) IS BEGIN NULL; END HP; PROCEDURE HP (P3 : CHILD1; P4 : PARENT) IS BEGIN NULL; END HP; FUNCTION HF (P1 : CHILD1; P2 : PARENT) RETURN PARENT IS BEGIN RETURN E1; END HF; FUNCTION HF (P3 : PARENT; P4 : CHILD1) RETURN PARENT IS BEGIN RETURN E2; END HF; END IN_PACK2; BEGIN NULL; END PACK2; BEGIN NULL; END; DECLARE -- PARENT TYPE IN GENERIC INSTANCE HAS DERIVABLE HOMOGRAPHS. GENERIC PACKAGE PACK1 IS PACKAGE INSTANCE2 IS NEW G_PACK (CHARACTER, CHARACTER); TYPE CHILD2 IS NEW INSTANCE2.PARENT; TYPE CHILD3 IS PRIVATE; PRIVATE PACKAGE INSTANCE3 IS NEW G_PACK (ENUM, ENUM); TYPE CHILD3 IS NEW INSTANCE3.PARENT; END PACK1; GENERIC PROCEDURE P1; PROCEDURE P1 IS PACKAGE INSTANCE4 IS NEW G_PACK (BOOLEAN, BOOLEAN); TYPE CHILD4 IS NEW INSTANCE4.PARENT; BEGIN NULL; END P1; PACKAGE BODY PACK1 IS PACKAGE INSTANCE5 IS NEW G_PACK (ENUM, ENUM); TYPE CHILD5 IS NEW INSTANCE5.PARENT; END PACK1; BEGIN NULL; END; RESULT; END A83009B;
package body Ada.Characters.Conversions is use type System.UTF_Conversions.From_Status_Type; use type System.UTF_Conversions.To_Status_Type; function Is_Wide_Character (Item : Character) return Boolean is begin return Character'Pos (Item) <= 16#7f#; end Is_Wide_Character; function Is_Wide_String (Item : String) return Boolean is Last : Natural := Item'First - 1; begin while Last /= Item'Last loop declare Code : System.UTF_Conversions.UCS_4; From_State : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_8 ( Item, Last, Code, From_State); -- a check for detecting illegal sequence are omitted if System.UTF_Conversions.UCS_4'Pos (Code) > 16#10ffff# then return False; end if; end; end loop; return True; end Is_Wide_String; function Is_Character (Item : Wide_Character) return Boolean is begin return Wide_Character'Pos (Item) <= 16#7f#; end Is_Character; function Is_String (Item : Wide_String) return Boolean is pragma Unreferenced (Item); begin -- a check for detecting illegal sequence are omitted return True; end Is_String; function Is_Wide_Wide_Character (Item : Wide_Character) return Boolean is begin return Wide_Character'Pos (Item) not in 16#d800# .. 16#dfff#; end Is_Wide_Wide_Character; function Is_Character (Item : Wide_Wide_Character) return Boolean is begin return Wide_Wide_Character'Pos (Item) <= 16#7f#; end Is_Character; function Is_String (Item : Wide_Wide_String) return Boolean is pragma Unreferenced (Item); begin -- a check for detecting illegal sequence are omitted return True; end Is_String; function Is_Wide_Character (Item : Wide_Wide_Character) return Boolean is begin -- a check for detecting illegal sequence are omitted return Wide_Wide_Character'Pos (Item) <= 16#ffff#; end Is_Wide_Character; function Is_Wide_String (Item : Wide_Wide_String) return Boolean is begin for I in Item'Range loop -- a check for detecting illegal sequence are omitted if Wide_Wide_Character'Pos (Item (I)) > 16#10ffff# then return False; end if; end loop; return True; end Is_Wide_String; function To_Wide_Character ( Item : Character; Substitute : Wide_Character := ' ') return Wide_Character is begin if Is_Wide_Character (Item) then return Wide_Character'Val (Character'Pos (Item)); else return Substitute; end if; end To_Wide_Character; function To_Wide_Wide_Character ( Item : Character; Substitute : Wide_Wide_Character := ' ') return Wide_Wide_Character is begin if Is_Wide_Wide_Character (Item) then return Wide_Wide_Character'Val (Character'Pos (Item)); else return Substitute; end if; end To_Wide_Wide_Character; function To_Wide_Wide_Character ( Item : Wide_Character; Substitute : Wide_Wide_Character := ' ') return Wide_Wide_Character is begin if Is_Wide_Wide_Character (Item) then return Wide_Wide_Character'Val (Wide_Character'Pos (Item)); else return Substitute; end if; end To_Wide_Wide_Character; function To_Character ( Item : Wide_Character; Substitute : Character := ' ') return Character is begin if Is_Character (Item) then return Character'Val (Wide_Character'Pos (Item)); else return Substitute; end if; end To_Character; function To_String ( Item : Wide_String; Substitute : Character := ' ') return String is begin return To_String (Item, Substitute => (1 => Substitute)); end To_String; function To_Character ( Item : Wide_Wide_Character; Substitute : Character := ' ') return Character is begin if Is_Character (Item) then return Character'Val (Wide_Wide_Character'Pos (Item)); else return Substitute; end if; end To_Character; function To_String ( Item : Wide_Wide_String; Substitute : Character := ' ') return String is begin return To_String (Item, Substitute => (1 => Substitute)); end To_String; function To_Wide_Character ( Item : Wide_Wide_Character; Substitute : Wide_Character := ' ') return Wide_Character is begin if Is_Wide_Character (Item) then return Wide_Character'Val (Wide_Wide_Character'Pos (Item)); else return Substitute; end if; end To_Wide_Character; function To_Wide_String ( Item : Wide_Wide_String; Substitute : Wide_Character := ' ') return Wide_String is begin return To_Wide_String (Item, Substitute => (1 => Substitute)); end To_Wide_String; procedure Get ( Item : String; Last : out Natural; Value : out Wide_Wide_Character; Substitute : Wide_Wide_Character := ' ') is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_8 ( Item, Last, Code, From_Status); if From_Status /= System.UTF_Conversions.Success then Value := Substitute; else Value := Wide_Wide_Character'Val (Code); end if; end Get; procedure Get ( Item : String; Last : out Natural; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean) is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_8 ( Item, Last, Code, From_Status); Value := Wide_Wide_Character'Val (Code); Is_Illegal_Sequence := From_Status /= System.UTF_Conversions.Success; end Get; procedure Get_Reverse ( Item : String; First : out Positive; Value : out Wide_Wide_Character; Substitute : Wide_Wide_Character := ' ') is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_8_Reverse ( Item, First, Code, From_Status); if From_Status /= System.UTF_Conversions.Success then Value := Substitute; else Value := Wide_Wide_Character'Val (Code); end if; end Get_Reverse; procedure Get_Reverse ( Item : String; First : out Positive; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean) is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_8_Reverse ( Item, First, Code, From_Status); Value := Wide_Wide_Character'Val (Code); Is_Illegal_Sequence := From_Status /= System.UTF_Conversions.Success; end Get_Reverse; procedure Get ( Item : Wide_String; Last : out Natural; Value : out Wide_Wide_Character; Substitute : Wide_Wide_Character := ' ') is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_16 ( Item, Last, Code, From_Status); if From_Status /= System.UTF_Conversions.Success then Value := Substitute; else Value := Wide_Wide_Character'Val (Code); end if; end Get; procedure Get ( Item : Wide_String; Last : out Natural; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean) is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_16 ( Item, Last, Code, From_Status); Value := Wide_Wide_Character'Val (Code); Is_Illegal_Sequence := From_Status /= System.UTF_Conversions.Success; end Get; procedure Get_Reverse ( Item : Wide_String; First : out Positive; Value : out Wide_Wide_Character; Substitute : Wide_Wide_Character := ' ') is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_16_Reverse ( Item, First, Code, From_Status); if From_Status /= System.UTF_Conversions.Success then Value := Substitute; else Value := Wide_Wide_Character'Val (Code); end if; end Get_Reverse; procedure Get_Reverse ( Item : Wide_String; First : out Positive; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean) is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_16_Reverse ( Item, First, Code, From_Status); Value := Wide_Wide_Character'Val (Code); Is_Illegal_Sequence := From_Status /= System.UTF_Conversions.Success; end Get_Reverse; procedure Get ( Item : Wide_Wide_String; Last : out Natural; Value : out Wide_Wide_Character; Substitute : Wide_Wide_Character := ' ') is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_32 ( Item, Last, Code, From_Status); if From_Status /= System.UTF_Conversions.Success then Value := Substitute; else Value := Wide_Wide_Character'Val (Code); end if; end Get; procedure Get ( Item : Wide_Wide_String; Last : out Natural; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean) is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_32 ( Item, Last, Code, From_Status); Value := Wide_Wide_Character'Val (Code); Is_Illegal_Sequence := From_Status /= System.UTF_Conversions.Success; end Get; procedure Get_Reverse ( Item : Wide_Wide_String; First : out Positive; Value : out Wide_Wide_Character; Substitute : Wide_Wide_Character := ' ') is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_32_Reverse ( Item, First, Code, From_Status); if From_Status /= System.UTF_Conversions.Success then Value := Substitute; else Value := Wide_Wide_Character'Val (Code); end if; end Get_Reverse; procedure Get_Reverse ( Item : Wide_Wide_String; First : out Positive; Value : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean) is Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; begin System.UTF_Conversions.From_UTF_32_Reverse ( Item, First, Code, From_Status); Value := Wide_Wide_Character'Val (Code); Is_Illegal_Sequence := From_Status /= System.UTF_Conversions.Success; end Get_Reverse; procedure Put ( Value : Wide_Wide_Character; Item : out String; Last : out Natural) is To_Status : System.UTF_Conversions.To_Status_Type; begin System.UTF_Conversions.To_UTF_8 ( Wide_Wide_Character'Pos (Value), Item, Last, To_Status); if To_Status /= System.UTF_Conversions.Success then raise Constraint_Error; -- Strings.Length_Error ??? end if; end Put; procedure Put ( Value : Wide_Wide_Character; Item : out Wide_String; Last : out Natural) is To_Status : System.UTF_Conversions.To_Status_Type; begin System.UTF_Conversions.To_UTF_16 ( Wide_Wide_Character'Pos (Value), Item, Last, To_Status); if To_Status /= System.UTF_Conversions.Success then raise Constraint_Error; end if; end Put; procedure Put ( Value : Wide_Wide_Character; Item : out Wide_Wide_String; Last : out Natural) is To_Status : System.UTF_Conversions.To_Status_Type; begin System.UTF_Conversions.To_UTF_32 ( Wide_Wide_Character'Pos (Value), Item, Last, To_Status); if To_Status /= System.UTF_Conversions.Success then raise Constraint_Error; end if; end Put; end Ada.Characters.Conversions;
package Return2 is type Kind_T is (One, Two); type T is array (Kind_T) of Boolean; type Result_Internal_T (Member : Boolean := False) is record case Member is when True => Data : Kind_T := Kind_T'First; when False => null; end case; end record; function Value (Img : String) return T; end Return2;