content
stringlengths
23
1.05M
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <contact@flyx.org> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with System; with Interfaces.C.Pointers; with Ada.Unchecked_Deallocation; with GL.Low_Level.Enums; with GL.Objects.Buffers; with GL.Objects.Shaders; with GL.Pixels.Extensions; with GL.Types.Pointers; package GL.Objects.Textures is pragma Preelaborate; package LE renames Low_Level.Enums; package PE renames Pixels.Extensions; use all type LE.Texture_Kind; type Dimension_Count is (One, Two, Three); function Get_Dimensions (Kind : LE.Texture_Kind) return Dimension_Count; function Maximum_Anisotropy return Single with Post => Maximum_Anisotropy'Result >= 16.0; ----------------------------------------------------------------------------- -- Basic Types -- ----------------------------------------------------------------------------- type Minifying_Function is (Nearest, Linear, Nearest_Mipmap_Nearest, Linear_Mipmap_Nearest, Nearest_Mipmap_Linear, Linear_Mipmap_Linear); -- Has to be defined here because of following subtype declaration. for Minifying_Function use (Nearest => 16#2600#, Linear => 16#2601#, Nearest_Mipmap_Nearest => 16#2700#, Linear_Mipmap_Nearest => 16#2701#, Nearest_Mipmap_Linear => 16#2702#, Linear_Mipmap_Linear => 16#2703#); for Minifying_Function'Size use Int'Size; subtype Magnifying_Function is Minifying_Function range Nearest .. Linear; type Wrapping_Mode is (Repeat, Clamp_To_Border, Clamp_To_Edge, Mirrored_Repeat, Mirror_Clamp_To_Edge); -- Actual range is implementation-defined -- -- - OpenGL 2.x: At least 2 -- - OpenGL 3.x: At least 48 -- - OpenGL 4.x: At least 80 subtype Texture_Unit is UInt; subtype Image_Unit is UInt; subtype Mipmap_Level is Size; ----------------------------------------------------------------------------- -- Texture Objects -- ----------------------------------------------------------------------------- type Texture_Base (Kind : LE.Texture_Kind) is abstract new GL_Object with private; function Has_Levels (Object : Texture_Base) return Boolean is (Object.Kind not in Texture_Buffer | Texture_Rectangle | Texture_2D_Multisample | Texture_2D_Multisample_Array) with Inline; function Layered (Object : Texture_Base) return Boolean is (Object.Kind in Texture_1D_Array | Texture_2D_Array | Texture_3D | Texture_Cube_Map | Texture_Cube_Map_Array | Texture_2D_Multisample_Array) with Inline; overriding procedure Initialize_Id (Object : in out Texture_Base); overriding procedure Delete_Id (Object : in out Texture_Base); overriding function Identifier (Object : Texture_Base) return Types.Debug.Identifier is (Types.Debug.Texture); procedure Invalidate_Image (Object : Texture_Base; Level : Mipmap_Level) with Pre => (if not Object.Has_Levels then Level = 0); procedure Invalidate_Sub_Image (Object : Texture_Base; Level : Mipmap_Level; X, Y, Z : Int; Width, Height, Depth : Size) with Pre => (if not Object.Has_Levels then Level = 0); procedure Bind_Texture_Unit (Object : Texture_Base; Unit : Texture_Unit); procedure Bind_Image_Texture (Object : Texture_Base; Unit : Image_Unit); ----------------------------------------------------------------------------- type Texture is new Texture_Base with private; function Dimensions (Object : Texture) return Dimension_Count; function Allocated (Object : Texture) return Boolean; procedure Clear_Using_Data (Object : Texture; Level : Mipmap_Level; Source_Format : Pixels.Format; Source_Type : Pixels.Data_Type; Source : System.Address) with Pre => not Object.Compressed; procedure Clear_Using_Zeros (Object : Texture; Level : Mipmap_Level) with Pre => not Object.Compressed; procedure Generate_Mipmap (Object : Texture) with Pre => Object.Has_Levels; ----------------------------------------------------------------------------- generic Kind : LE.Texture_Kind; package Texture_Bindings is type Texture_Array is array (Texture_Unit range <>) of Texture (Kind); type Image_Array is array (Image_Unit range <>) of Texture (Kind); procedure Bind_Textures (Textures : Texture_Array); procedure Bind_Images (Images : Image_Array); end Texture_Bindings; ----------------------------------------------------------------------------- -- Texture Parameters -- ----------------------------------------------------------------------------- procedure Set_Lowest_Mipmap_Level (Object : Texture; Level : Mipmap_Level); procedure Set_Highest_Mipmap_Level (Object : Texture; Level : Mipmap_Level); function Lowest_Mipmap_Level (Object : Texture) return Mipmap_Level; function Highest_Mipmap_Level (Object : Texture) return Mipmap_Level; function Mipmap_Levels (Object : Texture) return Mipmap_Level with Pre => Object.Allocated, Post => Mipmap_Levels'Result >= 1; ----------------------------------------------------------------------------- function Internal_Format (Object : Texture) return Pixels.Internal_Format with Pre => Object.Allocated and not Object.Compressed; function Compressed_Format (Object : Texture) return Pixels.Compressed_Format with Pre => Object.Allocated and Object.Compressed; function Compressed (Object : Texture) return Boolean; function Samples (Object : Texture) return Size; function Fixed_Sample_Locations (Object : Texture) return Boolean with Pre => Object.Kind in Texture_2D_Multisample | Texture_2D_Multisample_Array; ----------------------------------------------------------------------------- -- Texture Level Parameters -- ----------------------------------------------------------------------------- function Width (Object : Texture; Level : Mipmap_Level) return Size; function Height (Object : Texture; Level : Mipmap_Level) return Size; function Depth (Object : Texture; Level : Mipmap_Level) return Size; function Compressed_Image_Size (Object : Texture; Level : Mipmap_Level) return Size with Pre => Object.Compressed; ----------------------------------------------------------------------------- -- Texture Units -- ----------------------------------------------------------------------------- function Texture_Unit_Count return Natural; -- Return the maximum combined number of texture image units available -- to all shaders -- -- If a texture image unit is used by multiple shaders, each shader stage -- is counted separately. function Texture_Unit_Count (Shader : Shaders.Shader_Type) return Natural; -- Return the maximum number of texture image units available for -- the specified shader ----------------------------------------------------------------------------- -- Buffer Texture Loading -- ----------------------------------------------------------------------------- type Buffer_Texture is new Texture_Base (Kind => Texture_Buffer) with private; procedure Attach_Buffer (Object : Buffer_Texture; Internal_Format : Pixels.Internal_Format_Buffer_Texture; Buffer : Objects.Buffers.Buffer); procedure Attach_Buffer (Object : Buffer_Texture; Internal_Format : Pixels.Internal_Format_Buffer_Texture; Buffer : Objects.Buffers.Buffer; Offset, Size : Types.Size); function Buffer_Offset (Object : Buffer_Texture) return Size; function Buffer_Size (Object : Buffer_Texture) return Size; ----------------------------------------------------------------------------- -- Texture Loading -- ----------------------------------------------------------------------------- procedure Allocate_Storage (Object : in out Texture; Levels, Samples : Types.Size; Format : Pixels.Internal_Format; Width, Height, Depth : Types.Size; Fixed_Locations : Boolean := True) with Pre => not Object.Allocated, Post => Object.Allocated; procedure Allocate_Storage (Object : in out Texture; Levels, Samples : Types.Size; Format : Pixels.Compressed_Format; Width, Height, Depth : Types.Size; Fixed_Locations : Boolean := True) with Pre => not Object.Allocated and Object.Kind /= Texture_Rectangle, Post => Object.Allocated; procedure Allocate_Storage (Object : in out Texture; Subject : Texture; Fixed_Locations : Boolean := True) with Pre => not Object.Allocated and Subject.Allocated, Post => Object.Allocated; -- Allocate storage using the same format, mipmap levels, samples, and -- dimensions of the given texture procedure Load_From_Data (Object : Texture; Level : Mipmap_Level; X, Y, Z : Types.Size := 0; Width, Height, Depth : Types.Positive_Size; Source_Format : Pixels.Format; Source_Type : Pixels.Data_Type; Source : System.Address) with Pre => Object.Allocated and not Object.Compressed; -- Load data to allocated texture -- -- Data is considered to be packed. When loading it to a texture, -- it will be unpacked. Therefore, each row in bytes must be a multiple -- of the current unpack alignment. Call Set_Unpack_Alignment if necessary. procedure Load_From_Data (Object : Texture; Level : Mipmap_Level; X, Y, Z : Types.Size := 0; Width, Height, Depth : Types.Positive_Size; Source_Format : Pixels.Compressed_Format; Image_Size : Types.Size; Source : System.Address) with Pre => Object.Dimensions /= One and Object.Allocated and Object.Compressed; procedure Copy_Data (Object : Texture; Subject : Texture; Source_Level, Target_Level : Mipmap_Level) with Pre => Object.Allocated and Subject.Allocated; procedure Copy_Sub_Data (Object : Texture; Subject : Texture; Source_Level, Target_Level : Mipmap_Level; Source_X, Source_Y, Source_Z : Types.Size := 0; Target_X, Target_Y, Target_Z : Types.Size := 0; Width, Height, Depth : Types.Size) with Pre => Object.Allocated and Subject.Allocated; procedure Clear_Using_Data (Object : Texture; Level : Mipmap_Level; X, Y, Z : Types.Size := 0; Width, Height, Depth : Types.Positive_Size; Source_Format : Pixels.Format; Source_Type : Pixels.Data_Type; Source : System.Address) with Pre => not Object.Compressed; procedure Clear_Using_Zeros (Object : Texture; Level : Mipmap_Level; X, Y, Z : Types.Size := 0; Width, Height, Depth : Types.Positive_Size) with Pre => not Object.Compressed; ----------------------------------------------------------------------------- function Get_Compressed_Data (Object : Texture; Level : Mipmap_Level; X, Y, Z : Types.Size := 0; Width, Height, Depth : Types.Positive_Size; Format : Pixels.Compressed_Format) return not null Types.Pointers.UByte_Array_Access with Pre => Object.Dimensions /= One and Object.Allocated and Object.Compressed and Object.Kind not in Texture_2D_Multisample | Texture_2D_Multisample_Array; generic with package Pointers is new Interfaces.C.Pointers (<>); package Texture_Pointers is type Element_Array_Access is access Pointers.Element_Array; procedure Free is new Ada.Unchecked_Deallocation (Object => Pointers.Element_Array, Name => Element_Array_Access); function Get_Data (Object : Texture; Level : Mipmap_Level; X, Y, Z : Types.Size := 0; Width, Height, Depth : Types.Positive_Size; Format : Pixels.Format; Data_Type : PE.Non_Packed_Data_Type) return not null Element_Array_Access with Pre => Object.Allocated and not Object.Compressed and PE.Compatible (Format, Data_Type); end Texture_Pointers; ----------------------------------------------------------------------------- -- Texture Views -- ----------------------------------------------------------------------------- function Create_View (Object : Texture; Kind : LE.Texture_Kind; Format : Pixels.Internal_Format; Min_Level, Levels : Mipmap_Level; Min_Layer, Layers : Size) return Texture with Pre => Object.Allocated; -- Create a Texture object that shares some of the original texture's data -- -- The format and kind must be compatible with the original texture. See -- the OpenGL documentation. function Create_View (Object : Texture; Kind : LE.Texture_Kind; Format : Pixels.Compressed_Format; Min_Level, Levels : Mipmap_Level; Min_Layer, Layers : Size) return Texture with Pre => Object.Allocated; -- Create a Texture object that shares some of the original texture's data -- -- The format and kind must be compatible with the original texture. See -- the OpenGL documentation. function Create_View (Object : Texture; Kind : LE.Texture_Kind; Layer : Size) return Texture with Pre => Object.Allocated and Object.Layered; -- Create a Texture object that shares one layer or six layer-faces -- of the original texture's data private for Wrapping_Mode use (Repeat => 16#2901#, Clamp_To_Border => 16#812D#, Clamp_To_Edge => 16#812F#, Mirrored_Repeat => 16#8370#, Mirror_Clamp_To_Edge => 16#8743#); for Wrapping_Mode'Size use Int'Size; type Texture_Base (Kind : LE.Texture_Kind) is new GL_Object with null record; type Texture is new Texture_Base with record Allocated : Boolean := False; Dimensions : Dimension_Count := Get_Dimensions (Texture.Kind); end record; type Buffer_Texture is new Texture_Base (Kind => Texture_Buffer) with null record; end GL.Objects.Textures;
package body Bounded_Stack with SPARK_Mode is procedure Push (S : in out Stack; E : Element_Type) is begin S.Content (S.Top + 1) := E; S.Top := S.Top + 1; end Push; procedure Pop (S : in out Stack; E : out Element_Type) is begin E := S.Content (S.Top); S.Top := S.Top - 1; end Pop; end Bounded_Stack;
pragma License (Unrestricted); -- implementation unit required by compiler with System.Storage_Elements; package System.Boolean_Array_Operations is pragma Pure; -- required for "not" unpacked boolean array by compiler (s-boarop.ads) procedure Vector_Not ( R, X : Address; Length : Storage_Elements.Storage_Count); -- required for "and" unpacked boolean arrays by compiler (s-boarop.ads) procedure Vector_And ( R, X, Y : Address; Length : Storage_Elements.Storage_Count); -- required for "or" unpacked boolean arrays by compiler (s-boarop.ads) procedure Vector_Or ( R, X, Y : Address; Length : Storage_Elements.Storage_Count); -- required for "xor" unpacked boolean arrays by compiler (s-boarop.ads) procedure Vector_Xor ( R, X, Y : Address; Length : Storage_Elements.Storage_Count); -- required by compiler ??? (s-boarop.ads) -- procedure Vector_Nand ( -- R, X, Y : Address; -- Length : Storage_Elements.Storage_Count); -- procedure Vector_Nor ( -- R, X, Y : Address; -- Length : Storage_Elements.Storage_Count); -- procedure Vector_Nxor ( -- R, X, Y : Address; -- Length : Storage_Elements.Storage_Count); end System.Boolean_Array_Operations;
----------------------------------------------------------------------- -- locales.tests -- Unit tests for locales -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; package body Util.Locales.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Locales"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Locales.Get_Locale", Test_Get_Locale'Access); Caller.Add_Test (Suite, "Test Util.Locales.Get_Language", Test_Get_Locale'Access); Caller.Add_Test (Suite, "Test Util.Locales.Get_Country", Test_Get_Locale'Access); Caller.Add_Test (Suite, "Test Util.Locales.Get_Variant", Test_Get_Locale'Access); Caller.Add_Test (Suite, "Test Util.Locales.Hash", Test_Hash_Locale'Access); Caller.Add_Test (Suite, "Test Util.Locales.=", Test_Compare_Locale'Access); Caller.Add_Test (Suite, "Test Util.Locales.Locales", Test_Get_Locales'Access); end Add_Tests; procedure Test_Get_Locale (T : in out Test) is Loc : Locale; begin Loc := Get_Locale ("en"); Assert_Equals (T, "en", Get_Language (Loc), "Invalid language"); Assert_Equals (T, "", Get_Country (Loc), "Invalid country"); Assert_Equals (T, "", Get_Variant (Loc), "Invalid variant"); Loc := Get_Locale ("ja", "JP", "JP"); Assert_Equals (T, "ja", Get_Language (Loc), "Invalid language"); Assert_Equals (T, "JP", Get_Country (Loc), "Invalid country"); Assert_Equals (T, "JP", Get_Variant (Loc), "Invalid variant"); Loc := Get_Locale ("no", "NO", "NY"); Assert_Equals (T, "no", Get_Language (Loc), "Invalid language"); Assert_Equals (T, "NO", Get_Country (Loc), "Invalid country"); Assert_Equals (T, "NY", Get_Variant (Loc), "Invalid variant"); end Test_Get_Locale; procedure Test_Hash_Locale (T : in out Test) is use type Ada.Containers.Hash_Type; begin T.Assert (Hash (FRANCE) /= Hash (FRENCH), "Hash should be different"); T.Assert (Hash (FRANCE) /= Hash (ENGLISH), "Hash should be different"); T.Assert (Hash (FRENCH) /= Hash (ENGLISH), "Hash should be different"); end Test_Hash_Locale; procedure Test_Compare_Locale (T : in out Test) is begin T.Assert (FRANCE /= FRENCH, "Equality"); T.Assert (FRANCE = FRANCE, "Equality"); T.Assert (FRANCE = Get_Locale ("fr", "FR"), "Equality"); T.Assert (FRANCE /= ENGLISH, "Equality"); T.Assert (FRENCH /= ENGLISH, "Equaliy"); end Test_Compare_Locale; procedure Test_Get_Locales (T : in out Test) is begin for I in Locales'Range loop declare Language : constant String := Get_Language (Locales (I)); Country : constant String := Get_Country (Locales (I)); Variant : constant String := Get_Variant (Locales (I)); Loc : constant Locale := Get_Locale (Language, Country, Variant); Name : constant String := To_String (Loc); begin T.Assert (Loc = Locales (I), "Invalid locale at " & Positive'Image (I) & " " & Loc.all); if Variant'Length > 0 then Assert_Equals (T, Name, Language & "_" & Country & "_" & Variant, "Invalid To_String"); elsif Country'Length > 0 then Assert_Equals (T, Name, Language & "_" & Country, "Invalid To_String"); else Assert_Equals (T, Name, Language, "Invalid To_String"); end if; end; end loop; end Test_Get_Locales; end Util.Locales.Tests;
pragma Warnings (Off); with SDL; with SDL.RWops; with SDL.Types; with SDL.Mutex; with SDL.Video; with SDL.Active; with SDL.Keysym; with SDL.Keyboard; with SDL.Mouse; with SDL.Joystick; with SDL.Events; with SDL.Error; with SDL.Byteorder; with SDL.Byteorder.Extra; with SDL.Audio; with SDL.Audio.Extra; with SDL.Quit; with SDL.Version; with SDL.Timer; with SDL.Thread; with SDL.Cdrom; with Lib_C; procedure Make is begin null; end Make;
-- { dg-do compile } package Unchecked_Union2 is type Small_Int is range 0 .. 2**19 - 1; type R1 (B : Boolean := True) is record case B is when True => Data1 : Small_Int; when False => Data2 : Small_Int; end case; end record; for R1 use record Data1 at 0 range 0 .. 18; Data2 at 0 range 0 .. 18; end record; for R1'Size use 24; pragma Unchecked_Union (R1); type R2 is record Data : R1; end record; for R2 use record Data at 0 range 3 .. 26; end record; end Unchecked_Union2;
----------------------------------------------------------------------- -- Logs -- Utility Log Package -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- The <b>Util.Log</b> package provides a simple logging framework inspired -- from the Java Log4j library. package Util.Log is pragma Preelaborate; subtype Level_Type is Natural; FATAL_LEVEL : constant Level_Type := 0; ERROR_LEVEL : constant Level_Type := 5; WARN_LEVEL : constant Level_Type := 7; INFO_LEVEL : constant Level_Type := 10; DEBUG_LEVEL : constant Level_Type := 20; -- Get the log level name. function Get_Level_Name (Level : Level_Type) return String; -- Get the log level from the property value function Get_Level (Value : in String; Default : in Level_Type := INFO_LEVEL) return Level_Type; end Util.Log;
-- { dg-do compile } -- { dg-options "-O -fdump-tree-optimized" } procedure Loop_Optimization20 is type Array_T is array (Positive range <>) of Integer; type Obj_T (Length : Natural) is record Elements : Array_T (1 .. Length); end record; type T is access Obj_T; function Is_Null (S1 : Obj_T) return Boolean; pragma No_Inline (Is_Null); function Is_Null (S1 : Obj_T) return Boolean is begin for I in 1 .. S1.Length loop if S1.Elements (I) /= 0 then return False; end if; end loop; return True; end; A : T := new Obj_T'(Length => 10, Elements => (others => 0)); begin if not Is_Null (A.all) then raise Program_Error; end if; end; -- { dg-final { scan-tree-dump-not "Index_Check" "optimized" } }
-- This package has been generated automatically by GNATtest. -- You are allowed to add your code to the bodies of test routines. -- Such changes will be kept during further regeneration of this file. -- All code placed outside of test routine bodies will be lost. The -- code intended to set up and tear down the test environment should be -- placed into Tk.TtkLabelFrame.Ttk_Label_Frame_Options_Test_Data. with AUnit.Assertions; use AUnit.Assertions; with System.Assertions; -- begin read only -- id:2.2/00/ -- -- This section can be used to add with clauses if necessary. -- -- end read only with Ada.Environment_Variables; use Ada.Environment_Variables; -- begin read only -- end read only package body Tk.TtkLabelFrame.Ttk_Label_Frame_Options_Test_Data .Ttk_Label_Frame_Options_Tests is -- begin read only -- id:2.2/01/ -- -- This section can be used to add global variables and other elements. -- -- end read only -- begin read only -- end read only -- begin read only procedure Wrap_Test_Configure_0076be_459bf9 (Frame_Widget: Ttk_Label_Frame; Options: Ttk_Label_Frame_Options) is begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-ttklabelframe.ads:0):Test_Configure_TtkLabelFrame test requirement violated"); end; GNATtest_Generated.GNATtest_Standard.Tk.TtkLabelFrame.Configure (Frame_Widget, Options); begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-ttklabelframe.ads:0:):Test_Configure_TtkLabelFrame test commitment violated"); end; end Wrap_Test_Configure_0076be_459bf9; -- end read only -- begin read only procedure Test_Configure_test_configure_ttklabelframe (Gnattest_T: in out Test_Ttk_Label_Frame_Options); procedure Test_Configure_0076be_459bf9 (Gnattest_T: in out Test_Ttk_Label_Frame_Options) renames Test_Configure_test_configure_ttklabelframe; -- id:2.2/0076be6725db0897/Configure/1/0/test_configure_ttklabelframe/ procedure Test_Configure_test_configure_ttklabelframe (Gnattest_T: in out Test_Ttk_Label_Frame_Options) is procedure Configure (Frame_Widget: Ttk_Label_Frame; Options: Ttk_Label_Frame_Options) renames Wrap_Test_Configure_0076be_459bf9; -- end read only pragma Unreferenced(Gnattest_T); Frame: Ttk_Label_Frame; Options: Ttk_Label_Frame_Options; begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Create (Frame, ".myframe", Ttk_Label_Frame_Options'(Relief => RAISED, others => <>)); Configure (Frame, Ttk_Label_Frame_Options'(Relief => SOLID, others => <>)); Options := Get_Options(Frame); Assert (Options.Relief = SOLID, "Failed to set options for Ttk labelframe."); Destroy(Frame); -- begin read only end Test_Configure_test_configure_ttklabelframe; -- end read only -- begin read only function Wrap_Test_Create_32e405_465c74 (Path_Name: Tk_Path_String; Options: Ttk_Label_Frame_Options; Interpreter: Tcl_Interpreter := Get_Interpreter) return Ttk_Label_Frame is begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-ttklabelframe.ads:0):Test_Create_TtkLabelFrame1 test requirement violated"); end; declare Test_Create_32e405_465c74_Result: constant Ttk_Label_Frame := GNATtest_Generated.GNATtest_Standard.Tk.TtkLabelFrame.Create (Path_Name, Options, Interpreter); begin begin pragma Assert(Test_Create_32e405_465c74_Result /= Null_Widget); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-ttklabelframe.ads:0:):Test_Create_TtkLabelFrame1 test commitment violated"); end; return Test_Create_32e405_465c74_Result; end; end Wrap_Test_Create_32e405_465c74; -- end read only -- begin read only procedure Test_1_Create_test_create_ttklabelframe1 (Gnattest_T: in out Test_Ttk_Label_Frame_Options); procedure Test_Create_32e405_465c74 (Gnattest_T: in out Test_Ttk_Label_Frame_Options) renames Test_1_Create_test_create_ttklabelframe1; -- id:2.2/32e405543423d7b8/Create/1/0/test_create_ttklabelframe1/ procedure Test_1_Create_test_create_ttklabelframe1 (Gnattest_T: in out Test_Ttk_Label_Frame_Options) is function Create (Path_Name: Tk_Path_String; Options: Ttk_Label_Frame_Options; Interpreter: Tcl_Interpreter := Get_Interpreter) return Ttk_Label_Frame renames Wrap_Test_Create_32e405_465c74; -- end read only pragma Unreferenced(Gnattest_T); Frame: Ttk_Label_Frame; begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Frame := Create(".myframe", Ttk_Label_Frame_Options'(others => <>)); Assert (Frame /= Null_Widget, "Failed to create a new Ttk labelframe with function."); Destroy(Frame); -- begin read only end Test_1_Create_test_create_ttklabelframe1; -- end read only -- begin read only procedure Wrap_Test_Create_ebbdc1_d1ec6f (Frame_Widget: out Ttk_Label_Frame; Path_Name: Tk_Path_String; Options: Ttk_Label_Frame_Options; Interpreter: Tcl_Interpreter := Get_Interpreter) is begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-ttklabelframe.ads:0):Test_Create_TtkLabelFrame2 test requirement violated"); end; GNATtest_Generated.GNATtest_Standard.Tk.TtkLabelFrame.Create (Frame_Widget, Path_Name, Options, Interpreter); begin pragma Assert(Frame_Widget /= Null_Widget); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-ttklabelframe.ads:0:):Test_Create_TtkLabelFrame2 test commitment violated"); end; end Wrap_Test_Create_ebbdc1_d1ec6f; -- end read only -- begin read only procedure Test_2_Create_test_create_ttklabelframe2 (Gnattest_T: in out Test_Ttk_Label_Frame_Options); procedure Test_Create_ebbdc1_d1ec6f (Gnattest_T: in out Test_Ttk_Label_Frame_Options) renames Test_2_Create_test_create_ttklabelframe2; -- id:2.2/ebbdc1934f0fa33d/Create/0/0/test_create_ttklabelframe2/ procedure Test_2_Create_test_create_ttklabelframe2 (Gnattest_T: in out Test_Ttk_Label_Frame_Options) is procedure Create (Frame_Widget: out Ttk_Label_Frame; Path_Name: Tk_Path_String; Options: Ttk_Label_Frame_Options; Interpreter: Tcl_Interpreter := Get_Interpreter) renames Wrap_Test_Create_ebbdc1_d1ec6f; -- end read only pragma Unreferenced(Gnattest_T); Frame: Ttk_Label_Frame; begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Create(Frame, ".myframe", Ttk_Label_Frame_Options'(others => <>)); Assert (Frame /= Null_Widget, "Failed to create a new Ttk labelframe with procedure."); Destroy(Frame); -- begin read only end Test_2_Create_test_create_ttklabelframe2; -- end read only -- begin read only function Wrap_Test_Get_Options_ded36e_39fa14 (Frame_Widget: Ttk_Label_Frame) return Ttk_Label_Frame_Options is begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "req_sloc(tk-ttklabelframe.ads:0):Test_Get_Options_TtkLabelFrame test requirement violated"); end; declare Test_Get_Options_ded36e_39fa14_Result: constant Ttk_Label_Frame_Options := GNATtest_Generated.GNATtest_Standard.Tk.TtkLabelFrame.Get_Options (Frame_Widget); begin begin pragma Assert(True); null; exception when System.Assertions.Assert_Failure => AUnit.Assertions.Assert (False, "ens_sloc(tk-ttklabelframe.ads:0:):Test_Get_Options_TtkLabelFrame test commitment violated"); end; return Test_Get_Options_ded36e_39fa14_Result; end; end Wrap_Test_Get_Options_ded36e_39fa14; -- end read only -- begin read only procedure Test_Get_Options_test_get_options_ttklabelframe (Gnattest_T: in out Test_Ttk_Label_Frame_Options); procedure Test_Get_Options_ded36e_39fa14 (Gnattest_T: in out Test_Ttk_Label_Frame_Options) renames Test_Get_Options_test_get_options_ttklabelframe; -- id:2.2/ded36e34d54c20f9/Get_Options/1/0/test_get_options_ttklabelframe/ procedure Test_Get_Options_test_get_options_ttklabelframe (Gnattest_T: in out Test_Ttk_Label_Frame_Options) is function Get_Options (Frame_Widget: Ttk_Label_Frame) return Ttk_Label_Frame_Options renames Wrap_Test_Get_Options_ded36e_39fa14; -- end read only pragma Unreferenced(Gnattest_T); Frame: Ttk_Label_Frame; Options: Ttk_Label_Frame_Options; begin if Value("DISPLAY", "")'Length = 0 then Assert(True, "No display, can't test"); return; end if; Create (Frame, ".myframe", Ttk_Label_Frame_Options'(Relief => RAISED, others => <>)); Options := Get_Options(Frame); Assert (Options.Relief = Raised, "Failed to get options of Ttk labelframe."); Destroy(Frame); -- begin read only end Test_Get_Options_test_get_options_ttklabelframe; -- end read only -- begin read only -- id:2.2/02/ -- -- This section can be used to add elaboration code for the global state. -- begin -- end read only null; -- begin read only -- end read only end Tk.TtkLabelFrame.Ttk_Label_Frame_Options_Test_Data .Ttk_Label_Frame_Options_Tests;
with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; with Ada.Io_Exceptions; with Ada.Text_Io.Bounded_Io; with Arbre_Genealogique; use Arbre_Genealogique; with Date; use Date; procedure Main is -- On utilise des chaines de taille variable package Ada_Strings_Io is new Ada.Text_Io.Bounded_Io (Sb); use Ada_Strings_Io; type T_Menu is (Menu_Principal, Menu_Registre, Menu_Registre_Consultation_Selection, Menu_Registre_Consultation_Personne, Menu_Registre_Consultation_Recherche, Menu_Registre_Ajout, Menu_Registre_Modification, Menu_Arbre_Selection, Menu_Arbre_Consultation, Menu_Arbre_Ajouter_Relation, Menu_Arbre_Supprimer_Relation, Menu_Arbre_Parente, Menu_Statistiques, Quitter); -- Etat global du programme type T_Etat is record Arbre : T_Arbre_Genealogique; Cle : Integer; Menu : T_Menu; end record; -- Affiche la phrase "Votre choix [1, 2, ... `Nb_Choix`]" -- et capture la saisie de l'utilisateur dans `Choix`. procedure Choisir (Nb_Choix : in Integer; Choix : out Integer) is procedure Afficher_Liste_Choix is begin for I in 1 .. Nb_Choix - 2 loop Put (I, 0); Put (", "); end loop; Put (Nb_Choix - 1, 0); Put (" ou "); Put (Nb_Choix - 0, 0); end Afficher_Liste_Choix; Correct : Boolean := False; -- Premiere_Entree : Boolean := True; begin while not Correct loop Put ("Votre choix ["); Afficher_Liste_Choix; -- Fonctionnalité desactivée : --if not Premiere_Entree then -- Put (" / 0 pour quitter"); --end if; Put ("] : "); begin Get (Choix); Correct := Choix in 1 .. Nb_Choix; --Correct := Choix in 0 .. Nb_Choix; exception when Ada.Io_Exceptions.Data_Error => Correct := False; end; Skip_Line; if not Correct then Put_Line ("Choix incorrect."); New_Line; end if; -- Premiere_Entree := False; end loop; end Choisir; -- Permet de choisir un entier positif ou nul de facon robuste. procedure Choisir_Cle (Cle : out Integer) is Correct : Boolean := False; Premiere_Entree : Boolean := True; begin while not Correct loop Put ("Votre choix"); if not Premiere_Entree then Put (" [0 pour retour]"); end if; Put (" : "); begin Get (Cle); Correct := Cle >= 0; exception -- Si la valeur entrée n'est pas un entier when Ada.Io_Exceptions.Data_Error => Correct := False; end; Skip_Line; if not Correct then Put_Line ("Clé incorrecte."); New_Line; end if; Premiere_Entree := False; end loop; end Choisir_Cle; -- Affiche le menu principal. procedure Afficher_Menu_Principal (Etat : in out T_Etat) is Choix : Integer; begin Put_Line ("**********************"); Put_Line ("* Arbre Généalogique *"); Put_Line ("**********************"); New_Line; Put_Line ("Menu principal :"); Put_Line ("1. Accéder au registre"); Put_Line ("2. Accéder a un arbre généalogique"); Put_Line ("3. Statistiques"); Put_Line ("4. Quitter"); New_Line; Choisir (4, Choix); New_Line; case Choix is when 1 => Etat.Menu := Menu_Registre; when 2 => Etat.Menu := Menu_Arbre_Selection; when 3 => Etat.Menu := Menu_Statistiques; when others => Etat.Menu := Quitter; end case; end Afficher_Menu_Principal; -- Affiche le menu du registre. procedure Afficher_Menu_Registre (Etat : in out T_Etat) is Choix : Integer; begin Put_Line ("* Registre *"); New_Line; Put_Line ("Menu :"); Put_Line ("1. Consulter une personne a partir de sa clé"); Put_Line ("2. Chercher une personne a partir de son nom"); Put_Line ("3. Ajouter une personne"); Put_Line ("4. Retour"); New_Line; Choisir (4, Choix); New_Line; case Choix is when 1 => Etat.Menu := Menu_Registre_Consultation_Selection; when 2 => Etat.Menu := Menu_Registre_Consultation_Recherche; when 3 => Etat.Menu := Menu_Registre_Ajout; when 4 => Etat.Menu := Menu_Principal; when others => Etat.Menu := Quitter; end case; end Afficher_Menu_Registre; -- Affiche toutes les informations d'une personne. procedure Afficher_Personne (Cle : in Integer; Personne : in T_Personne) is begin Put ("<"); Put (Cle, 0); Put (">"); New_Line; Put (Personne.Nom_Usuel); New_Line; Put (" * Nom complet : "); Put (Personne.Nom_Complet); New_Line; Put (" * Sexe : "); Put (T_Genre'Image (Personne.Genre)); New_Line; Put (" * Né le "); Put (Personne.Date_De_Naissance.Jour, 0); Put (" "); Put (T_Mois'Image (Personne.Date_De_Naissance.Mois)); Put (" "); Put (Personne.Date_De_Naissance.Annee, 0); Put (" a "); Put (Personne.Lieu_De_Naissance); New_Line; end Afficher_Personne; procedure Afficher_Nom_Usuel (Etat : in T_Etat; Cle : in Integer) is Personne : T_Personne; begin Personne := Lire_Registre (Etat.Arbre, Cle); Put (Personne.Nom_Usuel); Put (" <"); Put (Cle, 0); Put (">"); end Afficher_Nom_Usuel; -- Affiche le menu qui permet de choisir une personne a consulter dans le registre. procedure Afficher_Menu_Registre_Consultation_Selection (Etat : in out T_Etat) is Cle : Integer; Correct : Boolean; begin Correct := False; while not Correct loop Put_Line ("Entrez la clé de la personne que vous voulez consulter [0 pour retour]."); Choisir_Cle (Cle); Correct := Cle = 0 or else Existe_Registre (Etat.Arbre, Cle); if not Correct then Put_Line ("Clé inconnue."); New_Line; end if; end loop; New_Line; if Cle = 0 then Etat.Menu := Menu_Registre; else Etat.Cle := Cle; Etat.Menu := Menu_Registre_Consultation_Personne; end if; end Afficher_Menu_Registre_Consultation_Selection; -- Affiche les résultats de la recherche. procedure Afficher_Resultats (Etat : in out T_Etat; Recherche : in String) is Nombre_Resultats : Integer := 0; procedure Tester_Personne (Cle : in Integer; Personne : in T_Personne) is begin if Sb.Index (Personne.Nom_Usuel, Recherche) > 0 or else Sb.Index (Personne.Nom_Complet, Recherche) > 0 then Nombre_Resultats := Nombre_Resultats + 1; Put (" * "); Put (Personne.Nom_Usuel); Put (" <"); Put (Cle, 0); Put (">"); New_Line; end if; end Tester_Personne; procedure Rechercher is new Appliquer_Sur_Registre (Tester_Personne); begin Put_Line ("Résultats de la recherche :"); Rechercher (Etat.Arbre); if Nombre_Resultats = 0 then Put_Line ("Aucun résultat."); Etat.Menu := Menu_Registre; else Etat.Menu := Menu_Registre_Consultation_Selection; end if; New_Line; end Afficher_Resultats; -- Affiche le menu qui permet de rechercher dans le registre. procedure Afficher_Menu_Registre_Consultation_Recherche (Etat : in out T_Etat) is Recherche : Sb.Bounded_String; begin Put_Line ("* Recherche dans le registre *"); New_Line; Put ("Nom a rechercher [Entrée pour retour] : "); Recherche := Get_Line; New_Line; if Sb.Length (Recherche) > 0 then Afficher_Resultats (Etat, Sb.To_String (Recherche)); else Etat.Menu := Menu_Registre; end if; end Afficher_Menu_Registre_Consultation_Recherche; -- Affiche le menu des possibilités pour une personne du registre. procedure Afficher_Menu_Registre_Consultation_Personne (Etat : in out T_Etat) is Personne : T_Personne; Choix : Integer; begin Personne := Lire_Registre (Etat.Arbre, Etat.Cle); Afficher_Personne (Etat.Cle, Personne); New_Line; Put_Line ("Menu : "); Put_Line ("1. Consulter son arbre généalogique"); Put_Line ("2. Modifier les informations"); Put_Line ("3. Retour"); New_Line; Choisir (3, Choix); New_Line; case Choix is when 1 => Etat.Menu := Menu_Arbre_Consultation; when 2 => Etat.Menu := Menu_Registre_Modification; when 3 => Etat.Menu := Menu_Registre; when others => Etat.Menu := Quitter; end case; end Afficher_Menu_Registre_Consultation_Personne; -- Demande a l'utilisateur toutes les informations pour peupler `Personne`. procedure Saisir_Personne (Personne : out T_Personne) is Nom_Complet : Sb.Bounded_String; Nom_Usuel : Sb.Bounded_String; Genre : T_Genre; Date_De_Naissance : T_Date; Lieu_De_Naissance : Sb.Bounded_String; Correct : Boolean; Date_Lue : Integer; Genre_Lu : Character; begin Put ("Nom usuel : "); Nom_Usuel := Get_Line; Put ("Nom Complet : "); Nom_Complet := Get_Line; Put ("Sexe [F pour féminin, M pour masculin, A pour autre] : "); Get (Genre_Lu); Skip_Line; case Genre_Lu is when 'f' | 'F' => Genre := Feminin; when 'm' | 'M' => Genre := Masculin; when others => Genre := Autre; end case; Correct := False; -- La date entrée est correcte ? while not Correct loop Put ("Date de naissance [au format JJMMAAAA] : "); begin Get (Date_Lue); Date_De_Naissance := Creer_Date (Date_Lue / 1000000, (Date_Lue / 10000) mod 100, Date_Lue mod 10000); Correct := True; exception when Ada.Io_Exceptions.Data_Error | Date_Incorrecte => Correct := False; end; Skip_Line; if not Correct then Put_Line ("Date incorrecte."); end if; end loop; Put ("Lieu de naissance [au format Ville, Pays] : "); Lieu_De_Naissance := Get_Line; New_Line; Personne := (Nom_Usuel, Nom_Complet, Genre, Date_De_Naissance, Lieu_De_Naissance); end Saisir_Personne; -- Affiche un menu pour ajouter une personne au registre. procedure Afficher_Menu_Registre_Ajout (Etat : in out T_Etat) is Cle : Integer; Personne : T_Personne; Choix : Character; begin Put_Line ("* Ajouter une personne au registre *"); New_Line; Put_Line ("Informations requises : nom usuel, nom complet, sexe, date et lieu de naissance."); New_Line; Saisir_Personne (Personne); Put ("Confirmer l'ajout [O pour oui, autre pour non] : "); Get (Choix); Skip_Line; if Choix = 'o' or Choix = 'O' then Ajouter_Personne (Etat.Arbre, Personne, Cle); Put ("Personne ajoutée avec la clé : "); Put (Cle, 0); else Put ("Ajout annulé."); end if; New_Line; New_Line; Etat.Menu := Menu_Registre; end Afficher_Menu_Registre_Ajout; -- Permet de modifier une personne enregistrée. procedure Afficher_Menu_Registre_Modification (Etat : in out T_Etat) is Personne : T_Personne; Choix : Character; begin Put_Line ("* Modification d'une personne du registre *"); New_Line; Put_Line ("Informations actuelles : "); Personne := Lire_Registre (Etat.Arbre, Etat.Cle); Afficher_Personne (Etat.Cle, Personne); New_Line; Saisir_Personne (Personne); New_Line; Put ("Confirmer la modification [O pour oui, autre pour non] : "); Get (Choix); Skip_Line; if Choix = 'o' or Choix = 'O' then Attribuer_Registre (Etat.Arbre, Etat.Cle, Personne); Put_Line ("Personne modifiée avec succès."); else Put_Line ("Modification annulée."); end if; New_Line; Etat.Menu := Menu_Registre; end Afficher_Menu_Registre_Modification; -- Demande une clé pour afficher les relations d'une personne. procedure Afficher_Menu_Arbre_Selection (Etat : in out T_Etat) is Cle : Integer; Correct : Boolean; begin Put_Line ("* Arbre généalogique *"); New_Line; Correct := False; while not Correct loop Put_Line ("Entrez la clé de la personne dont vous voulez consulter l'arbre [0 pour retour]."); Choisir_Cle (Cle); Correct := Cle = 0 or else Existe_Registre (Etat.Arbre, Cle); if not Correct then Put_Line ("Clé inconnue."); New_Line; end if; end loop; New_Line; if Cle = 0 then Etat.Menu := Menu_Principal; else Etat.Cle := Cle; Etat.Menu := Menu_Arbre_Consultation; end if; end Afficher_Menu_Arbre_Selection; -- Affiche les relations d'une personne. procedure Afficher_Menu_Arbre_Consultation (Etat : in out T_Etat) is -- Groupe toutes les relations de même étiquette ensemble. procedure Afficher_Relations_Groupees (Etat : in T_Etat; Etiquette : in T_Etiquette_Arete; Titre : in String) is Liste : T_Liste_Relations; Relation : T_Arete_Etiquetee; Titre_Affiche : Boolean := False; begin Liste_Relations (Liste, Etat.Arbre, Etat.Cle); -- On affiche toutes les relations notées Etiquette while Liste_Non_Vide (Liste) loop Relation_Suivante (Liste, Relation); if Relation.Etiquette = Etiquette then if not Titre_Affiche then Put_Line (Titre); Titre_Affiche := True; end if; Put (" * "); Afficher_Nom_Usuel (Etat, Relation.Destination); New_Line; end if; end loop; end Afficher_Relations_Groupees; Liste : T_Liste_Relations; Choix : Integer; begin Afficher_Nom_Usuel (Etat, Etat.Cle); New_Line; New_Line; Liste_Relations (Liste, Etat.Arbre, Etat.Cle); if not Liste_Non_Vide (Liste) then Put_Line ("Aucune relation."); else Afficher_Relations_Groupees (Etat, A_Pour_Parent, "Parent(s) :"); Afficher_Relations_Groupees (Etat, A_Pour_Enfant, "Enfant(s) :"); Afficher_Relations_Groupees (Etat, A_Pour_Conjoint, "Conjoint(e) :"); end if; New_Line; Put_Line ("Menu :"); Put_Line ("1. Consulter dans le registre"); Put_Line ("2. Consulter une autre personne"); Put_Line ("3. Ajouter une relation"); Put_Line ("4. Supprimer une relation"); Put_Line ("5. Afficher un arbre de parenté"); Put_Line ("6. Retour"); New_Line; Choisir (6, Choix); New_Line; case Choix is when 1 => Etat.Menu := Menu_Registre_Consultation_Personne; when 2 => Etat.Menu := Menu_Arbre_Selection; when 3 => Etat.Menu := Menu_Arbre_Ajouter_Relation; when 4 => Etat.Menu := Menu_Arbre_Supprimer_Relation; when 5 => Etat.Menu := Menu_Arbre_Parente; when 6 => Etat.Menu := Menu_Principal; when others => Etat.Menu := Quitter; end case; end Afficher_Menu_Arbre_Consultation; -- Permet d'ajouter une relation. procedure Afficher_Menu_Arbre_Ajouter_Relation (Etat : in out T_Etat) is Dates_Incompatibles : exception; Personne_Origine : T_Personne; Personne_Destination : T_Personne; Cle_Destination : Integer; Relation_Lue : Integer; Correct : Boolean; begin Put_Line ("Ajouter une relation :"); Put_Line ("1. Ajouter un parent"); Put_Line ("2. Ajouter un enfant"); Put_Line ("3. Ajouter un conjoint"); New_Line; Choisir (3, Relation_Lue); New_Line; Correct := False; while not Correct loop Put_Line ("Entrez la clé de la personne a lier [0 pour retour]."); Choisir_Cle (Cle_Destination); Correct := Cle_Destination = 0 or else Existe_Registre (Etat.Arbre, Cle_Destination); if not Correct then Put_Line ("Clé inconnue."); New_Line; end if; end loop; if Cle_Destination = 0 then Put_Line ("Ajout annulé."); else Personne_Origine := Lire_Registre (Etat.Arbre, Etat.Cle); Personne_Destination := Lire_Registre (Etat.Arbre, Cle_Destination); begin case Relation_Lue is when 1 => -- On vérifie qu'un parent est plus vieux que son enfant if D1_Inf_D2 (Personne_Origine.Date_De_Naissance, Personne_Destination.Date_De_Naissance) then raise Dates_Incompatibles; end if; Ajouter_Relation (Etat.Arbre, Etat.Cle, A_Pour_Parent, Cle_Destination); when 2 => if D1_Inf_D2 (Personne_Destination.Date_De_Naissance, Personne_Origine.Date_De_Naissance) then raise Dates_Incompatibles; end if; Ajouter_Relation (Etat.Arbre, Etat.Cle, A_Pour_Enfant, Cle_Destination); when 3 => Ajouter_Relation (Etat.Arbre, Etat.Cle, A_Pour_Conjoint, Cle_Destination); when others => null; end case; Put_Line ("Relation ajoutée."); exception when Dates_Incompatibles => Put_Line ("Un parent doit etre plus agé que son enfant."); when Relation_Existante => Put_Line ("Une relation entre ces deux personnes existe déja."); end; end if; New_Line; Etat.Menu := Menu_Arbre_Consultation; end Afficher_Menu_Arbre_Ajouter_Relation; -- Supprime les relations avec une personne. procedure Afficher_Menu_Arbre_Supprimer_Relation (Etat : in out T_Etat) is Cle_Destination : Integer; Correct : Boolean; begin Correct := False; while not Correct loop Put_Line ("Entrez la clé de la personne a délier [0 pour retour]."); Choisir_Cle (Cle_Destination); Correct := Cle_Destination = 0 or else Existe_Registre (Etat.Arbre, Cle_Destination); if not Correct then Put_Line ("Clé inconnue."); New_Line; end if; end loop; if Cle_Destination = 0 then Put_Line ("Suppression annulée."); Etat.Menu := Menu_Arbre_Consultation; else Supprimer_Relation (Etat.Arbre, Etat.Cle, A_Pour_Parent, Cle_Destination); Supprimer_Relation (Etat.Arbre, Etat.Cle, A_Pour_Enfant, Cle_Destination); Supprimer_Relation (Etat.Arbre, Etat.Cle, A_Pour_Conjoint, Cle_Destination); Put_Line ("Suppression effectuée."); end if; New_Line; Etat.Menu := Menu_Arbre_Consultation; end Afficher_Menu_Arbre_Supprimer_Relation; -- Affiche un arbre de parenté, ascendant ou descendant. procedure Afficher_Menu_Arbre_Parente (Etat : in out T_Etat) is -- Affiche un bandeau -- 0 1 2 génération -- ====================== procedure Afficher_Bandeau (Nombre_Generations : in Integer) is begin for I in 0 .. Nombre_Generations loop Put (I, 2); Put (" "); end loop; Put_Line (" génération"); for I in 1 .. (Nombre_Generations * 4 + 15) loop Put ("="); end loop; New_Line; end Afficher_Bandeau; procedure Afficher_Parente (Etat : in T_Etat; Cle : in Integer; Etiquette : in T_Etiquette_Arete; Nombre_Generations : in Integer; Indentation : in String) is Liste : T_Liste_Relations; Relation : T_Arete_Etiquetee; begin Put (Indentation); Put ("-- "); Afficher_Nom_Usuel (Etat, Cle); New_Line; if Nombre_Generations <= 0 then return; end if; Liste_Relations (Liste, Etat.Arbre, Cle); while Liste_Non_Vide (Liste) loop Relation_Suivante (Liste, Relation); if Relation.Etiquette = Etiquette then Afficher_Parente (Etat, Relation.Destination, Etiquette, Nombre_Generations - 1, Indentation & " "); end if; end loop; end Afficher_Parente; Nombre_Generations : Integer; Correct : Boolean; begin Correct := False; while not Correct loop begin Put_Line ("Nombre de générations a afficher [> 0 pour les parents,"); Put ("< 0 pour les enfants, 0 pour retour] : "); Get (Nombre_Generations); Correct := True; exception when Ada.Io_Exceptions.Data_Error => Correct := False; end; Skip_Line; end loop; New_Line; if Nombre_Generations > 0 then Afficher_Bandeau (Nombre_Generations); Afficher_Parente (Etat, Etat.Cle, A_Pour_Parent, Nombre_Generations, ""); New_Line; elsif Nombre_Generations < 0 then Afficher_Bandeau (-Nombre_Generations); Afficher_Parente (Etat, Etat.Cle, A_Pour_Enfant, -Nombre_Generations, ""); New_Line; end if; Etat.Menu := Menu_Arbre_Consultation; end Afficher_Menu_Arbre_Parente; -- Affiche diverses statistiques sur le graphe. procedure Afficher_Menu_Statistiques (Etat : in out T_Etat) is Nombre_Personnes : Integer := 0; Nombre_Relations : Integer := 0; Nombre_Orphelins : Integer := 0; type Stats_Parents is array (1 .. 4) of Integer; Nombre_Parents_Connus : Stats_Parents := (0, 0, 0, 0); -- Parcourt le graphe et compte les détails des personnes procedure P (Cle : in Integer; Liste : in out T_Liste_Relations) is Relation : T_Arete_Etiquetee; Nombre_Parents : Integer := 0; begin Nombre_Personnes := Nombre_Personnes + 1; if Liste_Non_Vide (Liste) then while Liste_Non_Vide (Liste) loop Nombre_Relations := Nombre_Relations + 1; Relation_Suivante (Liste, Relation); if Relation.Etiquette = A_Pour_Parent then Nombre_Parents := Nombre_Parents + 1; end if; end loop; if Nombre_Parents > 2 then Nombre_Parents_Connus (4) := Nombre_Parents_Connus (4) + 1; else Nombre_Parents_Connus (Nombre_Parents + 1) := Nombre_Parents_Connus (Nombre_Parents + 1) + 1; end if; else Nombre_Orphelins := Nombre_Orphelins + 1; -- On pourrait ici utiliser Afficher_Nom_Usuel (Etat, Cle) end if; end P; procedure Compter is new Appliquer_Sur_Graphe (P); begin Put_Line ("* Statistiques *"); New_Line; Compter (Etat.Arbre); Put ("Nombre de personnes enregistrées : "); Put (Nombre_Personnes, 0); New_Line; Put ("Nombre de relations enregistrées : "); Put (Nombre_Relations, 0); New_Line; Put ("Nombre de personnes sans aucune relation : "); Put (Nombre_Orphelins, 0); New_Line; Put_Line ("Nombre de personne avec"); Put (" * Aucun parent connu : "); Put (Nombre_Parents_Connus (1), 0); New_Line; Put (" * Un parent connu : "); Put (Nombre_Parents_Connus (2), 0); New_Line; Put (" * Deux parents connus : "); Put (Nombre_Parents_Connus (3), 0); New_Line; Put (" * Trois ou plus : "); Put (Nombre_Parents_Connus (4), 0); New_Line; New_Line; Etat.Menu := Menu_Principal; end Afficher_Menu_Statistiques; -- Affiche le menu correspondant a l'état du programme. procedure Afficher_Menu (Etat : in out T_Etat) is begin case Etat.Menu is when Menu_Principal => Afficher_Menu_Principal (Etat); when Menu_Registre => Afficher_Menu_Registre (Etat); when Menu_Registre_Consultation_Selection => Afficher_Menu_Registre_Consultation_Selection (Etat); when Menu_Registre_Consultation_Personne => Afficher_Menu_Registre_Consultation_Personne (Etat); when Menu_Registre_Consultation_Recherche => Afficher_Menu_Registre_Consultation_Recherche (Etat); when Menu_Registre_Ajout => Afficher_Menu_Registre_Ajout (Etat); when Menu_Registre_Modification => Afficher_Menu_Registre_Modification (Etat); when Menu_Arbre_Selection => Afficher_Menu_Arbre_Selection (Etat); when Menu_Arbre_Consultation => Afficher_Menu_Arbre_Consultation (Etat); when Menu_Arbre_Ajouter_Relation => Afficher_Menu_Arbre_Ajouter_Relation (Etat); when Menu_Arbre_Supprimer_Relation => Afficher_Menu_Arbre_Supprimer_Relation (Etat); when Menu_Arbre_Parente => Afficher_Menu_Arbre_Parente (Etat); when Menu_Statistiques => Afficher_Menu_Statistiques (Etat); when others => Etat.Menu := Quitter; end case; end Afficher_Menu; Etat : T_Etat; Cle : Integer; begin Initialiser (Etat.Arbre); Etat.Menu := Menu_Principal; -- Quelques personnes enregistrées pour la démo Ajouter_Personne (Etat.Arbre, (Sb.To_Bounded_String ("Jean Bon"), Sb.To_Bounded_String ("Jean, Eude Bon"), Masculin, Creer_Date (31, 1, 1960), Sb.To_Bounded_String ("Paris, France")), Cle); Ajouter_Personne (Etat.Arbre, (Sb.To_Bounded_String ("Kevin Bon"), Sb.To_Bounded_String ("Kevin, Junior Bon"), Masculin, Creer_Date (1, 4, 1999), Sb.To_Bounded_String ("Toulouse, France")), Cle); while Etat.Menu /= Quitter loop Afficher_Menu (Etat); end loop; Detruire (Etat.Arbre); end Main;
WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C; USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C; PROCEDURE Main IS FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U)); FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Integer (S)); FUNCTION Image_Cleared (M : Mpz_T) RETURN String IS (Image (To_Unbounded_Integer (M))); N : Unbounded_Integer := +"9516311845790656153499716760847001433441357"; E : Unbounded_Integer := +"65537"; D : Unbounded_Integer := +"5617843187844953170308463622230283376298685"; Plain_Text : CONSTANT String := "Rosetta Code"; M, M_C, M_D : Mpz_T; -- We import two C functions from the GMP library which are not in the specs of the gmp package PROCEDURE Mpz_Import (Rop : Mpz_T; Count : Size_T; Order : Int; Size : Size_T; Endian : Int; Nails : Size_T; Op : Char_Array); PRAGMA Import (C, Mpz_Import, "__gmpz_import"); PROCEDURE Mpz_Export (Rop : OUT Char_Array; Count : ACCESS Size_T; Order : Int; Size : Size_T; Endian : Int; Nails : Size_T; Op : Mpz_T); PRAGMA Import (C, Mpz_Export, "__gmpz_export"); BEGIN Mpz_Init (M); Mpz_Init (M_C); Mpz_Init (M_D); Mpz_Import (M, Plain_Text'Length + 1, 1, 1, 0, 0, To_C (Plain_Text)); Mpz_Powm (M_C, M, +E, +N); Mpz_Powm (M_D, M_C, +D, +N); Put_Line ("Encoded plain text: " & Image_Cleared (M)); DECLARE Decrypted : Char_Array (1 .. Mpz_Sizeinbase (M_C, 256)); BEGIN Put_Line ("Encryption of this encoding: " & Image_Cleared (M_C)); Mpz_Export (Decrypted, NULL, 1, 1, 0, 0, M_D); Put_Line ("Decryption of the encoding: " & Image_Cleared (M_D)); Put_Line ("Final decryption: " & To_Ada (Decrypted)); END; END Main;
with System; use System; private with STM32_SVD.DFSDM; package STM32.DFSDM is type DFSDM_Block is limited private; type DFSDM_Channel is (Channel_0, Channel_1, Channel_2, Channel_3, Channel_4, Channel_5, Channel_6, Channel_7 ); procedure Enable (This : in out DFSDM_Block; Channel : DFSDM_Channel) with Inline, Post => Enabled (This, Channel); procedure Disable (This : in out DFSDM_Block; Channel : DFSDM_Channel) with Inline, Post => not Enabled (This, Channel); function Enabled (This : DFSDM_Block; Channel : DFSDM_Channel) return Boolean; private type DFSDM_Block is new STM32_SVD.DFSDM.DFSDM1_Peripheral; end STM32.DFSDM;
-- 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 Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with GNAT.Sockets; use GNAT.Sockets; with DNSCatcher.Utils.Logger; use DNSCatcher.Utils.Logger; -- @summary -- Configuration information used by the DNSCatcher library -- -- @description -- The DNSCatcher library (and daemons) require configuration to know external -- resources such as validation resolvers, database storage information, and -- logger information. -- -- This information can be stored as a configuration file, loaded from the -- database (to be implemented), or programmatically stored. It is intended -- for configuration information to be dynamically updatable (either through -- runtime commands or sending SIGHUP to the Catcher daemon). As such -- configuration information will be migrated to being a protected object -- with standard setters and getters to prevent race conditions. -- package DNSCatcher.Config is -- Configuration record information -- -- @field Local_Listen_Port -- Port currently used to determine where DNS requests are listened for when -- accepting legacy DNS traffic. Defaults to 53. -- -- @field Upstream_DNS_Server -- Currently used to denote servers requests are forwarded to. At the moment -- only one server is supported at a time -- -- @field Upstream_DNS_Server_Port Port to communicate with the server with. -- Defaults to 53. -- -- @field Logger_Config -- Global configuration of the Logger object type Configuration is limited record Local_Listen_Port : Port_Type; Upstream_DNS_Server : Unbounded_String; Upstream_DNS_Server_Port : Port_Type; Logger_Config : Logger_Configuration; end record; --type Configuration_Ptr is access Configuration; -- Functions -- Initializes the Configuration parser by loading methods to handle data -- values and storage. Must be called before calling Parse_Config_File procedure Initialize_Config_Parse; -- Initializes a configuration object and returns it with default values set -- ready for further config procedure Initialize (Config : in out Configuration); -- Handles parsing the configuration file -- -- It is the caller's responsibility to deallocate the pointer after all -- DNSCatcher services have shutdown. -- -- @value Config -- Configuration object -- -- @value Config_File_Path -- Path to the configuration file -- -- @exception Malformed_Line -- Raised when a line is malformed and can't be properly parsed -- -- @exception Missing_Mandatory_Config_Option Raised when a mandatory option -- in the config file is not present -- procedure Read_Cfg_File (Config : in out Configuration; Config_File_Path : String); -- Defined Exceptions Malformed_Line : exception; Missing_Mandatory_Config_Option : exception; end DNSCatcher.Config;
----------------------------------------------------------------------- -- Action_Bean - Simple bean with methods that can be called from EL -- Copyright (C) 2010, 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Action_Bean is -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ function Get_Value (From : Action; Name : String) return EL.Objects.Object is begin if Name = "count" then return EL.Objects.To_Object (From.Count); end if; return From.Person.Get_Value (Name); end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ procedure Set_Value (From : in out Action; Name : in String; Value : in EL.Objects.Object) is begin From.Person.Set_Value (Name, Value); end Set_Value; -- ------------------------------ -- Action with one parameter. -- Sets the person. -- ------------------------------ procedure Notify (Target : in out Action; Param : in out Test_Bean.Person) is begin Target.Person := Param; end Notify; -- ------------------------------ -- Action with two parameters. -- Sets the person object and the counter. -- ------------------------------ procedure Notify (Target : in out Action; Param : in Test_Bean.Person; Count : in Natural) is begin Target.Person := Param; Target.Count := Count; end Notify; -- ------------------------------ -- Action with one parameter -- ------------------------------ procedure Print (Target : in out Action; Param : in out Test_Bean.Person) is begin Target.Person := Param; end Print; package Notify_Binding is new Proc_Action.Bind (Bean => Action, Method => Notify, Name => "notify"); package Notify_Count_Binding is new Proc2_Action.Bind (Bean => Action, Method => Notify, Name => "notify2"); package Print_Binding is new Proc_Action.Bind (Bean => Action, Method => Print, Name => "print"); Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (Notify_Binding.Proxy'Access, Print_Binding.Proxy'Access, Notify_Count_Binding.Proxy'Access); -- ------------------------------ -- Get the EL method bindings exposed by the Action type. -- ------------------------------ function Get_Method_Bindings (From : in Action) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Array'Access; end Get_Method_Bindings; end Action_Bean;
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C; use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C; procedure test_instant is type stringptr is access all char_array; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; function foo(a : in Integer; b : in Integer) return Integer is begin return a + b; end; begin PInt(10); end;
-- Copyright 2015 Steven Stewart-Gallus -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied. See the License for the specific language governing -- permissions and limitations under the License. with Interfaces.C; use Interfaces.C; with System; with Libc.Stdint; with Interfaces.C.Strings; limited with XCB.XProto; package XCB with Spark_Mode => Off is pragma Preelaborate; pragma Link_With ("-lxcb"); X_PROTOCOL : constant := 11; X_PROTOCOL_REVISION : constant := 0; X_TCP_PORT : constant := 6000; XCB_CONN_ERROR : constant := 1; XCB_CONN_CLOSED_EXT_NOTSUPPORTED : constant := 2; XCB_CONN_CLOSED_MEM_INSUFFICIENT : constant := 3; XCB_CONN_CLOSED_REQ_LEN_EXCEED : constant := 4; XCB_CONN_CLOSED_PARSE_ERR : constant := 5; XCB_CONN_CLOSED_INVALID_SCREEN : constant := 6; XCB_CONN_CLOSED_FDPASSING_FAILED : constant := 7; XCB_NONE : constant := 0; XCB_COPY_FROM_PARENT : constant := 0; XCB_CURRENT_TIME : constant := 0; XCB_NO_SYMBOL : constant := 0; type xcb_connection_t is limited private; type xcb_connection_t_access is access all xcb_connection_t; type xcb_generic_iterator_t is record data : System.Address; -- /usr/include/xcb/xcb.h:115 c_rem : aliased int; -- /usr/include/xcb/xcb.h:116 index : aliased int; -- /usr/include/xcb/xcb.h:117 end record; pragma Convention (C_Pass_By_Copy, xcb_generic_iterator_t); -- /usr/include/xcb/xcb.h:118 -- skipped anonymous struct anon_26 type xcb_generic_reply_t is record response_type : aliased Libc.Stdint .uint8_t; -- /usr/include/xcb/xcb.h:126 pad0 : aliased Libc.Stdint.uint8_t; -- /usr/include/xcb/xcb.h:127 sequence : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:128 length : aliased Libc.Stdint.uint32_t; -- /usr/include/xcb/xcb.h:129 end record; pragma Convention (C_Pass_By_Copy, xcb_generic_reply_t); -- /usr/include/xcb/xcb.h:130 type xcb_generic_event_t_pad_array is array (0 .. 6) of aliased Libc.Stdint.uint32_t; type xcb_generic_event_t is record response_type : aliased Libc.Stdint .uint8_t; -- /usr/include/xcb/xcb.h:138 pad0 : aliased Libc.Stdint.uint8_t; -- /usr/include/xcb/xcb.h:139 sequence : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:140 pad : aliased xcb_generic_event_t_pad_array; -- /usr/include/xcb/xcb.h:141 full_sequence : aliased Libc.Stdint .uint32_t; -- /usr/include/xcb/xcb.h:142 end record; pragma Convention (C_Pass_By_Copy, xcb_generic_event_t); -- /usr/include/xcb/xcb.h:143 type xcb_ge_event_t_pad_array is array (0 .. 4) of aliased Libc.Stdint.uint32_t; type xcb_ge_event_t is record response_type : aliased Libc.Stdint .uint8_t; -- /usr/include/xcb/xcb.h:155 pad0 : aliased Libc.Stdint.uint8_t; -- /usr/include/xcb/xcb.h:156 sequence : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:157 length : aliased Libc.Stdint.uint32_t; -- /usr/include/xcb/xcb.h:158 event_type : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:159 pad1 : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:160 pad : aliased xcb_ge_event_t_pad_array; -- /usr/include/xcb/xcb.h:161 full_sequence : aliased Libc.Stdint .uint32_t; -- /usr/include/xcb/xcb.h:162 end record; pragma Convention (C_Pass_By_Copy, xcb_ge_event_t); -- /usr/include/xcb/xcb.h:163 type xcb_generic_error_t_pad_array is array (0 .. 4) of aliased Libc.Stdint.uint32_t; type xcb_generic_error_t is record response_type : aliased Libc.Stdint .uint8_t; -- /usr/include/xcb/xcb.h:171 error_code : aliased Libc.Stdint.uint8_t; -- /usr/include/xcb/xcb.h:172 sequence : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:173 resource_id : aliased Libc.Stdint .uint32_t; -- /usr/include/xcb/xcb.h:174 minor_code : aliased Libc.Stdint.uint16_t; -- /usr/include/xcb/xcb.h:175 major_code : aliased Libc.Stdint.uint8_t; -- /usr/include/xcb/xcb.h:176 pad0 : aliased Libc.Stdint.uint8_t; -- /usr/include/xcb/xcb.h:177 pad : aliased xcb_generic_error_t_pad_array; -- /usr/include/xcb/xcb.h:178 full_sequence : aliased Libc.Stdint .uint32_t; -- /usr/include/xcb/xcb.h:179 end record; pragma Convention (C_Pass_By_Copy, xcb_generic_error_t); -- /usr/include/xcb/xcb.h:180 type xcb_generic_error_t_access is access all xcb_generic_error_t; type xcb_void_cookie_t is record sequence : aliased unsigned; -- /usr/include/xcb/xcb.h:188 end record; pragma Convention (C_Pass_By_Copy, xcb_void_cookie_t); -- /usr/include/xcb/xcb.h:189 type xcb_auth_info_t is record namelen : aliased int; -- /usr/include/xcb/xcb.h:217 name : Interfaces.C.Strings.chars_ptr; -- /usr/include/xcb/xcb.h:218 datalen : aliased int; -- /usr/include/xcb/xcb.h:219 data : Interfaces.C.Strings.chars_ptr; -- /usr/include/xcb/xcb.h:220 end record; pragma Convention (C_Pass_By_Copy, xcb_auth_info_t); -- /usr/include/xcb/xcb.h:216 function xcb_flush (c : xcb_connection_t_access) return int; -- /usr/include/xcb/xcb.h:234 pragma Import (C, xcb_flush, "xcb_flush"); function xcb_get_maximum_request_length (c : xcb_connection_t_access) return Libc.Stdint.uint32_t; -- /usr/include/xcb/xcb.h:251 pragma Import (C, xcb_get_maximum_request_length, "xcb_get_maximum_request_length"); procedure xcb_prefetch_maximum_request_length (c : xcb_connection_t_access); -- /usr/include/xcb/xcb.h:270 pragma Import (C, xcb_prefetch_maximum_request_length, "xcb_prefetch_maximum_request_length"); function xcb_wait_for_event (c : xcb_connection_t_access) return access xcb_generic_event_t; -- /usr/include/xcb/xcb.h:284 pragma Import (C, xcb_wait_for_event, "xcb_wait_for_event"); function xcb_poll_for_event (c : xcb_connection_t_access) return access xcb_generic_event_t; -- /usr/include/xcb/xcb.h:297 pragma Import (C, xcb_poll_for_event, "xcb_poll_for_event"); function xcb_poll_for_queued_event (c : xcb_connection_t_access) return access xcb_generic_event_t; -- /usr/include/xcb/xcb.h:313 pragma Import (C, xcb_poll_for_queued_event, "xcb_poll_for_queued_event"); type xcb_special_event_t is limited private; type xcb_special_event_t_access is access all xcb_special_event_t; function xcb_poll_for_special_event (c : xcb_connection_t_access; se : xcb_special_event_t) return access xcb_generic_event_t; -- /usr/include/xcb/xcb.h:320 pragma Import (C, xcb_poll_for_special_event, "xcb_poll_for_special_event"); function xcb_wait_for_special_event (c : xcb_connection_t_access; se : xcb_special_event_t) return access xcb_generic_event_t; -- /usr/include/xcb/xcb.h:326 pragma Import (C, xcb_wait_for_special_event, "xcb_wait_for_special_event"); type xcb_extension_t is limited private; type xcb_extension_t_access is access all xcb_extension_t; function xcb_register_for_special_xge (c : xcb_connection_t_access; ext : xcb_extension_t_access; eid : Libc.Stdint.uint32_t; stamp : access Libc.Stdint.uint32_t) return xcb_special_event_t_access; -- /usr/include/xcb/xcb.h:337 pragma Import (C, xcb_register_for_special_xge, "xcb_register_for_special_xge"); procedure xcb_unregister_for_special_event (c : xcb_connection_t_access; se : xcb_special_event_t); -- /usr/include/xcb/xcb.h:345 pragma Import (C, xcb_unregister_for_special_event, "xcb_unregister_for_special_event"); function xcb_request_check (c : xcb_connection_t_access; cookie : xcb_void_cookie_t) return access xcb_generic_error_t; -- /usr/include/xcb/xcb.h:364 pragma Import (C, xcb_request_check, "xcb_request_check"); procedure xcb_discard_reply (c : xcb_connection_t_access; sequence : unsigned); -- /usr/include/xcb/xcb.h:380 pragma Import (C, xcb_discard_reply, "xcb_discard_reply"); function xcb_get_extension_data (c : xcb_connection_t_access; ext : xcb_extension_t) return access constant XCB.XProto .xcb_query_extension_reply_t; -- /usr/include/xcb/xcb.h:401 pragma Import (C, xcb_get_extension_data, "xcb_get_extension_data"); procedure xcb_prefetch_extension_data (c : xcb_connection_t_access; ext : xcb_extension_t); -- /usr/include/xcb/xcb.h:414 pragma Import (C, xcb_prefetch_extension_data, "xcb_prefetch_extension_data"); function xcb_get_setup (c : xcb_connection_t_access) return access constant XCB.XProto .xcb_setup_t; -- /usr/include/xcb/xcb.h:437 pragma Import (C, xcb_get_setup, "xcb_get_setup"); function xcb_get_file_descriptor (c : xcb_connection_t_access) return int; -- /usr/include/xcb/xcb.h:447 pragma Import (C, xcb_get_file_descriptor, "xcb_get_file_descriptor"); function xcb_connection_has_error (c : xcb_connection_t_access) return int; -- /usr/include/xcb/xcb.h:466 pragma Import (C, xcb_connection_has_error, "xcb_connection_has_error"); function xcb_connect_to_fd (fd : int; auth_info : access xcb_auth_info_t) return xcb_connection_t_access; -- /usr/include/xcb/xcb.h:480 pragma Import (C, xcb_connect_to_fd, "xcb_connect_to_fd"); procedure xcb_disconnect (c : xcb_connection_t_access); -- /usr/include/xcb/xcb.h:489 pragma Import (C, xcb_disconnect, "xcb_disconnect"); function xcb_parse_display (name : Interfaces.C.Strings.chars_ptr; host : System.Address; display : access int; screen : access int) return int; -- /usr/include/xcb/xcb.h:511 pragma Import (C, xcb_parse_display, "xcb_parse_display"); function xcb_connect (displayname : Interfaces.C.Strings.chars_ptr; screenp : access int) return xcb_connection_t_access; -- /usr/include/xcb/xcb.h:525 pragma Import (C, xcb_connect, "xcb_connect"); function xcb_connect_to_display_with_auth_info (display : Interfaces.C.Strings.chars_ptr; auth : access xcb_auth_info_t; screen : access int) return xcb_connection_t_access; -- /usr/include/xcb/xcb.h:539 pragma Import (C, xcb_connect_to_display_with_auth_info, "xcb_connect_to_display_with_auth_info"); function xcb_generate_id (c : xcb_connection_t_access) return Libc.Stdint.uint32_t; -- /usr/include/xcb/xcb.h:552 pragma Import (C, xcb_generate_id, "xcb_generate_id"); private type xcb_connection_t is limited record null; end record; type xcb_special_event_t is limited record null; end record; type xcb_extension_t is limited record null; end record; end XCB;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M A K E U T L -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2010, 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 ALI; use ALI; with Debug; with Fname; with Hostparm; with Osint; use Osint; with Output; use Output; with Opt; use Opt; with Prj.Ext; with Prj.Util; with Snames; use Snames; with Table; with Tempdir; with Ada.Command_Line; use Ada.Command_Line; with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.HTable; package body Makeutl is type Mark_Key is record File : File_Name_Type; Index : Int; end record; -- Identify either a mono-unit source (when Index = 0) or a specific unit -- (index = 1's origin index of unit) in a multi-unit source. -- There follow many global undocumented declarations, comments needed ??? Max_Mask_Num : constant := 2048; subtype Mark_Num is Union_Id range 0 .. Max_Mask_Num - 1; function Hash (Key : Mark_Key) return Mark_Num; package Marks is new GNAT.HTable.Simple_HTable (Header_Num => Mark_Num, Element => Boolean, No_Element => False, Key => Mark_Key, Hash => Hash, Equal => "="); -- A hash table to keep tracks of the marked units type Linker_Options_Data is record Project : Project_Id; Options : String_List_Id; end record; Linker_Option_Initial_Count : constant := 20; Linker_Options_Buffer : String_List_Access := new String_List (1 .. Linker_Option_Initial_Count); Last_Linker_Option : Natural := 0; package Linker_Opts is new Table.Table ( Table_Component_Type => Linker_Options_Data, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Make.Linker_Opts"); procedure Add_Linker_Option (Option : String); --------- -- Add -- --------- procedure Add (Option : String_Access; To : in out String_List_Access; Last : in out Natural) is begin if Last = To'Last then declare New_Options : constant String_List_Access := new String_List (1 .. To'Last * 2); begin New_Options (To'Range) := To.all; -- Set all elements of the original options to null to avoid -- deallocation of copies. To.all := (others => null); Free (To); To := New_Options; end; end if; Last := Last + 1; To (Last) := Option; end Add; procedure Add (Option : String; To : in out String_List_Access; Last : in out Natural) is begin Add (Option => new String'(Option), To => To, Last => Last); end Add; ----------------------- -- Add_Linker_Option -- ----------------------- procedure Add_Linker_Option (Option : String) is begin if Option'Length > 0 then if Last_Linker_Option = Linker_Options_Buffer'Last then declare New_Buffer : constant String_List_Access := new String_List (1 .. Linker_Options_Buffer'Last + Linker_Option_Initial_Count); begin New_Buffer (Linker_Options_Buffer'Range) := Linker_Options_Buffer.all; Linker_Options_Buffer.all := (others => null); Free (Linker_Options_Buffer); Linker_Options_Buffer := New_Buffer; end; end if; Last_Linker_Option := Last_Linker_Option + 1; Linker_Options_Buffer (Last_Linker_Option) := new String'(Option); end if; end Add_Linker_Option; ------------------------- -- Base_Name_Index_For -- ------------------------- function Base_Name_Index_For (Main : String; Main_Index : Int; Index_Separator : Character) return File_Name_Type is Result : File_Name_Type; begin Name_Len := 0; Add_Str_To_Name_Buffer (Base_Name (Main)); -- Remove the extension, if any, that is the last part of the base name -- starting with a dot and following some characters. for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Len := J - 1; exit; end if; end loop; -- Add the index info, if index is different from 0 if Main_Index > 0 then Add_Char_To_Name_Buffer (Index_Separator); declare Img : constant String := Main_Index'Img; begin Add_Str_To_Name_Buffer (Img (2 .. Img'Last)); end; end if; Result := Name_Find; return Result; end Base_Name_Index_For; ------------------------------ -- Check_Source_Info_In_ALI -- ------------------------------ function Check_Source_Info_In_ALI (The_ALI : ALI_Id; Tree : Project_Tree_Ref) return Boolean is Unit_Name : Name_Id; begin -- Loop through units for U in ALIs.Table (The_ALI).First_Unit .. ALIs.Table (The_ALI).Last_Unit loop -- Check if the file name is one of the source of the unit Get_Name_String (Units.Table (U).Uname); Name_Len := Name_Len - 2; Unit_Name := Name_Find; if File_Not_A_Source_Of (Unit_Name, Units.Table (U).Sfile) then return False; end if; -- Loop to do same check for each of the withed units for W in Units.Table (U).First_With .. Units.Table (U).Last_With loop declare WR : ALI.With_Record renames Withs.Table (W); begin if WR.Sfile /= No_File then Get_Name_String (WR.Uname); Name_Len := Name_Len - 2; Unit_Name := Name_Find; if File_Not_A_Source_Of (Unit_Name, WR.Sfile) then return False; end if; end if; end; end loop; end loop; -- Loop to check subunits and replaced sources for D in ALIs.Table (The_ALI).First_Sdep .. ALIs.Table (The_ALI).Last_Sdep loop declare SD : Sdep_Record renames Sdep.Table (D); begin Unit_Name := SD.Subunit_Name; if Unit_Name = No_Name then -- Check if this source file has been replaced by a source with -- a different file name. if Tree /= null and then Tree.Replaced_Source_Number > 0 then declare Replacement : constant File_Name_Type := Replaced_Source_HTable.Get (Tree.Replaced_Sources, SD.Sfile); begin if Replacement /= No_File then if Verbose_Mode then Write_Line ("source file" & Get_Name_String (SD.Sfile) & " has been replaced by " & Get_Name_String (Replacement)); end if; return False; end if; end; end if; else -- For separates, the file is no longer associated with the -- unit ("proc-sep.adb" is not associated with unit "proc.sep") -- so we need to check whether the source file still exists in -- the source tree: it will if it matches the naming scheme -- (and then will be for the same unit). if Find_Source (In_Tree => Project_Tree, Project => No_Project, Base_Name => SD.Sfile) = No_Source then -- If this is not a runtime file or if, when gnatmake switch -- -a is used, we are not able to find this subunit in the -- source directories, then recompilation is needed. if not Fname.Is_Internal_File_Name (SD.Sfile) or else (Check_Readonly_Files and then Full_Source_Name (SD.Sfile) = No_File) then if Verbose_Mode then Write_Line ("While parsing ALI file, file " & Get_Name_String (SD.Sfile) & " is indicated as containing subunit " & Get_Name_String (Unit_Name) & " but this does not match what was found while" & " parsing the project. Will recompile"); end if; return False; end if; end if; end if; end; end loop; return True; end Check_Source_Info_In_ALI; -------------------------------- -- Create_Binder_Mapping_File -- -------------------------------- function Create_Binder_Mapping_File return Path_Name_Type is Mapping_Path : Path_Name_Type := No_Path; Mapping_FD : File_Descriptor := Invalid_FD; -- A File Descriptor for an eventual mapping file ALI_Unit : Unit_Name_Type := No_Unit_Name; -- The unit name of an ALI file ALI_Name : File_Name_Type := No_File; -- The file name of the ALI file ALI_Project : Project_Id := No_Project; -- The project of the ALI file Bytes : Integer; OK : Boolean := False; Unit : Unit_Index; Status : Boolean; -- For call to Close begin Tempdir.Create_Temp_File (Mapping_FD, Mapping_Path); Record_Temp_File (Project_Tree, Mapping_Path); if Mapping_FD /= Invalid_FD then OK := True; -- Traverse all units Unit := Units_Htable.Get_First (Project_Tree.Units_HT); while Unit /= No_Unit_Index loop if Unit.Name /= No_Name then -- If there is a body, put it in the mapping if Unit.File_Names (Impl) /= No_Source and then Unit.File_Names (Impl).Project /= No_Project then Get_Name_String (Unit.Name); Add_Str_To_Name_Buffer ("%b"); ALI_Unit := Name_Find; ALI_Name := Lib_File_Name (Unit.File_Names (Impl).Display_File); ALI_Project := Unit.File_Names (Impl).Project; -- Otherwise, if there is a spec, put it in the mapping elsif Unit.File_Names (Spec) /= No_Source and then Unit.File_Names (Spec).Project /= No_Project then Get_Name_String (Unit.Name); Add_Str_To_Name_Buffer ("%s"); ALI_Unit := Name_Find; ALI_Name := Lib_File_Name (Unit.File_Names (Spec).Display_File); ALI_Project := Unit.File_Names (Spec).Project; else ALI_Name := No_File; end if; -- If we have something to put in the mapping then do it now. -- However, if the project is extended, we don't put anything -- in the mapping file, since we don't know where the ALI file -- is: it might be in the extended project object directory as -- well as in the extending project object directory. if ALI_Name /= No_File and then ALI_Project.Extended_By = No_Project and then ALI_Project.Extends = No_Project then -- First check if the ALI file exists. If it does not, do -- not put the unit in the mapping file. declare ALI : constant String := Get_Name_String (ALI_Name); begin -- For library projects, use the library ALI directory, -- for other projects, use the object directory. if ALI_Project.Library then Get_Name_String (ALI_Project.Library_ALI_Dir.Display_Name); else Get_Name_String (ALI_Project.Object_Directory.Display_Name); end if; if not Is_Directory_Separator (Name_Buffer (Name_Len)) then Add_Char_To_Name_Buffer (Directory_Separator); end if; Add_Str_To_Name_Buffer (ALI); Add_Char_To_Name_Buffer (ASCII.LF); declare ALI_Path_Name : constant String := Name_Buffer (1 .. Name_Len); begin if Is_Regular_File (ALI_Path_Name (1 .. ALI_Path_Name'Last - 1)) then -- First line is the unit name Get_Name_String (ALI_Unit); Add_Char_To_Name_Buffer (ASCII.LF); Bytes := Write (Mapping_FD, Name_Buffer (1)'Address, Name_Len); OK := Bytes = Name_Len; exit when not OK; -- Second line it the ALI file name Get_Name_String (ALI_Name); Add_Char_To_Name_Buffer (ASCII.LF); Bytes := Write (Mapping_FD, Name_Buffer (1)'Address, Name_Len); OK := (Bytes = Name_Len); exit when not OK; -- Third line it the ALI path name Bytes := Write (Mapping_FD, ALI_Path_Name (1)'Address, ALI_Path_Name'Length); OK := (Bytes = ALI_Path_Name'Length); -- If OK is False, it means we were unable to -- write a line. No point in continuing with the -- other units. exit when not OK; end if; end; end; end if; end if; Unit := Units_Htable.Get_Next (Project_Tree.Units_HT); end loop; Close (Mapping_FD, Status); OK := OK and Status; end if; -- If the creation of the mapping file was successful, we add the switch -- to the arguments of gnatbind. if OK then return Mapping_Path; else return No_Path; end if; end Create_Binder_Mapping_File; ----------------- -- Create_Name -- ----------------- function Create_Name (Name : String) return File_Name_Type is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; function Create_Name (Name : String) return Name_Id is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; function Create_Name (Name : String) return Path_Name_Type is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; ---------------------- -- Delete_All_Marks -- ---------------------- procedure Delete_All_Marks is begin Marks.Reset; end Delete_All_Marks; ---------------------------- -- Executable_Prefix_Path -- ---------------------------- function Executable_Prefix_Path return String is Exec_Name : constant String := Command_Name; function Get_Install_Dir (S : String) return String; -- S is the executable name preceded by the absolute or relative path, -- e.g. "c:\usr\bin\gcc.exe". Returns the absolute directory where "bin" -- lies (in the example "C:\usr"). If the executable is not in a "bin" -- directory, return "". --------------------- -- Get_Install_Dir -- --------------------- function Get_Install_Dir (S : String) return String is Exec : String := S; Path_Last : Integer := 0; begin for J in reverse Exec'Range loop if Exec (J) = Directory_Separator then Path_Last := J - 1; exit; end if; end loop; if Path_Last >= Exec'First + 2 then To_Lower (Exec (Path_Last - 2 .. Path_Last)); end if; if Path_Last < Exec'First + 2 or else Exec (Path_Last - 2 .. Path_Last) /= "bin" or else (Path_Last - 3 >= Exec'First and then Exec (Path_Last - 3) /= Directory_Separator) then return ""; end if; return Normalize_Pathname (Exec (Exec'First .. Path_Last - 4), Resolve_Links => Opt.Follow_Links_For_Dirs) & Directory_Separator; end Get_Install_Dir; -- Beginning of Executable_Prefix_Path begin -- For VMS, the path returned is always /gnu/ if Hostparm.OpenVMS then return "/gnu/"; end if; -- First determine if a path prefix was placed in front of the -- executable name. for J in reverse Exec_Name'Range loop if Exec_Name (J) = Directory_Separator then return Get_Install_Dir (Exec_Name); end if; end loop; -- If we get here, the user has typed the executable name with no -- directory prefix. declare Path : String_Access := Locate_Exec_On_Path (Exec_Name); begin if Path = null then return ""; else declare Dir : constant String := Get_Install_Dir (Path.all); begin Free (Path); return Dir; end; end if; end; end Executable_Prefix_Path; -------------------------- -- File_Not_A_Source_Of -- -------------------------- function File_Not_A_Source_Of (Uname : Name_Id; Sfile : File_Name_Type) return Boolean is Unit : constant Unit_Index := Units_Htable.Get (Project_Tree.Units_HT, Uname); At_Least_One_File : Boolean := False; begin if Unit /= No_Unit_Index then for F in Unit.File_Names'Range loop if Unit.File_Names (F) /= null then At_Least_One_File := True; if Unit.File_Names (F).File = Sfile then return False; end if; end if; end loop; if not At_Least_One_File then -- The unit was probably created initially for a separate unit -- (which are initially created as IMPL when both suffixes are the -- same). Later on, Override_Kind changed the type of the file, -- and the unit is no longer valid in fact. return False; end if; Verbose_Msg (Uname, "sources do not include ", Name_Id (Sfile)); return True; end if; return False; end File_Not_A_Source_Of; ---------- -- Hash -- ---------- function Hash (Key : Mark_Key) return Mark_Num is begin return Union_Id (Key.File) mod Max_Mask_Num; end Hash; ------------ -- Inform -- ------------ procedure Inform (N : File_Name_Type; Msg : String) is begin Inform (Name_Id (N), Msg); end Inform; procedure Inform (N : Name_Id := No_Name; Msg : String) is begin Osint.Write_Program_Name; Write_Str (": "); if N /= No_Name then Write_Str (""""); declare Name : constant String := Get_Name_String (N); begin if Debug.Debug_Flag_F and then Is_Absolute_Path (Name) then Write_Str (File_Name (Name)); else Write_Str (Name); end if; end; Write_Str (""" "); end if; Write_Str (Msg); Write_Eol; end Inform; ---------------------------- -- Is_External_Assignment -- ---------------------------- function Is_External_Assignment (Tree : Prj.Tree.Project_Node_Tree_Ref; Argv : String) return Boolean is Start : Positive := 3; Finish : Natural := Argv'Last; pragma Assert (Argv'First = 1); pragma Assert (Argv (1 .. 2) = "-X"); begin if Argv'Last < 5 then return False; elsif Argv (3) = '"' then if Argv (Argv'Last) /= '"' or else Argv'Last < 7 then return False; else Start := 4; Finish := Argv'Last - 1; end if; end if; return Prj.Ext.Check (Tree => Tree, Declaration => Argv (Start .. Finish)); end Is_External_Assignment; --------------- -- Is_Marked -- --------------- function Is_Marked (Source_File : File_Name_Type; Index : Int := 0) return Boolean is begin return Marks.Get (K => (File => Source_File, Index => Index)); end Is_Marked; ----------------------------- -- Linker_Options_Switches -- ----------------------------- function Linker_Options_Switches (Project : Project_Id; In_Tree : Project_Tree_Ref) return String_List is procedure Recursive_Add (Proj : Project_Id; Dummy : in out Boolean); -- The recursive routine used to add linker options ------------------- -- Recursive_Add -- ------------------- procedure Recursive_Add (Proj : Project_Id; Dummy : in out Boolean) is pragma Unreferenced (Dummy); Linker_Package : Package_Id; Options : Variable_Value; begin Linker_Package := Prj.Util.Value_Of (Name => Name_Linker, In_Packages => Proj.Decl.Packages, In_Tree => In_Tree); Options := Prj.Util.Value_Of (Name => Name_Ada, Index => 0, Attribute_Or_Array_Name => Name_Linker_Options, In_Package => Linker_Package, In_Tree => In_Tree); -- If attribute is present, add the project with -- the attribute to table Linker_Opts. if Options /= Nil_Variable_Value then Linker_Opts.Increment_Last; Linker_Opts.Table (Linker_Opts.Last) := (Project => Proj, Options => Options.Values); end if; end Recursive_Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Recursive_Add); Dummy : Boolean := False; -- Start of processing for Linker_Options_Switches begin Linker_Opts.Init; For_All_Projects (Project, Dummy, Imported_First => True); Last_Linker_Option := 0; for Index in reverse 1 .. Linker_Opts.Last loop declare Options : String_List_Id; Proj : constant Project_Id := Linker_Opts.Table (Index).Project; Option : Name_Id; Dir_Path : constant String := Get_Name_String (Proj.Directory.Name); begin Options := Linker_Opts.Table (Index).Options; while Options /= Nil_String loop Option := In_Tree.String_Elements.Table (Options).Value; Get_Name_String (Option); -- Do not consider empty linker options if Name_Len /= 0 then Add_Linker_Option (Name_Buffer (1 .. Name_Len)); -- Object files and -L switches specified with relative -- paths must be converted to absolute paths. Test_If_Relative_Path (Switch => Linker_Options_Buffer (Last_Linker_Option), Parent => Dir_Path, Including_L_Switch => True); end if; Options := In_Tree.String_Elements.Table (Options).Next; end loop; end; end loop; return Linker_Options_Buffer (1 .. Last_Linker_Option); end Linker_Options_Switches; ----------- -- Mains -- ----------- package body Mains is type File_And_Loc is record File_Name : File_Name_Type; Index : Int := 0; Location : Source_Ptr := No_Location; end record; package Names is new Table.Table (Table_Component_Type => File_And_Loc, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Makeutl.Mains.Names"); -- The table that stores the mains Current : Natural := 0; -- The index of the last main retrieved from the table -------------- -- Add_Main -- -------------- procedure Add_Main (Name : String) is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); Names.Increment_Last; Names.Table (Names.Last) := (Name_Find, 0, No_Location); end Add_Main; ------------ -- Delete -- ------------ procedure Delete is begin Names.Set_Last (0); Mains.Reset; end Delete; --------------- -- Get_Index -- --------------- function Get_Index return Int is begin if Current in Names.First .. Names.Last then return Names.Table (Current).Index; else return 0; end if; end Get_Index; ------------------ -- Get_Location -- ------------------ function Get_Location return Source_Ptr is begin if Current in Names.First .. Names.Last then return Names.Table (Current).Location; else return No_Location; end if; end Get_Location; --------------- -- Next_Main -- --------------- function Next_Main return String is begin if Current >= Names.Last then return ""; else Current := Current + 1; return Get_Name_String (Names.Table (Current).File_Name); end if; end Next_Main; --------------------- -- Number_Of_Mains -- --------------------- function Number_Of_Mains return Natural is begin return Names.Last; end Number_Of_Mains; ----------- -- Reset -- ----------- procedure Reset is begin Current := 0; end Reset; --------------- -- Set_Index -- --------------- procedure Set_Index (Index : Int) is begin if Names.Last > 0 then Names.Table (Names.Last).Index := Index; end if; end Set_Index; ------------------ -- Set_Location -- ------------------ procedure Set_Location (Location : Source_Ptr) is begin if Names.Last > 0 then Names.Table (Names.Last).Location := Location; end if; end Set_Location; ----------------- -- Update_Main -- ----------------- procedure Update_Main (Name : String) is begin if Current in Names.First .. Names.Last then Name_Len := 0; Add_Str_To_Name_Buffer (Name); Names.Table (Current).File_Name := Name_Find; end if; end Update_Main; end Mains; ---------- -- Mark -- ---------- procedure Mark (Source_File : File_Name_Type; Index : Int := 0) is begin Marks.Set (K => (File => Source_File, Index => Index), E => True); end Mark; ----------------------- -- Path_Or_File_Name -- ----------------------- function Path_Or_File_Name (Path : Path_Name_Type) return String is Path_Name : constant String := Get_Name_String (Path); begin if Debug.Debug_Flag_F then return File_Name (Path_Name); else return Path_Name; end if; end Path_Or_File_Name; --------------------------- -- Test_If_Relative_Path -- --------------------------- procedure Test_If_Relative_Path (Switch : in out String_Access; Parent : String; Including_L_Switch : Boolean := True; Including_Non_Switch : Boolean := True; Including_RTS : Boolean := False) is begin if Switch /= null then declare Sw : String (1 .. Switch'Length); Start : Positive; begin Sw := Switch.all; if Sw (1) = '-' then if Sw'Length >= 3 and then (Sw (2) = 'A' or else Sw (2) = 'I' or else (Including_L_Switch and then Sw (2) = 'L')) then Start := 3; if Sw = "-I-" then return; end if; elsif Sw'Length >= 4 and then (Sw (2 .. 3) = "aL" or else Sw (2 .. 3) = "aO" or else Sw (2 .. 3) = "aI") then Start := 4; elsif Including_RTS and then Sw'Length >= 7 and then Sw (2 .. 6) = "-RTS=" then Start := 7; else return; end if; -- Because relative path arguments to --RTS= may be relative -- to the search directory prefix, those relative path -- arguments are converted only when they include directory -- information. if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then if Parent'Length = 0 then Do_Fail ("relative search path switches (""" & Sw & """) are not allowed"); elsif Including_RTS then for J in Start .. Sw'Last loop if Sw (J) = Directory_Separator then Switch := new String' (Sw (1 .. Start - 1) & Parent & Directory_Separator & Sw (Start .. Sw'Last)); return; end if; end loop; else Switch := new String' (Sw (1 .. Start - 1) & Parent & Directory_Separator & Sw (Start .. Sw'Last)); end if; end if; elsif Including_Non_Switch then if not Is_Absolute_Path (Sw) then if Parent'Length = 0 then Do_Fail ("relative paths (""" & Sw & """) are not allowed"); else Switch := new String'(Parent & Directory_Separator & Sw); end if; end if; end if; end; end if; end Test_If_Relative_Path; ------------------- -- Unit_Index_Of -- ------------------- function Unit_Index_Of (ALI_File : File_Name_Type) return Int is Start : Natural; Finish : Natural; Result : Int := 0; begin Get_Name_String (ALI_File); -- First, find the last dot Finish := Name_Len; while Finish >= 1 and then Name_Buffer (Finish) /= '.' loop Finish := Finish - 1; end loop; if Finish = 1 then return 0; end if; -- Now check that the dot is preceded by digits Start := Finish; Finish := Finish - 1; while Start >= 1 and then Name_Buffer (Start - 1) in '0' .. '9' loop Start := Start - 1; end loop; -- If there are no digits, or if the digits are not preceded by the -- character that precedes a unit index, this is not the ALI file of -- a unit in a multi-unit source. if Start > Finish or else Start = 1 or else Name_Buffer (Start - 1) /= Multi_Unit_Index_Character then return 0; end if; -- Build the index from the digit(s) while Start <= Finish loop Result := Result * 10 + Character'Pos (Name_Buffer (Start)) - Character'Pos ('0'); Start := Start + 1; end loop; return Result; end Unit_Index_Of; ----------------- -- Verbose_Msg -- ----------------- procedure Verbose_Msg (N1 : Name_Id; S1 : String; N2 : Name_Id := No_Name; S2 : String := ""; Prefix : String := " -> "; Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low) is begin if not Opt.Verbose_Mode or else Minimum_Verbosity > Opt.Verbosity_Level then return; end if; Write_Str (Prefix); Write_Str (""""); Write_Name (N1); Write_Str (""" "); Write_Str (S1); if N2 /= No_Name then Write_Str (" """); Write_Name (N2); Write_Str (""" "); end if; Write_Str (S2); Write_Eol; end Verbose_Msg; procedure Verbose_Msg (N1 : File_Name_Type; S1 : String; N2 : File_Name_Type := No_File; S2 : String := ""; Prefix : String := " -> "; Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low) is begin Verbose_Msg (Name_Id (N1), S1, Name_Id (N2), S2, Prefix, Minimum_Verbosity); end Verbose_Msg; end Makeutl;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- 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 Casing; use Casing; with Debug; use Debug; with Elists; use Elists; with Errout; use Errout; with Fname; use Fname; with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; with Scans; use Scans; with Scn; use Scn; with Sinput; use Sinput; with Sinput.L; use Sinput.L; with Sinfo; use Sinfo; with Snames; use Snames; with Style; with Table; with Tbuild; use Tbuild; --------- -- Par -- --------- function Par (Configuration_Pragmas : Boolean; From_Limited_With : Boolean := False) return List_Id is Num_Library_Units : Natural := 0; -- Count number of units parsed (relevant only in syntax check only mode, -- since in semantics check mode only a single unit is permitted anyway) Save_Config_Switches : Config_Switches_Type; -- Variable used to save values of config switches while we parse the -- new unit, to be restored on exit for proper recursive behavior. Loop_Block_Count : Nat := 0; -- Counter used for constructing loop/block names (see the routine -- Par.Ch5.Get_Loop_Block_Name) -------------------- -- Error Recovery -- -------------------- -- When an error is encountered, a call is made to one of the Error_Msg -- routines to record the error. If the syntax scan is not derailed by the -- error (e.g. a complaint that logical operators are inconsistent in an -- EXPRESSION), then control returns from the Error_Msg call, and the -- parse continues unimpeded. -- If on the other hand, the Error_Msg represents a situation from which -- the parser cannot recover locally, the exception Error_Resync is raised -- immediately after the call to Error_Msg. Handlers for Error_Resync -- are located at strategic points to resynchronize the parse. For example, -- when an error occurs in a statement, the handler skips to the next -- semicolon and continues the scan from there. -- Each parsing procedure contains a note with the heading "Error recovery" -- which shows if it can propagate the Error_Resync exception. In order -- not to propagate the exception, a procedure must either contain its own -- handler for this exception, or it must not call any other routines which -- propagate the exception. -- Note: the arrangement of Error_Resync handlers is such that it should -- never be possible to transfer control through a procedure which made -- an entry in the scope stack, invalidating the contents of the stack. Error_Resync : exception; -- Exception raised on error that is not handled locally, see above Last_Resync_Point : Source_Ptr; -- The resynchronization routines in Par.Sync run a risk of getting -- stuck in an infinite loop if they do not skip a token, and the caller -- keeps repeating the same resync call. On the other hand, if they skip -- a token unconditionally, some recovery opportunities are missed. The -- variable Last_Resync_Point records the token location previously set -- by a Resync call, and if a subsequent Resync call occurs at the same -- location, then the Resync routine does guarantee to skip a token. -------------------------------------------- -- Handling Semicolon Used in Place of IS -- -------------------------------------------- -- The following global variables are used in handling the error situation -- of using a semicolon in place of IS in a subprogram declaration as in: -- procedure X (Y : Integer); -- Q : Integer; -- begin -- ... -- end; -- The two contexts in which this can appear are at the outer level, and -- within a declarative region. At the outer level, we know something is -- wrong as soon as we see the Q (or begin, if there are no declarations), -- and we can immediately decide that the semicolon should have been IS. -- The situation in a declarative region is more complex. The declaration -- of Q could belong to the outer region, and we do not know that we have -- an error until we hit the begin. It is still not clear at this point -- from a syntactic point of view that something is wrong, because the -- begin could belong to the enclosing subprogram or package. However, we -- can incorporate a bit of semantic knowledge and note that the body of -- X is missing, so we definitely DO have an error. We diagnose this error -- as semicolon in place of IS on the subprogram line. -- There are two styles for this diagnostic. If the begin immediately -- follows the semicolon, then we can place a flag (IS expected) right -- on the semicolon. Otherwise we do not detect the error until we hit -- the begin which refers back to the line with the semicolon. -- To control the process in the second case, the following global -- variables are set to indicate that we have a subprogram declaration -- whose body is required and has not yet been found. The prefix SIS -- stands for "Subprogram IS" handling. SIS_Entry_Active : Boolean; -- Set True to indicate that an entry is active (i.e. that a subprogram -- declaration has been encountered, and no body for this subprogram has -- been encountered). The remaining fields are valid only if this is True. SIS_Labl : Node_Id; -- Subprogram designator SIS_Sloc : Source_Ptr; -- Source location of FUNCTION/PROCEDURE keyword SIS_Ecol : Column_Number; -- Column number of FUNCTION/PROCEDURE keyword SIS_Semicolon_Sloc : Source_Ptr; -- Source location of semicolon at end of subprogram declaration SIS_Declaration_Node : Node_Id; -- Pointer to tree node for subprogram declaration SIS_Missing_Semicolon_Message : Error_Msg_Id; -- Used to save message ID of missing semicolon message (which will be -- modified to missing IS if necessary). Set to No_Error_Msg in the -- normal (non-error) case. -- Five things can happen to an active SIS entry -- 1. If a BEGIN is encountered with an SIS entry active, then we have -- exactly the situation in which we know the body of the subprogram is -- missing. After posting an error message, we change the spec to a body, -- rechaining the declarations that intervened between the spec and BEGIN. -- 2. Another subprogram declaration or body is encountered. In this -- case the entry gets overwritten with the information for the new -- subprogram declaration. We don't catch some nested cases this way, -- but it doesn't seem worth the effort. -- 3. A nested declarative region (e.g. package declaration or package -- body) is encountered. The SIS active indication is reset at the start -- of such a nested region. Again, like case 2, this causes us to miss -- some nested cases, but it doesn't seen worth the effort to stack and -- unstack the SIS information. Maybe we will reconsider this if we ever -- get a complaint about a missed case :-) -- 4. We encounter a valid pragma INTERFACE or IMPORT that effectively -- supplies the missing body. In this case we reset the entry. -- 5. We encounter the end of the declarative region without encoutering -- a BEGIN first. In this situation we simply reset the entry. We know -- that there is a missing body, but it seems more reasonable to let the -- later semantic checking discover this. ---------------------------------------------------- -- Handling of Reserved Words Used as Identifiers -- ---------------------------------------------------- -- Note: throughout the parser, the terms reserved word and keyword -- are used interchangably to refer to the same set of reserved -- keywords (including until, protected, etc). -- If a reserved word is used in place of an identifier, the parser -- where possible tries to recover gracefully. In particular, if the -- keyword is clearly spelled using identifier casing, e.g. Until in -- a source program using mixed case identifiers and lower case keywords, -- then the keyword is treated as an identifier if it appears in a place -- where an identifier is required. -- The situation is more complex if the keyword is spelled with normal -- keyword casing. In this case, the parser is more reluctant to -- consider it to be intended as an identifier, unless it has some -- further confirmation. -- In the case of an identifier appearing in the identifier list of a -- declaration, the appearence of a comma or colon right after the -- keyword on the same line is taken as confirmation. For an enumeration -- literal, a comma or right paren right after the identifier is also -- treated as adequate confirmation. -- The following type is used in calls to Is_Reserved_Identifier and -- also to P_Defining_Identifier and P_Identifier. The default for all -- these functins is that reserved words in reserved word case are not -- considered to be reserved identifiers. The Id_Check value indicates -- tokens, which if they appear immediately after the identifier, are -- taken as confirming that the use of an identifier was expected type Id_Check is (None, -- Default, no special token test C_Comma_Right_Paren, -- Consider as identifier if followed by comma or right paren C_Comma_Colon, -- Consider as identifier if followed by comma or colon C_Do, -- Consider as identifier if followed by DO C_Dot, -- Consider as identifier if followed by period C_Greater_Greater, -- Consider as identifier if followed by >> C_In, -- Consider as identifier if followed by IN C_Is, -- Consider as identifier if followed by IS C_Left_Paren_Semicolon, -- Consider as identifier if followed by left paren or semicolon C_Use, -- Consider as identifier if followed by USE C_Vertical_Bar_Arrow); -- Consider as identifier if followed by | or => -------------------------------------------- -- Handling IS Used in Place of Semicolon -- -------------------------------------------- -- This is a somewhat trickier situation, and we can't catch it in all -- cases, but we do our best to detect common situations resulting from -- a "cut and paste" operation which forgets to change the IS to semicolon. -- Consider the following example: -- package body X is -- procedure A; -- procedure B is -- procedure C; -- ... -- procedure D is -- begin -- ... -- end; -- begin -- ... -- end; -- The trouble is that the section of text from PROCEDURE B through END; -- consitutes a valid procedure body, and the danger is that we find out -- far too late that something is wrong (indeed most compilers will behave -- uncomfortably on the above example). -- We have two approaches to helping to control this situation. First we -- make every attempt to avoid swallowing the last END; if we can be -- sure that some error will result from doing so. In particular, we won't -- accept the END; unless it is exactly correct (in particular it must not -- have incorrect name tokens), and we won't accept it if it is immediately -- followed by end of file, WITH or SEPARATE (all tokens that unmistakeably -- signal the start of a compilation unit, and which therefore allow us to -- reserve the END; for the outer level.) For more details on this aspect -- of the handling, see package Par.Endh. -- If we can avoid eating up the END; then the result in the absense of -- any additional steps would be to post a missing END referring back to -- the subprogram with the bogus IS. Similarly, if the enclosing package -- has no BEGIN, then the result is a missing BEGIN message, which again -- refers back to the subprogram header. -- Such an error message is not too bad (it's already a big improvement -- over what many parsers do), but it's not ideal, because the declarations -- following the IS have been absorbed into the wrong scope. In the above -- case, this could result for example in a bogus complaint that the body -- of D was missing from the package. -- To catch at least some of these cases, we take the following additional -- steps. First, a subprogram body is marked as having a suspicious IS if -- the declaration line is followed by a line which starts with a symbol -- that can start a declaration in the same column, or to the left of the -- column in which the FUNCTION or PROCEDURE starts (normal style is to -- indent any declarations which really belong a subprogram). If such a -- subprogram encounters a missing BEGIN or missing END, then we decide -- that the IS should have been a semicolon, and the subprogram body node -- is marked (by setting the Bad_Is_Detected flag true. Note that we do -- not do this for library level procedures, only for nested procedures, -- since for library level procedures, we must have a body. -- The processing for a declarative part checks to see if the last -- declaration scanned is marked in this way, and if it is, the tree -- is modified to reflect the IS being interpreted as a semicolon. --------------------------------------------------- -- Parser Type Definitions and Control Variables -- --------------------------------------------------- -- The following variable and associated type declaration are used by the -- expression parsing routines to return more detailed information about -- the categorization of a parsed expression. type Expr_Form_Type is ( EF_Simple_Name, -- Simple name, i.e. possibly qualified identifier EF_Name, -- Simple expression which could also be a name EF_Simple, -- Simple expression which is not call or name EF_Range_Attr, -- Range attribute reference EF_Non_Simple); -- Expression that is not a simple expression Expr_Form : Expr_Form_Type; -- The following type is used for calls to P_Subprogram, P_Package, P_Task, -- P_Protected to indicate which of several possibilities is acceptable. type Pf_Rec is record Spcn : Boolean; -- True if specification OK Decl : Boolean; -- True if declaration OK Gins : Boolean; -- True if generic instantiation OK Pbod : Boolean; -- True if proper body OK Rnam : Boolean; -- True if renaming declaration OK Stub : Boolean; -- True if body stub OK Fil1 : Boolean; -- Filler to fill to 8 bits Fil2 : Boolean; -- Filler to fill to 8 bits end record; pragma Pack (Pf_Rec); function T return Boolean renames True; function F return Boolean renames False; Pf_Decl_Gins_Pbod_Rnam_Stub : constant Pf_Rec := Pf_Rec'(F, T, T, T, T, T, F, F); Pf_Decl : constant Pf_Rec := Pf_Rec'(F, T, F, F, F, F, F, F); Pf_Decl_Gins_Pbod_Rnam : constant Pf_Rec := Pf_Rec'(F, T, T, T, T, F, F, F); Pf_Decl_Pbod : constant Pf_Rec := Pf_Rec'(F, T, F, T, F, F, F, F); Pf_Pbod : constant Pf_Rec := Pf_Rec'(F, F, F, T, F, F, F, F); Pf_Spcn : constant Pf_Rec := Pf_Rec'(T, F, F, F, F, F, F, F); -- The above are the only allowed values of Pf_Rec arguments type SS_Rec is record Eftm : Boolean; -- ELSIF can terminate sequence Eltm : Boolean; -- ELSE can terminate sequence Extm : Boolean; -- EXCEPTION can terminate sequence Ortm : Boolean; -- OR can terminate sequence Sreq : Boolean; -- at least one statement required Tatm : Boolean; -- THEN ABORT can terminate sequence Whtm : Boolean; -- WHEN can terminate sequence Unco : Boolean; -- Unconditional terminate after one statement end record; pragma Pack (SS_Rec); SS_Eftm_Eltm_Sreq : constant SS_Rec := SS_Rec'(T, T, F, F, T, F, F, F); SS_Eltm_Ortm_Tatm : constant SS_Rec := SS_Rec'(F, T, F, T, F, T, F, F); SS_Extm_Sreq : constant SS_Rec := SS_Rec'(F, F, T, F, T, F, F, F); SS_None : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, F, F); SS_Ortm_Sreq : constant SS_Rec := SS_Rec'(F, F, F, T, T, F, F, F); SS_Sreq : constant SS_Rec := SS_Rec'(F, F, F, F, T, F, F, F); SS_Sreq_Whtm : constant SS_Rec := SS_Rec'(F, F, F, F, T, F, T, F); SS_Whtm : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, T, F); SS_Unco : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, F, T); Goto_List : Elist_Id; -- List of goto nodes appearing in the current compilation. Used to -- recognize natural loops and convert them into bona fide loops for -- optimization purposes. Label_List : Elist_Id; -- List of label nodes for labels appearing in the current compilation. -- Used by Par.Labl to construct the corresponding implicit declarations. ----------------- -- Scope Table -- ----------------- -- The scope table, also referred to as the scope stack, is used to -- record the current scope context. It is organized as a stack, with -- inner nested entries corresponding to higher entries on the stack. -- An entry is made when the parser encounters the opening of a nested -- construct (such as a record, task, package etc.), and then package -- Par.Endh uses this stack to deal with END lines (including properly -- dealing with END nesting errors). type SS_End_Type is -- Type of end entry required for this scope. The last two entries are -- used only in the subprogram body case to mark the case of a suspicious -- IS, or a bad IS (i.e. suspicions confirmed by missing BEGIN or END). -- See separate section on dealing with IS used in place of semicolon. -- Note that for many purposes E_Name, E_Suspicious_Is and E_Bad_Is are -- treated the same (E_Suspicious_Is and E_Bad_Is are simply special cases -- of E_Name). They are placed at the end of the enumeration so that a -- test for >= E_Name catches all three cases efficiently. (E_Dummy, -- dummy entry at outer level E_Case, -- END CASE; E_If, -- END IF; E_Loop, -- END LOOP; E_Record, -- END RECORD; E_Select, -- END SELECT; E_Name, -- END [name]; E_Suspicious_Is, -- END [name]; (case of suspicious IS) E_Bad_Is); -- END [name]; (case of bad IS) -- The following describes a single entry in the scope table type Scope_Table_Entry is record Etyp : SS_End_Type; -- Type of end entry, as per above description Lreq : Boolean; -- A flag indicating whether the label, if present, is required to -- appear on the end line. It is referenced only in the case of -- Etyp = E_Name or E_Suspicious_Is where the name may or may not be -- required (yes for labeled block, no in other cases). Note that for -- all cases except begin, the question of whether a label is required -- can be determined from the other fields (for loop, it is required if -- it is present, and for the other constructs it is never required or -- allowed). Ecol : Column_Number; -- Contains the absolute column number (with tabs expanded) of the -- the expected column of the end assuming normal Ada indentation -- usage. If the RM_Column_Check mode is set, this value is used for -- generating error messages about indentation. Otherwise it is used -- only to control heuristic error recovery actions. Labl : Node_Id; -- This field is used only for the LOOP and BEGIN cases, and is the -- Node_Id value of the label name. For all cases except child units, -- this value is an entity whose Chars field contains the name pointer -- that identifies the label uniquely. For the child unit case the Labl -- field references an N_Defining_Program_Unit_Name node for the name. -- For cases other than LOOP or BEGIN, the Label field is set to Error, -- indicating that it is an error to have a label on the end line. -- (this is really a misuse of Error since there is no Error ???) Decl : List_Id; -- Points to the list of declarations (i.e. the declarative part) -- associated with this construct. It is set only in the END [name] -- cases, and is set to No_List for all other cases which do not have a -- declarative unit associated with them. This is used for determining -- the proper location for implicit label declarations. Node : Node_Id; -- Empty except in the case of entries for IF and CASE statements, -- in which case it contains the N_If_Statement or N_Case_Statement -- node. This is used for setting the End_Span field. Sloc : Source_Ptr; -- Source location of the opening token of the construct. This is -- used to refer back to this line in error messages (such as missing -- or incorrect end lines). The Sloc field is not used, and is not set, -- if a label is present (the Labl field provides the text name of the -- label in this case, which is fine for error messages). S_Is : Source_Ptr; -- S_Is is relevant only if Etyp is set to E_Suspicious_Is or -- E_Bad_Is. It records the location of the IS that is considered -- to be suspicious. Junk : Boolean; -- A boolean flag that is set true if the opening entry is the dubious -- result of some prior error, e.g. a record entry where the record -- keyword was missing. It is used to suppress the issuing of a -- corresponding junk complaint about the end line (we do not want -- to complain about a missing end record when there was no record). end record; -- The following declares the scope table itself. The Last field is the -- stack pointer, so that Scope.Table (Scope.Last) is the top entry. The -- oldest entry, at Scope_Stack (0), is a dummy entry with Etyp set to -- E_Dummy, and the other fields undefined. This dummy entry ensures that -- Scope_Stack (Scope_Stack_Ptr).Etyp can always be tested, and that the -- scope stack pointer is always in range. package Scope is new Table.Table ( Table_Component_Type => Scope_Table_Entry, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 50, Table_Increment => 100, Table_Name => "Scope"); --------------------------------- -- Parsing Routines by Chapter -- --------------------------------- -- Uncommented declarations in this section simply parse the construct -- corresponding to their name, and return an ID value for the Node or -- List that is created. ------------- -- Par.Ch2 -- ------------- package Ch2 is function P_Pragma return Node_Id; function P_Identifier (C : Id_Check := None) return Node_Id; -- Scans out an identifier. The parameter C determines the treatment -- of reserved identifiers. See declaration of Id_Check for details. function P_Pragmas_Opt return List_Id; -- This function scans for a sequence of pragmas in other than a -- declaration sequence or statement sequence context. All pragmas -- can appear except pragmas Assert and Debug, which are only allowed -- in a declaration or statement sequence context. procedure P_Pragmas_Misplaced; -- Skips misplaced pragmas with a complaint procedure P_Pragmas_Opt (List : List_Id); -- Parses optional pragmas and appends them to the List end Ch2; ------------- -- Par.Ch3 -- ------------- package Ch3 is Missing_Begin_Msg : Error_Msg_Id; -- This variable is set by a call to P_Declarative_Part. Normally it -- is set to No_Error_Msg, indicating that no special processing is -- required by the caller. The special case arises when a statement -- is found in the sequence of declarations. In this case the Id of -- the message issued ("declaration expected") is preserved in this -- variable, then the caller can change it to an appropriate missing -- begin message if indeed the BEGIN is missing. function P_Array_Type_Definition return Node_Id; function P_Basic_Declarative_Items return List_Id; function P_Constraint_Opt return Node_Id; function P_Declarative_Part return List_Id; function P_Discrete_Choice_List return List_Id; function P_Discrete_Range return Node_Id; function P_Discrete_Subtype_Definition return Node_Id; function P_Known_Discriminant_Part_Opt return List_Id; function P_Signed_Integer_Type_Definition return Node_Id; function P_Range return Node_Id; function P_Range_Or_Subtype_Mark return Node_Id; function P_Range_Constraint return Node_Id; function P_Record_Definition return Node_Id; function P_Subtype_Mark return Node_Id; function P_Subtype_Mark_Resync return Node_Id; function P_Unknown_Discriminant_Part_Opt return Boolean; function P_Access_Definition (Null_Exclusion_Present : Boolean) return Node_Id; -- Ada 2005 (AI-231/AI-254): The caller parses the null-exclusion part -- and indicates if it was present function P_Access_Type_Definition (Header_Already_Parsed : Boolean := False) return Node_Id; -- Ada 2005 (AI-254): The formal is used to indicate if the caller has -- parsed the null_exclusion part. In this case the caller has also -- removed the ACCESS token procedure P_Component_Items (Decls : List_Id); -- Scan out one or more component items and append them to the -- given list. Only scans out more than one declaration in the -- case where the source has a single declaration with multiple -- defining identifiers. function P_Defining_Identifier (C : Id_Check := None) return Node_Id; -- Scan out a defining identifier. The parameter C controls the -- treatment of errors in case a reserved word is scanned. See the -- declaration of this type for details. function P_Interface_Type_Definition (Is_Synchronized : Boolean) return Node_Id; -- Ada 2005 (AI-251): Parse the interface type definition part. The -- parameter Is_Synchronized is True in case of task interfaces, -- protected interfaces, and synchronized interfaces; it is used to -- generate a record_definition node. In the rest of cases (limited -- interfaces and interfaces) we generate a record_definition node if -- the list of interfaces is empty; otherwise we generate a -- derived_type_definition node (the first interface in this list is the -- ancestor interface). function P_Null_Exclusion return Boolean; -- Ada 2005 (AI-231): Parse the null-excluding part. True indicates -- that the null-excluding part was present. function P_Subtype_Indication (Not_Null_Present : Boolean := False) return Node_Id; -- Ada 2005 (AI-231): The flag Not_Null_Present indicates that the -- null-excluding part has been scanned out and it was present. function Init_Expr_Opt (P : Boolean := False) return Node_Id; -- If an initialization expression is present (:= expression), then -- it is scanned out and returned, otherwise Empty is returned if no -- initialization expression is present. This procedure also handles -- certain common error cases cleanly. The parameter P indicates if -- a right paren can follow the expression (default = no right paren -- allowed). procedure Skip_Declaration (S : List_Id); -- Used when scanning statements to skip past a mispaced declaration -- The declaration is scanned out and appended to the given list. -- Token is known to be a declaration token (in Token_Class_Declk) -- on entry, so there definition is a declaration to be scanned. function P_Subtype_Indication (Subtype_Mark : Node_Id; Not_Null_Present : Boolean := False) return Node_Id; -- This version of P_Subtype_Indication is called when the caller has -- already scanned out the subtype mark which is passed as a parameter. -- Ada 2005 (AI-231): The flag Not_Null_Present indicates that the -- null-excluding part has been scanned out and it was present. function P_Subtype_Mark_Attribute (Type_Node : Node_Id) return Node_Id; -- Parse a subtype mark attribute. The caller has already parsed the -- subtype mark, which is passed in as the argument, and has checked -- that the current token is apostrophe. end Ch3; ------------- -- Par.Ch4 -- ------------- package Ch4 is function P_Aggregate return Node_Id; function P_Expression return Node_Id; function P_Expression_No_Right_Paren return Node_Id; function P_Expression_Or_Range_Attribute return Node_Id; function P_Function_Name return Node_Id; function P_Name return Node_Id; function P_Qualified_Simple_Name return Node_Id; function P_Qualified_Simple_Name_Resync return Node_Id; function P_Simple_Expression return Node_Id; function P_Simple_Expression_Or_Range_Attribute return Node_Id; function P_Qualified_Expression (Subtype_Mark : Node_Id) return Node_Id; -- This routine scans out a qualified expression when the caller has -- already scanned out the name and apostrophe of the construct. end Ch4; ------------- -- Par.Ch5 -- ------------- package Ch5 is function P_Statement_Name (Name_Node : Node_Id) return Node_Id; -- Given a node representing a name (which is a call), converts it -- to the syntactically corresponding procedure call statement. function P_Sequence_Of_Statements (SS_Flags : SS_Rec) return List_Id; -- The argument indicates the acceptable termination tokens. -- See body in Par.Ch5 for details of the use of this parameter. procedure Parse_Decls_Begin_End (Parent : Node_Id); -- Parses declarations and handled statement sequence, setting -- fields of Parent node appropriately. end Ch5; ------------- -- Par.Ch6 -- ------------- package Ch6 is function P_Designator return Node_Id; function P_Defining_Program_Unit_Name return Node_Id; function P_Formal_Part return List_Id; function P_Parameter_Profile return List_Id; function P_Return_Statement return Node_Id; function P_Subprogram_Specification return Node_Id; procedure P_Mode (Node : Node_Id); -- Sets In_Present and/or Out_Present flags in Node scanning past -- IN, OUT or IN OUT tokens in the source. function P_Subprogram (Pf_Flags : Pf_Rec) return Node_Id; -- Scans out any construct starting with either of the keywords -- PROCEDURE or FUNCTION. The parameter indicates which possible -- possible kinds of construct (body, spec, instantiation etc.) -- are permissible in the current context. end Ch6; ------------- -- Par.Ch7 -- ------------- package Ch7 is function P_Package (Pf_Flags : Pf_Rec) return Node_Id; -- Scans out any construct starting with the keyword PACKAGE. The -- parameter indicates which possible kinds of construct (body, spec, -- instantiation etc.) are permissible in the current context. end Ch7; ------------- -- Par.Ch8 -- ------------- package Ch8 is function P_Use_Clause return Node_Id; end Ch8; ------------- -- Par.Ch9 -- ------------- package Ch9 is function P_Abort_Statement return Node_Id; function P_Abortable_Part return Node_Id; function P_Accept_Statement return Node_Id; function P_Delay_Statement return Node_Id; function P_Entry_Body return Node_Id; function P_Protected return Node_Id; function P_Requeue_Statement return Node_Id; function P_Select_Statement return Node_Id; function P_Task return Node_Id; function P_Terminate_Alternative return Node_Id; end Ch9; -------------- -- Par.Ch10 -- -------------- package Ch10 is function P_Compilation_Unit return Node_Id; -- Note: this function scans a single compilation unit, and -- checks that an end of file follows this unit, diagnosing -- any unexpected input as an error, and then skipping it, so -- that Token is set to Tok_EOF on return. An exception is in -- syntax-only mode, where multiple compilation units are -- permitted. In this case, P_Compilation_Unit does not check -- for end of file and there may be more compilation units to -- scan. The caller can uniquely detect this situation by the -- fact that Token is not set to Tok_EOF on return. -- -- The Ignore parameter is normally set False. It is set True -- in multiple unit per file mode if we are skipping past a unit -- that we are not interested in. end Ch10; -------------- -- Par.Ch11 -- -------------- package Ch11 is function P_Handled_Sequence_Of_Statements return Node_Id; function P_Raise_Statement return Node_Id; function Parse_Exception_Handlers return List_Id; -- Parses the partial construct EXCEPTION followed by a list of -- exception handlers which appears in a number of productions, -- and returns the list of exception handlers. end Ch11; -------------- -- Par.Ch12 -- -------------- package Ch12 is function P_Generic return Node_Id; function P_Generic_Actual_Part_Opt return List_Id; end Ch12; -------------- -- Par.Ch13 -- -------------- package Ch13 is function P_Representation_Clause return Node_Id; function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id; -- Function to parse a code statement. The caller has scanned out -- the name to be used as the subtype mark (but has not checked that -- it is suitable for use as a subtype mark, i.e. is either an -- identifier or a selected component). The current token is an -- apostrophe and the following token is either a left paren or -- RANGE (the latter being an error to be caught by P_Code_Statement. end Ch13; -- Note: the parsing for annexe J features (i.e. obsolescent features) -- is found in the logical section where these features would be if -- they were not obsolescent. In particular: -- Delta constraint is parsed by P_Delta_Constraint (3.5.9) -- At clause is parsed by P_At_Clause (13.1) -- Mod clause is parsed by P_Mod_Clause (13.5.1) -------------- -- Par.Endh -- -------------- -- Routines for handling end lines, including scope recovery package Endh is function Check_End return Boolean; -- Called when an end sequence is required. In the absence of an error -- situation, Token contains Tok_End on entry, but in a missing end -- case, this may not be the case. Pop_End_Context is used to determine -- the appropriate action to be taken. The returned result is True if -- an End sequence was encountered and False if no End sequence was -- present. This occurs if the END keyword encountered was determined -- to be improper and deleted (i.e. Pop_End_Context set End_Action to -- Skip_And_Reject). Note that the END sequence includes a semicolon, -- except in the case of END RECORD, where a semicolon follows the END -- RECORD, but is not part of the record type definition itself. procedure End_Skip; -- Skip past an end sequence. On entry Token contains Tok_End, and we -- we know that the end sequence is syntactically incorrect, and that -- an appropriate error message has already been posted. The mission -- is simply to position the scan pointer to be the best guess of the -- position after the end sequence. We do not issue any additional -- error messages while carrying this out. procedure End_Statements (Parent : Node_Id := Empty); -- Called when an end is required or expected to terminate a sequence -- of statements. The caller has already made an appropriate entry in -- the Scope.Table to describe the expected form of the end. This can -- only be used in cases where the only appropriate terminator is end. -- If Parent is non-empty, then if a correct END line is encountered, -- the End_Label field of Parent is set appropriately. end Endh; -------------- -- Par.Sync -- -------------- -- These procedures are used to resynchronize after errors. Following an -- error which is not immediately locally recoverable, the exception -- Error_Resync is raised. The handler for Error_Resync typically calls -- one of these recovery procedures to resynchronize the source position -- to a point from which parsing can be restarted. -- Note: these procedures output an information message that tokens are -- being skipped, but this message is output only if the option for -- Multiple_Errors_Per_Line is set in Options. package Sync is procedure Resync_Choice; -- Used if an error occurs scanning a choice. The scan pointer is -- advanced to the next vertical bar, arrow, or semicolon, whichever -- comes first. We also quit if we encounter an end of file. procedure Resync_Expression; -- Used if an error is detected during the parsing of an expression. -- It skips past tokens until either a token which cannot be part of -- an expression is encountered (an expression terminator), or if a -- comma or right parenthesis or vertical bar is encountered at the -- current parenthesis level (a parenthesis level counter is maintained -- to carry out this test). procedure Resync_Past_Semicolon; -- Used if an error occurs while scanning a sequence of declarations. -- The scan pointer is positioned past the next semicolon and the scan -- resumes. The scan is also resumed on encountering a token which -- starts a declaration (but we make sure to skip at least one token -- in this case, to avoid getting stuck in a loop). procedure Resync_To_Semicolon; -- Similar to Resync_Past_Semicolon, except that the scan pointer is -- left pointing to the semicolon rather than past it. procedure Resync_Past_Semicolon_Or_To_Loop_Or_Then; -- Used if an error occurs while scanning a sequence of statements. -- The scan pointer is positioned past the next semicolon, or to the -- next occurrence of either then or loop, and the scan resumes. procedure Resync_To_When; -- Used when an error occurs scanning an entry index specification. -- The scan pointer is positioned to the next WHEN (or to IS or -- semicolon if either of these appear before WHEN, indicating -- another error has occurred). procedure Resync_Semicolon_List; -- Used if an error occurs while scanning a parenthesized list of items -- separated by semicolons. The scan pointer is advanced to the next -- semicolon or right parenthesis at the outer parenthesis level, or -- to the next is or RETURN keyword occurence, whichever comes first. procedure Resync_Cunit; -- Synchronize to next token which could be the start of a compilation -- unit, or to the end of file token. end Sync; -------------- -- Par.Tchk -- -------------- -- Routines to check for expected tokens package Tchk is -- Procedures with names of the form T_xxx, where Tok_xxx is a token -- name, check that the current token matches the required token, and -- if so, scan past it. If not, an error is issued indicating that -- the required token is not present (xxx expected). In most cases, the -- scan pointer is not moved in the not-found case, but there are some -- exceptions to this, see for example T_Id, where the scan pointer is -- moved across a literal appearing where an identifier is expected. procedure T_Abort; procedure T_Arrow; procedure T_At; procedure T_Body; procedure T_Box; procedure T_Colon; procedure T_Colon_Equal; procedure T_Comma; procedure T_Dot_Dot; procedure T_For; procedure T_Greater_Greater; procedure T_Identifier; procedure T_In; procedure T_Is; procedure T_Left_Paren; procedure T_Loop; procedure T_Mod; procedure T_New; procedure T_Of; procedure T_Or; procedure T_Private; procedure T_Range; procedure T_Record; procedure T_Right_Paren; procedure T_Semicolon; procedure T_Then; procedure T_Type; procedure T_Use; procedure T_When; procedure T_With; -- Procedures have names of the form TF_xxx, where Tok_xxx is a token -- name check that the current token matches the required token, and -- if so, scan past it. If not, an error message is issued indicating -- that the required token is not present (xxx expected). -- If the missing token is at the end of the line, then control returns -- immediately after posting the message. If there are remaining tokens -- on the current line, a search is conducted to see if the token -- appears later on the current line, as follows: -- A call to Scan_Save is issued and a forward search for the token -- is carried out. If the token is found on the current line before a -- semicolon, then it is scanned out and the scan continues from that -- point. If not the scan is restored to the point where it was missing. procedure TF_Arrow; procedure TF_Is; procedure TF_Loop; procedure TF_Return; procedure TF_Semicolon; procedure TF_Then; procedure TF_Use; end Tchk; -------------- -- Par.Util -- -------------- package Util is function Bad_Spelling_Of (T : Token_Type) return Boolean; -- This function is called in an error situation. It checks if the -- current token is an identifier whose name is a plausible bad -- spelling of the given keyword token, and if so, issues an error -- message, sets Token from T, and returns True. Otherwise Token is -- unchanged, and False is returned. procedure Check_Bad_Layout; -- Check for bad indentation in RM checking mode. Used for statements -- and declarations. Checks if current token is at start of line and -- is exdented from the current expected end column, and if so an -- error message is generated. procedure Check_Misspelling_Of (T : Token_Type); pragma Inline (Check_Misspelling_Of); -- This is similar to the function above, except that it does not -- return a result. It is typically used in a situation where any -- identifier is an error, and it makes sense to simply convert it -- to the given token if it is a plausible misspelling of it. procedure Check_95_Keyword (Token_95, Next : Token_Type); -- This routine checks if the token after the current one matches the -- Next argument. If so, the scan is backed up to the current token -- and Token_Type is changed to Token_95 after issuing an appropriate -- error message ("(Ada 83) keyword xx cannot be used"). If not, -- the scan is backed up with Token_Type unchanged. This routine -- is used to deal with an attempt to use a 95 keyword in Ada 83 -- mode. The caller has typically checked that the current token, -- an identifier, matches one of the 95 keywords. procedure Check_Simple_Expression (E : Node_Id); -- Given an expression E, that has just been scanned, so that Expr_Form -- is still set, outputs an error if E is a non-simple expression. E is -- not modified by this call. procedure Check_Simple_Expression_In_Ada_83 (E : Node_Id); -- Like Check_Simple_Expression, except that the error message is only -- given when operating in Ada 83 mode, and includes "in Ada 83". function Check_Subtype_Mark (Mark : Node_Id) return Node_Id; -- Called to check that a node representing a name (or call) is -- suitable for a subtype mark, i.e, that it is an identifier or -- a selected component. If so, or if it is already Error, then -- it is returned unchanged. Otherwise an error message is issued -- and Error is returned. function Comma_Present return Boolean; -- Used in comma delimited lists to determine if a comma is present, or -- can reasonably be assumed to have been present (an error message is -- generated in the latter case). If True is returned, the scan has been -- positioned past the comma. If False is returned, the scan position -- is unchanged. Note that all comma-delimited lists are terminated by -- a right paren, so the only legitimate tokens when Comma_Present is -- called are right paren and comma. If some other token is found, then -- Comma_Present has the job of deciding whether it is better to pretend -- a comma was present, post a message for a missing comma and return -- True, or return False and let the caller diagnose the missing right -- parenthesis. procedure Discard_Junk_Node (N : Node_Id); procedure Discard_Junk_List (L : List_Id); pragma Inline (Discard_Junk_Node); pragma Inline (Discard_Junk_List); -- These procedures do nothing at all, their effect is simply to discard -- the argument. A typical use is to skip by some junk that is not -- expected in the current context. procedure Ignore (T : Token_Type); -- If current token matches T, then give an error message and skip -- past it, otherwise the call has no effect at all. T may be any -- reserved word token, or comma, left or right paren, or semicolon. function Is_Reserved_Identifier (C : Id_Check := None) return Boolean; -- Test if current token is a reserved identifier. This test is based -- on the token being a keyword and being spelled in typical identifier -- style (i.e. starting with an upper case letter). The parameter C -- determines the special treatment if a reserved word is encountered -- that has the normal casing of a reserved word. procedure Merge_Identifier (Prev : Node_Id; Nxt : Token_Type); -- Called when the previous token is an identifier (whose Token_Node -- value is given by Prev) to check if current token is an identifier -- that can be merged with the previous one adding an underscore. The -- merge is only attempted if the following token matches Nxt. If all -- conditions are met, an error message is issued, and the merge is -- carried out, modifying the Chars field of Prev. procedure No_Constraint; -- Called in a place where no constraint is allowed, but one might -- appear due to a common error (e.g. after the type mark in a procedure -- parameter. If a constraint is present, an error message is posted, -- and the constraint is scanned and discarded. function No_Right_Paren (Expr : Node_Id) return Node_Id; -- Function to check for no right paren at end of expression, returns -- its argument if no right paren, else flags paren and returns Error. procedure Push_Scope_Stack; pragma Inline (Push_Scope_Stack); -- Push a new entry onto the scope stack. Scope.Last (the stack pointer) -- is incremented. The Junk field is preinitialized to False. The caller -- is expected to fill in all remaining entries of the new new top stack -- entry at Scope.Table (Scope.Last). procedure Pop_Scope_Stack; -- Pop an entry off the top of the scope stack. Scope_Last (the scope -- table stack pointer) is decremented by one. It is a fatal error to -- try to pop off the dummy entry at the bottom of the stack (i.e. -- Scope.Last must be non-zero at the time of call). function Separate_Present return Boolean; -- Determines if the current token is either Tok_Separate, or an -- identifier that is a possible misspelling of "separate" followed -- by a semicolon. True is returned if so, otherwise False. procedure Signal_Bad_Attribute; -- The current token is an identifier that is supposed to be an -- attribute identifier but is not. This routine posts appropriate -- error messages, including a check for a near misspelling. function Token_Is_At_Start_Of_Line return Boolean; pragma Inline (Token_Is_At_Start_Of_Line); -- Determines if the current token is the first token on the line function Token_Is_At_End_Of_Line return Boolean; -- Determines if the current token is the last token on the line end Util; -------------- -- Par.Prag -- -------------- -- The processing for pragmas is split off from chapter 2 function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id; -- This function is passed a tree for a pragma that has been scanned out. -- The pragma is syntactically well formed according to the general syntax -- for pragmas and the pragma identifier is for one of the recognized -- pragmas. It performs specific syntactic checks for specific pragmas. -- The result is the input node if it is OK, or Error otherwise. The -- reason that this is separated out is to facilitate the addition -- of implementation defined pragmas. The second parameter records the -- location of the semicolon following the pragma (this is needed for -- correct processing of the List and Page pragmas). The returned value -- is a copy of Pragma_Node, or Error if an error is found. Note that -- at the point where Prag is called, the right paren ending the pragma -- has been scanned out, and except in the case of pragma Style_Checks, -- so has the following semicolon. For Style_Checks, the caller delays -- the scanning of the semicolon so that it will be scanned using the -- settings from the Style_Checks pragma preceding it. -------------- -- Par.Labl -- -------------- procedure Labl; -- This procedure creates implicit label declarations for all label that -- are declared in the current unit. Note that this could conceptually -- be done at the point where the labels are declared, but it is tricky -- to do it then, since the tree is not hooked up at the point where the -- label is declared (e.g. a sequence of statements is not yet attached -- to its containing scope at the point a label in the sequence is found) -------------- -- Par.Load -- -------------- procedure Load; -- This procedure loads all subsidiary units that are required by this -- unit, including with'ed units, specs for bodies, and parents for child -- units. It does not load bodies for inlined procedures and generics, -- since we don't know till semantic analysis is complete what is needed. ----------- -- Stubs -- ----------- -- The package bodies can see all routines defined in all other subpackages use Ch2; use Ch3; use Ch4; use Ch5; use Ch6; use Ch7; use Ch8; use Ch9; use Ch10; use Ch11; use Ch12; use Ch13; use Endh; use Tchk; use Sync; use Util; package body Ch2 is separate; package body Ch3 is separate; package body Ch4 is separate; package body Ch5 is separate; package body Ch6 is separate; package body Ch7 is separate; package body Ch8 is separate; package body Ch9 is separate; package body Ch10 is separate; package body Ch11 is separate; package body Ch12 is separate; package body Ch13 is separate; package body Endh is separate; package body Tchk is separate; package body Sync is separate; package body Util is separate; function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is separate; procedure Labl is separate; procedure Load is separate; -- Start of processing for Par begin -- Deal with configuration pragmas case first if Configuration_Pragmas then declare Pragmas : constant List_Id := Empty_List; P_Node : Node_Id; begin loop if Token = Tok_EOF then return Pragmas; elsif Token /= Tok_Pragma then Error_Msg_SC ("only pragmas allowed in configuration file"); return Error_List; else P_Node := P_Pragma; if Nkind (P_Node) = N_Pragma then -- Give error if bad pragma if Chars (P_Node) > Last_Configuration_Pragma_Name and then Chars (P_Node) /= Name_Source_Reference then if Is_Pragma_Name (Chars (P_Node)) then Error_Msg_N ("only configuration pragmas allowed " & "in configuration file", P_Node); else Error_Msg_N ("unrecognized pragma in configuration file", P_Node); end if; -- Pragma is OK config pragma, so collect it else Append (P_Node, Pragmas); end if; end if; end if; end loop; end; -- Normal case of compilation unit else Save_Opt_Config_Switches (Save_Config_Switches); -- The following loop runs more than once in syntax check mode -- where we allow multiple compilation units in the same file -- and in Multiple_Unit_Per_file mode where we skip units till -- we get to the unit we want. for Ucount in Pos loop Set_Opt_Config_Switches (Is_Internal_File_Name (File_Name (Current_Source_File)), Current_Source_Unit = Main_Unit); -- Initialize scope table and other parser control variables Compiler_State := Parsing; Scope.Init; Scope.Increment_Last; Scope.Table (0).Etyp := E_Dummy; SIS_Entry_Active := False; Last_Resync_Point := No_Location; Goto_List := New_Elmt_List; Label_List := New_Elmt_List; -- If in multiple unit per file mode, skip past ignored unit if Ucount < Multiple_Unit_Index then -- We skip in syntax check only mode, since we don't want -- to do anything more than skip past the unit and ignore it. -- This causes processing like setting up a unit table entry -- to be skipped. declare Save_Operating_Mode : constant Operating_Mode_Type := Operating_Mode; Save_Style_Check : constant Boolean := Style_Check; begin Operating_Mode := Check_Syntax; Style_Check := False; Discard_Node (P_Compilation_Unit); Operating_Mode := Save_Operating_Mode; Style_Check := Save_Style_Check; -- If we are at an end of file, and not yet at the right -- unit, then we have a fatal error. The unit is missing. if Token = Tok_EOF then Error_Msg_SC ("file has too few compilation units"); raise Unrecoverable_Error; end if; end; -- Here if we are not skipping a file in multiple unit per file -- mode. Parse the unit that we are interested in. Note that in -- check syntax mode we are interested in all units in the file. else declare Comp_Unit_Node : constant Node_Id := P_Compilation_Unit; begin -- If parsing was successful and we are not in check syntax -- mode, check that language defined units are compiled in -- GNAT mode. For this purpose we do NOT consider renamings -- in annex J as predefined. That allows users to compile -- their own versions of these files, and in particular, -- in the VMS implementation, the DEC versions can be -- substituted for the standard Ada 95 versions. Another -- exception is System.RPC and its children. This allows -- a user to supply their own communication layer. if Comp_Unit_Node /= Error and then Operating_Mode = Generate_Code and then Current_Source_Unit = Main_Unit and then not GNAT_Mode then declare Uname : constant String := Get_Name_String (Unit_Name (Current_Source_Unit)); Name : String (1 .. Uname'Length - 2); begin -- Because Unit_Name includes "%s" or "%b", we need to -- strip the last two characters to get the real unit -- name. Name := Uname (Uname'First .. Uname'Last - 2); if Name = "ada" or else Name = "calendar" or else Name = "interfaces" or else Name = "system" or else Name = "machine_code" or else Name = "unchecked_conversion" or else Name = "unchecked_deallocation" then Error_Msg ("language defined units may not be recompiled", Sloc (Unit (Comp_Unit_Node))); elsif Name'Length > 4 and then Name (Name'First .. Name'First + 3) = "ada." then Error_Msg ("descendents of package Ada " & "may not be compiled", Sloc (Unit (Comp_Unit_Node))); elsif Name'Length > 11 and then Name (Name'First .. Name'First + 10) = "interfaces." then Error_Msg ("descendents of package Interfaces " & "may not be compiled", Sloc (Unit (Comp_Unit_Node))); elsif Name'Length > 7 and then Name (Name'First .. Name'First + 6) = "system." and then Name /= "system.rpc" and then (Name'Length < 11 or else Name (Name'First .. Name'First + 10) /= "system.rpc.") then Error_Msg ("descendents of package System " & "may not be compiled", Sloc (Unit (Comp_Unit_Node))); end if; end; end if; end; -- All done if at end of file exit when Token = Tok_EOF; -- If we are not at an end of file, it means we are in syntax -- check only mode, and we keep the loop going to parse all -- remaining units in the file. end if; Restore_Opt_Config_Switches (Save_Config_Switches); end loop; -- Now that we have completely parsed the source file, we can -- complete the source file table entry. Complete_Source_File_Entry; -- An internal error check, the scope stack should now be empty pragma Assert (Scope.Last = 0); -- Remaining steps are to create implicit label declarations and to -- load required subsidiary sources. These steps are required only -- if we are doing semantic checking. if Operating_Mode /= Check_Syntax or else Debug_Flag_F then Par.Labl; Par.Load; end if; -- Restore settings of switches saved on entry Restore_Opt_Config_Switches (Save_Config_Switches); Set_Comes_From_Source_Default (False); return Empty_List; end if; end Par;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with Ada.Streams; with Ada.Exceptions; with League.Stream_Element_Vectors; with League.Text_Codecs; with Spawn.Environments; with Spawn.Processes.Monitor_Loop; with Spawn.Processes; with Spawn.String_Vectors; package body Processes is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; --------- -- Run -- --------- procedure Run (Program : League.Strings.Universal_String; Arguments : League.String_Vectors.Universal_String_Vector; Directory : League.Strings.Universal_String; Env : Environment := No_Env; Output : out League.Strings.Universal_String; Errors : out League.Strings.Universal_String; Status : out Integer) is type Listener is new Spawn.Processes.Process_Listener with record Output : League.Stream_Element_Vectors.Stream_Element_Vector; Errors : League.Stream_Element_Vectors.Stream_Element_Vector; Status : Integer := 0; Done : Boolean := False; Write : Boolean := True; end record; procedure Standard_Output_Available (Self : in out Listener); procedure Standard_Error_Available (Self : in out Listener); procedure Finished (Self : in out Listener; Exit_Status : Spawn.Processes.Process_Exit_Status; Exit_Code : Spawn.Processes.Process_Exit_Code); procedure Error_Occurred (Self : in out Listener; Process_Error : Integer); procedure Exception_Occurred (Self : in out Listener; Occurrence : Ada.Exceptions.Exception_Occurrence); Process : Spawn.Processes.Process; Codec : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec_For_Application_Locale; ------------------------------- -- Standard_Output_Available -- ------------------------------- procedure Standard_Output_Available (Self : in out Listener) is use type Ada.Streams.Stream_Element_Count; Data : Ada.Streams.Stream_Element_Array (1 .. 512); Last : Ada.Streams.Stream_Element_Count; begin loop Process.Read_Standard_Output (Data, Last); exit when Last < Data'First; Self.Output.Append (Data (1 .. Last)); end loop; end Standard_Output_Available; ------------------------------ -- Standard_Error_Available -- ------------------------------ procedure Standard_Error_Available (Self : in out Listener) is use type Ada.Streams.Stream_Element_Count; Data : Ada.Streams.Stream_Element_Array (1 .. 512); Last : Ada.Streams.Stream_Element_Count; begin loop Process.Read_Standard_Error (Data, Last); exit when Last < Data'First; Self.Errors.Append (Data (1 .. Last)); end loop; end Standard_Error_Available; -------------- -- Finished -- -------------- procedure Finished (Self : in out Listener; Exit_Status : Spawn.Processes.Process_Exit_Status; Exit_Code : Spawn.Processes.Process_Exit_Code) is pragma Unreferenced (Exit_Status); begin Self.Status := Integer (Exit_Code); Self.Done := True; end Finished; -------------------- -- Error_Occurred -- -------------------- procedure Error_Occurred (Self : in out Listener; Process_Error : Integer) is pragma Unreferenced (Self); begin Errors.Append (+"Error_Occurred"); Self.Status := Process_Error; Self.Done := True; end Error_Occurred; procedure Exception_Occurred (Self : in out Listener; Occurrence : Ada.Exceptions.Exception_Occurrence) is begin Errors.Append (League.Strings.From_UTF_8_String (Ada.Exceptions.Exception_Information (Occurrence))); Self.Status := -1; Self.Done := True; end Exception_Occurred; Args : Spawn.String_Vectors.UTF_8_String_Vector; Feedback : aliased Listener; begin Process.Set_Program (Program.To_UTF_8_String); for J in 1 .. Arguments.Length loop Args.Append (Arguments (J).To_UTF_8_String); end loop; if Env /= No_Env then declare Environment : Spawn.Environments.Process_Environment := Process.Environment; begin for J in 1 .. Env.Names.Length loop Environment.Insert (Env.Names (J).To_UTF_8_String, Env.Values (J).To_UTF_8_String); end loop; Process.Set_Environment (Environment); end; end if; Process.Set_Arguments (Args); Process.Set_Working_Directory (Directory.To_UTF_8_String); Process.Set_Listener (Feedback'Unchecked_Access); Process.Start; while not Feedback.Done loop Spawn.Processes.Monitor_Loop (Timeout => 50); end loop; Output := Codec.Decode (Feedback.Output); Errors.Append (Codec.Decode (Feedback.Errors)); Status := Feedback.Status; end Run; end Processes;
-- Philip Bjorge -- Simple barrier using protected types that -- waits on a certain number of entrants package body Barrier is protected body Barrier_Type is entry Here when not leave is begin count := count + 1; if count < wait_for then requeue Wait; else count := count - 1; if count /= 0 then leave := True; end if; end if; end; entry Wait when leave is begin count := count - 1; if count = 0 then leave := False; end if; end; end Barrier_Type; end Barrier;
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package ft2build is --*************************************************************************** -- * -- * ft2build.h -- * -- * FreeType 2 build and setup macros. -- * -- * Copyright (C) 1996-2020 by -- * David Turner, Robert Wilhelm, and Werner Lemberg. -- * -- * This file is part of the FreeType project, and may only be used, -- * modified, and distributed under the terms of the FreeType project -- * license, LICENSE.TXT. By continuing to use, modify, or distribute -- * this file you indicate that you have read the license and -- * understand and accept it fully. -- * -- --************************************************************************* -- * -- * This is the 'entry point' for FreeType header file inclusions, to be -- * loaded before all other header files. -- * -- * A typical example is -- * -- * ``` -- * #include <ft2build.h> -- * #include <freetype/freetype.h> -- * ``` -- * -- -- END end ft2build;
-- see OpenUxAS\src\Communications\ZeroMqAddressedAttributedMessageSender.h with ZMQ.Sockets; with UxAS.Comms.Data.Addressed.Attributed; use UxAS.Comms.Data.Addressed.Attributed; package UxAS.Comms.Transport.ZeroMQ_Sender.Addr_Attr_Msg_Senders is type ZeroMq_Addressed_Attributed_Message_Sender (Kind : ZMQ.Sockets.Socket_Type) is new ZeroMq_Sender_Base with private; type ZeroMq_Addressed_Attributed_Message_Sender_Ref is access all ZeroMq_Addressed_Attributed_Message_Sender; type Any_ZeroMq_Addressed_Attributed_Message_Sender is access all ZeroMq_Addressed_Attributed_Message_Sender'Class; -- void -- sendMessage(const std::string& address, const std::string& contentType, const std::string& descriptor, const std::string payload); procedure Send_Message (This : in out ZeroMq_Addressed_Attributed_Message_Sender; Address : String; Content_Type : String; Descriptor : String; Payload : String); -- TODO: add preconditions on string lengths, as done elsewhere -- void -- sendAddressedAttributedMessage(std::unique_ptr<uxas::communications::data::AddressedAttributedMessage> message); procedure Send_Addressed_Attributed_Message (This : in out ZeroMq_Addressed_Attributed_Message_Sender; Message : Addressed_Attributed_Message_Ref); private type ZeroMq_Addressed_Attributed_Message_Sender (Kind : ZMQ.Sockets.Socket_Type) is new ZeroMq_Sender_Base with null record; -- by design end UxAS.Comms.Transport.ZeroMQ_Sender.Addr_Attr_Msg_Senders;
with DecaDriver; package Configurations is procedure Get_Switches_Configuration (Config : out DecaDriver.Core.Configuration_Type); end Configurations;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Definitions; use Definitions; with Ada.Text_IO; package Port_Specification.Json is package TIO renames Ada.Text_IO; -- Describes the port using standard parameters formatted in JSON -- Used for Repology index procedure describe_port (specs : Portspecs; dossier : TIO.File_Type; bucket : String; index : Positive); private pad : constant Natural := 4; -- returns "generated" instead of raw value when generated is true function fpc_value (is_generated : Boolean; raw_value : String) return String; -- returns Keyword array function describe_keywords (specs : Portspecs) return String; -- returns array of distfiles function describe_distfiles (specs : Portspecs) return String; -- return array of subpackages function describe_subpackages (specs : Portspecs; variant : String) return String; -- When the homepage is set to "none", return an empty string, otherwise return a json string function homepage_line (specs : Portspecs) return String; -- If USES=cpe set, push CPE_VENDOR and CPE_PRODUCT values function describe_Common_Platform_Enumeration (specs : Portspecs) return String; end Port_Specification.Json;
pragma License (Unrestricted); -- implementation unit required by compiler with Ada.Streams; package System.Shared_Storage is -- no-operation procedure Nop (Key : String) is null; function Nop (Key : String) return access Ada.Streams.Root_Stream_Type'Class is (null); type Lock_Handler is access procedure (Key : String); Lock_Hook : not null Lock_Handler := Nop'Access; type Unlock_Handler is access procedure (Key : String); Unlock_Hook : not null Unlock_Handler := Nop'Access; type Read_Handler is access function (Key : String) return access Ada.Streams.Root_Stream_Type'Class; Read_Hook : not null Read_Handler := Nop'Access; type Write_Handler is access function (Key : String) return access Ada.Streams.Root_Stream_Type'Class; Write_Hook : not null Write_Handler := Nop'Access; -- required for a protected in a package with pragma Shared_Passive -- by compiler (s-shasto.ads) procedure Shared_Var_Lock (Var : String); procedure Shared_Var_Unlock (Var : String); -- required for a variable in a package with pragma Shared_Passive -- by compiler (s-shasto.ads) generic type Typ is limited private; V : in out Typ; Full_Name : String; package Shared_Var_Procs is procedure Read; procedure Write; end Shared_Var_Procs; end System.Shared_Storage;
--=========================================================================== -- -- This package is the implementation of the SH1107 package -- --=========================================================================== -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with SH1107.I2C; with SH1107.SPI; with SH1107.Transformer; package body SH1107 is -------------------------------------------------------------------------- -- Commands -------------------------------------------------------------------------- -- Display On/Off CMD_DISPLAY_OFF : constant HAL.UInt8 := 16#AE#; CMD_DISPLAY_ON : constant HAL.UInt8 := 16#AF#; -- CMD_FORCE_DISPLAY_ON : constant HAL.UInt8 := 16#A5#; -- Setup commands to initialize the display CMD_PAGE_ADDRESSING_MODE : constant HAL.UInt8 := 16#20#; CMD_SET_CONTRAST : constant HAL.UInt8 := 16#81#; CMD_SEGMENT_REMAP_DOWN : constant HAL.UInt8 := 16#A0#; CMD_NORMAL_DISPLAY : constant HAL.UInt8 := 16#A6#; CMD_SET_DISPLAY_OFFSET : constant HAL.UInt8 := 16#D3#; CMD_COMMON_OUPUT_SCAN_DIRECTION_INCREMENT : constant HAL.UInt8 := 16#C0#; CMD_SET_DISPLAY_START_LINE : constant HAL.UInt8 := 16#DC#; CMD_OUTPUT_RAM_TO_DISPLAY : constant HAL.UInt8 := 16#A4#; -- Memory addressing CMD_SET_PAGE_ADDRESS : constant HAL.UInt8 := 16#B0#; CMD_SET_LOWER_COLUMN_ADDRESS : constant HAL.UInt8 := 16#00#; CMD_SET_HIGHER_COLUMN_ADDRESS : constant HAL.UInt8 := 16#10#; -- COmmand prefix CMD_PREFIX_DATA : constant HAL.UInt8 := 16#40#; -------------------------------------------------------------------------- -- Package internal rocedures to write to the device -- Implementation at the end of the file. -------------------------------------------------------------------------- -------------------------------------------------------------------------- -- Writes the -- Cmd : to -- This : Screen procedure Write_Command (This : SH1107_Screen; Cmd : HAL.UInt8); -------------------------------------------------------------------------- -- Writes the -- Cmd : with the -- Arg : to -- This : Screen procedure Write_Command_Argument (This : SH1107_Screen; Cmd : HAL.UInt8; Arg : HAL.UINt8); -------------------------------------------------------------------------- -- Writes the -- Data : to -- This : Screen procedure Write_Data (This : SH1107_Screen; Data : HAL.UInt8_Array); -------------------------------------------------------------------------- -- Writes -- Data : as raw pixels to -- This : Screen procedure Write_Raw_Pixels (This : SH1107_Screen; Data : HAL.UInt8_Array); procedure Initialize_Screen (This : in out SH1107_Screen) is begin This.Turn_Off; Write_Command (This, CMD_PAGE_ADDRESSING_MODE); Write_Command_Argument (This, CMD_SET_DISPLAY_OFFSET, 16#00#); Write_Command (This, CMD_SEGMENT_REMAP_DOWN); Write_Command (This, CMD_COMMON_OUPUT_SCAN_DIRECTION_INCREMENT); Write_Command_Argument (This, CMD_SET_CONTRAST, 16#80#); Write_Command (This, CMD_NORMAL_DISPLAY); Write_Command_Argument (This, CMD_SET_DISPLAY_START_LINE, 16#00#); Write_Command (This, CMD_OUTPUT_RAM_TO_DISPLAY); This.Turn_On; -- make screen black This.Memory_Layer.Native_Source := 0; This.Memory_Layer.Fill; This.Update_Layer (Layer => 1); end Initialize_Screen; -------------------------------------------------------------------------- -- see .ads procedure Initialize (This : in out SH1107_Screen; Orientation : SH1107_Orientation; Port : not null HAL.I2C.Any_I2C_Port; Address : HAL.I2C.I2C_Address) is begin if This.Connect_With /= Connect_I2C then raise Program_Error with "Invalid screen parameters, must be I2C!"; end if; This.Orientation := Orientation; This.Port_I2C := Port; This.Address_I2C := Address; Initialize_Screen (This); This.Device_Initialized := True; end Initialize; -------------------------------------------------------------------------- -- see .ads procedure Initialize (This : in out SH1107_Screen; Orientation : SH1107_Orientation; Port : not null HAL.SPI.Any_SPI_Port; DC_SPI : not null HAL.GPIO.Any_GPIO_Point) is begin if This.Connect_With /= Connect_SPI then raise Program_Error with "Invalid screen parameters, must be SPI!"; end if; This.Orientation := Orientation; This.Port_SPI := Port; This.DC_SPI := DC_SPI; Initialize_Screen (This); This.Device_Initialized := True; end Initialize; -------------------------------------------------------------------------- -- see .ads procedure Turn_On (This : SH1107_Screen) is begin Write_Command (This, CMD_DISPLAY_ON); end Turn_On; -------------------------------------------------------------------------- -- see .ads procedure Turn_Off (This : SH1107_Screen) is begin Write_Command (This, CMD_DISPLAY_OFF); end Turn_Off; --======================================================================== -- -- This section is the collection of overriding procedures/functions -- from the parent class -- --======================================================================== procedure Set_Orientation (This : in out SH1107_Screen; Orientation : SH1107_Orientation) is begin This.Orientation := Orientation; This.Memory_Layer.Orientation := Orientation; end Set_Orientation; overriding function Supported (This : SH1107_Screen; Mode : HAL.Framebuffer.FB_Color_Mode) return Boolean is pragma Unreferenced (This); use HAL.Bitmap; begin return (Mode = HAL.Bitmap.M_1); end Supported; overriding procedure Set_Orientation (This : in out SH1107_Screen; Orientation : HAL.Framebuffer.Display_Orientation) is pragma Unreferenced (This); pragma Unreferenced (Orientation); begin null; end Set_Orientation; overriding procedure Set_Mode (This : in out SH1107_Screen; Mode : HAL.Framebuffer.Wait_Mode) is pragma Unreferenced (This); pragma Unreferenced (Mode); begin null; end Set_Mode; overriding function Initialized (This : SH1107_Screen) return Boolean is (This.Device_Initialized); overriding procedure Set_Background (This : SH1107_Screen; R, G, B : HAL.UInt8) is begin -- Does it make sense when there's no alpha channel... raise Program_Error; end Set_Background; overriding procedure Initialize_Layer (This : in out SH1107_Screen; Layer : Positive; Mode : HAL.Framebuffer.FB_Color_Mode; X : Natural := 0; Y : Natural := 0; Width : Positive := Positive'Last; Height : Positive := Positive'Last) is pragma Unreferenced (X, Y, Width, Height); use HAL.Bitmap; begin if Layer /= 1 or else Mode /= HAL.Bitmap.M_1 then raise Program_Error; end if; This.Memory_Layer.Orientation := This.Orientation; This.Memory_Layer.Actual_Width := This.Width; This.Memory_Layer.Actual_Height := This.Height; This.Memory_Layer.Addr := This.Memory_Layer.Data'Address; This.Memory_Layer.Actual_Color_Mode := Mode; This.Layer_Initialized := True; end Initialize_Layer; overriding function Initialized (This : SH1107_Screen; Layer : Positive) return Boolean is begin return Layer = 1 and then This.Layer_Initialized; end Initialized; overriding procedure Update_Layer (This : in out SH1107_Screen; Layer : Positive; Copy_Back : Boolean := False) is pragma Unreferenced (Copy_Back); begin if Layer /= 1 then raise Program_Error with "This screen only supports one layer"; end if; This.Write_Raw_Pixels (This.Memory_Layer.Data); end Update_Layer; overriding procedure Update_Layers (This : in out SH1107_Screen) is begin Update_Layer (This, 1); end Update_Layers; overriding function Hidden_Buffer (This : in out SH1107_Screen; Layer : Positive := THE_LAYER) return not null HAL.Bitmap.Any_Bitmap_Buffer is begin if Layer /= 1 then raise Program_Error with "This screen only supports one layer"; end if; return This.Memory_Layer'Unchecked_Access; end Hidden_Buffer; overriding function Pixel_Size (Display : SH1107_Screen; Layer : Positive := THE_LAYER) return Positive is (1); --======================================================================== -- -- This section is the collection of overriding procedures/functions -- from the parent class for the Bitmap Buffer -- --======================================================================== overriding procedure Set_Pixel (Buffer : in out SH1107_Bitmap_Buffer; Pt : HAL.Bitmap.Point) is Index : constant Natural := SH1107.Transformer.Get_Byte_Index (Buffer.Orientation, Pt.X, Pt.Y); Byte : HAL.UInt8 renames Buffer.Data (Buffer.Data'First + Index); Bit : constant HAL.UInt8 := SH1107.Transformer.Get_Bit_Mask (Buffer.Orientation, Pt.X, Pt.Y); use HAL; begin if Buffer.Native_Source = 0 then Byte := Byte and not Bit; else Byte := Byte or Bit; end if; end Set_Pixel; overriding procedure Set_Pixel (Buffer : in out SH1107_Bitmap_Buffer; Pt : HAL.Bitmap.Point; Color : HAL.Bitmap.Bitmap_Color) is use HAL.Bitmap; begin Buffer.Set_Pixel (Pt, (if Color = HAL.Bitmap.Black then 0 else 1)); end Set_Pixel; overriding procedure Set_Pixel (Buffer : in out SH1107_Bitmap_Buffer; Pt : HAL.Bitmap.Point; Raw : HAL.UInt32) is begin Buffer.Native_Source := Raw; Buffer.Set_Pixel (Pt); end Set_Pixel; overriding function Pixel (Buffer : SH1107_Bitmap_Buffer; Pt : HAL.Bitmap.Point) return HAL.Bitmap.Bitmap_Color is use HAL; begin return (if Buffer.Pixel (Pt) = 0 then HAL.Bitmap.Black else HAL.Bitmap.White); end Pixel; overriding function Pixel (Buffer : SH1107_Bitmap_Buffer; Pt : HAL.Bitmap.Point) return HAL.UInt32 is Index : constant Natural := SH1107.Transformer.Get_Byte_Index (Buffer.Orientation, Pt.X, Pt.Y); Byte : HAL.UInt8 renames Buffer.Data (Buffer.Data'First + Index); Bit : constant HAL.UInt8 := SH1107.Transformer.Get_Bit_Mask (Buffer.Orientation, Pt.X, Pt.Y); use HAL; begin if (Byte and Bit) /= 0 then return 1; else return 0; end if; end Pixel; overriding procedure Fill (Buffer : in out SH1107_Bitmap_Buffer) is use HAL; Val : constant HAL.UInt8 := (if Buffer.Native_Source /= 0 then 16#FF# else 0); begin Buffer.Data := (others => Val); end Fill; --======================================================================== -- -- Package internal procedures to write to the device -- --======================================================================== procedure Write_Command (This : SH1107_Screen; Cmd : HAL.UInt8) is begin case This.Connect_With is when Connect_I2C => SH1107.I2C.Write_Command (This.Port_I2C, This.Address_I2C, Cmd); when Connect_SPI => SH1107.SPI.Write_Command (This.Port_SPI, This.DC_SPI, Cmd); end case; end Write_Command; procedure Write_Command_Argument (This : SH1107_Screen; Cmd : HAL.UInt8; Arg : HAL.UINt8) is begin case This.Connect_With is when Connect_I2C => SH1107.I2C.Write_Command_Argument (This.Port_I2C, This.Address_I2C, Cmd, Arg); when Connect_SPI => SH1107.SPI.Write_Command_Argument (This.Port_SPI, This.DC_SPI, Cmd, Arg); end case; end Write_Command_Argument; procedure Write_Data (This : SH1107_Screen; Data : HAL.UInt8_Array) is SPI_DATA : HAL.SPI.SPI_Data_8b (Data'First .. Data'Last); begin case This.Connect_With is when Connect_I2C => SH1107.I2C.Write_Data (This.Port_I2C, This.Address_I2C, Data); when Connect_SPI => for I in Data'First .. Data'Last loop SPI_DATA (I) := Data (I); end loop; SH1107.SPI.Write_Data (This.Port_SPI, This.DC_SPI, SPI_DATA); end case; end Write_Data; procedure Write_Raw_Pixels (This : SH1107_Screen; Data : HAL.UInt8_Array) is Index : Natural := 1; Data_Prefix : constant HAL.UInt8_Array (1 .. 1) := (1 => CMD_PREFIX_DATA); Page_Address : HAL.UInt8; use HAL; begin for Page_Number in HAL.UInt8 (0) .. HAL.UInt8 (15) loop Page_Address := CMD_SET_PAGE_ADDRESS + Page_Number; Write_Command (This, CMD_SET_LOWER_COLUMN_ADDRESS); Write_Command_Argument (This, CMD_SET_HIGHER_COLUMN_ADDRESS, Page_Address); if This.Connect_With = Connect_I2C then Write_Data (This, Data_Prefix & Data (Index .. Index + 128)); else Write_Command (This, CMD_PREFIX_DATA); Write_Data (This, Data (Index .. Index + 128)); end if; Index := Index + 128; end loop; end Write_Raw_Pixels; end SH1107;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Vectors; procedure Test_Ada2022 is package Integer_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Integer); use Integer_Vectors; procedure Increment_All (V : in out Vector) is begin for E of V loop E := @ + 1; end loop; end Increment_All; V : Vector := [0, 0, 0]; begin Increment_All (V); Put_Line (V'Image); end Test_Ada2022;
pragma Check_Policy (Validate => Disable); -- with Ada.Strings.Naked_Maps.Debug; with Ada.UCD.Simple_Case_Mapping; with System.Once; with System.Reference_Counting; package body Ada.Strings.Naked_Maps.Case_Mapping is use type UCD.Difference_Base; use type UCD.UCS_4; procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type); procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type) is begin for J in Table'Range loop declare F : UCD.Map_16x1_Item_Type renames Table (J); begin Mapping.From (I) := Character_Type'Val (F.Code); Mapping.To (I) := Character_Type'Val (F.Mapping); end; I := I + 1; end loop; end Decode; procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base); procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base) is begin for J in Table'Range loop declare F : UCD.Simple_Case_Mapping.Compressed_Item_Type renames Table (J); From : Character_Type := Character_Type'Val (UCD.Difference_Base (F.Start) + Offset); To : Character_Type := Character_Type'Val (Character_Type'Pos (From) + F.Diff); begin for K in 1 .. F.Length loop Mapping.From (I) := From; Mapping.To (I) := To; From := Character_Type'Succ (From); To := Character_Type'Succ (To); I := I + 1; end loop; end; end loop; end Decode; procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type); procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type) is begin for J in Table'Range loop declare F : UCD.Map_16x1_Item_Type renames Table (J); begin Mapping.From (I) := Character_Type'Val (F.Mapping); Mapping.To (I) := Character_Type'Val (F.Code); end; I := I + 1; end loop; end Decode_Reverse; procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base); procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base) is begin for J in Table'Range loop declare F : UCD.Simple_Case_Mapping.Compressed_Item_Type renames Table (J); To : Character_Type := Character_Type'Val (UCD.Difference_Base (F.Start) + Offset); From : Character_Type := Character_Type'Val (Character_Type'Pos (To) + F.Diff); begin for K in 1 .. F.Length loop Mapping.From (I) := From; Mapping.To (I) := To; From := Character_Type'Succ (From); To := Character_Type'Succ (To); I := I + 1; end loop; end; end loop; end Decode_Reverse; type Character_Mapping_Access_With_Pool is access Character_Mapping_Data; -- lower case map L_Mapping : Character_Mapping_Access_With_Pool; L_Mapping_Flag : aliased System.Once.Flag := 0; procedure L_Mapping_Init; procedure L_Mapping_Init is Mapping : Character_Mapping_Access_With_Pool renames L_Mapping; begin Mapping := new Character_Mapping_Data'( Length => UCD.Simple_Case_Mapping.L_Total, Reference_Count => System.Reference_Counting.Static, From => <>, To => <>); declare I : Positive := Mapping.From'First; begin -- 16#0041# Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX_Compressed, Offset => 0); -- 16#0100# .. Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX); -- 16#0130# .. Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.DL_Table_XXXX); -- 16#10400# Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_1XXXX_Compressed, Offset => 16#10000#); pragma Assert (I = Mapping.From'Last + 1); end; Sort (Mapping.From, Mapping.To); pragma Check (Validate, Debug.Valid (Mapping.all)); end L_Mapping_Init; -- implementation of lower case map function Lower_Case_Map return not null Character_Mapping_Access is begin System.Once.Initialize (L_Mapping_Flag'Access, L_Mapping_Init'Access); return Character_Mapping_Access (L_Mapping); end Lower_Case_Map; -- upper case map U_Mapping : Character_Mapping_Access_With_Pool; U_Mapping_Flag : aliased System.Once.Flag := 0; procedure U_Mapping_Init; procedure U_Mapping_Init is Mapping : Character_Mapping_Access_With_Pool renames U_Mapping; begin Mapping := new Character_Mapping_Data'( Length => UCD.Simple_Case_Mapping.U_Total, Reference_Count => System.Reference_Counting.Static, From => <>, To => <>); declare I : Positive := Mapping.From'First; begin -- 16#0061# Decode_Reverse ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX_Compressed, Offset => 0); -- 16#00B5# .. Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.DU_Table_XXXX); -- 16#0101# .. Decode_Reverse ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX); -- 16#10440# Decode_Reverse ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_1XXXX_Compressed, Offset => 16#10000#); pragma Assert (I = Mapping.From'Last + 1); end; Sort (Mapping.From, Mapping.To); pragma Check (Validate, Debug.Valid (Mapping.all)); end U_Mapping_Init; -- implementation of upper case map function Upper_Case_Map return not null Character_Mapping_Access is begin System.Once.Initialize (U_Mapping_Flag'Access, U_Mapping_Init'Access); return Character_Mapping_Access (U_Mapping); end Upper_Case_Map; end Ada.Strings.Naked_Maps.Case_Mapping;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M A K E _ U T I L -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Debug; with Errutil; with Osint; use Osint; with Output; use Output; with Opt; use Opt; with Table; with Ada.Command_Line; use Ada.Command_Line; with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.HTable; package body Make_Util is --------- -- Add -- --------- procedure Add (Option : String_Access; To : in out String_List_Access; Last : in out Natural) is begin if Last = To'Last then declare New_Options : constant String_List_Access := new String_List (1 .. To'Last * 2); begin New_Options (To'Range) := To.all; -- Set all elements of the original options to null to avoid -- deallocation of copies. To.all := (others => null); Free (To); To := New_Options; end; end if; Last := Last + 1; To (Last) := Option; end Add; procedure Add (Option : String; To : in out String_List_Access; Last : in out Natural) is begin Add (Option => new String'(Option), To => To, Last => Last); end Add; ------------------------- -- Base_Name_Index_For -- ------------------------- function Base_Name_Index_For (Main : String; Main_Index : Int; Index_Separator : Character) return File_Name_Type is Result : File_Name_Type; begin Name_Len := 0; Add_Str_To_Name_Buffer (Base_Name (Main)); -- Remove the extension, if any, that is the last part of the base name -- starting with a dot and following some characters. for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Len := J - 1; exit; end if; end loop; -- Add the index info, if index is different from 0 if Main_Index > 0 then Add_Char_To_Name_Buffer (Index_Separator); declare Img : constant String := Main_Index'Img; begin Add_Str_To_Name_Buffer (Img (2 .. Img'Last)); end; end if; Result := Name_Find; return Result; end Base_Name_Index_For; ----------------- -- Create_Name -- ----------------- function Create_Name (Name : String) return File_Name_Type is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; function Create_Name (Name : String) return Name_Id is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; function Create_Name (Name : String) return Path_Name_Type is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; --------------------------- -- Ensure_Absolute_Path -- --------------------------- procedure Ensure_Absolute_Path (Switch : in out String_Access; Parent : String; Do_Fail : Fail_Proc; For_Gnatbind : Boolean := False; Including_Non_Switch : Boolean := True; Including_RTS : Boolean := False) is begin if Switch /= null then declare Sw : String (1 .. Switch'Length); Start : Positive; begin Sw := Switch.all; if Sw (1) = '-' then if Sw'Length >= 3 and then (Sw (2) = 'I' or else (not For_Gnatbind and then (Sw (2) = 'L' or else Sw (2) = 'A'))) then Start := 3; if Sw = "-I-" then return; end if; elsif Sw'Length >= 4 and then (Sw (2 .. 3) = "aL" or else Sw (2 .. 3) = "aO" or else Sw (2 .. 3) = "aI" or else (For_Gnatbind and then Sw (2 .. 3) = "A=")) then Start := 4; elsif Including_RTS and then Sw'Length >= 7 and then Sw (2 .. 6) = "-RTS=" then Start := 7; else return; end if; -- Because relative path arguments to --RTS= may be relative to -- the search directory prefix, those relative path arguments -- are converted only when they include directory information. if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then if Parent'Length = 0 then Do_Fail ("relative search path switches (""" & Sw & """) are not allowed"); elsif Including_RTS then for J in Start .. Sw'Last loop if Sw (J) = Directory_Separator then Switch := new String' (Sw (1 .. Start - 1) & Parent & Directory_Separator & Sw (Start .. Sw'Last)); return; end if; end loop; else Switch := new String' (Sw (1 .. Start - 1) & Parent & Directory_Separator & Sw (Start .. Sw'Last)); end if; end if; elsif Including_Non_Switch then if not Is_Absolute_Path (Sw) then if Parent'Length = 0 then Do_Fail ("relative paths (""" & Sw & """) are not allowed"); else Switch := new String'(Parent & Directory_Separator & Sw); end if; end if; end if; end; end if; end Ensure_Absolute_Path; ---------------------------- -- Executable_Prefix_Path -- ---------------------------- function Executable_Prefix_Path return String is Exec_Name : constant String := Command_Name; function Get_Install_Dir (S : String) return String; -- S is the executable name preceded by the absolute or relative path, -- e.g. "c:\usr\bin\gcc.exe". Returns the absolute directory where "bin" -- lies (in the example "C:\usr"). If the executable is not in a "bin" -- directory, return "". --------------------- -- Get_Install_Dir -- --------------------- function Get_Install_Dir (S : String) return String is Exec : String := S; Path_Last : Integer := 0; begin for J in reverse Exec'Range loop if Exec (J) = Directory_Separator then Path_Last := J - 1; exit; end if; end loop; if Path_Last >= Exec'First + 2 then To_Lower (Exec (Path_Last - 2 .. Path_Last)); end if; if Path_Last < Exec'First + 2 or else Exec (Path_Last - 2 .. Path_Last) /= "bin" or else (Path_Last - 3 >= Exec'First and then Exec (Path_Last - 3) /= Directory_Separator) then return ""; end if; return Normalize_Pathname (Exec (Exec'First .. Path_Last - 4), Resolve_Links => Opt.Follow_Links_For_Dirs) & Directory_Separator; end Get_Install_Dir; -- Beginning of Executable_Prefix_Path begin -- First determine if a path prefix was placed in front of the -- executable name. for J in reverse Exec_Name'Range loop if Exec_Name (J) = Directory_Separator then return Get_Install_Dir (Exec_Name); end if; end loop; -- If we get here, the user has typed the executable name with no -- directory prefix. declare Path : String_Access := Locate_Exec_On_Path (Exec_Name); begin if Path = null then return ""; else declare Dir : constant String := Get_Install_Dir (Path.all); begin Free (Path); return Dir; end; end if; end; end Executable_Prefix_Path; ------------------ -- Fail_Program -- ------------------ procedure Fail_Program (S : String; Flush_Messages : Boolean := True) is begin if Flush_Messages and not No_Exit_Message then if Total_Errors_Detected /= 0 or else Warnings_Detected /= 0 then Errutil.Finalize; end if; end if; Finish_Program (E_Fatal, S => S); end Fail_Program; -------------------- -- Finish_Program -- -------------------- procedure Finish_Program (Exit_Code : Osint.Exit_Code_Type := Osint.E_Success; S : String := "") is begin if S'Length > 0 then if Exit_Code /= E_Success then if No_Exit_Message then Osint.Exit_Program (E_Fatal); else Osint.Fail (S); end if; elsif not No_Exit_Message then Write_Str (S); end if; end if; -- Output Namet statistics Namet.Finalize; Exit_Program (Exit_Code); end Finish_Program; ---------- -- Hash -- ---------- function Hash is new GNAT.HTable.Hash (Header_Num => Header_Num); -- Used in implementation of other functions Hash below ---------- -- Hash -- ---------- function Hash (Name : File_Name_Type) return Header_Num is begin return Hash (Get_Name_String (Name)); end Hash; function Hash (Name : Name_Id) return Header_Num is begin return Hash (Get_Name_String (Name)); end Hash; function Hash (Name : Path_Name_Type) return Header_Num is begin return Hash (Get_Name_String (Name)); end Hash; ------------ -- Inform -- ------------ procedure Inform (N : File_Name_Type; Msg : String) is begin Inform (Name_Id (N), Msg); end Inform; procedure Inform (N : Name_Id := No_Name; Msg : String) is begin Osint.Write_Program_Name; Write_Str (": "); if N /= No_Name then Write_Str (""""); declare Name : constant String := Get_Name_String (N); begin if Debug.Debug_Flag_F and then Is_Absolute_Path (Name) then Write_Str (File_Name (Name)); else Write_Str (Name); end if; end; Write_Str (""" "); end if; Write_Str (Msg); Write_Eol; end Inform; ----------- -- Mains -- ----------- package body Mains is package Names is new Table.Table (Table_Component_Type => Main_Info, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Makeutl.Mains.Names"); -- The table that stores the mains Current : Natural := 0; -- The index of the last main retrieved from the table Count_Of_Mains_With_No_Tree : Natural := 0; -- Number of main units for which we do not know the project tree -------------- -- Add_Main -- -------------- procedure Add_Main (Name : String; Index : Int := 0) is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); Names.Increment_Last; Names.Table (Names.Last) := (Name_Find, Index); Mains.Count_Of_Mains_With_No_Tree := Mains.Count_Of_Mains_With_No_Tree + 1; end Add_Main; ------------ -- Delete -- ------------ procedure Delete is begin Names.Set_Last (0); Mains.Reset; end Delete; --------------- -- Next_Main -- --------------- function Next_Main return String is Info : constant Main_Info := Next_Main; begin if Info = No_Main_Info then return ""; else return Get_Name_String (Info.File); end if; end Next_Main; function Next_Main return Main_Info is begin if Current >= Names.Last then return No_Main_Info; else Current := Current + 1; declare Orig_Main : constant File_Name_Type := Names.Table (Current).File; Current_Main : File_Name_Type; begin if Strip_Suffix (Orig_Main) = Orig_Main then Get_Name_String (Orig_Main); Add_Str_To_Name_Buffer (".adb"); Current_Main := Name_Find; if Full_Source_Name (Current_Main) = No_File then Get_Name_String (Orig_Main); Add_Str_To_Name_Buffer (".ads"); Current_Main := Name_Find; if Full_Source_Name (Current_Main) /= No_File then Names.Table (Current).File := Current_Main; end if; else Names.Table (Current).File := Current_Main; end if; end if; end; return Names.Table (Current); end if; end Next_Main; --------------------- -- Number_Of_Mains -- --------------------- function Number_Of_Mains return Natural is begin return Names.Last; end Number_Of_Mains; ----------- -- Reset -- ----------- procedure Reset is begin Current := 0; end Reset; -------------------------- -- Set_Multi_Unit_Index -- -------------------------- procedure Set_Multi_Unit_Index (Index : Int := 0) is begin if Index /= 0 then if Names.Last = 0 then Fail_Program ("cannot specify a multi-unit index but no main " & "on the command line"); elsif Names.Last > 1 then Fail_Program ("cannot specify several mains with a multi-unit index"); else Names.Table (Names.Last).Index := Index; end if; end if; end Set_Multi_Unit_Index; end Mains; ----------------------- -- Path_Or_File_Name -- ----------------------- function Path_Or_File_Name (Path : Path_Name_Type) return String is Path_Name : constant String := Get_Name_String (Path); begin if Debug.Debug_Flag_F then return File_Name (Path_Name); else return Path_Name; end if; end Path_Or_File_Name; ------------------- -- Unit_Index_Of -- ------------------- function Unit_Index_Of (ALI_File : File_Name_Type) return Int is Start : Natural; Finish : Natural; Result : Int := 0; begin Get_Name_String (ALI_File); -- First, find the last dot Finish := Name_Len; while Finish >= 1 and then Name_Buffer (Finish) /= '.' loop Finish := Finish - 1; end loop; if Finish = 1 then return 0; end if; -- Now check that the dot is preceded by digits Start := Finish; Finish := Finish - 1; while Start >= 1 and then Name_Buffer (Start - 1) in '0' .. '9' loop Start := Start - 1; end loop; -- If there are no digits, or if the digits are not preceded by the -- character that precedes a unit index, this is not the ALI file of -- a unit in a multi-unit source. if Start > Finish or else Start = 1 or else Name_Buffer (Start - 1) /= Multi_Unit_Index_Character then return 0; end if; -- Build the index from the digit(s) while Start <= Finish loop Result := Result * 10 + Character'Pos (Name_Buffer (Start)) - Character'Pos ('0'); Start := Start + 1; end loop; return Result; end Unit_Index_Of; ----------------- -- Verbose_Msg -- ----------------- procedure Verbose_Msg (N1 : Name_Id; S1 : String; N2 : Name_Id := No_Name; S2 : String := ""; Prefix : String := " -> "; Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low) is begin if not Opt.Verbose_Mode or else Minimum_Verbosity > Opt.Verbosity_Level then return; end if; Write_Str (Prefix); Write_Str (""""); Write_Name (N1); Write_Str (""" "); Write_Str (S1); if N2 /= No_Name then Write_Str (" """); Write_Name (N2); Write_Str (""" "); end if; Write_Str (S2); Write_Eol; end Verbose_Msg; procedure Verbose_Msg (N1 : File_Name_Type; S1 : String; N2 : File_Name_Type := No_File; S2 : String := ""; Prefix : String := " -> "; Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low) is begin Verbose_Msg (Name_Id (N1), S1, Name_Id (N2), S2, Prefix, Minimum_Verbosity); end Verbose_Msg; ----------- -- Queue -- ----------- package body Queue is type Q_Record is record Info : Source_Info; Processed : Boolean; end record; package Q is new Table.Table (Table_Component_Type => Q_Record, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 1000, Table_Increment => 100, Table_Name => "Makeutl.Queue.Q"); -- This is the actual Queue type Mark_Key is record File : File_Name_Type; Index : Int; end record; -- Identify either a mono-unit source (when Index = 0) or a specific -- unit (index = 1's origin index of unit) in a multi-unit source. Max_Mask_Num : constant := 2048; subtype Mark_Num is Union_Id range 0 .. Max_Mask_Num - 1; function Hash (Key : Mark_Key) return Mark_Num; package Marks is new GNAT.HTable.Simple_HTable (Header_Num => Mark_Num, Element => Boolean, No_Element => False, Key => Mark_Key, Hash => Hash, Equal => "="); -- A hash table to keep tracks of the marked units. -- These are the units that have already been processed, when using the -- gnatmake format. When using the gprbuild format, we can directly -- store in the source_id whether the file has already been processed. procedure Mark (Source_File : File_Name_Type; Index : Int := 0); -- Mark a unit, identified by its source file and, when Index is not 0, -- the index of the unit in the source file. Marking is used to signal -- that the unit has already been inserted in the Q. function Is_Marked (Source_File : File_Name_Type; Index : Int := 0) return Boolean; -- Returns True if the unit was previously marked Q_Processed : Natural := 0; Q_Initialized : Boolean := False; Q_First : Natural := 1; -- Points to the first valid element in the queue procedure Debug_Display (S : Source_Info); -- A debug display for S function Was_Processed (S : Source_Info) return Boolean; -- Whether S has already been processed. This marks the source as -- processed, if it hasn't already been processed. ------------------- -- Was_Processed -- ------------------- function Was_Processed (S : Source_Info) return Boolean is begin if Is_Marked (S.File, S.Index) then return True; end if; Mark (S.File, Index => S.Index); return False; end Was_Processed; ------------------- -- Debug_Display -- ------------------- procedure Debug_Display (S : Source_Info) is begin Write_Name (S.File); if S.Index /= 0 then Write_Str (", "); Write_Int (S.Index); end if; end Debug_Display; ---------- -- Hash -- ---------- function Hash (Key : Mark_Key) return Mark_Num is begin return Union_Id (Key.File) mod Max_Mask_Num; end Hash; --------------- -- Is_Marked -- --------------- function Is_Marked (Source_File : File_Name_Type; Index : Int := 0) return Boolean is begin return Marks.Get (K => (File => Source_File, Index => Index)); end Is_Marked; ---------- -- Mark -- ---------- procedure Mark (Source_File : File_Name_Type; Index : Int := 0) is begin Marks.Set (K => (File => Source_File, Index => Index), E => True); end Mark; ------------- -- Extract -- ------------- procedure Extract (Found : out Boolean; Source : out Source_Info) is begin Found := False; if Q_First <= Q.Last then Source := Q.Table (Q_First).Info; Q.Table (Q_First).Processed := True; Q_First := Q_First + 1; Found := True; end if; if Found then Q_Processed := Q_Processed + 1; end if; if Found and then Debug.Debug_Flag_Q then Write_Str (" Q := Q - [ "); Debug_Display (Source); Write_Str (" ]"); Write_Eol; Write_Str (" Q_First ="); Write_Int (Int (Q_First)); Write_Eol; Write_Str (" Q.Last ="); Write_Int (Int (Q.Last)); Write_Eol; end if; end Extract; --------------- -- Processed -- --------------- function Processed return Natural is begin return Q_Processed; end Processed; ---------------- -- Initialize -- ---------------- procedure Initialize (Force : Boolean := False) is begin if Force or else not Q_Initialized then Q_Initialized := True; Q.Init; Q_Processed := 0; Q_First := 1; end if; end Initialize; ------------ -- Insert -- ------------ function Insert (Source : Source_Info) return Boolean is begin -- Only insert in the Q if it is not already done, to avoid -- simultaneous compilations if -jnnn is used. if Was_Processed (Source) then return False; end if; Q.Append (New_Val => (Info => Source, Processed => False)); if Debug.Debug_Flag_Q then Write_Str (" Q := Q + [ "); Debug_Display (Source); Write_Str (" ] "); Write_Eol; Write_Str (" Q_First ="); Write_Int (Int (Q_First)); Write_Eol; Write_Str (" Q.Last ="); Write_Int (Int (Q.Last)); Write_Eol; end if; return True; end Insert; procedure Insert (Source : Source_Info) is Discard : Boolean; begin Discard := Insert (Source); end Insert; -------------- -- Is_Empty -- -------------- function Is_Empty return Boolean is begin return Q_Processed >= Q.Last; end Is_Empty; ---------- -- Size -- ---------- function Size return Natural is begin return Q.Last; end Size; ------------- -- Element -- ------------- function Element (Rank : Positive) return File_Name_Type is begin if Rank <= Q.Last then return Q.Table (Rank).Info.File; else return No_File; end if; end Element; ------------------ -- Remove_Marks -- ------------------ procedure Remove_Marks is begin Marks.Reset; end Remove_Marks; end Queue; end Make_Util;
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "VirusTotal" type = "api" function start() setratelimit(15) end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end local haskey = true if (c == nil or c.key == nil or c.key == "") then haskey = false end local resp local vurl = buildurl(domain) if haskey then vurl = apiurl(domain, c.key) end -- Check if the response data is in the graph database if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(domain, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return end if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(domain, resp) end end local d = json.decode(resp) if haskey then if d['response_code'] ~= 1 then log(ctx, name .. ": " .. vurl .. ": Response code " .. d['response_code'] .. ": " .. d['verbose_msg']) return end for i, sub in pairs(d.subdomains) do sendnames(ctx, sub) end else for i, data in pairs(d.data) do if data.type == "domain" then sendnames(ctx, data.id) end end end end function buildurl(domain) return "https://www.virustotal.com/ui/domains/" .. domain .. "/subdomains?limit=40" end function apiurl(domain, key) return "https://www.virustotal.com/vtapi/v2/domain/report?apikey=" .. key .. "&domain=" .. domain end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end for i, v in pairs(names) do newname(ctx, v) end end
-- { dg-do compile } with Array25_Pkg; procedure Array25 is package My_Pkg is new Array25_Pkg (0, 0); begin null; end;
with AUnit.Test_Suites; use AUnit.Test_Suites; package AOC_Test_Suite is function Suite return Access_Test_Suite; end AOC_Test_Suite;
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This file provides declarations for STM32F429xx boards manufactured by -- from ST Microelectronics. For example: the STM32F429I Discovery kit. with System; use System; with STM32F4.GPIO; use STM32F4.GPIO; with STM32F4.DMA; use STM32F4.DMA; with STM32F4.USARTs; use STM32F4.USARTs; with STM32F4.I2C; use STM32F4.I2C; with STM32F4.SPI; use STM32F4.SPI; with STM32F4.Timers; use STM32F4.Timers; use STM32F4; -- for base addresses package STM32F429_Discovery is pragma Elaborate_Body; subtype User_LED is GPIO_Pin; Green : User_LED renames Pin_13; Red : User_LED renames Pin_14; LED3 : User_LED renames Green; LED4 : User_LED renames Red; procedure Initialize_LEDs; -- MUST be called prior to any use of the LEDs procedure On (This : User_LED) with Inline; procedure Off (This : User_LED) with Inline; procedure Toggle (This : User_LED) with Inline; procedure All_LEDs_Off with Inline; procedure All_LEDs_On with Inline; GPIO_A : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOA_Base); GPIO_B : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOB_Base); GPIO_C : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOC_Base); GPIO_D : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOD_Base); GPIO_E : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOE_Base); GPIO_F : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOF_Base); GPIO_G : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOG_Base); GPIO_H : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOH_Base); GPIO_I : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOI_Base); GPIO_J : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOJ_Base); GPIO_K : aliased GPIO_Port with Volatile, Address => System'To_Address (GPIOK_Base); procedure Enable_Clock (This : aliased in out GPIO_Port); USART_1 : aliased USART with Volatile, Address => System'To_Address (USART1_Base); USART_2 : aliased USART with Volatile, Address => System'To_Address (USART2_Base); USART_3 : aliased USART with Volatile, Address => System'To_Address (USART3_Base); -- UART_4 : aliased UART with Volatile, Address => System'To_Address (UART4_Base); -- UART_5 : aliased UART with Volatile, Address => System'To_Address (UART5_Base); USART_6 : aliased USART with Volatile, Address => System'To_Address (USART6_Base); -- UART_7 : aliased UART with Volatile, Address => System'To_Address (UART7_Base); -- UART_8 : aliased UART with Volatile, Address => System'To_Address (UART8_Base); procedure Enable_Clock (This : aliased in out USART); DMA_1 : aliased DMA_Controller with Volatile, Address => System'To_Address (DMA1_BASE); DMA_2 : aliased DMA_Controller with Volatile, Address => System'To_Address (DMA2_BASE); procedure Enable_Clock (This : aliased in out DMA_Controller); I2C_1 : aliased I2C_Port with Volatile, Address => System'To_Address (I2C1_Base); I2C_2 : aliased I2C_Port with Volatile, Address => System'To_Address (I2C2_Base); I2C_3 : aliased I2C_Port with Volatile, Address => System'To_Address (I2C3_Base); procedure Enable_Clock (This : aliased in out I2C_Port); procedure Reset (This : in out I2C_Port); SPI_1 : aliased SPI_Port with Volatile, Address => System'To_Address (SPI1_Base); SPI_2 : aliased SPI_Port with Volatile, Address => System'To_Address (SPI2_Base); SPI_3 : aliased SPI_Port with Volatile, Address => System'To_Address (SPI3_Base); SPI_4 : aliased SPI_Port with Volatile, Address => System'To_Address (SPI4_Base); SPI_5 : aliased SPI_Port with Volatile, Address => System'To_Address (SPI5_Base); SPI_6 : aliased SPI_Port with Volatile, Address => System'To_Address (SPI6_Base); procedure Enable_Clock (This : aliased in out SPI_Port); procedure Reset (This : in out SPI_Port); Timer_1 : Timer with Volatile, Address => System'To_Address (TIM1_Base); pragma Import (Ada, Timer_1); Timer_2 : Timer with Volatile, Address => System'To_Address (TIM2_Base); pragma Import (Ada, Timer_2); Timer_3 : Timer with Volatile, Address => System'To_Address (TIM3_Base); pragma Import (Ada, Timer_3); Timer_4 : Timer with Volatile, Address => System'To_Address (TIM4_Base); pragma Import (Ada, Timer_4); Timer_5 : Timer with Volatile, Address => System'To_Address (TIM5_Base); pragma Import (Ada, Timer_5); Timer_6 : Timer with Volatile, Address => System'To_Address (TIM6_Base); pragma Import (Ada, Timer_6); Timer_7 : Timer with Volatile, Address => System'To_Address (TIM7_Base); pragma Import (Ada, Timer_7); Timer_8 : Timer with Volatile, Address => System'To_Address (TIM8_Base); pragma Import (Ada, Timer_8); Timer_9 : Timer with Volatile, Address => System'To_Address (TIM9_Base); pragma Import (Ada, Timer_9); Timer_10 : Timer with Volatile, Address => System'To_Address (TIM10_Base); pragma Import (Ada, Timer_10); Timer_11 : Timer with Volatile, Address => System'To_Address (TIM11_Base); pragma Import (Ada, Timer_11); Timer_12 : Timer with Volatile, Address => System'To_Address (TIM12_Base); pragma Import (Ada, Timer_12); Timer_13 : Timer with Volatile, Address => System'To_Address (TIM13_Base); pragma Import (Ada, Timer_13); Timer_14 : Timer with Volatile, Address => System'To_Address (TIM14_Base); pragma Import (Ada, Timer_14); procedure Enable_Clock (This : in out Timer); procedure Reset (This : in out Timer); end STM32F429_Discovery;
----------------------------------------------------------------------- -- awa-events-queues -- AWA Event Queues -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Util.Serialize.Mappers; with AWA.Events.Queues.Fifos; with AWA.Events.Queues.Persistents; package body AWA.Events.Queues is -- ------------------------------ -- Queue the event. -- ------------------------------ procedure Enqueue (Into : in Queue_Ref; Event : in AWA.Events.Module_Event'Class) is Q : constant Queue_Info_Access := Into.Value; begin if Q = null or else Q.Queue = null then return; end if; Q.Queue.Enqueue (Event); end Enqueue; -- ------------------------------ -- Dequeue an event and process it with the <b>Process</b> procedure. -- ------------------------------ procedure Dequeue (From : in Queue_Ref; Process : access procedure (Event : in Module_Event'Class)) is Q : constant Queue_Info_Access := From.Value; begin if Q = null or else Q.Queue = null then return; end if; Q.Queue.Dequeue (Process); end Dequeue; -- ------------------------------ -- Returns true if the reference does not contain any element. -- ------------------------------ function Is_Null (Queue : in Queue_Ref'Class) return Boolean is Q : constant Queue_Info_Access := Queue.Value; begin return Q = null or else Q.Queue = null; end Is_Null; -- ------------------------------ -- Returns the queue name. -- ------------------------------ function Get_Name (Queue : in Queue_Ref'Class) return String is Q : constant Queue_Info_Access := Queue.Value; begin if Q = null then return ""; else return Q.Name; end if; end Get_Name; -- ------------------------------ -- Get the model queue reference object. -- Returns a null object if the queue is not persistent. -- ------------------------------ function Get_Queue (Queue : in Queue_Ref'Class) return AWA.Events.Models.Queue_Ref is Q : constant Queue_Info_Access := Queue.Value; begin if Q = null or else Q.Queue = null then return AWA.Events.Models.Null_Queue; else return Q.Queue.Get_Queue; end if; end Get_Queue; FIFO_QUEUE_TYPE : constant String := "fifo"; PERSISTENT_QUEUE_TYPE : constant String := "persist"; -- ------------------------------ -- Create the event queue identified by the name <b>Name</b>. The queue factory -- identified by <b>Kind</b> is called to create the event queue instance. -- Returns a reference to the queue. -- ------------------------------ function Create_Queue (Name : in String; Kind : in String; Props : in EL.Beans.Param_Vectors.Vector; Context : in EL.Contexts.ELContext'Class) return Queue_Ref is Result : Queue_Ref; Q : constant Queue_Info_Access := new Queue_Info '(Util.Refs.Ref_Entity with Length => Name'Length, Name => Name, others => <>); begin Queue_Refs.Ref (Result) := Queue_Refs.Create (Q); if Kind = FIFO_QUEUE_TYPE then Q.Queue := AWA.Events.Queues.Fifos.Create_Queue (Name, Props, Context); elsif Kind = PERSISTENT_QUEUE_TYPE then Q.Queue := AWA.Events.Queues.Persistents.Create_Queue (Name, Props, Context); else raise Util.Serialize.Mappers.Field_Error with "Invalid queue type: " & Kind; end if; return Result; end Create_Queue; function Null_Queue return Queue_Ref is Result : Queue_Ref; begin return Result; end Null_Queue; -- ------------------------------ -- Finalize the referenced object. This is called before the object is freed. -- ------------------------------ overriding procedure Finalize (Object : in out Queue_Info) is procedure Free is new Ada.Unchecked_Deallocation (Object => Queue'Class, Name => Queue_Access); begin if Object.Queue /= null then Object.Queue.Finalize; Free (Object.Queue); end if; end Finalize; end AWA.Events.Queues;
with Types; use Types; with Curve25519_Add; use Curve25519_Add; with Curve25519_Mult; use Curve25519_Mult; with Curve25519_Other_Mult; use Curve25519_Other_Mult; with Ada.Text_IO; use Ada.Text_IO; procedure Test_Functions is begin -- Testing Add pragma Assert (Add ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Add ((94746531, 84168, 3265, 85385, 31543, 18538, 36351, 846, 553, 126805), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (94746531, 84168, 3265, 85385, 31543, 18538, 36351, 846, 553, 126805)); pragma Assert (Add ((94746531, 84168, 3265 , 85385, 31543, 18538, 36351 , 846 , 553 , 126805), (564854 , 86435, 8641684, 35218, 53197, 94653, 984165, 81384, 93618, 61063)) = (95311385, 170603 , 8644949, 120603, 84740, 113191 , 1020516, 82230 , 94171 , 187868)); -- Testing Multiply pragma Assert (Multiply ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (854651, 54654, 6486, 342, 8946, 8564, 7863, 48964, 786, 54)) = (854651, 54654, 6486, 342, 8946, 8564, 7863, 48964, 786, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply ((854651 , 54654, 6486, 342 , 8946 , 8564 , 7863 , 48964, 786, 54), (94746531, 84168, 3265, 85385, 31543, 18538, 36351, 846 , 553, 126805)) = (80975217465681, 5250211170642, 626516671325, 106102048195, 883972734101 , 830284653512 , 779819572890, 4643463560012, 85297057072 , 114871856552 , 23128942595 , 2899049302 , 2241403601 , 2941950074 , 2289685357 , 1026772717 , 12418286066 , 99698592 , 13694940)); -- Testing Multiply_1 pragma Assert (Multiply_1 ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply_1 ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply_1 ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (854651, 54654, 6486, 342, 8946, 8564, 7863, 48964, 786, 54)) = (854651, 54654, 6486, 342, 8946, 8564, 7863, 48964, 786, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply_1 ((854651 , 54654, 6486, 342 , 8946 , 8564 , 7863 , 48964, 786, 54), (94746531, 84168, 3265, 85385, 31543, 18538, 36351, 846 , 553, 126805)) = (80975217465681, 5250211170642, 626516671325, 106102048195, 883972734101 , 830284653512 , 779819572890, 4643463560012, 85297057072 , 114871856552 , 23128942595 , 2899049302 , 2241403601 , 2941950074 , 2289685357 , 1026772717 , 12418286066 , 99698592 , 13694940)); -- Testing Multiply_2 pragma Assert (Multiply_2 ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply_2 ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply_2 ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (854651, 54654, 6486, 342, 8946, 8564, 7863, 48964, 786, 54)) = (854651, 54654, 6486, 342, 8946, 8564, 7863, 48964, 786, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0)); pragma Assert (Multiply_2 ((854651 , 54654, 6486, 342 , 8946 , 8564 , 7863 , 48964, 786, 54), (94746531, 84168, 3265, 85385, 31543, 18538, 36351, 846 , 553, 126805)) = (80975217465681, 5250211170642, 626516671325, 106102048195, 883972734101 , 830284653512 , 779819572890, 4643463560012, 85297057072 , 114871856552 , 23128942595 , 2899049302 , 2241403601 , 2941950074 , 2289685357 , 1026772717 , 12418286066 , 99698592 , 13694940)); Put_Line ("All tests passed successfully."); end Test_Functions;
package Vect4_Pkg is function K return Integer; function N return Integer; end Vect4_Pkg;
-- with Interfaces.C.Strings; with Amp.Mono; with Amp.Stereo; package body Amp is function Descriptor (Index : C.unsigned_long) return access constant LADSPA.Descriptors is begin case Index is when 0 => return Amp.Mono.Mono_Descriptor.Data'Access; when 1 => return Amp.Stereo.Stereo_Descriptor.Data'Access; when others => null; end case; return null; end Descriptor; end Amp;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file font*.c -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief This file provides fonts for the LCD driver. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ package body BMP_Fonts is BMP_Font16x24 : constant array (0 .. 2279) of UInt16 := (16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#00CC#, 16#00CC#, 16#00CC#, 16#00CC#, 16#00CC#, 16#00CC#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0C60#, 16#0C60#, 16#0C60#, 16#0630#, 16#0630#, 16#1FFE#, 16#1FFE#, 16#0630#, 16#0738#, 16#0318#, 16#1FFE#, 16#1FFE#, 16#0318#, 16#0318#, 16#018C#, 16#018C#, 16#018C#, 16#0000#, 16#0000#, 16#0080#, 16#03E0#, 16#0FF8#, 16#0E9C#, 16#1C8C#, 16#188C#, 16#008C#, 16#0098#, 16#01F8#, 16#07E0#, 16#0E80#, 16#1C80#, 16#188C#, 16#188C#, 16#189C#, 16#0CB8#, 16#0FF0#, 16#03E0#, 16#0080#, 16#0080#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#180E#, 16#0C1B#, 16#0C11#, 16#0611#, 16#0611#, 16#0311#, 16#0311#, 16#019B#, 16#018E#, 16#38C0#, 16#6CC0#, 16#4460#, 16#4460#, 16#4430#, 16#4430#, 16#4418#, 16#6C18#, 16#380C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#01E0#, 16#03F0#, 16#0738#, 16#0618#, 16#0618#, 16#0330#, 16#01F0#, 16#00F0#, 16#00F8#, 16#319C#, 16#330E#, 16#1E06#, 16#1C06#, 16#1C06#, 16#3F06#, 16#73FC#, 16#21F0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0200#, 16#0300#, 16#0180#, 16#00C0#, 16#00C0#, 16#0060#, 16#0060#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0060#, 16#0060#, 16#00C0#, 16#00C0#, 16#0180#, 16#0300#, 16#0200#, 16#0000#, 16#0000#, 16#0020#, 16#0060#, 16#00C0#, 16#0180#, 16#0180#, 16#0300#, 16#0300#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0300#, 16#0300#, 16#0180#, 16#0180#, 16#00C0#, 16#0060#, 16#0020#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#06D8#, 16#07F8#, 16#01E0#, 16#0330#, 16#0738#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#3FFC#, 16#3FFC#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0100#, 16#0100#, 16#0080#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07E0#, 16#07E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0C00#, 16#0C00#, 16#0600#, 16#0600#, 16#0600#, 16#0300#, 16#0300#, 16#0300#, 16#0380#, 16#0180#, 16#0180#, 16#0180#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0060#, 16#0060#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#07F0#, 16#0E38#, 16#0C18#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#0C18#, 16#0E38#, 16#07F0#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0100#, 16#0180#, 16#01C0#, 16#01F0#, 16#0198#, 16#0188#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#0FF8#, 16#0C18#, 16#180C#, 16#180C#, 16#1800#, 16#1800#, 16#0C00#, 16#0600#, 16#0300#, 16#0180#, 16#00C0#, 16#0060#, 16#0030#, 16#0018#, 16#1FFC#, 16#1FFC#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#01E0#, 16#07F8#, 16#0E18#, 16#0C0C#, 16#0C0C#, 16#0C00#, 16#0600#, 16#03C0#, 16#07C0#, 16#0C00#, 16#1800#, 16#1800#, 16#180C#, 16#180C#, 16#0C18#, 16#07F8#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0C00#, 16#0E00#, 16#0F00#, 16#0F00#, 16#0D80#, 16#0CC0#, 16#0C60#, 16#0C60#, 16#0C30#, 16#0C18#, 16#0C0C#, 16#3FFC#, 16#3FFC#, 16#0C00#, 16#0C00#, 16#0C00#, 16#0C00#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0FF8#, 16#0FF8#, 16#0018#, 16#0018#, 16#000C#, 16#03EC#, 16#07FC#, 16#0E1C#, 16#1C00#, 16#1800#, 16#1800#, 16#1800#, 16#180C#, 16#0C1C#, 16#0E18#, 16#07F8#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07C0#, 16#0FF0#, 16#1C38#, 16#1818#, 16#0018#, 16#000C#, 16#03CC#, 16#0FEC#, 16#0E3C#, 16#1C1C#, 16#180C#, 16#180C#, 16#180C#, 16#1C18#, 16#0E38#, 16#07F0#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1FFC#, 16#1FFC#, 16#0C00#, 16#0600#, 16#0600#, 16#0300#, 16#0380#, 16#0180#, 16#01C0#, 16#00C0#, 16#00E0#, 16#0060#, 16#0060#, 16#0070#, 16#0030#, 16#0030#, 16#0030#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#07F0#, 16#0E38#, 16#0C18#, 16#0C18#, 16#0C18#, 16#0638#, 16#07F0#, 16#07F0#, 16#0C18#, 16#180C#, 16#180C#, 16#180C#, 16#180C#, 16#0C38#, 16#0FF8#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#07F0#, 16#0E38#, 16#0C1C#, 16#180C#, 16#180C#, 16#180C#, 16#1C1C#, 16#1E38#, 16#1BF8#, 16#19E0#, 16#1800#, 16#0C00#, 16#0C00#, 16#0E1C#, 16#07F8#, 16#01F0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0100#, 16#0100#, 16#0080#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#1C00#, 16#0F80#, 16#03E0#, 16#00F8#, 16#0018#, 16#00F8#, 16#03E0#, 16#0F80#, 16#1C00#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1FF8#, 16#0000#, 16#0000#, 16#0000#, 16#1FF8#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0008#, 16#0038#, 16#01F0#, 16#07C0#, 16#1F00#, 16#1800#, 16#1F00#, 16#07C0#, 16#01F0#, 16#0038#, 16#0008#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#0FF8#, 16#0C18#, 16#180C#, 16#180C#, 16#1800#, 16#0C00#, 16#0600#, 16#0300#, 16#0180#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07E0#, 16#1818#, 16#2004#, 16#29C2#, 16#4A22#, 16#4411#, 16#4409#, 16#4409#, 16#4409#, 16#2209#, 16#1311#, 16#0CE2#, 16#4002#, 16#2004#, 16#1818#, 16#07E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0380#, 16#0380#, 16#06C0#, 16#06C0#, 16#06C0#, 16#0C60#, 16#0C60#, 16#1830#, 16#1830#, 16#1830#, 16#3FF8#, 16#3FF8#, 16#701C#, 16#600C#, 16#600C#, 16#C006#, 16#C006#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03FC#, 16#0FFC#, 16#0C0C#, 16#180C#, 16#180C#, 16#180C#, 16#0C0C#, 16#07FC#, 16#0FFC#, 16#180C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#180C#, 16#1FFC#, 16#07FC#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07C0#, 16#1FF0#, 16#3838#, 16#301C#, 16#700C#, 16#6006#, 16#0006#, 16#0006#, 16#0006#, 16#0006#, 16#0006#, 16#0006#, 16#6006#, 16#700C#, 16#301C#, 16#1FF0#, 16#07E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03FE#, 16#0FFE#, 16#0E06#, 16#1806#, 16#1806#, 16#3006#, 16#3006#, 16#3006#, 16#3006#, 16#3006#, 16#3006#, 16#3006#, 16#1806#, 16#1806#, 16#0E06#, 16#0FFE#, 16#03FE#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3FFC#, 16#3FFC#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#1FFC#, 16#1FFC#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#3FFC#, 16#3FFC#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3FF8#, 16#3FF8#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#1FF8#, 16#1FF8#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0FE0#, 16#3FF8#, 16#783C#, 16#600E#, 16#E006#, 16#C007#, 16#0003#, 16#0003#, 16#FE03#, 16#FE03#, 16#C003#, 16#C007#, 16#C006#, 16#C00E#, 16#F03C#, 16#3FF8#, 16#0FE0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#3FFC#, 16#3FFC#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0600#, 16#0618#, 16#0618#, 16#0738#, 16#03F0#, 16#01E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3006#, 16#1806#, 16#0C06#, 16#0606#, 16#0306#, 16#0186#, 16#00C6#, 16#0066#, 16#0076#, 16#00DE#, 16#018E#, 16#0306#, 16#0606#, 16#0C06#, 16#1806#, 16#3006#, 16#6006#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#1FF8#, 16#1FF8#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#E00E#, 16#F01E#, 16#F01E#, 16#F01E#, 16#D836#, 16#D836#, 16#D836#, 16#D836#, 16#CC66#, 16#CC66#, 16#CC66#, 16#C6C6#, 16#C6C6#, 16#C6C6#, 16#C6C6#, 16#C386#, 16#C386#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#300C#, 16#301C#, 16#303C#, 16#303C#, 16#306C#, 16#306C#, 16#30CC#, 16#30CC#, 16#318C#, 16#330C#, 16#330C#, 16#360C#, 16#360C#, 16#3C0C#, 16#3C0C#, 16#380C#, 16#300C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07E0#, 16#1FF8#, 16#381C#, 16#700E#, 16#6006#, 16#C003#, 16#C003#, 16#C003#, 16#C003#, 16#C003#, 16#C003#, 16#C003#, 16#6006#, 16#700E#, 16#381C#, 16#1FF8#, 16#07E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0FFC#, 16#1FFC#, 16#380C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#180C#, 16#1FFC#, 16#07FC#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07E0#, 16#1FF8#, 16#381C#, 16#700E#, 16#6006#, 16#E003#, 16#C003#, 16#C003#, 16#C003#, 16#C003#, 16#C003#, 16#E007#, 16#6306#, 16#3F0E#, 16#3C1C#, 16#3FF8#, 16#F7E0#, 16#C000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0FFE#, 16#1FFE#, 16#3806#, 16#3006#, 16#3006#, 16#3006#, 16#3806#, 16#1FFE#, 16#07FE#, 16#0306#, 16#0606#, 16#0C06#, 16#1806#, 16#1806#, 16#3006#, 16#3006#, 16#6006#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#0FF8#, 16#0C1C#, 16#180C#, 16#180C#, 16#000C#, 16#001C#, 16#03F8#, 16#0FE0#, 16#1E00#, 16#3800#, 16#3006#, 16#3006#, 16#300E#, 16#1C1C#, 16#0FF8#, 16#07E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7FFE#, 16#7FFE#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#300C#, 16#1818#, 16#1FF8#, 16#07E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#6003#, 16#3006#, 16#3006#, 16#3006#, 16#180C#, 16#180C#, 16#180C#, 16#0C18#, 16#0C18#, 16#0E38#, 16#0630#, 16#0630#, 16#0770#, 16#0360#, 16#0360#, 16#01C0#, 16#01C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#6003#, 16#61C3#, 16#61C3#, 16#61C3#, 16#3366#, 16#3366#, 16#3366#, 16#3366#, 16#3366#, 16#3366#, 16#1B6C#, 16#1B6C#, 16#1B6C#, 16#1A2C#, 16#1E3C#, 16#0E38#, 16#0E38#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#E00F#, 16#700C#, 16#3018#, 16#1830#, 16#0C70#, 16#0E60#, 16#07C0#, 16#0380#, 16#0380#, 16#03C0#, 16#06E0#, 16#0C70#, 16#1C30#, 16#1818#, 16#300C#, 16#600E#, 16#E007#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#C003#, 16#6006#, 16#300C#, 16#381C#, 16#1838#, 16#0C30#, 16#0660#, 16#07E0#, 16#03C0#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7FFC#, 16#7FFC#, 16#6000#, 16#3000#, 16#1800#, 16#0C00#, 16#0600#, 16#0300#, 16#0180#, 16#00C0#, 16#0060#, 16#0030#, 16#0018#, 16#000C#, 16#0006#, 16#7FFE#, 16#7FFE#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#03E0#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#0060#, 16#03E0#, 16#03E0#, 16#0000#, 16#0000#, 16#0030#, 16#0030#, 16#0060#, 16#0060#, 16#0060#, 16#00C0#, 16#00C0#, 16#00C0#, 16#01C0#, 16#0180#, 16#0180#, 16#0180#, 16#0300#, 16#0300#, 16#0300#, 16#0600#, 16#0600#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#03E0#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#0300#, 16#03E0#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#01C0#, 16#01C0#, 16#0360#, 16#0360#, 16#0360#, 16#0630#, 16#0630#, 16#0C18#, 16#0C18#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#FFFF#, 16#FFFF#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03F0#, 16#07F8#, 16#0C1C#, 16#0C0C#, 16#0F00#, 16#0FF0#, 16#0CF8#, 16#0C0C#, 16#0C0C#, 16#0F1C#, 16#0FF8#, 16#18F0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#03D8#, 16#0FF8#, 16#0C38#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#0C38#, 16#0FF8#, 16#03D8#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03C0#, 16#07F0#, 16#0E30#, 16#0C18#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0C18#, 16#0E30#, 16#07F0#, 16#03C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1800#, 16#1800#, 16#1800#, 16#1800#, 16#1800#, 16#1BC0#, 16#1FF0#, 16#1C30#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1C30#, 16#1FF0#, 16#1BC0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03C0#, 16#0FF0#, 16#0C30#, 16#1818#, 16#1FF8#, 16#1FF8#, 16#0018#, 16#0018#, 16#1838#, 16#1C30#, 16#0FF0#, 16#07C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0F80#, 16#0FC0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#07F0#, 16#07F0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0DE0#, 16#0FF8#, 16#0E18#, 16#0C0C#, 16#0C0C#, 16#0C0C#, 16#0C0C#, 16#0C0C#, 16#0C0C#, 16#0E18#, 16#0FF8#, 16#0DE0#, 16#0C00#, 16#0C0C#, 16#061C#, 16#07F8#, 16#01F0#, 16#0000#, 16#0000#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#07D8#, 16#0FF8#, 16#1C38#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00F8#, 16#0078#, 16#0000#, 16#0000#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#000C#, 16#0C0C#, 16#060C#, 16#030C#, 16#018C#, 16#00CC#, 16#006C#, 16#00FC#, 16#019C#, 16#038C#, 16#030C#, 16#060C#, 16#0C0C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3C7C#, 16#7EFF#, 16#E3C7#, 16#C183#, 16#C183#, 16#C183#, 16#C183#, 16#C183#, 16#C183#, 16#C183#, 16#C183#, 16#C183#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0798#, 16#0FF8#, 16#1C38#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03C0#, 16#0FF0#, 16#0C30#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#0C30#, 16#0FF0#, 16#03C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03D8#, 16#0FF8#, 16#0C38#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#0C38#, 16#0FF8#, 16#03D8#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0018#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1BC0#, 16#1FF0#, 16#1C30#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1C30#, 16#1FF0#, 16#1BC0#, 16#1800#, 16#1800#, 16#1800#, 16#1800#, 16#1800#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#07B0#, 16#03F0#, 16#0070#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0030#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#03E0#, 16#03F0#, 16#0E38#, 16#0C18#, 16#0038#, 16#03F0#, 16#07C0#, 16#0C00#, 16#0C18#, 16#0E38#, 16#07F0#, 16#03E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0080#, 16#00C0#, 16#00C0#, 16#00C0#, 16#07F0#, 16#07F0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#07C0#, 16#0780#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1818#, 16#1C38#, 16#1FF0#, 16#19E0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#180C#, 16#0C18#, 16#0C18#, 16#0C18#, 16#0630#, 16#0630#, 16#0630#, 16#0360#, 16#0360#, 16#0360#, 16#01C0#, 16#01C0#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#41C1#, 16#41C1#, 16#61C3#, 16#6363#, 16#6363#, 16#6363#, 16#3636#, 16#3636#, 16#3636#, 16#1C1C#, 16#1C1C#, 16#1C1C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#381C#, 16#1C38#, 16#0C30#, 16#0660#, 16#0360#, 16#0360#, 16#0360#, 16#0360#, 16#0660#, 16#0C30#, 16#1C38#, 16#381C#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3018#, 16#1830#, 16#1830#, 16#1870#, 16#0C60#, 16#0C60#, 16#0CE0#, 16#06C0#, 16#06C0#, 16#0380#, 16#0380#, 16#0380#, 16#0180#, 16#0180#, 16#01C0#, 16#00F0#, 16#0070#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#1FFC#, 16#1FFC#, 16#0C00#, 16#0600#, 16#0300#, 16#0180#, 16#00C0#, 16#0060#, 16#0030#, 16#0018#, 16#1FFC#, 16#1FFC#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0300#, 16#0180#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0060#, 16#0060#, 16#0030#, 16#0060#, 16#0040#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#00C0#, 16#0180#, 16#0300#, 16#0000#, 16#0000#, 16#0000#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0000#, 16#0000#, 16#0060#, 16#00C0#, 16#01C0#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0300#, 16#0300#, 16#0600#, 16#0300#, 16#0100#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#0180#, 16#00C0#, 16#0060#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#10F0#, 16#1FF8#, 16#0F08#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#); BMP_Font12x12 : constant array (0 .. 1151) of UInt16 := (16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#5000#, 16#5000#, 16#5000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0900#, 16#0900#, 16#1200#, 16#7f00#, 16#1200#, 16#7f00#, 16#1200#, 16#2400#, 16#2400#, 16#0000#, 16#0000#, 16#1000#, 16#3800#, 16#5400#, 16#5000#, 16#5000#, 16#3800#, 16#1400#, 16#5400#, 16#5400#, 16#3800#, 16#1000#, 16#0000#, 16#0000#, 16#3080#, 16#4900#, 16#4900#, 16#4a00#, 16#32c0#, 16#0520#, 16#0920#, 16#0920#, 16#10c0#, 16#0000#, 16#0000#, 16#0000#, 16#0c00#, 16#1200#, 16#1200#, 16#1400#, 16#1800#, 16#2500#, 16#2300#, 16#2300#, 16#1d80#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0800#, 16#1000#, 16#1000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#1000#, 16#1000#, 16#0000#, 16#4000#, 16#2000#, 16#2000#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#2000#, 16#2000#, 16#0000#, 16#2000#, 16#7000#, 16#2000#, 16#5000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0800#, 16#0800#, 16#7f00#, 16#0800#, 16#0800#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#2000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#1000#, 16#1000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#2800#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#2800#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#3000#, 16#5000#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#3000#, 16#4800#, 16#4400#, 16#0400#, 16#0800#, 16#1000#, 16#2000#, 16#4000#, 16#7c00#, 16#0000#, 16#0000#, 16#0000#, 16#3000#, 16#4800#, 16#0400#, 16#0800#, 16#1000#, 16#0800#, 16#4400#, 16#4800#, 16#3000#, 16#0000#, 16#0000#, 16#0000#, 16#0800#, 16#1800#, 16#1800#, 16#2800#, 16#2800#, 16#4800#, 16#7c00#, 16#0800#, 16#0800#, 16#0000#, 16#0000#, 16#0000#, 16#3c00#, 16#2000#, 16#4000#, 16#7000#, 16#4800#, 16#0400#, 16#4400#, 16#4800#, 16#3000#, 16#0000#, 16#0000#, 16#0000#, 16#1800#, 16#2400#, 16#4000#, 16#5000#, 16#6800#, 16#4400#, 16#4400#, 16#2800#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#7c00#, 16#0400#, 16#0800#, 16#1000#, 16#1000#, 16#1000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#2800#, 16#4400#, 16#2800#, 16#1000#, 16#2800#, 16#4400#, 16#2800#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#2800#, 16#4400#, 16#4400#, 16#2c00#, 16#1400#, 16#0400#, 16#4800#, 16#3000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#2000#, 16#4000#, 16#0000#, 16#0000#, 16#0400#, 16#0800#, 16#3000#, 16#4000#, 16#3000#, 16#0800#, 16#0400#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7c00#, 16#0000#, 16#0000#, 16#7c00#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#2000#, 16#1800#, 16#0400#, 16#1800#, 16#2000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3800#, 16#6400#, 16#4400#, 16#0400#, 16#0800#, 16#1000#, 16#1000#, 16#0000#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#0f80#, 16#1040#, 16#2ea0#, 16#51a0#, 16#5120#, 16#5120#, 16#5120#, 16#5320#, 16#4dc0#, 16#2020#, 16#1040#, 16#0000#, 16#0800#, 16#1400#, 16#1400#, 16#1400#, 16#2200#, 16#3e00#, 16#2200#, 16#4100#, 16#4100#, 16#0000#, 16#0000#, 16#0000#, 16#3c00#, 16#2200#, 16#2200#, 16#2200#, 16#3c00#, 16#2200#, 16#2200#, 16#2200#, 16#3c00#, 16#0000#, 16#0000#, 16#0000#, 16#0e00#, 16#1100#, 16#2100#, 16#2000#, 16#2000#, 16#2000#, 16#2100#, 16#1100#, 16#0e00#, 16#0000#, 16#0000#, 16#0000#, 16#3c00#, 16#2200#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2200#, 16#3c00#, 16#0000#, 16#0000#, 16#0000#, 16#3e00#, 16#2000#, 16#2000#, 16#2000#, 16#3e00#, 16#2000#, 16#2000#, 16#2000#, 16#3e00#, 16#0000#, 16#0000#, 16#0000#, 16#3e00#, 16#2000#, 16#2000#, 16#2000#, 16#3c00#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0e00#, 16#1100#, 16#2100#, 16#2000#, 16#2700#, 16#2100#, 16#2100#, 16#1100#, 16#0e00#, 16#0000#, 16#0000#, 16#0000#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#3f00#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#4800#, 16#4800#, 16#3000#, 16#0000#, 16#0000#, 16#0000#, 16#2200#, 16#2400#, 16#2800#, 16#2800#, 16#3800#, 16#2800#, 16#2400#, 16#2400#, 16#2200#, 16#0000#, 16#0000#, 16#0000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#3e00#, 16#0000#, 16#0000#, 16#0000#, 16#2080#, 16#3180#, 16#3180#, 16#3180#, 16#2a80#, 16#2a80#, 16#2a80#, 16#2a80#, 16#2480#, 16#0000#, 16#0000#, 16#0000#, 16#2100#, 16#3100#, 16#3100#, 16#2900#, 16#2900#, 16#2500#, 16#2300#, 16#2300#, 16#2100#, 16#0000#, 16#0000#, 16#0000#, 16#0c00#, 16#1200#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#1200#, 16#0c00#, 16#0000#, 16#0000#, 16#0000#, 16#3c00#, 16#2200#, 16#2200#, 16#2200#, 16#3c00#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0c00#, 16#1200#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#1600#, 16#0d00#, 16#0100#, 16#0000#, 16#0000#, 16#3e00#, 16#2100#, 16#2100#, 16#2100#, 16#3e00#, 16#2400#, 16#2200#, 16#2100#, 16#2080#, 16#0000#, 16#0000#, 16#0000#, 16#1c00#, 16#2200#, 16#2200#, 16#2000#, 16#1c00#, 16#0200#, 16#2200#, 16#2200#, 16#1c00#, 16#0000#, 16#0000#, 16#0000#, 16#3e00#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0000#, 16#0000#, 16#0000#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#2100#, 16#1200#, 16#0c00#, 16#0000#, 16#0000#, 16#0000#, 16#4100#, 16#4100#, 16#2200#, 16#2200#, 16#2200#, 16#1400#, 16#1400#, 16#1400#, 16#0800#, 16#0000#, 16#0000#, 16#0000#, 16#4440#, 16#4a40#, 16#2a40#, 16#2a80#, 16#2a80#, 16#2a80#, 16#2a80#, 16#2a80#, 16#1100#, 16#0000#, 16#0000#, 16#0000#, 16#4100#, 16#2200#, 16#1400#, 16#1400#, 16#0800#, 16#1400#, 16#1400#, 16#2200#, 16#4100#, 16#0000#, 16#0000#, 16#0000#, 16#4100#, 16#2200#, 16#2200#, 16#1400#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0800#, 16#0000#, 16#0000#, 16#0000#, 16#7e00#, 16#0200#, 16#0400#, 16#0800#, 16#1000#, 16#1000#, 16#2000#, 16#4000#, 16#7e00#, 16#0000#, 16#0000#, 16#0000#, 16#3000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#4000#, 16#4000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#1000#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#6000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#1000#, 16#2800#, 16#2800#, 16#2800#, 16#4400#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7e00#, 16#4000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3800#, 16#4400#, 16#0400#, 16#3c00#, 16#4400#, 16#4400#, 16#3c00#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#4000#, 16#5800#, 16#6400#, 16#4400#, 16#4400#, 16#4400#, 16#6400#, 16#5800#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3000#, 16#4800#, 16#4000#, 16#4000#, 16#4000#, 16#4800#, 16#3000#, 16#0000#, 16#0000#, 16#0000#, 16#0400#, 16#0400#, 16#3400#, 16#4c00#, 16#4400#, 16#4400#, 16#4400#, 16#4c00#, 16#3400#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3800#, 16#4400#, 16#4400#, 16#7c00#, 16#4000#, 16#4400#, 16#3800#, 16#0000#, 16#0000#, 16#0000#, 16#6000#, 16#4000#, 16#e000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3400#, 16#4c00#, 16#4400#, 16#4400#, 16#4400#, 16#4c00#, 16#3400#, 16#0400#, 16#4400#, 16#0000#, 16#4000#, 16#4000#, 16#5800#, 16#6400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#0000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#0000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#0000#, 16#4000#, 16#4000#, 16#4800#, 16#5000#, 16#6000#, 16#5000#, 16#5000#, 16#4800#, 16#4800#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#5200#, 16#6d00#, 16#4900#, 16#4900#, 16#4900#, 16#4900#, 16#4900#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#5800#, 16#6400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3800#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#3800#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#5800#, 16#6400#, 16#4400#, 16#4400#, 16#4400#, 16#6400#, 16#5800#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#3400#, 16#4c00#, 16#4400#, 16#4400#, 16#4400#, 16#4c00#, 16#3400#, 16#0400#, 16#0400#, 16#0000#, 16#0000#, 16#0000#, 16#5000#, 16#6000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#3000#, 16#4800#, 16#4000#, 16#3000#, 16#0800#, 16#4800#, 16#3000#, 16#0000#, 16#0000#, 16#0000#, 16#4000#, 16#4000#, 16#e000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#4000#, 16#6000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#4400#, 16#4c00#, 16#3400#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#4400#, 16#4400#, 16#2800#, 16#2800#, 16#2800#, 16#2800#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#4900#, 16#4900#, 16#5500#, 16#5500#, 16#5500#, 16#5500#, 16#2200#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#4400#, 16#2800#, 16#2800#, 16#1000#, 16#2800#, 16#2800#, 16#4400#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#4400#, 16#4400#, 16#2800#, 16#2800#, 16#2800#, 16#1000#, 16#1000#, 16#1000#, 16#1000#, 16#0000#, 16#0000#, 16#0000#, 16#7800#, 16#0800#, 16#1000#, 16#2000#, 16#2000#, 16#4000#, 16#7800#, 16#0000#, 16#0000#, 16#0000#, 16#1000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#4000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#4000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#1000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#2000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7400#, 16#5800#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#0000#, 16#7000#, 16#5000#, 16#5000#, 16#5000#, 16#5000#, 16#5000#, 16#5000#, 16#7000#, 16#0000#, 16#0000#); BMP_Font8x8 : constant array (0 .. 767) of UInt8 := (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#40#, 16#40#, 16#40#, 16#40#, 16#40#, 16#00#, 16#40#, 16#a0#, 16#a0#, 16#a0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#24#, 16#24#, 16#fe#, 16#48#, 16#fc#, 16#48#, 16#48#, 16#38#, 16#54#, 16#50#, 16#38#, 16#14#, 16#14#, 16#54#, 16#38#, 16#44#, 16#a8#, 16#a8#, 16#50#, 16#14#, 16#1a#, 16#2a#, 16#24#, 16#10#, 16#28#, 16#28#, 16#10#, 16#74#, 16#4c#, 16#4c#, 16#30#, 16#10#, 16#10#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#08#, 16#10#, 16#08#, 16#08#, 16#08#, 16#08#, 16#08#, 16#08#, 16#10#, 16#00#, 16#00#, 16#24#, 16#18#, 16#3c#, 16#18#, 16#24#, 16#00#, 16#00#, 16#00#, 16#10#, 16#10#, 16#7c#, 16#10#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#08#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3c#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#18#, 16#08#, 16#08#, 16#08#, 16#10#, 16#10#, 16#20#, 16#20#, 16#20#, 16#18#, 16#24#, 16#24#, 16#24#, 16#24#, 16#24#, 16#24#, 16#18#, 16#08#, 16#18#, 16#28#, 16#08#, 16#08#, 16#08#, 16#08#, 16#08#, 16#38#, 16#44#, 16#00#, 16#04#, 16#08#, 16#10#, 16#20#, 16#7c#, 16#18#, 16#24#, 16#04#, 16#18#, 16#04#, 16#04#, 16#24#, 16#18#, 16#04#, 16#0c#, 16#14#, 16#24#, 16#44#, 16#7e#, 16#04#, 16#04#, 16#3c#, 16#20#, 16#20#, 16#38#, 16#04#, 16#04#, 16#24#, 16#18#, 16#18#, 16#24#, 16#20#, 16#38#, 16#24#, 16#24#, 16#24#, 16#18#, 16#3c#, 16#04#, 16#08#, 16#08#, 16#08#, 16#10#, 16#10#, 16#10#, 16#18#, 16#24#, 16#24#, 16#18#, 16#24#, 16#24#, 16#24#, 16#18#, 16#18#, 16#24#, 16#24#, 16#24#, 16#1c#, 16#04#, 16#24#, 16#18#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#08#, 16#10#, 16#00#, 16#00#, 16#00#, 16#04#, 16#18#, 16#20#, 16#18#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3c#, 16#00#, 16#3c#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#18#, 16#04#, 16#18#, 16#20#, 16#00#, 16#18#, 16#24#, 16#04#, 16#08#, 16#10#, 16#10#, 16#00#, 16#10#, 16#3c#, 16#42#, 16#99#, 16#a5#, 16#a5#, 16#9d#, 16#42#, 16#38#, 16#38#, 16#44#, 16#44#, 16#44#, 16#7c#, 16#44#, 16#44#, 16#44#, 16#78#, 16#44#, 16#44#, 16#78#, 16#44#, 16#44#, 16#44#, 16#78#, 16#1c#, 16#22#, 16#42#, 16#40#, 16#40#, 16#42#, 16#22#, 16#1c#, 16#70#, 16#48#, 16#44#, 16#44#, 16#44#, 16#44#, 16#48#, 16#70#, 16#7c#, 16#40#, 16#40#, 16#7c#, 16#40#, 16#40#, 16#40#, 16#7c#, 16#3c#, 16#20#, 16#20#, 16#38#, 16#20#, 16#20#, 16#20#, 16#20#, 16#1c#, 16#22#, 16#42#, 16#40#, 16#4e#, 16#42#, 16#22#, 16#1c#, 16#44#, 16#44#, 16#44#, 16#7c#, 16#44#, 16#44#, 16#44#, 16#44#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#04#, 16#04#, 16#04#, 16#04#, 16#04#, 16#24#, 16#24#, 16#18#, 16#44#, 16#48#, 16#50#, 16#70#, 16#50#, 16#48#, 16#48#, 16#44#, 16#20#, 16#20#, 16#20#, 16#20#, 16#20#, 16#20#, 16#20#, 16#3c#, 16#82#, 16#c6#, 16#c6#, 16#aa#, 16#aa#, 16#aa#, 16#aa#, 16#92#, 16#42#, 16#62#, 16#52#, 16#52#, 16#4a#, 16#4a#, 16#46#, 16#42#, 16#18#, 16#24#, 16#42#, 16#42#, 16#42#, 16#42#, 16#24#, 16#18#, 16#78#, 16#44#, 16#44#, 16#44#, 16#78#, 16#40#, 16#40#, 16#40#, 16#18#, 16#24#, 16#42#, 16#42#, 16#42#, 16#42#, 16#2c#, 16#1a#, 16#78#, 16#44#, 16#44#, 16#78#, 16#50#, 16#48#, 16#44#, 16#42#, 16#38#, 16#44#, 16#40#, 16#38#, 16#04#, 16#44#, 16#44#, 16#38#, 16#7c#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#42#, 16#42#, 16#42#, 16#42#, 16#42#, 16#42#, 16#24#, 16#18#, 16#44#, 16#44#, 16#28#, 16#28#, 16#28#, 16#28#, 16#28#, 16#10#, 16#92#, 16#aa#, 16#aa#, 16#aa#, 16#aa#, 16#aa#, 16#aa#, 16#44#, 16#42#, 16#24#, 16#24#, 16#18#, 16#18#, 16#24#, 16#24#, 16#42#, 16#44#, 16#28#, 16#28#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#7c#, 16#04#, 16#08#, 16#10#, 16#10#, 16#20#, 16#40#, 16#7c#, 16#1c#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#1c#, 16#10#, 16#10#, 16#08#, 16#08#, 16#08#, 16#08#, 16#04#, 16#04#, 16#1c#, 16#04#, 16#04#, 16#04#, 16#04#, 16#04#, 16#04#, 16#1c#, 16#10#, 16#28#, 16#44#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#10#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#1c#, 16#24#, 16#24#, 16#1c#, 16#20#, 16#20#, 16#28#, 16#34#, 16#24#, 16#24#, 16#34#, 16#28#, 16#00#, 16#00#, 16#18#, 16#24#, 16#20#, 16#20#, 16#24#, 16#18#, 16#04#, 16#04#, 16#14#, 16#2c#, 16#24#, 16#24#, 16#2c#, 16#14#, 16#00#, 16#00#, 16#18#, 16#24#, 16#3c#, 16#20#, 16#24#, 16#18#, 16#00#, 16#18#, 16#10#, 16#10#, 16#18#, 16#10#, 16#10#, 16#10#, 16#00#, 16#18#, 16#24#, 16#24#, 16#18#, 16#04#, 16#24#, 16#18#, 16#20#, 16#20#, 16#28#, 16#34#, 16#24#, 16#24#, 16#24#, 16#24#, 16#10#, 16#00#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#08#, 16#00#, 16#08#, 16#08#, 16#08#, 16#08#, 16#28#, 16#10#, 16#20#, 16#20#, 16#24#, 16#28#, 16#30#, 16#28#, 16#24#, 16#24#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#00#, 16#00#, 16#a6#, 16#da#, 16#92#, 16#92#, 16#92#, 16#92#, 16#00#, 16#00#, 16#28#, 16#34#, 16#24#, 16#24#, 16#24#, 16#24#, 16#00#, 16#00#, 16#18#, 16#24#, 16#24#, 16#24#, 16#24#, 16#18#, 16#00#, 16#28#, 16#34#, 16#24#, 16#38#, 16#20#, 16#20#, 16#20#, 16#00#, 16#14#, 16#2c#, 16#24#, 16#1c#, 16#04#, 16#04#, 16#04#, 16#00#, 16#00#, 16#2c#, 16#30#, 16#20#, 16#20#, 16#20#, 16#20#, 16#00#, 16#00#, 16#18#, 16#24#, 16#10#, 16#08#, 16#24#, 16#18#, 16#00#, 16#10#, 16#38#, 16#10#, 16#10#, 16#10#, 16#10#, 16#18#, 16#00#, 16#00#, 16#24#, 16#24#, 16#24#, 16#24#, 16#2c#, 16#14#, 16#00#, 16#00#, 16#44#, 16#44#, 16#28#, 16#28#, 16#28#, 16#10#, 16#00#, 16#00#, 16#92#, 16#aa#, 16#aa#, 16#aa#, 16#aa#, 16#44#, 16#00#, 16#00#, 16#44#, 16#28#, 16#10#, 16#10#, 16#28#, 16#44#, 16#00#, 16#28#, 16#28#, 16#28#, 16#10#, 16#10#, 16#10#, 16#10#, 16#00#, 16#00#, 16#3c#, 16#04#, 16#08#, 16#10#, 16#20#, 16#3c#, 16#00#, 16#08#, 16#10#, 16#10#, 16#20#, 16#10#, 16#10#, 16#08#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#10#, 16#00#, 16#10#, 16#08#, 16#08#, 16#04#, 16#08#, 16#08#, 16#10#, 16#00#, 16#00#, 16#00#, 16#60#, 16#92#, 16#0c#, 16#00#, 16#00#, 16#ff#, 16#ff#, 16#ff#, 16#ff#, 16#ff#, 16#ff#, 16#ff#, 16#ff#); ---------- -- Mask -- ---------- function Mask (Font : BMP_Font; Width_Offset : Natural) return UInt16 is begin case Font is when Font8x8 => return 2**(8 - Width_Offset); when Font12x12 => return 2**(16 - Width_Offset); when Font16x24 => return 2**Width_Offset; end case; end Mask; ---------- -- Data -- ---------- function Data (Font : BMP_Font; C : Character; Height_Offset : Natural) return UInt16 is Char_Num : constant Natural := Character'Pos (C); Char_Index : constant Natural := Char_Height (Font) * (if Char_Num >= 32 and then Char_Num <= 128 then Char_Num - 32 else Character'Pos ('?') - 32); begin case Font is when Font8x8 => return UInt16 (BMP_Font8x8 (Char_Index + Height_Offset)); when Font12x12 => return BMP_Font12x12 (Char_Index + Height_Offset); when Font16x24 => return BMP_Font16x24 (Char_Index + Height_Offset); end case; end Data; ----------------- -- Char_Height -- ----------------- function Char_Height (Font : BMP_Font) return Natural is begin case Font is when Font8x8 => return 8; when Font12x12 => return 12; when Font16x24 => return 24; end case; end Char_Height; ---------------- -- Char_Width -- ---------------- function Char_Width (Font : BMP_Font) return Natural is begin case Font is when Font8x8 => return 8; when Font12x12 => return 12; when Font16x24 => return 16; end case; end Char_Width; end BMP_Fonts;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with League.String_Vectors; package body Markdown.Common_Patterns is Link_Destination : constant Wide_Wide_String := "\<([^\<\>\\]|\\.)*\>"; Link_Destination_Pattern : constant League.Regexps.Regexp_Pattern := League.Regexps.Compile (League.Strings.To_Universal_String (Link_Destination)); ---------------------------- -- Parse_Link_Destination -- ---------------------------- procedure Parse_Link_Destination (Line : League.Strings.Universal_String; Last : out Natural; URL : out League.Strings.Universal_String) is function Unescape (Text : League.Strings.Universal_String) return League.Strings.Universal_String; -------------- -- Unescape -- -------------- function Unescape (Text : League.Strings.Universal_String) return League.Strings.Universal_String is Masked : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("!""#$%&'()*+,-./:;<=>?@[]^_`{|}~"); List : constant League.String_Vectors.Universal_String_Vector := Text.Split ('\'); Result : League.Strings.Universal_String; begin if List.Length > 0 then Result := List (1); end if; for J in 2 .. List.Length loop declare Item : constant League.Strings.Universal_String := List (J); begin if Item.Is_Empty or else Masked.Index (Item (1)) = 0 then Result.Append ("\"); end if; Result.Append (Item); end; end loop; return Result; end Unescape; Is_Escape : Boolean := False; Stop : Natural := 0; -- index of first unmatched '(' Count : Natural := 0; -- Count of unmatched '(' begin if Line.Starts_With ("<") then declare Match : constant League.Regexps.Regexp_Match := Link_Destination_Pattern.Find_Match (Line); Text : League.Strings.Universal_String; begin if Match.Is_Matched then Text := Match.Capture; URL := Unescape (Text.Slice (2, Text.Length - 1)); Last := Match.Last_Index; else Last := 0; end if; return; end; end if; Last := Line.Length; for J in 1 .. Line.Length loop declare Char : constant Wide_Wide_Character := Line (J).To_Wide_Wide_Character; begin if Is_Escape then Is_Escape := False; elsif Char = '\' then Is_Escape := True; elsif Char <= ' ' then Last := J - 1; exit; elsif Char = '(' then if Count = 0 then Stop := J; end if; Count := Count + 1; elsif Char = ')' then if Count = 0 then Last := J - 1; exit; else Count := Count - 1; end if; end if; end; end loop; if Count > 0 then Last := Stop - 1; elsif Is_Escape then Last := Last - 1; end if; if Last > 0 then URL := Unescape (Line.Head_To (Last)); end if; end Parse_Link_Destination; end Markdown.Common_Patterns;
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. package body Words_Engine.Trick_Tables is function Member (Needle : Unbounded_String; Haystack : Strings) return Boolean is begin for S in Haystack'Range loop if Needle = Haystack (S) then return True; end if; end loop; return False; end Member; function Common_Prefix (S : String) return Boolean is -- Common prefixes that have corresponding words (prepositions -- usually) which could confuse TWO_WORDS. We wish to reject -- these. Common_Prefixes : constant Strings := ( +"dis", +"ex", +"in", +"per", +"prae", +"pro", +"re", +"si", +"sub", +"super", +"trans" ); begin return Member (+S, Common_Prefixes); end Common_Prefix; A_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip_Flop, FF1 => +"adgn", FF2 => +"agn"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"adsc", FF2 => +"asc"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"adsp", FF2 => +"asp"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"arqui", FF2 => +"arci"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"arqu", FF2 => +"arcu"), (Max => 0, Op => TC_Flip, FF3 => +"ae", FF4 => +"e"), (Max => 0, Op => TC_Flip, FF3 => +"al", FF4 => +"hal"), (Max => 0, Op => TC_Flip, FF3 => +"am", FF4 => +"ham"), (Max => 0, Op => TC_Flip, FF3 => +"ar", FF4 => +"har"), (Max => 0, Op => TC_Flip, FF3 => +"aur", FF4 => +"or") ); D_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"dampn", FF4 => +"damn"), -- OLD p.54, (Max => 0, Op => TC_Flip_Flop, FF1 => +"dij", FF2 => +"disj"), -- OLD p.55, (Max => 0, Op => TC_Flip_Flop, FF1 => +"dir", FF2 => +"disr"), -- OLD p.54, (Max => 0, Op => TC_Flip_Flop, FF1 => +"dir", FF2 => +"der"), -- OLD p.507/54, (Max => 0, Op => TC_Flip_Flop, FF1 => +"del", FF2 => +"dil") ); E_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip_Flop, FF1 => +"ecf", FF2 => +"eff"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"ecs", FF2 => +"exs"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"es", FF2 => +"ess"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"ex", FF2 => +"exs"), (Max => 0, Op => TC_Flip, FF3 => +"eid", FF4 => +"id"), (Max => 0, Op => TC_Flip, FF3 => +"el", FF4 => +"hel"), (Max => 0, Op => TC_Flip, FF3 => +"e", FF4 => +"ae") ); F_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip_Flop, FF1 => +"faen", FF2 => +"fen"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"faen", FF2 => +"foen"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"fed", FF2 => +"foed"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"fet", FF2 => +"foet"), (Max => 0, Op => TC_Flip, FF3 => +"f", FF4 => +"ph") ); -- Try lead then all G_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Flip, FF3 => +"gna", FF4 => +"na") ); H_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"har", FF4 => +"ar"), (Max => 0, Op => TC_Flip, FF3 => +"hal", FF4 => +"al"), (Max => 0, Op => TC_Flip, FF3 => +"ham", FF4 => +"am"), (Max => 0, Op => TC_Flip, FF3 => +"hel", FF4 => +"el"), (Max => 0, Op => TC_Flip, FF3 => +"hol", FF4 => +"ol"), (Max => 0, Op => TC_Flip, FF3 => +"hum", FF4 => +"um") ); K_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"k", FF4 => +"c"), (Max => 0, Op => TC_Flip, FF3 => +"c", FF4 => +"k") ); L_Tricks : constant TricksT := (1 => (Max => 1, Op => TC_Flip_Flop, FF1 => +"lub", FF2 => +"lib") ); M_Tricks : constant TricksT := (1 => (Max => 1, Op => TC_Flip_Flop, FF1 => +"mani", FF2 => +"manu") ); N_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"na", FF4 => +"gna"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"nihil", FF2 => +"nil") ); O_Tricks : constant TricksT := ( (Max => 1, Op => TC_Flip_Flop, FF1 => +"obt", FF2 => +"opt"), (Max => 1, Op => TC_Flip_Flop, FF1 => +"obs", FF2 => +"ops"), (Max => 0, Op => TC_Flip, FF3 => +"ol", FF4 => +"hol"), (Max => 1, Op => TC_Flip, FF3 => +"opp", FF4 => +"op"), (Max => 0, Op => TC_Flip, FF3 => +"or", FF4 => +"aur") ); P_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"ph", FF4 => +"f"), (Max => 1, Op => TC_Flip_Flop, FF1 => +"pre", FF2 => +"prae") ); -- From Oxford Latin Dictionary p.1835 "sub-" S_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip_Flop, FF1 => +"subsc", FF2 => +"susc"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"subsp", FF2 => +"susp"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"subc", FF2 => +"susc"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"succ", FF2 => +"susc"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"subt", FF2 => +"supt"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"subt", FF2 => +"sust") ); T_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Flip_Flop, FF1 => +"transv", FF2 => +"trav") ); U_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"ul", FF4 => +"hul"), (Max => 0, Op => TC_Flip, FF3 => +"uol", FF4 => +"vul") -- u is not v for this purpose ); Y_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Flip, FF3 => +"y", FF4 => +"i") ); Z_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Flip, FF3 => +"z", FF4 => +"di") ); function Get_Tricks_Table (C : Character) return TricksT is begin case C is when 'a' => return A_Tricks; when 'd' => return D_Tricks; when 'e' => return E_Tricks; when 'f' => return F_Tricks; when 'g' => return G_Tricks; when 'h' => return H_Tricks; when 'k' => return K_Tricks; when 'l' => return L_Tricks; when 'm' => return M_Tricks; when 'n' => return N_Tricks; when 'o' => return O_Tricks; when 'p' => return P_Tricks; when 's' => return S_Tricks; when 't' => return T_Tricks; when 'u' => return U_Tricks; when 'y' => return Y_Tricks; when 'z' => return Z_Tricks; when others => raise Tricks_Exception; end case; end Get_Tricks_Table; A_Slur_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip_Flop, FF1 => +"abs", FF2 => +"aps"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"acq", FF2 => +"adq"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"ante", FF2 => +"anti"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"auri", FF2 => +"aure"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"auri", FF2 => +"auru"), (Max => 0, Op => TC_Slur, S1 => +"ad") ); C_Slur_Tricks : constant TricksT := ( (Max => 0, Op => TC_Flip, FF3 => +"circum", FF4 => +"circun"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"con", FF2 => +"com"), (Max => 0, Op => TC_Flip, FF3 => +"co", FF4 => +"com"), (Max => 0, Op => TC_Flip, FF3 => +"co", FF4 => +"con"), (Max => 0, Op => TC_Flip_Flop, FF1 => +"conl", FF2 => +"coll") ); I_Slur_Tricks : constant TricksT := ( (Max => 1, Op => TC_Slur, S1 => +"in"), (Max => 1, Op => TC_Flip_Flop, FF1 => +"inb", FF2 => +"imb"), (Max => 1, Op => TC_Flip_Flop, FF1 => +"inp", FF2 => +"imp") -- for some forms of eo the stem "i" grates with -- an "is .. ." ending ); N_Slur_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Flip, FF3 => +"nun", FF4 => +"non") ); O_Slur_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Slur, S1 => +"ob") ); Q_Slur_Tricks : constant TricksT := (1 => (Max => 0, Op => TC_Flip_Flop, FF1 => +"quadri", FF2 => +"quadru") ); S_Slur_Tricks : constant TricksT := ( -- Latham, (Max => 0, Op => TC_Flip, FF3 => +"se", FF4 => +"ce"), -- From Oxford Latin Dictionary p.1835 "sub-" (Max => 0, Op => TC_Slur, S1 => +"sub") ); function Get_Slur_Tricks_Table (C : Character) return TricksT is begin case C is when 'a' => return A_Slur_Tricks; when 'c' => return C_Slur_Tricks; when 'i' => return I_Slur_Tricks; when 'n' => return N_Slur_Tricks; when 'o' => return O_Slur_Tricks; when 'q' => return Q_Slur_Tricks; when 's' => return S_Slur_Tricks; when others => raise Tricks_Exception; end case; end Get_Slur_Tricks_Table; end Words_Engine.Trick_Tables;
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE table compression routines -- AUTHOR: John Self (UCI) -- DESCRIPTION used for compressed tables only -- NOTES somewhat complicated but works fast and generates efficient scanners -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/tblcmpB.a,v 1.8 90/01/12 15:20:43 self Exp Locker: self $ with Ada.Unchecked_Deallocation; with DFA, ECS; with Unicode; package body TBLCMP is use Unicode; -- bldtbl - build table entries for dfa state -- -- synopsis -- int state[numecs], statenum, totaltrans, comstate, comfreq; -- bldtbl( state, statenum, totaltrans, comstate, comfreq ); -- -- State is the statenum'th dfa state. It is indexed by equivalence class and -- gives the number of the state to enter for a given equivalence class. -- totaltrans is the total number of transitions out of the state. Comstate -- is that state which is the destination of the most transitions out of State. -- Comfreq is how many transitions there are out of State to Comstate. -- -- A note on terminology: -- "protos" are transition tables which have a high probability of -- either being redundant (a state processed later will have an identical -- transition table) or nearly redundant (a state processed later will have -- many of the same out-transitions). A "most recently used" queue of -- protos is kept around with the hope that most states will find a proto -- which is similar enough to be usable, and therefore compacting the -- output tables. -- "templates" are a special type of proto. If a transition table is -- homogeneous or nearly homogeneous (all transitions go to the same -- destination) then the odds are good that future states will also go -- to the same destination state on basically the same character set. -- These homogeneous states are so common when dealing with large rule -- sets that they merit special attention. If the transition table were -- simply made into a proto, then (typically) each subsequent, similar -- state will differ from the proto for two out-transitions. One of these -- out-transitions will be that character on which the proto does not go -- to the common destination, and one will be that character on which the -- state does not go to the common destination. Templates, on the other -- hand, go to the common state on EVERY transition character, and therefore -- cost only one difference. procedure BLDTBL(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, TOTALTRANS, COMSTATE, COMFREQ : in INTEGER) is subtype CARRAY is UNBOUNDED_INT_ARRAY(0 .. CSIZE + 1); type CARRAY_Access is access all CARRAY; procedure Free is new Ada.Unchecked_Deallocation (CARRAY, CARRAY_Access); EXTPTR : INTEGER; EXTRCT : array(0 .. 1) of CARRAY_Access := (new CARRAY, new CARRAY); MINDIFF, MINPROT, I, D : INTEGER; CHECKCOM : BOOLEAN; LOCAL_COMSTATE : INTEGER; begin -- If extptr is 0 then the first array of extrct holds the result of the -- "best difference" to date, which is those transitions which occur in -- "state" but not in the proto which, to date, has the fewest differences -- between itself and "state". If extptr is 1 then the second array of -- extrct hold the best difference. The two arrays are toggled -- between so that the best difference to date can be kept around and -- also a difference just created by checking against a candidate "best" -- proto. LOCAL_COMSTATE := COMSTATE; EXTPTR := 0; -- if the state has too few out-transitions, don't bother trying to -- compact its tables if ((TOTALTRANS*100) < (NUMECS*PROTO_SIZE_PERCENTAGE)) then MKENTRY(STATE, NUMECS, STATENUM, JAMSTATE_CONST, TOTALTRANS); else -- checkcom is true if we should only check "state" against -- protos which have the same "comstate" value CHECKCOM := COMFREQ*100 > TOTALTRANS*CHECK_COM_PERCENTAGE; MINPROT := FIRSTPROT; MINDIFF := TOTALTRANS; if (CHECKCOM) then -- find first proto which has the same "comstate" I := FIRSTPROT; while (I /= NIL) loop if (PROTCOMST(I) = LOCAL_COMSTATE) then MINPROT := I; TBLDIFF(STATE, MINPROT, EXTRCT (EXTPTR).all, MINDIFF); exit; end if; I := PROTNEXT(I); end loop; else -- since we've decided that the most common destination out -- of "state" does not occur with a high enough frequency, -- we set the "comstate" to zero, assuring that if this state -- is entered into the proto list, it will not be considered -- a template. LOCAL_COMSTATE := 0; if (FIRSTPROT /= NIL) then MINPROT := FIRSTPROT; TBLDIFF(STATE, MINPROT, EXTRCT (EXTPTR).all, MINDIFF); end if; end if; -- we now have the first interesting proto in "minprot". If -- it matches within the tolerances set for the first proto, -- we don't want to bother scanning the rest of the proto list -- to see if we have any other reasonable matches. if (MINDIFF*100 > TOTALTRANS*FIRST_MATCH_DIFF_PERCENTAGE) then -- not a good enough match. Scan the rest of the protos I := MINPROT; while (I /= NIL) loop TBLDIFF(STATE, I, EXTRCT (1 - EXTPTR).all, D); if (D < MINDIFF) then EXTPTR := 1 - EXTPTR; MINDIFF := D; MINPROT := I; end if; I := PROTNEXT(I); end loop; end if; -- check if the proto we've decided on as our best bet is close -- enough to the state we want to match to be usable if (MINDIFF*100 > TOTALTRANS*ACCEPTABLE_DIFF_PERCENTAGE) then -- no good. If the state is homogeneous enough, we make a -- template out of it. Otherwise, we make a proto. if (COMFREQ*100 >= TOTALTRANS*TEMPLATE_SAME_PERCENTAGE) then MKTEMPLATE(STATE, STATENUM, LOCAL_COMSTATE); else MKPROT(STATE, STATENUM, LOCAL_COMSTATE); MKENTRY(STATE, NUMECS, STATENUM, JAMSTATE_CONST, TOTALTRANS); end if; else -- use the proto MKENTRY (EXTRCT (EXTPTR).all, NUMECS, STATENUM, PROTTBL (MINPROT), MINDIFF); -- if this state was sufficiently different from the proto -- we built it from, make it, too, a proto if (MINDIFF*100 >= TOTALTRANS*NEW_PROTO_DIFF_PERCENTAGE) then MKPROT(STATE, STATENUM, LOCAL_COMSTATE); end if; -- since mkprot added a new proto to the proto queue, it's possible -- that "minprot" is no longer on the proto queue (if it happened -- to have been the last entry, it would have been bumped off). -- If it's not there, then the new proto took its physical place -- (though logically the new proto is at the beginning of the -- queue), so in that case the following call will do nothing. MV2FRONT(MINPROT); end if; end if; for J in EXTRCT'Range loop Free (EXTRCT (J)); end loop; end BLDTBL; -- cmptmps - compress template table entries -- -- template tables are compressed by using the 'template equivalence -- classes', which are collections of transition character equivalence -- classes which always appear together in templates - really meta-equivalence -- classes. until this point, the tables for templates have been stored -- up at the top end of the nxt array; they will now be compressed and have -- table entries made for them. procedure CMPTMPS is TMPSTORAGE : C_Size_Array_Access := new C_Size_Array; TOTALTRANS, TRANS : INTEGER; begin PEAKPAIRS := NUMTEMPS*NUMECS + TBLEND; if (USEMECS) then -- create equivalence classes base on data gathered on template -- transitions ECS.CRE8ECS(TECFWD, TECBCK, NUMECS, NUMMECS); else NUMMECS := NUMECS; end if; if (LASTDFA + NUMTEMPS + 1 >= CURRENT_MAX_DFAS) then DFA.INCREASE_MAX_DFAS; end if; -- loop through each template for I in 1 .. NUMTEMPS loop TOTALTRANS := 0; -- number of non-jam transitions out of this template for J in 1 .. NUMECS loop TRANS := TNXT(NUMECS*I + J); if (USEMECS) then -- the absolute value of tecbck is the meta-equivalence class -- of a given equivalence class, as set up by cre8ecs if (TECBCK(J) > 0) then TMPSTORAGE(TECBCK(J)) := TRANS; if (TRANS > 0) then TOTALTRANS := TOTALTRANS + 1; end if; end if; else TMPSTORAGE(J) := TRANS; if (TRANS > 0) then TOTALTRANS := TOTALTRANS + 1; end if; end if; end loop; -- it is assumed (in a rather subtle way) in the skeleton that -- if we're using meta-equivalence classes, the def[] entry for -- all templates is the jam template, i.e., templates never default -- to other non-jam table entries (e.g., another template) -- leave room for the jam-state after the last real state MKENTRY (TMPSTORAGE.all, NUMMECS, LASTDFA + I + 1, JAMSTATE_CONST, TOTALTRANS); end loop; Free (TMPSTORAGE); end CMPTMPS; -- expand_nxt_chk - expand the next check arrays procedure EXPAND_NXT_CHK is OLD_MAX : constant INTEGER := CURRENT_MAX_XPAIRS; begin CURRENT_MAX_XPAIRS := CURRENT_MAX_XPAIRS + MAX_XPAIRS_INCREMENT; NUM_REALLOCS := NUM_REALLOCS + 1; REALLOCATE_INTEGER_ARRAY(NXT, CURRENT_MAX_XPAIRS); REALLOCATE_INTEGER_ARRAY(CHK, CURRENT_MAX_XPAIRS); for I in OLD_MAX .. CURRENT_MAX_XPAIRS loop CHK(I) := 0; end loop; end EXPAND_NXT_CHK; -- find_table_space - finds a space in the table for a state to be placed -- -- State is the state to be added to the full speed transition table. -- Numtrans is the number of out-transitions for the state. -- -- find_table_space() returns the position of the start of the first block (in -- chk) able to accommodate the state -- -- In determining if a state will or will not fit, find_table_space() must take -- into account the fact that an end-of-buffer state will be added at [0], -- and an action number will be added in [-1]. function FIND_TABLE_SPACE(STATE : in UNBOUNDED_INT_ARRAY; NUMTRANS : in INTEGER) return INTEGER is -- firstfree is the position of the first possible occurrence of two -- consecutive unused records in the chk and nxt arrays I : INTEGER; CNT, SCNT : INTEGER; -- if there are too many out-transitions, put the state at the end of -- nxt and chk begin if (NUMTRANS > MAX_XTIONS_FULL_INTERIOR_FIT) then -- if table is empty, return the first available spot in chk/nxt, -- which should be 1 if (TBLEND < 2) then return (1); end if; I := TBLEND - NUMECS; -- start searching for table space near the -- end of chk/nxt arrays else I := FIRSTFREE; -- start searching for table space from the -- beginning (skipping only the elements -- which will definitely not hold the new -- state) end if; loop -- loops until a space is found if (I + NUMECS > CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; -- loops until space for end-of-buffer and action number are found loop if (CHK(I - 1) = 0) then -- check for action number space if (CHK(I) = 0) then -- check for end-of-buffer space exit; else I := I + 2; -- since i != 0, there is no use checking to -- see if (++i) - 1 == 0, because that's the -- same as i == 0, so we skip a space end if; else I := I + 1; end if; if (I + NUMECS > CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; end loop; -- if we started search from the beginning, store the new firstfree for -- the next call of find_table_space() if (NUMTRANS <= MAX_XTIONS_FULL_INTERIOR_FIT) then FIRSTFREE := I + 1; end if; -- check to see if all elements in chk (and therefore nxt) that are -- needed for the new state have not yet been taken CNT := I + 1; SCNT := 1; while (CNT /= I + NUMECS + 1) loop if ((STATE(SCNT) /= 0) and (CHK(CNT) /= 0)) then exit; end if; SCNT := SCNT + 1; CNT := CNT + 1; end loop; if (CNT = I + NUMECS + 1) then return I; else I := I + 1; end if; end loop; end FIND_TABLE_SPACE; -- inittbl - initialize transition tables -- -- Initializes "firstfree" to be one beyond the end of the table. Initializes -- all "chk" entries to be zero. Note that templates are built in their -- own tbase/tdef tables. They are shifted down to be contiguous -- with the non-template entries during table generation. procedure INITTBL is begin for I in 0 .. CURRENT_MAX_XPAIRS loop CHK(I) := 0; end loop; TBLEND := 0; FIRSTFREE := TBLEND + 1; NUMTEMPS := 0; if (USEMECS) then -- set up doubly-linked meta-equivalence classes -- these are sets of equivalence classes which all have identical -- transitions out of TEMPLATES TECBCK(1) := NIL; for I in 2 .. NUMECS loop TECBCK(I) := I - 1; TECFWD(I - 1) := I; end loop; TECFWD(NUMECS) := NIL; end if; end INITTBL; -- mkdeftbl - make the default, "jam" table entries procedure MKDEFTBL is begin JAMSTATE := LASTDFA + 1; TBLEND := TBLEND + 1; -- room for transition on end-of-buffer character if (TBLEND + NUMECS > CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; -- add in default end-of-buffer transition NXT(TBLEND) := END_OF_BUFFER_STATE; CHK(TBLEND) := JAMSTATE; for I in 1 .. NUMECS loop NXT(TBLEND + I) := 0; CHK(TBLEND + I) := JAMSTATE; end loop; JAMBASE := TBLEND; BASE(JAMSTATE) := JAMBASE; DEF(JAMSTATE) := 0; TBLEND := TBLEND + NUMECS; NUMTEMPS := NUMTEMPS + 1; end MKDEFTBL; -- mkentry - create base/def and nxt/chk entries for transition array -- -- "state" is a transition array "numchars" characters in size, "statenum" -- is the offset to be used into the base/def tables, and "deflink" is the -- entry to put in the "def" table entry. If "deflink" is equal to -- "JAMSTATE", then no attempt will be made to fit zero entries of "state" -- (i.e., jam entries) into the table. It is assumed that by linking to -- "JAMSTATE" they will be taken care of. In any case, entries in "state" -- marking transitions to "SAME_TRANS" are treated as though they will be -- taken care of by whereever "deflink" points. "totaltrans" is the total -- number of transitions out of the state. If it is below a certain threshold, -- the tables are searched for an interior spot that will accommodate the -- state array. procedure MKENTRY(STATE : in UNBOUNDED_INT_ARRAY; NUMCHARS, STATENUM, DEFLINK, TOTALTRANS : in INTEGER) is I, MINEC, MAXEC, BASEADDR, TBLBASE, TBLLAST : INTEGER; begin if (TOTALTRANS = 0) then -- there are no out-transitions if (DEFLINK = JAMSTATE_CONST) then BASE(STATENUM) := JAMSTATE_CONST; else BASE(STATENUM) := 0; end if; DEF(STATENUM) := DEFLINK; return; end if; MINEC := 1; while (MINEC <= NUMCHARS) loop if (STATE(MINEC) /= SAME_TRANS) then if ((STATE(MINEC) /= 0) or (DEFLINK /= JAMSTATE_CONST)) then exit; end if; end if; MINEC := MINEC + 1; end loop; if (TOTALTRANS = 1) then -- there's only one out-transition. Save it for later to fill -- in holes in the tables. STACK1(STATENUM, MINEC, STATE(MINEC), DEFLINK); return; end if; MAXEC := NUMCHARS; while (MAXEC >= 1) loop if (STATE(MAXEC) /= SAME_TRANS) then if ((STATE(MAXEC) /= 0) or (DEFLINK /= JAMSTATE_CONST)) then exit; end if; end if; MAXEC := MAXEC - 1; end loop; -- Whether we try to fit the state table in the middle of the table -- entries we have already generated, or if we just take the state -- table at the end of the nxt/chk tables, we must make sure that we -- have a valid base address (i.e., non-negative). Note that not only are -- negative base addresses dangerous at run-time (because indexing the -- next array with one and a low-valued character might generate an -- array-out-of-bounds error message), but at compile-time negative -- base addresses denote TEMPLATES. -- find the first transition of state that we need to worry about. if (TOTALTRANS*100 <= NUMCHARS*INTERIOR_FIT_PERCENTAGE) then -- attempt to squeeze it into the middle of the tabls BASEADDR := FIRSTFREE; while (BASEADDR < MINEC) loop -- using baseaddr would result in a negative base address below -- find the next free slot BASEADDR := BASEADDR + 1; while (CHK(BASEADDR) /= 0) loop BASEADDR := BASEADDR + 1; end loop; end loop; if (BASEADDR + MAXEC - MINEC >= CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; I := MINEC; while (I <= MAXEC) loop if (STATE(I) /= SAME_TRANS) then if ((STATE(I) /= 0) or (DEFLINK /= JAMSTATE_CONST)) then if (CHK(BASEADDR + I - MINEC) /= 0) then -- baseaddr unsuitable - find another BASEADDR := BASEADDR + 1; while ((BASEADDR < CURRENT_MAX_XPAIRS) and (CHK(BASEADDR) /= 0)) loop BASEADDR := BASEADDR + 1; end loop; if (BASEADDR + MAXEC - MINEC >= CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; -- reset the loop counter so we'll start all -- over again next time it's incremented I := MINEC - 1; end if; end if; end if; I := I + 1; end loop; else -- ensure that the base address we eventually generate is -- non-negative BASEADDR := Integer'Max (TBLEND + 1, MINEC); end if; TBLBASE := BASEADDR - MINEC; TBLLAST := TBLBASE + MAXEC; if (TBLLAST >= CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; BASE(STATENUM) := TBLBASE; DEF(STATENUM) := DEFLINK; for J in MINEC .. MAXEC loop if (STATE(J) /= SAME_TRANS) then if ((STATE(J) /= 0) or (DEFLINK /= JAMSTATE_CONST)) then NXT(TBLBASE + J) := STATE(J); CHK(TBLBASE + J) := STATENUM; end if; end if; end loop; if (BASEADDR = FIRSTFREE) then -- find next free slot in tables FIRSTFREE := FIRSTFREE + 1; while (CHK(FIRSTFREE) /= 0) loop FIRSTFREE := FIRSTFREE + 1; end loop; end if; TBLEND := Integer'Max (TBLEND, TBLLAST); end MKENTRY; -- mk1tbl - create table entries for a state (or state fragment) which -- has only one out-transition procedure MK1TBL(STATE, SYM, ONENXT, ONEDEF : in INTEGER) is begin if (FIRSTFREE < SYM) then FIRSTFREE := SYM; end if; while (CHK(FIRSTFREE) /= 0) loop FIRSTFREE := FIRSTFREE + 1; if (FIRSTFREE >= CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; end loop; BASE(STATE) := FIRSTFREE - SYM; DEF(STATE) := ONEDEF; CHK(FIRSTFREE) := STATE; NXT(FIRSTFREE) := ONENXT; if (FIRSTFREE > TBLEND) then TBLEND := FIRSTFREE; FIRSTFREE := FIRSTFREE + 1; if (FIRSTFREE >= CURRENT_MAX_XPAIRS) then EXPAND_NXT_CHK; end if; end if; end MK1TBL; -- mkprot - create new proto entry procedure MKPROT(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, COMSTATE : in INTEGER) is SLOT, TBLBASE : INTEGER; begin NUMPROTS := NUMPROTS + 1; if ((NUMPROTS >= MSP) or (NUMECS*NUMPROTS >= PROT_SAVE_SIZE)) then -- gotta make room for the new proto by dropping last entry in -- the queue SLOT := LASTPROT; LASTPROT := PROTPREV(LASTPROT); PROTNEXT(LASTPROT) := NIL; else SLOT := NUMPROTS; end if; PROTNEXT(SLOT) := FIRSTPROT; if (FIRSTPROT /= NIL) then PROTPREV(FIRSTPROT) := SLOT; end if; FIRSTPROT := SLOT; PROTTBL(SLOT) := STATENUM; PROTCOMST(SLOT) := COMSTATE; -- copy state into save area so it can be compared with rapidly TBLBASE := NUMECS*(SLOT - 1); for I in 1 .. NUMECS loop PROTSAVE(TBLBASE + I) := STATE(I + STATE'FIRST); end loop; end MKPROT; -- mktemplate - create a template entry based on a state, and connect the state -- to it procedure MKTEMPLATE(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, COMSTATE : in INTEGER) is subtype TARRAY is Unicode_Character_Array (0 .. CSIZE); type TARRAY_Access is access all TARRAY; procedure Free is new Ada.Unchecked_Deallocation (TARRAY, TARRAY_Access); NUMDIFF, TMPBASE : INTEGER; TMP : C_Size_Array_Access := new C_Size_Array; TRANSSET : TARRAY_Access := new TARRAY; TSPTR : INTEGER; begin NUMTEMPS := NUMTEMPS + 1; TSPTR := 0; -- calculate where we will temporarily store the transition table -- of the template in the tnxt[] array. The final transition table -- gets created by cmptmps() TMPBASE := NUMTEMPS*NUMECS; if (TMPBASE + NUMECS >= CURRENT_MAX_TEMPLATE_XPAIRS) then CURRENT_MAX_TEMPLATE_XPAIRS := CURRENT_MAX_TEMPLATE_XPAIRS + MAX_TEMPLATE_XPAIRS_INCREMENT; NUM_REALLOCS := NUM_REALLOCS + 1; REALLOCATE_INTEGER_ARRAY(TNXT, CURRENT_MAX_TEMPLATE_XPAIRS); end if; for I in 1 .. NUMECS loop if (STATE(I) = 0) then TNXT(TMPBASE + I) := 0; else TRANSSET(TSPTR) := Unicode_Character'Val (I); TSPTR := TSPTR + 1; TNXT(TMPBASE + I) := COMSTATE; end if; end loop; if (USEMECS) then ECS.MKECCL (TRANSSET.all, TSPTR, TECFWD, TECBCK, NUMECS); end if; MKPROT(TNXT(TMPBASE .. CURRENT_MAX_TEMPLATE_XPAIRS), -NUMTEMPS, COMSTATE); -- we rely on the fact that mkprot adds things to the beginning -- of the proto queue TBLDIFF(STATE, FIRSTPROT, TMP.all, NUMDIFF); MKENTRY(TMP.all, NUMECS, STATENUM, -NUMTEMPS, NUMDIFF); Free (TMP); Free (TRANSSET); end MKTEMPLATE; -- mv2front - move proto queue element to front of queue procedure MV2FRONT(QELM : in INTEGER) is begin if (FIRSTPROT /= QELM) then if (QELM = LASTPROT) then LASTPROT := PROTPREV(LASTPROT); end if; PROTNEXT(PROTPREV(QELM)) := PROTNEXT(QELM); if (PROTNEXT(QELM) /= NIL) then PROTPREV(PROTNEXT(QELM)) := PROTPREV(QELM); end if; PROTPREV(QELM) := NIL; PROTNEXT(QELM) := FIRSTPROT; PROTPREV(FIRSTPROT) := QELM; FIRSTPROT := QELM; end if; end MV2FRONT; -- place_state - place a state into full speed transition table -- -- State is the statenum'th state. It is indexed by equivalence class and -- gives the number of the state to enter for a given equivalence class. -- Transnum is the number of out-transitions for the state. procedure PLACE_STATE(STATE : in UNBOUNDED_INT_ARRAY; STATENUM, TRANSNUM : in INTEGER) is I : INTEGER; POSITION : constant INTEGER := FIND_TABLE_SPACE(STATE, TRANSNUM); begin -- base is the table of start positions BASE(STATENUM) := POSITION; -- put in action number marker; this non-zero number makes sure that -- find_table_space() knows that this position in chk/nxt is taken -- and should not be used for another accepting number in another state CHK(POSITION - 1) := 1; -- put in end-of-buffer marker; this is for the same purposes as above CHK(POSITION) := 1; -- place the state into chk and nxt I := 1; while (I <= NUMECS) loop if (STATE(I) /= 0) then CHK(POSITION + I) := I; NXT(POSITION + I) := STATE(I); end if; I := I + 1; end loop; if (POSITION + NUMECS > TBLEND) then TBLEND := POSITION + NUMECS; end if; end PLACE_STATE; -- stack1 - save states with only one out-transition to be processed later -- -- if there's room for another state one the "one-transition" stack, the -- state is pushed onto it, to be processed later by mk1tbl. If there's -- no room, we process the sucker right now. procedure STACK1(STATENUM, SYM, NEXTSTATE, DEFLINK : in INTEGER) is begin if (ONESP >= ONE_STACK_SIZE - 1) then MK1TBL(STATENUM, SYM, NEXTSTATE, DEFLINK); else ONESP := ONESP + 1; ONESTATE(ONESP) := STATENUM; ONESYM(ONESP) := SYM; ONENEXT(ONESP) := NEXTSTATE; ONEDEF(ONESP) := DEFLINK; end if; end STACK1; -- tbldiff - compute differences between two state tables -- -- "state" is the state array which is to be extracted from the pr'th -- proto. "pr" is both the number of the proto we are extracting from -- and an index into the save area where we can find the proto's complete -- state table. Each entry in "state" which differs from the corresponding -- entry of "pr" will appear in "ext". -- Entries which are the same in both "state" and "pr" will be marked -- as transitions to "SAME_TRANS" in "ext". The total number of differences -- between "state" and "pr" is returned as function value. Note that this -- number is "numecs" minus the number of "SAME_TRANS" entries in "ext". procedure TBLDIFF(STATE : in UNBOUNDED_INT_ARRAY; PR : in INTEGER; EXT : out UNBOUNDED_INT_ARRAY; RESULT : out INTEGER) is SP : INTEGER := 0; EP : INTEGER := 0; NUMDIFF : INTEGER := 0; PROTP : INTEGER; begin PROTP := NUMECS*(PR - 1); for I in reverse 1 .. NUMECS loop PROTP := PROTP + 1; SP := SP + 1; if (PROTSAVE(PROTP) = STATE(SP)) then EP := EP + 1; EXT(EP) := SAME_TRANS; else EP := EP + 1; EXT(EP) := STATE(SP); NUMDIFF := NUMDIFF + 1; end if; end loop; RESULT := NUMDIFF; return; end TBLDIFF; end TBLCMP;
pragma Style_Checks (Off); with Lv.Style; with System; with Lv.Objx.Label; with Lv.Objx.Page; with Lv.Objx.Btn; package Lv.Objx.List is subtype Instance is Obj_T; type Style_T is (Style_Bg, Style_Scrl, Style_Sb, Style_Btn_Rel, Style_Btn_Pr, Style_Btn_Tgl_Rel, Style_Btn_Tgl_Pr, Style_Btn_Ina); -- Create a list objects -- @param par pointer to an object, it will be the parent of the new list -- @param copy pointer to a list object, if not NULL then the new object will be copied from it -- @return pointer to the created list function Create (Par : Obj_T; Copy : Instance) return Instance; -- Delete all children of the scrl object, without deleting scrl child. -- @param obj pointer to an object procedure Clean (Self : Instance); -- Add a list element to the list -- @param self pointer to list object -- @param img_fn file name of an image before the text (NULL if unused) -- @param txt text of the list element (NULL if unused) -- @param rel_action pointer to release action function (like with lv_btn) -- @return pointer to the new list element which can be customized (a button) function Add (Self : Instance; Img_Gn : System.Address; Txt : C_String_Ptr; Rel_Action : Action_Func_T) return Btn.Instance; ---------------------- -- Setter functions -- ---------------------- -- Make a button selected -- @param self pointer to a list object -- @param btn pointer to a button to select procedure Set_Btn_Selected (Self : Instance; Btn : Obj_T); -- Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()' -- @param self pointer to a list object -- @param anim_time duration of animation [ms] procedure Set_Anim_Time (Self : Instance; Anim_Time : Uint16_T); -- Set the scroll bar mode of a list -- @param self pointer to a list object -- @param sb_mode the new mode from 'lv_page_sb_mode_t' enum procedure Set_Sb_Mode (Self : Instance; Mode : Lv.Objx.Page.Mode_T); -- Set a style of a list -- @param self pointer to a list object -- @param type which style should be set -- @param style pointer to a style procedure Set_Style (Self : Instance; Type_P : Style_T; Style : Lv.Style.Style); ---------------------- -- Getter functions -- ---------------------- -- Get the text of a list element -- @param btn pointer to list element -- @return pointer to the text function Btn_Text (Self : Instance) return C_String_Ptr; -- Get the label object from a list element -- @param self pointer to a list element (button) -- @return pointer to the label from the list element or NULL if not found function Btn_Label (Self : Instance) return Label.Instance; -- Get the image object from a list element -- @param self pointer to a list element (button) -- @return pointer to the image from the list element or NULL if not found function Btn_Img (Self : Instance) return Obj_T; -- Get the next button from list. (Starts from the bottom button) -- @param self pointer to a list object -- @param prev_btn pointer to button. Search the next after it. -- @return pointer to the next button or NULL when no more buttons function Prev_Btn (Self : Instance; Prev : Obj_T) return Obj_T; -- Get the previous button from list. (Starts from the top button) -- @param self pointer to a list object -- @param prev_btn pointer to button. Search the previous before it. -- @return pointer to the previous button or NULL when no more buttons function Next_Btn (Self : Instance; Next : Obj_T) return Obj_T; -- Get the currently selected button -- @param self pointer to a list object -- @return pointer to the selected button function Btn_Selected (Self : Instance) return Obj_T; -- Get scroll animation duration -- @param self pointer to a list object -- @return duration of animation [ms] function Anim_Time (Self : Instance) return Uint16_T; -- Get the scroll bar mode of a list -- @param self pointer to a list object -- @return scrollbar mode from 'lv_page_sb_mode_t' enum function Sb_Mode (Self : Instance) return Lv.Objx.Page.Mode_T; -- Get a style of a list -- @param self pointer to a list object -- @param type which style should be get -- @return style pointer to a style function Style (Self : Instance; Type_P : Style_T) return Lv.Style.Style; -- Other functions -- Move the list elements up by one -- @param self pointer a to list object procedure Up (Self : Instance); -- Move the list elements down by one -- @param self pointer to a list object procedure Down (Self : Instance); -- Focus on a list button. It ensures that the button will be visible on the list. -- @param self pointer to a list button to focus -- @param anim_en true: scroll with animation, false: without animation procedure Focus (Self : Instance; Anim_En : U_Bool); ------------- -- Imports -- ------------- pragma Import (C, Create, "lv_list_create"); pragma Import (C, Clean, "lv_list_clean"); pragma Import (C, Add, "lv_list_add"); pragma Import (C, Set_Btn_Selected, "lv_list_set_btn_selected"); pragma Import (C, Set_Anim_Time, "lv_list_set_anim_time"); pragma Import (C, Set_Sb_Mode, "lv_list_set_sb_mode_inline"); pragma Import (C, Set_Style, "lv_list_set_style"); pragma Import (C, Btn_Text, "lv_list_get_btn_text"); pragma Import (C, Btn_Label, "lv_list_get_btn_label"); pragma Import (C, Btn_Img, "lv_list_get_btn_img"); pragma Import (C, Prev_Btn, "lv_list_get_prev_btn"); pragma Import (C, Next_Btn, "lv_list_get_next_btn"); pragma Import (C, Btn_Selected, "lv_list_get_btn_selected"); pragma Import (C, Anim_Time, "lv_list_get_anim_time"); pragma Import (C, Sb_Mode, "lv_list_get_sb_mode_inline"); pragma Import (C, Style, "lv_list_get_style"); pragma Import (C, Up, "lv_list_up"); pragma Import (C, Down, "lv_list_down"); pragma Import (C, Focus, "lv_list_focus"); for Style_T'Size use 8; for Style_T use (Style_Bg => 0, Style_Scrl => 1, Style_Sb => 2, Style_Btn_Rel => 3, Style_Btn_Pr => 4, Style_Btn_Tgl_Rel => 5, Style_Btn_Tgl_Pr => 6, Style_Btn_Ina => 7); end Lv.Objx.List;
pragma License (Unrestricted); -- extended unit pragma Style_Checks (Off, Standard.Ascii); -- package ASCII is "ASCII" in standard, but "Ascii" in GNAT style... package Ada.Characters.ASCII is -- Alternative version of Standard.ASCII. pragma Pure; NUL : Character renames Standard.ASCII.NUL; end Ada.Characters.ASCII;
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Ada_Pretty.Clauses is -------------- -- Document -- -------------- overriding function Document (Self : Aspect; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.Append (Self.Name.Document (Printer, Pad)); if Self.Value /= null then declare Value : League.Pretty_Printers.Document := Printer.New_Document; begin Value.New_Line; Value.Append (Self.Value.Document (Printer, 0).Group); Value.Nest (2); Value.Group; Result.Put (" =>"); Result.Append (Value); end; end if; return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Pragma_Node; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("pragma "); Result.Append (Self.Name.Document (Printer, 0)); if Self.Arguments /= null then Result.Put (" ("); Result.Append (Self.Arguments.Document (Printer, Pad)); Result.Put (")"); end if; Result.Put (";"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : Use_Clause; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; Result.Put ("use "); if Self.Use_Type then Result.Put ("type "); end if; Result.Append (Self.Name.Document (Printer, Pad)); Result.Put (";"); return Result; end Document; -------------- -- Document -- -------------- overriding function Document (Self : With_Clause; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.New_Line; if Self.Is_Limited then Result.Put ("limited "); end if; if Self.Is_Private then Result.Put ("private "); end if; Result.Put ("with "); Result.Append (Self.Name.Document (Printer, Pad)); Result.Put (";"); return Result; end Document; ---------- -- Join -- ---------- overriding function Join (Self : Aspect; List : Node_Access_Array; Pad : Natural; Printer : not null access League.Pretty_Printers.Printer'Class) return League.Pretty_Printers.Document is Result : League.Pretty_Printers.Document := Printer.New_Document; begin Result.Append (Self.Document (Printer, Pad)); for J in List'Range loop Result.Put (","); Result.New_Line; Result.Put (" "); Result.Append (List (J).Document (Printer, Pad)); end loop; return Result; end Join; ---------------- -- New_Aspect -- ---------------- function New_Aspect (Name : not null Node_Access; Value : Node_Access) return Node'Class is begin return Aspect'(Name, Value); end New_Aspect; ---------------- -- New_Pragma -- ---------------- function New_Pragma (Name : not null Node_Access; Arguments : Node_Access) return Node'Class is begin return Pragma_Node'(Name, Arguments); end New_Pragma; ------------- -- New_Use -- ------------- function New_Use (Name : not null Node_Access; Use_Type : Boolean) return Node'Class is begin return Use_Clause'(Name, Use_Type); end New_Use; -------------- -- New_With -- -------------- function New_With (Name : not null Node_Access; Is_Limited : Boolean; Is_Private : Boolean) return Node'Class is begin return With_Clause'(Name, Is_Limited, Is_Private); end New_With; end Ada_Pretty.Clauses;
limited with Actors, Engines; package Components.AIs is type AI is abstract tagged null record; procedure update(self : in out AI; owner : in out Actors.Actor; engine : in out Engines.Engine) is abstract; type Player_AI is new AI with private; overriding procedure update(self : in out Player_AI; owner : in out Actors.Actor; engine : in out Engines.Engine); type Monster_AI is new AI with private; overriding procedure update(self : in out Monster_AI; owner : in out Actors.Actor; engine : in out Engines.Engine); private Turns_To_Track : constant := 3; type Player_AI is new AI with null record; type Monster_AI is new AI with record move_count : Natural := Turns_To_Track; end record; end Components.AIs;
-- { dg-do compile } with System; package body Bit_Packed_Array5 is function Inv (Word : Word_Type) return Word_Type is W : Word_Type := Word; pragma Volatile (W); A_W : constant System.Address := W'Address; V : Short_Bit_Array_Type; for V'Address use A_W; pragma Volatile (V); begin for I in V'Range loop V (I) := not V (I); end loop; return W; end; end Bit_Packed_Array5;
type Float_Luminance is new Float; type Float_Pixel is record R, G, B : Float_Luminance := 0.0; end record; function "*" (Left : Float_Pixel; Right : Float_Luminance) return Float_Pixel is pragma Inline ("*"); begin return (Left.R * Right, Left.G * Right, Left.B * Right); end "*"; function "+" (Left, Right : Float_Pixel) return Float_Pixel is pragma Inline ("+"); begin return (Left.R + Right.R, Left.G + Right.G, Left.B + Right.B); end "+"; function To_Luminance (X : Float_Luminance) return Luminance is pragma Inline (To_Luminance); begin if X <= 0.0 then return 0; elsif X >= 255.0 then return 255; else return Luminance (X); end if; end To_Luminance; function To_Pixel (X : Float_Pixel) return Pixel is pragma Inline (To_Pixel); begin return (To_Luminance (X.R), To_Luminance (X.G), To_Luminance (X.B)); end To_Pixel;
package body Memory.Prefetch is function Create_Prefetch(mem : access Memory_Type'Class; stride : Address_Type := 1) return Prefetch_Pointer is result : constant Prefetch_Pointer := new Prefetch_Type; begin result.stride := stride; Set_Memory(result.all, mem); return result; end Create_Prefetch; function Random_Prefetch(next : access Memory_Type'Class; generator : Distribution_Type; max_cost : Cost_Type) return Memory_Pointer is result : Prefetch_Pointer := new Prefetch_Type; wsize : constant Positive := Get_Word_Size(next.all); begin Set_Memory(result.all, next); if Get_Cost(result.all) > max_cost then Set_Memory(result.all, null); Destroy(Memory_Pointer(result)); return Memory_Pointer(next); end if; result.stride := Address_Type(Random(generator) mod 3) - 1; result.stride := result.stride * Address_Type(wsize); return Memory_Pointer(result); end Random_Prefetch; function Clone(mem : Prefetch_Type) return Memory_Pointer is result : constant Prefetch_Pointer := new Prefetch_Type'(mem); begin return Memory_Pointer(result); end Clone; procedure Permute(mem : in out Prefetch_Type; generator : in Distribution_Type; max_cost : in Cost_Type) is wsize : constant Positive := Get_Word_Size(mem); begin if (Random(generator) mod 2) = 0 then mem.stride := mem.stride + Address_Type(wsize); else mem.stride := mem.stride - Address_Type(wsize); end if; end Permute; procedure Reset(mem : in out Prefetch_Type; context : in Natural) is begin Reset(Container_Type(mem), context); mem.pending := 0; end Reset; procedure Read(mem : in out Prefetch_Type; address : in Address_Type; size : in Positive) is begin -- Add any time left from the last prefetch. Advance(mem, mem.pending); mem.pending := 0; -- Fetch the requested address. Read(Container_Type(mem), address, size); -- Prefetch the next address and save the time needed for the fetch. if mem.stride /= 0 and then address mod mem.stride = 0 then declare asize : constant Address_Type := Address_Type(size) + mem.stride; ssize : constant Address_Type := (asize - 1) / mem.stride; next : constant Address_Type := address + mem.stride * ssize; begin Start(mem); Do_Read(mem, next, 1); Commit(mem, mem.pending); end; end if; end Read; procedure Write(mem : in out Prefetch_Type; address : in Address_Type; size : in Positive) is begin -- Add any time left from the last prefetch. Advance(mem, mem.pending); mem.pending := 0; -- Write the requested address. Write(Container_Type(mem), address, size); end Write; procedure Idle(mem : in out Prefetch_Type; cycles : in Time_Type) is begin if cycles >= mem.pending then mem.pending := 0; else mem.pending := mem.pending - cycles; end if; Idle(Container_Type(mem), cycles); end Idle; function Get_Time(mem : Prefetch_Type) return Time_Type is begin return Get_Time(Container_Type(mem)) + mem.pending; end Get_Time; function To_String(mem : Prefetch_Type) return Unbounded_String is result : Unbounded_String; begin Append(result, "(prefetch "); Append(result, "(stride "); if (mem.stride and 2 ** 63) /= 0 then Append(result, "-" & To_String(-mem.stride)); else Append(result, To_String(mem.stride)); end if; Append(result, ")"); Append(result, "(memory "); Append(result, To_String(Container_Type(mem))); Append(result, ")"); Append(result, ")"); return result; end To_String; function Get_Cost(mem : Prefetch_Type) return Cost_Type is begin return Get_Cost(Container_Type(mem)); end Get_Cost; procedure Generate(mem : in Prefetch_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is wsize : constant Natural := Get_Word_Size(mem); word_bits : constant Natural := 8 * wsize; other : constant Memory_Pointer := Get_Memory(mem); name : constant String := "m" & To_String(Get_ID(mem)); oname : constant String := "m" & To_String(Get_ID(other.all)); stride : constant Address_Type := mem.stride; begin Generate(other.all, sigs, code); Declare_Signals(sigs, name, word_bits); Line(code, name & "_inst : entity work.prefetch"); Line(code, " generic map ("); Line(code, " ADDR_WIDTH => ADDR_WIDTH,"); Line(code, " WORD_WIDTH => " & To_String(word_bits) & ","); if (stride and 2 ** 63) /= 0 then Line(code, " STRIDE => -" & To_String((-stride) / Address_Type(wsize))); else Line(code, " STRIDE => " & To_String(stride / Address_Type(wsize))); end if; Line(code, " )"); Line(code, " port map ("); Line(code, " clk => clk,"); Line(code, " rst => rst,"); Line(code, " addr => " & name & "_addr,"); Line(code, " din => " & name & "_din,"); Line(code, " dout => " & name & "_dout,"); Line(code, " re => " & name & "_re,"); Line(code, " we => " & name & "_we,"); Line(code, " mask => " & name & "_mask,"); Line(code, " ready => " & name & "_ready,"); Line(code, " maddr => " & oname & "_addr,"); Line(code, " min => " & oname & "_dout,"); Line(code, " mout => " & oname & "_din,"); Line(code, " mre => " & oname & "_re,"); Line(code, " mwe => " & oname & "_we,"); Line(code, " mmask => " & oname & "_mask,"); Line(code, " mready => " & oname & "_ready"); Line(code, " );"); end Generate; end Memory.Prefetch;
-- Lumen.Binary.IO -- Read and write streams of binary data from external -- files. -- -- Chip Richards, NiEstu, Phoenix AZ, Summer 2010 -- This code is covered by the ISC License: -- -- Copyright © 2010, NiEstu -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- The software is provided "as is" and the author disclaims all warranties -- with regard to this software including all implied warranties of -- merchantability and fitness. In no event shall the author be liable for any -- special, direct, indirect, or consequential damages or any damages -- whatsoever resulting from loss of use, data or profits, whether in an -- action of contract, negligence or other tortious action, arising out of or -- in connection with the use or performance of this software. -- Environment with Ada.Streams.Stream_IO; package Lumen.Binary.IO is -- Our interpretation of the various file exceptions Access_Failed : exception; Malformed_Name : exception; Nonexistent_File : exception; Read_Error : exception; Unknown_Error : exception; Unreadable_File : exception; Unwriteable_File : exception; Write_Error : exception; -- Our version of the Stream_IO file type subtype File_Type is Ada.Streams.Stream_IO.File_Type; -- Open a file for reading procedure Open (File : in out File_Type; Pathname : in String); -- Create a file for writing procedure Create (File : in out File_Type; Pathname : in String); -- Close open file procedure Close (File : in out File_Type); -- Read and return a stream of bytes up to the given length function Read (File : File_Type; Length : Positive) return Byte_String; -- Read and return a stream of bytes up to the length of the given buffer procedure Read (File : in File_Type; Item : out Byte_String; Last : out Natural); -- Read and return a stream of shorts up to the given length function Read (File : File_Type; Length : Positive) return Short_String; -- Read and return a stream of shorts up to the length of the given buffer procedure Read (File : in File_Type; Item : out Short_String; Last : out Natural); -- Read and return a stream of words up to the given length function Read (File : File_Type; Length : Positive) return Word_String; -- Read and return a stream of words up to the length of the given buffer procedure Read (File : in File_Type; Item : out Word_String; Last : out Natural); -- Write a stream of bytes procedure Write (File : in File_Type; Item : in Byte_String); end Lumen.Binary.IO;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C A L E N D A R . F O R M A T T I N G -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2008, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- This package provides additional components to Time, as well as new -- Time_Of and Split routines which handle time zones and leap seconds. -- This package is defined in the Ada 2005 RM (9.6.1). with Ada.Calendar.Time_Zones; package Ada.Calendar.Formatting is -- Day of the week type Day_Name is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); function Day_Of_Week (Date : Time) return Day_Name; -- Hours:Minutes:Seconds access subtype Hour_Number is Natural range 0 .. 23; subtype Minute_Number is Natural range 0 .. 59; subtype Second_Number is Natural range 0 .. 59; subtype Second_Duration is Day_Duration range 0.0 .. 1.0; function Year (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0) return Year_Number; function Month (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0) return Month_Number; function Day (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0) return Day_Number; function Hour (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0) return Hour_Number; function Minute (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0) return Minute_Number; function Second (Date : Time) return Second_Number; function Sub_Second (Date : Time) return Second_Duration; function Seconds_Of (Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number := 0; Sub_Second : Second_Duration := 0.0) return Day_Duration; -- Returns a Day_Duration value for the combination of the given Hour, -- Minute, Second, and Sub_Second. This value can be used in Ada.Calendar. -- Time_Of as well as the argument to Calendar."+" and Calendar."–". If -- Seconds_Of is called with a Sub_Second value of 1.0, the value returned -- is equal to the value of Seconds_Of for the next second with a Sub_ -- Second value of 0.0. procedure Split (Seconds : Day_Duration; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Sub_Second : out Second_Duration); -- Splits Seconds into Hour, Minute, Second and Sub_Second in such a way -- that the resulting values all belong to their respective subtypes. The -- value returned in the Sub_Second parameter is always less than 1.0. procedure Split (Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Sub_Second : out Second_Duration; Time_Zone : Time_Zones.Time_Offset := 0); -- Splits Date into its constituent parts (Year, Month, Day, Hour, Minute, -- Second, Sub_Second), relative to the specified time zone offset. The -- value returned in the Sub_Second parameter is always less than 1.0. function Time_Of (Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Sub_Second : Second_Duration := 0.0; Leap_Second : Boolean := False; Time_Zone : Time_Zones.Time_Offset := 0) return Time; -- If Leap_Second is False, returns a Time built from the date and time -- values, relative to the specified time zone offset. If Leap_Second is -- True, returns the Time that represents the time within the leap second -- that is one second later than the time specified by the parameters. -- Time_Error is raised if the parameters do not form a proper date or -- time. If Time_Of is called with a Sub_Second value of 1.0, the value -- returned is equal to the value of Time_Of for the next second with a -- Sub_Second value of 0.0. function Time_Of (Year : Year_Number; Month : Month_Number; Day : Day_Number; Seconds : Day_Duration := 0.0; Leap_Second : Boolean := False; Time_Zone : Time_Zones.Time_Offset := 0) return Time; -- If Leap_Second is False, returns a Time built from the date and time -- values, relative to the specified time zone offset. If Leap_Second is -- True, returns the Time that represents the time within the leap second -- that is one second later than the time specified by the parameters. -- Time_Error is raised if the parameters do not form a proper date or -- time. If Time_Of is called with a Seconds value of 86_400.0, the value -- returned is equal to the value of Time_Of for the next day with a -- Seconds value of 0.0. procedure Split (Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Sub_Second : out Second_Duration; Leap_Second : out Boolean; Time_Zone : Time_Zones.Time_Offset := 0); -- If Date does not represent a time within a leap second, splits Date -- into its constituent parts (Year, Month, Day, Hour, Minute, Second, -- Sub_Second), relative to the specified time zone offset, and sets -- Leap_Second to False. If Date represents a time within a leap second, -- set the constituent parts to values corresponding to a time one second -- earlier than that given by Date, relative to the specified time zone -- offset, and sets Leap_Seconds to True. The value returned in the -- Sub_Second parameter is always less than 1.0. procedure Split (Date : Time; Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Seconds : out Day_Duration; Leap_Second : out Boolean; Time_Zone : Time_Zones.Time_Offset := 0); -- If Date does not represent a time within a leap second, splits Date -- into its constituent parts (Year, Month, Day, Seconds), relative to the -- specified time zone offset, and sets Leap_Second to False. If Date -- represents a time within a leap second, set the constituent parts to -- values corresponding to a time one second earlier than that given by -- Date, relative to the specified time zone offset, and sets Leap_Seconds -- to True. The value returned in the Seconds parameter is always less -- than 86_400.0. -- Simple image and value function Image (Date : Time; Include_Time_Fraction : Boolean := False; Time_Zone : Time_Zones.Time_Offset := 0) return String; -- Returns a string form of the Date relative to the given Time_Zone. The -- format is "Year-Month-Day Hour:Minute:Second", where the Year is a -- 4-digit value, and all others are 2-digit values, of the functions -- defined in Ada.Calendar and Ada.Calendar.Formatting, including a -- leading zero, if needed. The separators between the values are a minus, -- another minus, a colon, and a single space between the Day and Hour. If -- Include_Time_Fraction is True, the integer part of Sub_Seconds*100 is -- suffixed to the string as a point followed by a 2-digit value. function Value (Date : String; Time_Zone : Time_Zones.Time_Offset := 0) return Time; -- Returns a Time value for the image given as Date, relative to the given -- time zone. Constraint_Error is raised if the string is not formatted as -- described for Image, or the function cannot interpret the given string -- as a Time value. function Image (Elapsed_Time : Duration; Include_Time_Fraction : Boolean := False) return String; -- Returns a string form of the Elapsed_Time. The format is "Hour:Minute: -- Second", where all values are 2-digit values, including a leading zero, -- if needed. The separators between the values are colons. If Include_ -- Time_Fraction is True, the integer part of Sub_Seconds*100 is suffixed -- to the string as a point followed by a 2-digit value. If Elapsed_Time < -- 0.0, the result is Image (abs Elapsed_Time, Include_Time_Fraction) -- prefixed with a minus sign. If abs Elapsed_Time represents 100 hours or -- more, the result is implementation-defined. function Value (Elapsed_Time : String) return Duration; -- Returns a Duration value for the image given as Elapsed_Time. -- Constraint_Error is raised if the string is not formatted as described -- for Image, or the function cannot interpret the given string as a -- Duration value. end Ada.Calendar.Formatting;
with Sax.Readers; with Input_Sources.Strings; with Unicode.CES.Utf8; with My_Reader; procedure Extract_Students is Sample_String : String := "<Students>" & "<Student Name=""April"" Gender=""F"" DateOfBirth=""1989-01-02"" />" & "<Student Name=""Bob"" Gender=""M"" DateOfBirth=""1990-03-04"" />" & "<Student Name=""Chad"" Gender=""M"" DateOfBirth=""1991-05-06"" />" & "<Student Name=""Dave"" Gender=""M"" DateOfBirth=""1992-07-08"">" & "<Pet Type=""dog"" Name=""Rover"" />" & "</Student>" & "<Student DateOfBirth=""1993-09-10"" Gender=""F"" Name=""&#x00C9;mily"" />" & "</Students>"; Reader : My_Reader.Reader; Input : Input_Sources.Strings.String_Input; begin Input_Sources.Strings.Open (Sample_String, Unicode.CES.Utf8.Utf8_Encoding, Input); My_Reader.Parse (Reader, Input); Input_Sources.Strings.Close (Input); end Extract_Students;
----------------------------------------------------------------------- -- ado-sessions-factory -- Session Factory -- Copyright (C) 2009, 2010, 2011, 2012, 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 ADO.Sequences.Hilo; with ADO.Schemas.Entities; with ADO.Queries.Loaders; package body ADO.Sessions.Factory is -- ------------------------------ -- Get a read-only session from the factory. -- ------------------------------ function Get_Session (Factory : in Session_Factory) return Session is R : Session; S : constant Session_Record_Access := new Session_Record; begin R.Impl := S; S.Entities := Factory.Entities; S.Values := Factory.Cache_Values; S.Queries := Factory.Queries'Unrestricted_Access; Factory.Source.Create_Connection (S.Database); return R; end Get_Session; -- ------------------------------ -- Get a read-only session from the session proxy. -- If the session has been invalidated, raise the Session_Error exception. -- ------------------------------ function Get_Session (Proxy : in Session_Record_Access) return Session is R : Session; begin if Proxy = null then raise Session_Error; end if; R.Impl := Proxy; Util.Concurrent.Counters.Increment (R.Impl.Counter); return R; end Get_Session; -- ------------------------------ -- Get a read-write session from the factory. -- ------------------------------ function Get_Master_Session (Factory : in Session_Factory) return Master_Session is R : Master_Session; S : constant Session_Record_Access := new Session_Record; begin R.Impl := S; R.Sequences := Factory.Sequences; R.Audit := Factory.Audit; S.Entities := Factory.Entities; S.Values := Factory.Cache_Values; S.Queries := Factory.Queries'Unrestricted_Access; Factory.Source.Create_Connection (S.Database); return R; end Get_Master_Session; -- ------------------------------ -- Initialize the sequence factory associated with the session factory. -- ------------------------------ procedure Initialize_Sequences (Factory : in out Session_Factory) is use ADO.Sequences; begin Factory.Sequences := Factory.Seq_Factory'Unchecked_Access; Set_Default_Generator (Factory.Seq_Factory, ADO.Sequences.Hilo.Create_HiLo_Generator'Access, Factory'Unchecked_Access); end Initialize_Sequences; -- ------------------------------ -- Create the session factory to connect to the database represented -- by the data source. -- ------------------------------ procedure Create (Factory : out Session_Factory; Source : in ADO.Sessions.Sources.Data_Source) is begin Factory.Source := Source; Factory.Entities := new ADO.Schemas.Entities.Entity_Cache; Factory.Cache_Values := Factory.Cache'Unchecked_Access; Factory.Cache.Add_Cache (ENTITY_CACHE_NAME, Factory.Entities.all'Access); ADO.Queries.Loaders.Initialize (Factory.Queries, Factory.Source); Initialize_Sequences (Factory); if Factory.Source.Get_Database /= "" and not Configs.Is_On (Configs.NO_ENTITY_LOAD) then declare S : Session := Factory.Get_Session; begin ADO.Schemas.Entities.Initialize (Factory.Entities.all, S); end; end if; end Create; -- ------------------------------ -- Create the session factory to connect to the database identified -- by the URI. -- ------------------------------ procedure Create (Factory : out Session_Factory; URI : in String) is begin Factory.Source.Set_Connection (URI); Factory.Entities := new ADO.Schemas.Entities.Entity_Cache; Factory.Cache_Values := Factory.Cache'Unchecked_Access; Factory.Cache.Add_Cache (ENTITY_CACHE_NAME, Factory.Entities.all'Access); ADO.Queries.Loaders.Initialize (Factory.Queries, Factory.Source); Initialize_Sequences (Factory); if Factory.Source.Get_Database /= "" and not Configs.Is_On (Configs.NO_ENTITY_LOAD) then declare S : Session := Factory.Get_Session; begin ADO.Schemas.Entities.Initialize (Factory.Entities.all, S); end; end if; end Create; -- ------------------------------ -- Set the audit manager to be used for the object auditing support. -- ------------------------------ procedure Set_Audit_Manager (Factory : in out Session_Factory; Manager : in ADO.Audits.Audit_Manager_Access) is begin Factory.Audit := Manager; end Set_Audit_Manager; end ADO.Sessions.Factory;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" package body Yaml.Dom.Node_Memory is procedure Visit (Object : in out Instance; Value : not null access Node.Instance; Previously_Visited : out Boolean) is begin if Object.Data.Contains (Node_Pointer (Value)) then Previously_Visited := True; else Object.Data.Include (Node_Pointer (Value)); Previously_Visited := False; end if; end Visit; procedure Forget (Object : in out Instance; Value : not null access Node.Instance) is begin Object.Data.Exclude (Node_Pointer (Value)); end Forget; function Pop_First (Object : in out Instance) return not null access Node.Instance is First : Pointer_Sets.Cursor := Object.Data.First; begin return Ptr : constant not null access Node.Instance := Pointer_Sets.Element (First) do Object.Data.Delete (First); end return; end Pop_First; function Is_Empty (Object : Instance) return Boolean is (Object.Data.Is_Empty); procedure Visit (Object : in out Pair_Instance; Left, Right : not null access Node.Instance; Previously_Visited : out Boolean) is Pair : constant Pointer_Pair := (Left => Left, Right => Right); begin if Object.Data.Contains (Pair) then Previously_Visited := True; else Object.Data.Include (Pair); Previously_Visited := False; end if; end Visit; end Yaml.Dom.Node_Memory;
package TREE_STATIC_Def is type Int is record Value : Integer; end record; procedure check (I : Int; v : integer); One : constant Int := (Value => 1); end;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Characters.Conversions; use Ada.Characters.Conversions; with Langkit_Support.Text; package body Offmt_Lib.Rewrite is pragma Style_Checks ("M120"); function U2WW (U : Unbounded_String) return Wide_Wide_String is (To_Wide_Wide_String (To_String (U))); function Create_Start_Frame (RH : LALRW.Rewriting_Handle; Id : Trace_ID) return LALRW.Node_Rewriting_Handle; function Create_Push (RH : LALRW.Rewriting_Handle; Fmt : Format) return LALRW.Node_Rewriting_Handle; ------------------------ -- Create_Start_Frame -- ------------------------ function Create_Start_Frame (RH : LALRW.Rewriting_Handle; Id : Trace_ID) return LALRW.Node_Rewriting_Handle is begin return LALRW.Create_Call_Stmt (RH, LALRW.Create_Call_Expr (RH, LALRW.Create_Dotted_Name (RH, LALRW.Create_Token_Node (RH, LALCO.Ada_Identifier, Log_Root_Pkg), LALRW.Create_Token_Node (RH, LALCO.Ada_Identifier, "Start_Frame")), LALRW.Create_Token_Node (RH, LALCO.Ada_Int_Literal, To_Wide_Wide_String (Id'Img)))); end Create_Start_Frame; ----------------- -- Create_Push -- ----------------- function Create_Push (RH : LALRW.Rewriting_Handle; Fmt : Format) return LALRW.Node_Rewriting_Handle is Type_Str : constant String := (case Fmt.Typ is when Type_U8 => "U8", when Type_U16 => "U16", when Type_U32 => "U32"); Proc_Str : constant String := "Push_" & Type_Str; -- Make an Ada expression Expr : constant LALRW.Node_Rewriting_Handle := LALRW.Create_From_Template (Handle => RH, Template => U2WW (Fmt.Expression), Arguments => (1 .. 0 => <>), Rule => LALCO.Expr_Rule); -- Convert it to the target type Convert : constant LALRW.Node_Rewriting_Handle := LALRW.Create_Call_Expr (RH, LALRW.Create_Dotted_Name (RH, LALRW.Create_Token_Node (RH, LALCO.Ada_Identifier, Offmt_Lib.Log_Root_Pkg), LALRW.Create_Token_Node (RH, LALCO.Ada_Identifier, To_Wide_Wide_String (Type_Str))), Expr); -- Call the push procedure Push : constant LALRW.Node_Rewriting_Handle := LALRW.Create_Call_Stmt (RH, LALRW.Create_Call_Expr (RH, LALRW.Create_Dotted_Name (RH, LALRW.Create_Token_Node (RH, LALCO.Ada_Identifier, Offmt_Lib.Log_Root_Pkg), LALRW.Create_Token_Node (RH, LALCO.Ada_Identifier, To_Wide_Wide_String (Proc_Str))), Convert)); begin return Push; end Create_Push; ---------------------- -- Rewrite_Log_Call -- ---------------------- procedure Rewrite_Log_Call (RH : LALRW.Rewriting_Handle; Node : LAL.Call_Stmt'Class; T : Trace) is Stmt_List : constant LALRW.Node_Rewriting_Handle := LALRW.Create_Node (RH, LALCO.Ada_Stmt_List); SH : constant LALRW.Node_Rewriting_Handle := LALRW.Handle (Node); begin LALRW.Append_Child (Stmt_List, Create_Start_Frame (RH, T.Id)); for Elt of T.List loop case Elt.Kind is when Plain_String => null; when Format_String => LALRW.Append_Child (Stmt_List, Create_Push (RH, Elt.Fmt)); end case; end loop; LALRW.Append_Child (Stmt_List, LALRW.Create_From_Template (Handle => RH, Template => Log_Root_Pkg & ".End_Frame;", Arguments => (1 .. 0 => <>), Rule => LALCO.Simple_Stmt_Rule)); declare use Langkit_Support.Text; Str : constant String := Image (LALRW.Unparse (Stmt_List)); begin Put_Line ("Rewrite: '" & Str & "'"); end; LALRW.Replace (SH, Stmt_List); end Rewrite_Log_Call; end Offmt_Lib.Rewrite;
-- -- Copyright (C) 2017, AdaCore -- -- This spec has been automatically generated from M2Sxxx.svd -- This is a version for the Microcontroller Subsystem (MSS) -- - Hard 166 MHz 32-Bit ARM Cortex-M3 Processor (r2p1) -- Embedded Trace Macrocell (ETM) -- Memory Protection Unit (MPU) -- JTAG Debug (4 wires), SW Debug (SWD, 2wires), SW Viewer (SWV) -- - 64 KB Embedded SRAM (eSRAM) -- - Up to 512 KB Embedded Nonvolatile Memory (eNVM) -- - Triple Speed Ethernet (TSE) 10/100/1000 Mbps MAC -- - USB 2.0 High Speed On-The-Go (OTG) Controller with ULPI Interface -- - CAN Controller, 2.0B Compliant, Conforms to ISO11898-1 -- - 2 Each: SPI, I2C, Multi-Mode UARTs (MMUART) Peripherals -- - Hardware Based Watchdog Timer -- - 1 General Purpose 64-Bit (or two 32-bit) Timer(s) -- - Real-Time Calendar/Counter (RTC) -- - DDR Bridge (4 Port Data R/W Buffering Bridge to DDR Memory) with 64-Bit -- AXI IF -- - 2 AHB/APB Interfaces to FPGA Fabric (master/slave capable) -- - 2 DMA Controllers to Offload Data Transactions from the Cortex-M3 -- Processor -- - 8-Channel Peripheral DMA (PDMA) -- - High Performance DMA (HPDMA) -- -- Clocking Resources -- - Clock Sources -- Up to 2 High Precision 32 KHz to 20 MHz Main Crystal Oscillator -- 1 MHz Embedded RC Oscillator -- 50 MHz Embedded RC Oscillator -- - Up to 8 Clock Conditioning Circuits (CCCs) -- Output Clock with 8 Output Phases -- Frequency: Input 1 to 200 MHz, Output 20 to 400MHz -- -- High Speed Serial Interfaces -- - Up to 16 SERDES Lanes, Each Supporting: -- XGXS/XAUI Extension (to implement a 10 Gbps (XGMII) Ethernet PHY -- interface) -- Native SERDES Interface Facilitates Implementation of Serial RapidIO -- PCI Express (PCIe) Endpoint Controller -- -- High Speed Memory Interfaces -- - Up to 2 High Speed DDRx Memory Controllers -- MSS DDR (MDDR) and Fabric DDR (FDDR) Controllers -- Supports LPDDR/DDR2/DDR3 -- Maximum 333 MHz Clock Rate -- SECDED Enable/Disable Feature -- Supports Various DRAM Bus Width Modes, x16, x18, x32, x36 -- - SDRAM Support MCU package Ada.Interrupts.Names is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; ---------------- -- Interrupts -- ---------------- -- System tick Sys_Tick_Interrupt : constant Interrupt_ID := -1; WDOGWAKEUPINT_Interrupt : constant Interrupt_ID := 0; RTC_WAKEUP_INTR_Interrupt : constant Interrupt_ID := 1; SPIINT0_Interrupt : constant Interrupt_ID := 2; SPIINT1_Interrupt : constant Interrupt_ID := 3; I2C_INT0_Interrupt : constant Interrupt_ID := 4; I2C_SMBALERT0_Interrupt : constant Interrupt_ID := 5; I2C_SMBSUS0_Interrupt : constant Interrupt_ID := 6; I2C_INT1_Interrupt : constant Interrupt_ID := 7; I2C_SMBALERT1_Interrupt : constant Interrupt_ID := 8; I2C_SMBSUS1_Interrupt : constant Interrupt_ID := 9; MMUART0_INTR_Interrupt : constant Interrupt_ID := 10; MMUART1_INTR_Interrupt : constant Interrupt_ID := 11; MAC_INT_Interrupt : constant Interrupt_ID := 12; PDMAINTERRUPT_Interrupt : constant Interrupt_ID := 13; TIMER1_INTR_Interrupt : constant Interrupt_ID := 14; TIMER2_INTR_Interrupt : constant Interrupt_ID := 15; CAN_INTR_Interrupt : constant Interrupt_ID := 16; ENVM_INT0_Interrupt : constant Interrupt_ID := 17; ENVM_INT1_Interrupt : constant Interrupt_ID := 18; COMM_BLK_INTR_Interrupt : constant Interrupt_ID := 19; USB_MC_INT_Interrupt : constant Interrupt_ID := 20; USB_DMA_INT_Interrupt : constant Interrupt_ID := 21; MSSDDR_PLL_LOCK_INT_Interrupt : constant Interrupt_ID := 22; MSSDDR_PLL_LOCKLOST_INT_Interrupt : constant Interrupt_ID := 23; SW_ERRORINTERRUPT_Interrupt : constant Interrupt_ID := 24; CACHE_ERRINTR_Interrupt : constant Interrupt_ID := 25; DDRB_INTR_Interrupt : constant Interrupt_ID := 26; HPD_XFR_CMP_INT_Interrupt : constant Interrupt_ID := 27; HPD_XFR_ERR_INT_Interrupt : constant Interrupt_ID := 28; ECCINTR_Interrupt : constant Interrupt_ID := 29; MDDR_IO_CALIB_INT_Interrupt : constant Interrupt_ID := 30; FAB_PLL_LOCK_INT_Interrupt : constant Interrupt_ID := 31; FAB_PLL_LOCKLOST_INT_Interrupt : constant Interrupt_ID := 32; FIC64_INT_Interrupt : constant Interrupt_ID := 33; GPIO_INT_0_Interrupt : constant Interrupt_ID := 50; GPIO_INT_1_Interrupt : constant Interrupt_ID := 51; GPIO_INT_2_Interrupt : constant Interrupt_ID := 52; GPIO_INT_3_Interrupt : constant Interrupt_ID := 53; GPIO_INT_4_Interrupt : constant Interrupt_ID := 54; GPIO_INT_5_Interrupt : constant Interrupt_ID := 55; GPIO_INT_6_Interrupt : constant Interrupt_ID := 56; GPIO_INT_7_Interrupt : constant Interrupt_ID := 57; GPIO_INT_8_Interrupt : constant Interrupt_ID := 58; GPIO_INT_9_Interrupt : constant Interrupt_ID := 59; GPIO_INT_10_Interrupt : constant Interrupt_ID := 60; GPIO_INT_11_Interrupt : constant Interrupt_ID := 61; GPIO_INT_12_Interrupt : constant Interrupt_ID := 62; GPIO_INT_13_Interrupt : constant Interrupt_ID := 63; GPIO_INT_14_Interrupt : constant Interrupt_ID := 64; GPIO_INT_15_Interrupt : constant Interrupt_ID := 65; GPIO_INT_16_Interrupt : constant Interrupt_ID := 66; GPIO_INT_17_Interrupt : constant Interrupt_ID := 67; GPIO_INT_18_Interrupt : constant Interrupt_ID := 68; GPIO_INT_19_Interrupt : constant Interrupt_ID := 69; GPIO_INT_20_Interrupt : constant Interrupt_ID := 70; GPIO_INT_21_Interrupt : constant Interrupt_ID := 71; GPIO_INT_22_Interrupt : constant Interrupt_ID := 72; GPIO_INT_23_Interrupt : constant Interrupt_ID := 73; GPIO_INT_24_Interrupt : constant Interrupt_ID := 74; GPIO_INT_25_Interrupt : constant Interrupt_ID := 75; GPIO_INT_26_Interrupt : constant Interrupt_ID := 76; GPIO_INT_27_Interrupt : constant Interrupt_ID := 77; GPIO_INT_28_Interrupt : constant Interrupt_ID := 78; GPIO_INT_29_Interrupt : constant Interrupt_ID := 79; GPIO_INT_30_Interrupt : constant Interrupt_ID := 80; GPIO_INT_31_Interrupt : constant Interrupt_ID := 81; end Ada.Interrupts.Names;
-- { dg-do run } procedure Pack4 is type Time_T is record Hour : Integer; end record; type Date_And_Time_T is record Date : Integer; Time : Time_T; end record; pragma Pack(Date_And_Time_T); procedure Assign_Hour_Of (T : out Time_T) is begin T.Hour := 44; end; procedure Clobber_Hour_Of (DT: out Date_And_Time_T) is begin Assign_Hour_Of (Dt.Time); end; DT : Date_And_Time_T; begin DT.Time.Hour := 22; Clobber_Hour_Of (DT); if DT.Time.Hour /= 44 then raise Program_Error; end if; end;
-- -- Copyright (C) 2017 Nico Huber <nico.h@gmx.de> -- -- 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. -- generic Dev : PCI.Address := (0, 0, 0); package HW.PCI.Dev with Abstract_State => (Address_State, (PCI_State with External)), Initializes => Address_State is procedure Read8 (Value : out Word8; Offset : Index); procedure Read16 (Value : out Word16; Offset : Index) with Pre => Offset mod 2 = 0; procedure Read32 (Value : out Word32; Offset : Index) with Pre => Offset mod 4 = 0; procedure Write8 (Offset : Index; Value : Word8); procedure Write16 (Offset : Index; Value : Word16) with Pre => Offset mod 2 = 0; procedure Write32 (Offset : Index; Value : Word32) with Pre => Offset mod 4 = 0; pragma Warnings (GNATprove, Off, "unused variable ""WC""*", Reason => "Used for a common interface"); procedure Map (Addr : out Word64; Res : in Resource; Length : in Natural := 0; Offset : in Natural := 0; WC : in Boolean := False); pragma Warnings (GNATprove, On, "unused variable ""WC""*"); procedure Resource_Size (Length : out Natural; Res : Resource); pragma Warnings (GNATprove, Off, "unused variable ""MMConf_Base""*", Reason => "Used for a common interface"); procedure Initialize (Success : out Boolean; MMConf_Base : Word64 := 16#b0000000#); pragma Warnings (GNATprove, On, "unused variable ""MMConf_Base""*"); end HW.PCI.Dev;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M A K 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 Ada.Exceptions; use Ada.Exceptions; with Ada.Command_Line; use Ada.Command_Line; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.OS_Lib; use GNAT.OS_Lib; with ALI; use ALI; with ALI.Util; use ALI.Util; with Csets; with Debug; with Fname; use Fname; with Fname.SF; use Fname.SF; with Fname.UF; use Fname.UF; with Gnatvsn; use Gnatvsn; with Hostparm; use Hostparm; with Makeusg; with MLib.Prj; with MLib.Tgt; with MLib.Utl; with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; with Gnatvsn; with Output; use Output; with Prj; use Prj; with Prj.Com; with Prj.Env; with Prj.Ext; with Prj.Pars; with Prj.Util; with SFN_Scan; with Sinput.L; with Snames; use Snames; with Stringt; use Stringt; with Table; with Types; use Types; with Switch; use Switch; with System.WCh_Con; use System.WCh_Con; package body Make is use ASCII; -- Make control characters visible Standard_Library_Package_Body_Name : constant String := "s-stalib.adb"; -- Every program depends on this package, that must then be checked, -- especially when -f and -a are used. ------------------------- -- Note on terminology -- ------------------------- -- In this program, we use the phrase "termination" of a file name to -- refer to the suffix that appears after the unit name portion. Very -- often this is simply the extension, but in some cases, the sequence -- may be more complex, for example in main.1.ada, the termination in -- this name is ".1.ada" and in main_.ada the termination is "_.ada". ------------------------------------- -- Queue (Q) Manipulation Routines -- ------------------------------------- -- The Q is used in Compile_Sources below. Its implementation uses the -- GNAT generic package Table (basically an extensible array). Q_Front -- points to the first valid element in the Q, whereas Q.First is the first -- element ever enqueued, while Q.Last - 1 is the last element in the Q. -- -- +---+--------------+---+---+---+-----------+---+-------- -- Q | | ........ | | | | ....... | | -- +---+--------------+---+---+---+-----------+---+-------- -- ^ ^ ^ -- Q.First Q_Front Q.Last - 1 -- -- The elements comprised between Q.First and Q_Front - 1 are the -- elements that have been enqueued and then dequeued, while the -- elements between Q_Front and Q.Last - 1 are the elements currently -- in the Q. When the Q is initialized Q_Front = Q.First = Q.Last. -- After Compile_Sources has terminated its execution, Q_Front = Q.Last -- and the elements contained between Q.Front and Q.Last-1 are those that -- were explored and thus marked by Compile_Sources. Whenever the Q is -- reinitialized, the elements between Q.First and Q.Last - 1 are unmarked. procedure Init_Q; -- Must be called to (re)initialize the Q. procedure Insert_Q (Source_File : File_Name_Type; Source_Unit : Unit_Name_Type := No_Name); -- Inserts Source_File at the end of Q. Provide Source_Unit when -- possible for external use (gnatdist). function Empty_Q return Boolean; -- Returns True if Q is empty. procedure Extract_From_Q (Source_File : out File_Name_Type; Source_Unit : out Unit_Name_Type); -- Extracts the first element from the Q. procedure Insert_Project_Sources (The_Project : Project_Id; Into_Q : Boolean); -- If Into_Q is True, insert all sources of the project file that are not -- already marked into the Q. If Into_Q is False, call Osint.Add_File for -- all sources of the project file. First_Q_Initialization : Boolean := True; -- Will be set to false after Init_Q has been called once. Q_Front : Natural; -- Points to the first valid element in the Q. Unique_Compile : Boolean := False; type Q_Record is record File : File_Name_Type; Unit : Unit_Name_Type; end record; -- File is the name of the file to compile. Unit is for gnatdist -- use in order to easily get the unit name of a file to compile -- when its name is krunched or declared in gnat.adc. package Q is new Table.Table ( Table_Component_Type => Q_Record, Table_Index_Type => Natural, Table_Low_Bound => 0, Table_Initial => 4000, Table_Increment => 100, Table_Name => "Make.Q"); -- This is the actual Q. -- The following instantiations and variables are necessary to save what -- is found on the command line, in case there is a project file specified. package Saved_Gcc_Switches is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Saved_Gcc_Switches"); package Saved_Binder_Switches is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Saved_Binder_Switches"); package Saved_Linker_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Saved_Linker_Switches"); package Saved_Make_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Saved_Make_Switches"); Saved_Maximum_Processes : Natural := 0; Saved_WC_Encoding_Method : WC_Encoding_Method := WC_Encoding_Method'First; Saved_WC_Encoding_Method_Set : Boolean := False; type Arg_List_Ref is access Argument_List; The_Saved_Gcc_Switches : Arg_List_Ref; Project_File_Name : String_Access := null; Current_Verbosity : Prj.Verbosity := Prj.Default; Main_Project : Prj.Project_Id := No_Project; procedure Add_Source_Dir (N : String); -- Call Add_Src_Search_Dir. -- Output one line when in verbose mode. procedure Add_Source_Directories is new Prj.Env.For_All_Source_Dirs (Action => Add_Source_Dir); procedure Add_Object_Dir (N : String); -- Call Add_Lib_Search_Dir. -- Output one line when in verbose mode. procedure Add_Object_Directories is new Prj.Env.For_All_Object_Dirs (Action => Add_Object_Dir); type Bad_Compilation_Info is record File : File_Name_Type; Unit : Unit_Name_Type; Found : Boolean; end record; -- File is the name of the file for which a compilation failed. -- Unit is for gnatdist use in order to easily get the unit name -- of a file when its name is krunched or declared in gnat.adc. -- Found is False if the compilation failed because the file could -- not be found. package Bad_Compilation is new Table.Table ( Table_Component_Type => Bad_Compilation_Info, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Bad_Compilation"); -- Full name of all the source files for which compilation fails. type Special_Argument is record File : String_Access; Args : Argument_List_Access; end record; -- File is the name of the file for which a special set of compilation -- arguments (Args) is required. package Special_Args is new Table.Table ( Table_Component_Type => Special_Argument, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Special_Args"); -- Compilation arguments of all the source files for which an entry has -- been found in the project file. Original_Ada_Include_Path : constant String_Access := Getenv ("ADA_INCLUDE_PATH"); Original_Ada_Objects_Path : constant String_Access := Getenv ("ADA_OBJECTS_PATH"); Current_Ada_Include_Path : String_Access := null; Current_Ada_Objects_Path : String_Access := null; Max_Line_Length : constant := 127; -- Maximum number of characters per line, when displaying a path Do_Compile_Step : Boolean := True; Do_Bind_Step : Boolean := True; Do_Link_Step : Boolean := True; -- Flags to indicate what step should be executed. -- Can be set to False with the switches -c, -b and -l. -- These flags are reset to True for each invokation of procedure Gnatmake. ---------------------- -- Marking Routines -- ---------------------- procedure Mark (Source_File : File_Name_Type); -- Mark Source_File. Marking is used to signal that Source_File has -- already been inserted in the Q. function Is_Marked (Source_File : File_Name_Type) return Boolean; -- Returns True if Source_File was previously marked. procedure Unmark (Source_File : File_Name_Type); -- Unmarks Source_File. ------------------- -- Misc Routines -- ------------------- procedure List_Depend; -- Prints to standard output the list of object dependencies. This list -- can be used directly in a Makefile. A call to Compile_Sources must -- precede the call to List_Depend. Also because this routine uses the -- ALI files that were originally loaded and scanned by Compile_Sources, -- no additional ALI files should be scanned between the two calls (i.e. -- between the call to Compile_Sources and List_Depend.) procedure Inform (N : Name_Id := No_Name; Msg : String); -- Prints out the program name followed by a colon, N and S. procedure List_Bad_Compilations; -- Prints out the list of all files for which the compilation failed. procedure Verbose_Msg (N1 : Name_Id; S1 : String; N2 : Name_Id := No_Name; S2 : String := ""; Prefix : String := " -> "); -- If the verbose flag (Verbose_Mode) is set then print Prefix to standard -- output followed by N1 and S1. If N2 /= No_Name then N2 is then printed -- after S1. S2 is printed last. Both N1 and N2 are printed in quotation -- marks. ----------------------- -- Gnatmake Routines -- ----------------------- subtype Lib_Mark_Type is Byte; Ada_Lib_Dir : constant Lib_Mark_Type := 1; GNAT_Lib_Dir : constant Lib_Mark_Type := 2; -- Note that the notion of GNAT lib dir is no longer used. The code -- related to it has not been removed to give an idea on how to use -- the directory prefix marking mechanism. -- An Ada library directory is a directory containing ali and object -- files but no source files for the bodies (the specs can be in the -- same or some other directory). These directories are specified -- in the Gnatmake command line with the switch "-Adir" (to specify the -- spec location -Idir cab be used). Gnatmake skips the missing sources -- whose ali are in Ada library directories. For an explanation of why -- Gnatmake behaves that way, see the spec of Make.Compile_Sources. -- The directory lookup penalty is incurred every single time this -- routine is called. function Is_External_Assignment (Argv : String) return Boolean; -- Verify that an external assignment switch is syntactically correct. -- Correct forms are -- -Xname=value -- -X"name=other value" -- Assumptions: 'First = 1, Argv (1 .. 2) = "-X" -- When this function returns True, the external assignment has -- been entered by a call to Prj.Ext.Add, so that in a project -- file, External ("name") will return "value". function In_Ada_Lib_Dir (File : File_Name_Type) return Boolean; -- Get directory prefix of this file and get lib mark stored in name -- table for this directory. Then check if an Ada lib mark has been set. procedure Mark_Dir_Path (Path : String_Access; Mark : Lib_Mark_Type); -- Invoke Mark_Directory on each directory of the path. procedure Mark_Directory (Dir : String; Mark : Lib_Mark_Type); -- Store Dir in name table and set lib mark as name info to identify -- Ada libraries. function Object_File_Name (Source : String) return String; -- Returns the object file name suitable for switch -o. procedure Set_Ada_Paths (For_Project : Prj.Project_Id; Including_Libraries : Boolean); -- Set, if necessary, env. variables ADA_INCLUDE_PATH and -- ADA_OBJECTS_PATH. -- -- Note: this will modify these environment variables only -- for the current gnatmake process and all of its children -- (invocations of the compiler, the binder and the linker). -- The caller process ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are -- not affected. function Switches_Of (Source_File : Name_Id; Source_File_Name : String; Naming : Naming_Data; In_Package : Package_Id; Allow_ALI : Boolean) return Variable_Value; -- Return the switches for the source file in the specified package -- of a project file. If the Source_File ends with a standard GNAT -- extension (".ads" or ".adb"), try first the full name, then the -- name without the extension. If there is no switches for either -- names, try the default switches for Ada. If all failed, return -- No_Variable_Value. procedure Test_If_Relative_Path (Switch : String_Access); -- Test if Switch is a relative search path switch. -- Fail if it is. This subprogram is only called -- when using project files. procedure Set_Library_For (Project : Project_Id; There_Are_Libraries : in out Boolean); -- If Project is a library project, add the correct -- -L and -l switches to the linker invocation. procedure Set_Libraries is new For_Every_Project_Imported (Boolean, Set_Library_For); -- Add the -L and -l switches to the linker for all -- of the library projects. ---------------------------------------------------- -- Compiler, Binder & Linker Data and Subprograms -- ---------------------------------------------------- Gcc : String_Access := Program_Name ("gcc"); Gnatbind : String_Access := Program_Name ("gnatbind"); Gnatlink : String_Access := Program_Name ("gnatlink"); -- Default compiler, binder, linker programs Saved_Gcc : String_Access := null; Saved_Gnatbind : String_Access := null; Saved_Gnatlink : String_Access := null; -- Given by the command line. Will be used, if non null. Gcc_Path : String_Access := GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all); Gnatbind_Path : String_Access := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all); Gnatlink_Path : String_Access := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all); -- Path for compiler, binder, linker programs, defaulted now for gnatdist. -- Changed later if overridden on command line. Comp_Flag : constant String_Access := new String'("-c"); Output_Flag : constant String_Access := new String'("-o"); Ada_Flag_1 : constant String_Access := new String'("-x"); Ada_Flag_2 : constant String_Access := new String'("ada"); No_gnat_adc : constant String_Access := new String'("-gnatA"); GNAT_Flag : constant String_Access := new String'("-gnatpg"); Do_Not_Check_Flag : constant String_Access := new String'("-x"); Object_Suffix : constant String := Get_Object_Suffix.all; Executable_Suffix : constant String := Get_Executable_Suffix.all; Display_Executed_Programs : Boolean := True; -- Set to True if name of commands should be output on stderr. Output_File_Name_Seen : Boolean := False; -- Set to True after having scanned the file_name for -- switch "-o file_name" type Make_Program_Type is (None, Compiler, Binder, Linker); Program_Args : Make_Program_Type := None; -- Used to indicate if we are scanning gnatmake, gcc, gnatbind, or gnatbind -- options within the gnatmake command line. -- Used in Scan_Make_Arg only, but must be a global variable. procedure Add_Switches (The_Package : Package_Id; File_Name : String; Program : Make_Program_Type); procedure Add_Switch (S : String_Access; Program : Make_Program_Type; Append_Switch : Boolean := True; And_Save : Boolean := True); procedure Add_Switch (S : String; Program : Make_Program_Type; Append_Switch : Boolean := True; And_Save : Boolean := True); -- Make invokes one of three programs (the compiler, the binder or the -- linker). For the sake of convenience, some program specific switches -- can be passed directly on the gnatmake commande line. This procedure -- records these switches so that gnamake can pass them to the right -- program. S is the switch to be added at the end of the command line -- for Program if Append_Switch is True. If Append_Switch is False S is -- added at the beginning of the command line. procedure Check (Lib_File : File_Name_Type; ALI : out ALI_Id; O_File : out File_Name_Type; O_Stamp : out Time_Stamp_Type); -- Determines whether the library file Lib_File is up-to-date or not. The -- full name (with path information) of the object file corresponding to -- Lib_File is returned in O_File. Its time stamp is saved in O_Stamp. -- ALI is the ALI_Id corresponding to Lib_File. If Lib_File in not -- up-to-date, then the corresponding source file needs to be recompiled. -- In this case ALI = No_ALI_Id. procedure Check_Linker_Options (E_Stamp : Time_Stamp_Type; O_File : out File_Name_Type; O_Stamp : out Time_Stamp_Type); -- Checks all linker options for linker files that are newer -- than E_Stamp. If such objects are found, the youngest object -- is returned in O_File and its stamp in O_Stamp. -- -- If no obsolete linker files were found, the first missing -- linker file is returned in O_File and O_Stamp is empty. -- Otherwise O_File is No_File. procedure Display (Program : String; Args : Argument_List); -- Displays Program followed by the arguments in Args if variable -- Display_Executed_Programs is set. The lower bound of Args must be 1. -------------------- -- Add_Object_Dir -- -------------------- procedure Add_Object_Dir (N : String) is begin Add_Lib_Search_Dir (N); if Opt.Verbose_Mode then Write_Str ("Adding object directory """); Write_Str (N); Write_Str ("""."); Write_Eol; end if; end Add_Object_Dir; -------------------- -- Add_Source_Dir -- -------------------- procedure Add_Source_Dir (N : String) is begin Add_Src_Search_Dir (N); if Opt.Verbose_Mode then Write_Str ("Adding source directory """); Write_Str (N); Write_Str ("""."); Write_Eol; end if; end Add_Source_Dir; ---------------- -- Add_Switch -- ---------------- procedure Add_Switch (S : String_Access; Program : Make_Program_Type; Append_Switch : Boolean := True; And_Save : Boolean := True) is generic with package T is new Table.Table (<>); procedure Generic_Position (New_Position : out Integer); -- Generic procedure that allocates a position for S in T at the -- beginning or the end, depending on the boolean Append_Switch. ---------------------- -- Generic_Position -- ---------------------- procedure Generic_Position (New_Position : out Integer) is begin T.Increment_Last; if Append_Switch then New_Position := Integer (T.Last); else for J in reverse T.Table_Index_Type'Succ (T.First) .. T.Last loop T.Table (J) := T.Table (T.Table_Index_Type'Pred (J)); end loop; New_Position := Integer (T.First); end if; end Generic_Position; procedure Gcc_Switches_Pos is new Generic_Position (Gcc_Switches); procedure Binder_Switches_Pos is new Generic_Position (Binder_Switches); procedure Linker_Switches_Pos is new Generic_Position (Linker_Switches); procedure Saved_Gcc_Switches_Pos is new Generic_Position (Saved_Gcc_Switches); procedure Saved_Binder_Switches_Pos is new Generic_Position (Saved_Binder_Switches); procedure Saved_Linker_Switches_Pos is new Generic_Position (Saved_Linker_Switches); New_Position : Integer; -- Start of processing for Add_Switch begin if And_Save then case Program is when Compiler => Saved_Gcc_Switches_Pos (New_Position); Saved_Gcc_Switches.Table (New_Position) := S; when Binder => Saved_Binder_Switches_Pos (New_Position); Saved_Binder_Switches.Table (New_Position) := S; when Linker => Saved_Linker_Switches_Pos (New_Position); Saved_Linker_Switches.Table (New_Position) := S; when None => raise Program_Error; end case; else case Program is when Compiler => Gcc_Switches_Pos (New_Position); Gcc_Switches.Table (New_Position) := S; when Binder => Binder_Switches_Pos (New_Position); Binder_Switches.Table (New_Position) := S; when Linker => Linker_Switches_Pos (New_Position); Linker_Switches.Table (New_Position) := S; when None => raise Program_Error; end case; end if; end Add_Switch; procedure Add_Switch (S : String; Program : Make_Program_Type; Append_Switch : Boolean := True; And_Save : Boolean := True) is begin Add_Switch (S => new String'(S), Program => Program, Append_Switch => Append_Switch, And_Save => And_Save); end Add_Switch; ------------------ -- Add_Switches -- ------------------ procedure Add_Switches (The_Package : Package_Id; File_Name : String; Program : Make_Program_Type) is Switches : Variable_Value; Switch_List : String_List_Id; Element : String_Element; begin if File_Name'Length > 0 then Name_Len := File_Name'Length; Name_Buffer (1 .. Name_Len) := File_Name; Switches := Switches_Of (Source_File => Name_Find, Source_File_Name => File_Name, Naming => Projects.Table (Main_Project).Naming, In_Package => The_Package, Allow_ALI => Program = Binder or else Program = Linker); case Switches.Kind is when Undefined => null; when List => Program_Args := Program; Switch_List := Switches.Values; while Switch_List /= Nil_String loop Element := String_Elements.Table (Switch_List); String_To_Name_Buffer (Element.Value); if Name_Len > 0 then if Opt.Verbose_Mode then Write_Str (" Adding "); Write_Line (Name_Buffer (1 .. Name_Len)); end if; Scan_Make_Arg (Name_Buffer (1 .. Name_Len), And_Save => False); end if; Switch_List := Element.Next; end loop; when Single => Program_Args := Program; String_To_Name_Buffer (Switches.Value); if Name_Len > 0 then if Opt.Verbose_Mode then Write_Str (" Adding "); Write_Line (Name_Buffer (1 .. Name_Len)); end if; Scan_Make_Arg (Name_Buffer (1 .. Name_Len), And_Save => False); end if; end case; end if; end Add_Switches; ---------- -- Bind -- ---------- procedure Bind (ALI_File : File_Name_Type; Args : Argument_List) is Bind_Args : Argument_List (1 .. Args'Last + 2); Bind_Last : Integer; Success : Boolean; begin pragma Assert (Args'First = 1); -- Optimize the simple case where the gnatbind command line looks like -- gnatbind -aO. -I- file.ali --into-> gnatbind file.adb if Args'Length = 2 and then Args (Args'First).all = "-aO" & Normalized_CWD and then Args (Args'Last).all = "-I-" and then ALI_File = Strip_Directory (ALI_File) then Bind_Last := Args'First - 1; else Bind_Last := Args'Last; Bind_Args (Args'Range) := Args; end if; -- It is completely pointless to re-check source file time stamps. -- This has been done already by gnatmake Bind_Last := Bind_Last + 1; Bind_Args (Bind_Last) := Do_Not_Check_Flag; Get_Name_String (ALI_File); Bind_Last := Bind_Last + 1; Bind_Args (Bind_Last) := new String'(Name_Buffer (1 .. Name_Len)); Display (Gnatbind.all, Bind_Args (Args'First .. Bind_Last)); if Gnatbind_Path = null then Osint.Fail ("error, unable to locate " & Gnatbind.all); end if; GNAT.OS_Lib.Spawn (Gnatbind_Path.all, Bind_Args (Args'First .. Bind_Last), Success); if not Success then raise Bind_Failed; end if; end Bind; ----------- -- Check -- ----------- procedure Check (Lib_File : File_Name_Type; ALI : out ALI_Id; O_File : out File_Name_Type; O_Stamp : out Time_Stamp_Type) is function First_New_Spec (A : ALI_Id) return File_Name_Type; -- Looks in the with table entries of A and returns the spec file name -- of the first withed unit (subprogram) for which no spec existed when -- A was generated but for which there exists one now, implying that A -- is now obsolete. If no such unit is found No_File is returned. -- Otherwise the spec file name of the unit is returned. -- -- **WARNING** in the event of Uname format modifications, one *MUST* -- make sure this function is also updated. -- -- Note: This function should really be in ali.adb and use Uname -- services, but this causes the whole compiler to be dragged along -- for gnatbind and gnatmake. -------------------- -- First_New_Spec -- -------------------- function First_New_Spec (A : ALI_Id) return File_Name_Type is Spec_File_Name : File_Name_Type := No_File; function New_Spec (Uname : Unit_Name_Type) return Boolean; -- Uname is the name of the spec or body of some ada unit. -- This function returns True if the Uname is the name of a body -- which has a spec not mentioned inali file A. If True is returned -- Spec_File_Name above is set to the name of this spec file. -------------- -- New_Spec -- -------------- function New_Spec (Uname : Unit_Name_Type) return Boolean is Spec_Name : Unit_Name_Type; File_Name : File_Name_Type; begin -- Test whether Uname is the name of a body unit (ie ends with %b) Get_Name_String (Uname); pragma Assert (Name_Len > 2 and then Name_Buffer (Name_Len - 1) = '%'); if Name_Buffer (Name_Len) /= 'b' then return False; end if; -- Convert unit name into spec name -- ??? this code seems dubious in presence of pragma -- Source_File_Name since there is no more direct relationship -- between unit name and file name. -- ??? Further, what about alternative subunit naming Name_Buffer (Name_Len) := 's'; Spec_Name := Name_Find; File_Name := Get_File_Name (Spec_Name, Subunit => False); -- Look if File_Name is mentioned in A's sdep list. -- If not look if the file exists. If it does return True. for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop if Sdep.Table (D).Sfile = File_Name then return False; end if; end loop; if Full_Source_Name (File_Name) /= No_File then Spec_File_Name := File_Name; return True; end if; return False; end New_Spec; -- Start of processing for First_New_Spec begin U_Chk : for U in ALIs.Table (A).First_Unit .. ALIs.Table (A).Last_Unit loop exit U_Chk when Units.Table (U).Utype = Is_Body_Only and then New_Spec (Units.Table (U).Uname); for W in Units.Table (U).First_With .. Units.Table (U).Last_With loop exit U_Chk when Withs.Table (W).Afile /= No_File and then New_Spec (Withs.Table (W).Uname); end loop; end loop U_Chk; return Spec_File_Name; end First_New_Spec; --------------------------------- -- Data declarations for Check -- --------------------------------- Full_Lib_File : File_Name_Type; -- Full name of current library file Full_Obj_File : File_Name_Type; -- Full name of the object file corresponding to Lib_File. Lib_Stamp : Time_Stamp_Type; -- Time stamp of the current ada library file. Obj_Stamp : Time_Stamp_Type; -- Time stamp of the current object file. Modified_Source : File_Name_Type; -- The first source in Lib_File whose current time stamp differs -- from that stored in Lib_File. New_Spec : File_Name_Type; -- If Lib_File contains in its W (with) section a body (for a -- subprogram) for which there exists a spec and the spec did not -- appear in the Sdep section of Lib_File, New_Spec contains the file -- name of this new spec. Source_Name : Name_Id; Text : Text_Buffer_Ptr; Prev_Switch : Character; -- First character of previous switch processed Arg : Arg_Id := Arg_Id'First; -- Current index in Args.Table for a given unit (init to stop warning) Switch_Found : Boolean; -- True if a given switch has been found Num_Args : Integer; -- Number of compiler arguments processed Special_Arg : Argument_List_Access; -- Special arguments if any of a given compilation file -- Start of processing for Check begin pragma Assert (Lib_File /= No_File); Text := Read_Library_Info (Lib_File); Full_Lib_File := Full_Library_Info_Name; Full_Obj_File := Full_Object_File_Name; Lib_Stamp := Current_Library_File_Stamp; Obj_Stamp := Current_Object_File_Stamp; if Full_Lib_File = No_File then Verbose_Msg (Lib_File, "being checked ...", Prefix => " "); else Verbose_Msg (Full_Lib_File, "being checked ...", Prefix => " "); end if; ALI := No_ALI_Id; O_File := Full_Obj_File; O_Stamp := Obj_Stamp; if Text = null then if Full_Lib_File = No_File then Verbose_Msg (Lib_File, "missing."); elsif Obj_Stamp (Obj_Stamp'First) = ' ' then Verbose_Msg (Full_Obj_File, "missing."); else Verbose_Msg (Full_Lib_File, "(" & String (Lib_Stamp) & ") newer than", Full_Obj_File, "(" & String (Obj_Stamp) & ")"); end if; else ALI := Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True); Free (Text); if ALI = No_ALI_Id then Verbose_Msg (Full_Lib_File, "incorrectly formatted ALI file"); return; elsif ALIs.Table (ALI).Ver (1 .. ALIs.Table (ALI).Ver_Len) /= Library_Version then Verbose_Msg (Full_Lib_File, "compiled with old GNAT version"); ALI := No_ALI_Id; return; end if; -- Don't take Ali file into account if it was generated without -- object. if Opt.Operating_Mode /= Opt.Check_Semantics and then ALIs.Table (ALI).No_Object then Verbose_Msg (Full_Lib_File, "has no corresponding object"); ALI := No_ALI_Id; return; end if; -- Check for matching compiler switches if needed if Opt.Check_Switches then Prev_Switch := ASCII.Nul; Num_Args := 0; Get_Name_String (ALIs.Table (ALI).Sfile); for J in 1 .. Special_Args.Last loop if Special_Args.Table (J).File.all = Name_Buffer (1 .. Name_Len) then Special_Arg := Special_Args.Table (J).Args; exit; end if; end loop; if Main_Project /= No_Project then null; end if; if Special_Arg = null then for J in Gcc_Switches.First .. Gcc_Switches.Last loop -- Skip non switches, -I and -o switches if (Gcc_Switches.Table (J) (1) = '-' or else Gcc_Switches.Table (J) (1) = Switch_Character) and then Gcc_Switches.Table (J) (2) /= 'o' and then Gcc_Switches.Table (J) (2) /= 'I' then Num_Args := Num_Args + 1; -- Comparing switches is delicate because gcc reorders -- a number of switches, according to lang-specs.h, but -- gnatmake doesn't have the sufficient knowledge to -- perform the same reordering. Instead, we ignore orders -- between different "first letter" switches, but keep -- orders between same switches, e.g -O -O2 is different -- than -O2 -O, but -g -O is equivalent to -O -g. if Gcc_Switches.Table (J) (2) /= Prev_Switch then Prev_Switch := Gcc_Switches.Table (J) (2); Arg := Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; end if; Switch_Found := False; for K in Arg .. Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg loop if Gcc_Switches.Table (J).all = Args.Table (K).all then Arg := K + 1; Switch_Found := True; exit; end if; end loop; if not Switch_Found then if Opt.Verbose_Mode then Verbose_Msg (ALIs.Table (ALI).Sfile, "switch mismatch"); end if; ALI := No_ALI_Id; return; end if; end if; end loop; -- Special_Arg is non-null else for J in Special_Arg'Range loop -- Skip non switches, -I and -o switches if (Special_Arg (J) (1) = '-' or else Special_Arg (J) (1) = Switch_Character) and then Special_Arg (J) (2) /= 'o' and then Special_Arg (J) (2) /= 'I' then Num_Args := Num_Args + 1; if Special_Arg (J) (2) /= Prev_Switch then Prev_Switch := Special_Arg (J) (2); Arg := Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; end if; Switch_Found := False; for K in Arg .. Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg loop if Special_Arg (J).all = Args.Table (K).all then Arg := K + 1; Switch_Found := True; exit; end if; end loop; if not Switch_Found then if Opt.Verbose_Mode then Verbose_Msg (ALIs.Table (ALI).Sfile, "switch mismatch"); end if; ALI := No_ALI_Id; return; end if; end if; end loop; end if; if Num_Args /= Integer (Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg - Units.Table (ALIs.Table (ALI).First_Unit).First_Arg + 1) then if Opt.Verbose_Mode then Verbose_Msg (ALIs.Table (ALI).Sfile, "different number of switches"); end if; ALI := No_ALI_Id; return; end if; end if; -- Get the source files and their time stamps. Note that some -- sources may be missing if ALI is out-of-date. Set_Source_Table (ALI); Modified_Source := Time_Stamp_Mismatch (ALI); if Modified_Source /= No_File then ALI := No_ALI_Id; if Opt.Verbose_Mode then Source_Name := Full_Source_Name (Modified_Source); if Source_Name /= No_File then Verbose_Msg (Source_Name, "time stamp mismatch"); else Verbose_Msg (Modified_Source, "missing"); end if; end if; else New_Spec := First_New_Spec (ALI); if New_Spec /= No_File then ALI := No_ALI_Id; if Opt.Verbose_Mode then Source_Name := Full_Source_Name (New_Spec); if Source_Name /= No_File then Verbose_Msg (Source_Name, "new spec"); else Verbose_Msg (New_Spec, "old spec missing"); end if; end if; end if; end if; end if; end Check; -------------------------- -- Check_Linker_Options -- -------------------------- procedure Check_Linker_Options (E_Stamp : Time_Stamp_Type; O_File : out File_Name_Type; O_Stamp : out Time_Stamp_Type) is procedure Check_File (File : File_Name_Type); -- Update O_File and O_Stamp if the given file is younger than E_Stamp -- and O_Stamp, or if O_File is No_File and File does not exist. function Get_Library_File (Name : String) return File_Name_Type; -- Return the full file name including path of a library based -- on the name specified with the -l linker option, using the -- Ada object path. Return No_File if no such file can be found. type Char_Array is array (Natural) of Character; type Char_Array_Access is access constant Char_Array; Template : Char_Array_Access; pragma Import (C, Template, "__gnat_library_template"); ---------------- -- Check_File -- ---------------- procedure Check_File (File : File_Name_Type) is Stamp : Time_Stamp_Type; Name : File_Name_Type := File; begin Get_Name_String (Name); -- Remove any trailing NUL characters while Name_Len >= Name_Buffer'First and then Name_Buffer (Name_Len) = NUL loop Name_Len := Name_Len - 1; end loop; if Name_Len <= 0 then return; elsif Name_Buffer (1) = Get_Switch_Character or else Name_Buffer (1) = '-' then -- Do not check if File is a switch other than "-l" if Name_Buffer (2) /= 'l' then return; end if; -- The argument is a library switch, get actual name. It -- is necessary to make a copy of the relevant part of -- Name_Buffer as Get_Library_Name uses Name_Buffer as well. declare Base_Name : constant String := Name_Buffer (3 .. Name_Len); begin Name := Get_Library_File (Base_Name); end; if Name = No_File then return; end if; end if; Stamp := File_Stamp (Name); -- Find the youngest object file that is younger than the -- executable. If no such file exist, record the first object -- file that is not found. if (O_Stamp < Stamp and then E_Stamp < Stamp) or else (O_File = No_File and then Stamp (Stamp'First) = ' ') then O_Stamp := Stamp; O_File := Name; -- Strip the trailing NUL if present Get_Name_String (O_File); if Name_Buffer (Name_Len) = NUL then Name_Len := Name_Len - 1; O_File := Name_Find; end if; end if; end Check_File; ---------------------- -- Get_Library_Name -- ---------------------- -- See comments in a-adaint.c about template syntax function Get_Library_File (Name : String) return File_Name_Type is File : File_Name_Type := No_File; begin Name_Len := 0; for Ptr in Template'Range loop case Template (Ptr) is when '*' => Add_Str_To_Name_Buffer (Name); when ';' => File := Full_Lib_File_Name (Name_Find); exit when File /= No_File; Name_Len := 0; when NUL => exit; when others => Add_Char_To_Name_Buffer (Template (Ptr)); end case; end loop; -- The for loop exited because the end of the template -- was reached. File contains the last possible file name -- for the library. if File = No_File and then Name_Len > 0 then File := Full_Lib_File_Name (Name_Find); end if; return File; end Get_Library_File; -- Start of processing for Check_Linker_Options begin O_File := No_File; O_Stamp := (others => ' '); -- Process linker options from the ALI files. for Opt in 1 .. Linker_Options.Last loop Check_File (Linker_Options.Table (Opt).Name); end loop; -- Process options given on the command line. for Opt in Linker_Switches.First .. Linker_Switches.Last loop -- Check if the previous Opt has one of the two switches -- that take an extra parameter. (See GCC manual.) if Opt = Linker_Switches.First or else (Linker_Switches.Table (Opt - 1).all /= "-u" and then Linker_Switches.Table (Opt - 1).all /= "-Xlinker") then Name_Len := 0; Add_Str_To_Name_Buffer (Linker_Switches.Table (Opt).all); Check_File (Name_Find); end if; end loop; end Check_Linker_Options; --------------------- -- Compile_Sources -- --------------------- procedure Compile_Sources (Main_Source : File_Name_Type; Args : Argument_List; First_Compiled_File : out Name_Id; Most_Recent_Obj_File : out Name_Id; Most_Recent_Obj_Stamp : out Time_Stamp_Type; Main_Unit : out Boolean; Compilation_Failures : out Natural; Check_Readonly_Files : Boolean := False; Do_Not_Execute : Boolean := False; Force_Compilations : Boolean := False; Keep_Going : Boolean := False; In_Place_Mode : Boolean := False; Initialize_ALI_Data : Boolean := True; Max_Process : Positive := 1) is function Compile (S : Name_Id; L : Name_Id; Args : Argument_List) return Process_Id; -- Compiles S using Args. If S is a GNAT predefined source -- "-gnatpg" is added to Args. Non blocking call. L corresponds to the -- expected library file name. Process_Id of the process spawned to -- execute the compile. type Compilation_Data is record Pid : Process_Id; Full_Source_File : File_Name_Type; Lib_File : File_Name_Type; Source_Unit : Unit_Name_Type; end record; Running_Compile : array (1 .. Max_Process) of Compilation_Data; -- Used to save information about outstanding compilations. Outstanding_Compiles : Natural := 0; -- Current number of outstanding compiles Source_Unit : Unit_Name_Type; -- Current source unit Source_File : File_Name_Type; -- Current source file Full_Source_File : File_Name_Type; -- Full name of the current source file Lib_File : File_Name_Type; -- Current library file Full_Lib_File : File_Name_Type; -- Full name of the current library file Obj_File : File_Name_Type; -- Full name of the object file corresponding to Lib_File. Obj_Stamp : Time_Stamp_Type; -- Time stamp of the current object file. Sfile : File_Name_Type; -- Contains the source file of the units withed by Source_File ALI : ALI_Id; -- ALI Id of the current ALI file Compilation_OK : Boolean; Need_To_Compile : Boolean; Pid : Process_Id; Text : Text_Buffer_Ptr; Data : Prj.Project_Data; Arg_Index : Natural; -- Index in Special_Args.Table of a given compilation file Need_To_Check_Standard_Library : Boolean := Check_Readonly_Files; procedure Add_Process (Pid : Process_Id; Sfile : File_Name_Type; Afile : File_Name_Type; Uname : Unit_Name_Type); -- Adds process Pid to the current list of outstanding compilation -- processes and record the full name of the source file Sfile that -- we are compiling, the name of its library file Afile and the -- name of its unit Uname. procedure Await_Compile (Sfile : out File_Name_Type; Afile : out File_Name_Type; Uname : out Unit_Name_Type; OK : out Boolean); -- Awaits that an outstanding compilation process terminates. When -- it does set Sfile to the name of the source file that was compiled -- Afile to the name of its library file and Uname to the name of its -- unit. Note that this time stamp can be used to check whether the -- compilation did generate an object file. OK is set to True if the -- compilation succeeded. Note that Sfile, Afile and Uname could be -- resp. No_File, No_File and No_Name if there were no compilations -- to wait for. procedure Collect_Arguments_And_Compile; -- Collect arguments from project file (if any) and compile package Good_ALI is new Table.Table ( Table_Component_Type => ALI_Id, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 50, Table_Increment => 100, Table_Name => "Make.Good_ALI"); -- Contains the set of valid ALI files that have not yet been scanned. procedure Record_Good_ALI (A : ALI_Id); -- Records in the previous set the Id of an ALI file. function Good_ALI_Present return Boolean; -- Returns True if any ALI file was recorded in the previous set. function Get_Next_Good_ALI return ALI_Id; -- Returns the next good ALI_Id record; procedure Record_Failure (File : File_Name_Type; Unit : Unit_Name_Type; Found : Boolean := True); -- Records in the previous table that the compilation for File failed. -- If Found is False then the compilation of File failed because we -- could not find it. Records also Unit when possible. function Bad_Compilation_Count return Natural; -- Returns the number of compilation failures. procedure Debug_Msg (S : String; N : Name_Id); -- If Debug.Debug_Flag_W is set outputs string S followed by name N. function Configuration_Pragmas_Switch (For_Project : Project_Id) return Argument_List; -- Return an argument list of one element, if there is a configuration -- pragmas file to be specified for For_Project, -- otherwise return an empty argument list. ----------------- -- Add_Process -- ----------------- procedure Add_Process (Pid : Process_Id; Sfile : File_Name_Type; Afile : File_Name_Type; Uname : Unit_Name_Type) is OC1 : constant Positive := Outstanding_Compiles + 1; begin pragma Assert (OC1 <= Max_Process); pragma Assert (Pid /= Invalid_Pid); Running_Compile (OC1).Pid := Pid; Running_Compile (OC1).Full_Source_File := Sfile; Running_Compile (OC1).Lib_File := Afile; Running_Compile (OC1).Source_Unit := Uname; Outstanding_Compiles := OC1; end Add_Process; -------------------- -- Await_Compile -- ------------------- procedure Await_Compile (Sfile : out File_Name_Type; Afile : out File_Name_Type; Uname : out File_Name_Type; OK : out Boolean) is Pid : Process_Id; begin pragma Assert (Outstanding_Compiles > 0); Sfile := No_File; Afile := No_File; Uname := No_Name; OK := False; Wait_Process (Pid, OK); if Pid = Invalid_Pid then return; end if; for J in Running_Compile'First .. Outstanding_Compiles loop if Pid = Running_Compile (J).Pid then Sfile := Running_Compile (J).Full_Source_File; Afile := Running_Compile (J).Lib_File; Uname := Running_Compile (J).Source_Unit; -- To actually remove this Pid and related info from -- Running_Compile replace its entry with the last valid -- entry in Running_Compile. if J = Outstanding_Compiles then null; else Running_Compile (J) := Running_Compile (Outstanding_Compiles); end if; Outstanding_Compiles := Outstanding_Compiles - 1; return; end if; end loop; raise Program_Error; end Await_Compile; --------------------------- -- Bad_Compilation_Count -- --------------------------- function Bad_Compilation_Count return Natural is begin return Bad_Compilation.Last - Bad_Compilation.First + 1; end Bad_Compilation_Count; ----------------------------------- -- Collect_Arguments_And_Compile -- ----------------------------------- procedure Collect_Arguments_And_Compile is begin -- If no project file is used, then just call Compile with -- the specified Args. if Main_Project = No_Project then Pid := Compile (Full_Source_File, Lib_File, Args); -- A project file was used else -- First check if the current source is an immediate -- source of a project file. if Opt.Verbose_Mode then Write_Eol; Write_Line ("Establishing Project context."); end if; declare Source_File_Name : constant String := Name_Buffer (1 .. Name_Len); Current_Project : Prj.Project_Id; Path_Name : File_Name_Type := Source_File; Compiler_Package : Prj.Package_Id; Switches : Prj.Variable_Value; Object_File : String_Access; begin if Opt.Verbose_Mode then Write_Str ("Checking if the Project File exists for """); Write_Str (Source_File_Name); Write_Line ("""."); end if; Prj.Env. Get_Reference (Source_File_Name => Source_File_Name, Project => Current_Project, Path => Path_Name); if Current_Project = No_Project then -- The current source is not an immediate source of any -- project file. Call Compile with the specified Args plus -- the saved gcc switches. if Opt.Verbose_Mode then Write_Str ("No Project File."); Write_Eol; end if; Pid := Compile (Full_Source_File, Lib_File, Args & The_Saved_Gcc_Switches.all); -- We now know the project of the current source else -- Set ADA_INCLUDE_PATH and ADA_OBJECTS_PATH if the project -- has changed. -- Note: this will modify these environment variables only -- for the current gnatmake process and all of its children -- (invocations of the compiler, the binder and the linker). -- The caller's ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are -- not affected. Set_Ada_Paths (Current_Project, True); Data := Projects.Table (Current_Project); -- Check if it is a library project that needs to be -- processed, only if it is not the main project. if MLib.Tgt.Libraries_Are_Supported and then Current_Project /= Main_Project and then Data.Library and then not Data.Flag1 then -- Add to the Q all sources of the project that have -- not been marked Insert_Project_Sources (The_Project => Current_Project, Into_Q => True); -- Now mark the project as processed Data.Flag1 := True; Projects.Table (Current_Project).Flag1 := True; end if; Get_Name_String (Data.Object_Directory); if Name_Buffer (Name_Len) = '/' or else Name_Buffer (Name_Len) = Directory_Separator then Object_File := new String' (Name_Buffer (1 .. Name_Len) & Object_File_Name (Source_File_Name)); else Object_File := new String' (Name_Buffer (1 .. Name_Len) & Directory_Separator & Object_File_Name (Source_File_Name)); end if; if Opt.Verbose_Mode then Write_Str ("Project file is """); Write_Str (Get_Name_String (Data.Name)); Write_Str ("""."); Write_Eol; end if; -- We know look for package Compiler -- and get the switches from this package. if Opt.Verbose_Mode then Write_Str ("Checking package Compiler."); Write_Eol; end if; Compiler_Package := Prj.Util.Value_Of (Name => Name_Compiler, In_Packages => Data.Decl.Packages); if Compiler_Package /= No_Package then if Opt.Verbose_Mode then Write_Str ("Getting the switches."); Write_Eol; end if; -- If package Gnatmake.Compiler exists, we get -- the specific switches for the current source, -- or the global switches, if any. Switches := Switches_Of (Source_File => Source_File, Source_File_Name => Source_File_Name, Naming => Projects.Table (Current_Project).Naming, In_Package => Compiler_Package, Allow_ALI => False); end if; case Switches.Kind is -- We have a list of switches. We add to Args -- these switches, plus the saved gcc switches. when List => declare Current : String_List_Id := Switches.Values; Element : String_Element; Number : Natural := 0; begin while Current /= Nil_String loop Element := String_Elements.Table (Current); Number := Number + 1; Current := Element.Next; end loop; declare New_Args : Argument_List (1 .. Number); begin Current := Switches.Values; for Index in New_Args'Range loop Element := String_Elements.Table (Current); String_To_Name_Buffer (Element.Value); New_Args (Index) := new String' (Name_Buffer (1 .. Name_Len)); Test_If_Relative_Path (New_Args (Index)); Current := Element.Next; end loop; Pid := Compile (Path_Name, Lib_File, Args & Output_Flag & Object_File & Configuration_Pragmas_Switch (Current_Project) & New_Args & The_Saved_Gcc_Switches.all); end; end; -- We have a single switch. We add to Args -- this switch, plus the saved gcc switches. when Single => String_To_Name_Buffer (Switches.Value); declare New_Args : constant Argument_List := (1 => new String' (Name_Buffer (1 .. Name_Len))); begin Test_If_Relative_Path (New_Args (1)); Pid := Compile (Path_Name, Lib_File, Args & Output_Flag & Object_File & New_Args & Configuration_Pragmas_Switch (Current_Project) & The_Saved_Gcc_Switches.all); end; -- We have no switches from Gnatmake.Compiler. -- We add to Args the saved gcc switches. when Undefined => if Opt.Verbose_Mode then Write_Str ("There are no switches."); Write_Eol; end if; Pid := Compile (Path_Name, Lib_File, Args & Output_Flag & Object_File & Configuration_Pragmas_Switch (Current_Project) & The_Saved_Gcc_Switches.all); end case; end if; end; end if; end Collect_Arguments_And_Compile; ------------- -- Compile -- ------------- function Compile (S : Name_Id; L : Name_Id; Args : Argument_List) return Process_Id is Comp_Args : Argument_List (Args'First .. Args'Last + 7); Comp_Next : Integer := Args'First; Comp_Last : Integer; function Ada_File_Name (Name : Name_Id) return Boolean; -- Returns True if Name is the name of an ada source file -- (i.e. suffix is .ads or .adb) ------------------- -- Ada_File_Name -- ------------------- function Ada_File_Name (Name : Name_Id) return Boolean is begin Get_Name_String (Name); return Name_Len > 4 and then Name_Buffer (Name_Len - 3 .. Name_Len - 1) = ".ad" and then (Name_Buffer (Name_Len) = 'b' or else Name_Buffer (Name_Len) = 's'); end Ada_File_Name; -- Start of processing for Compile begin Comp_Args (Comp_Next) := Comp_Flag; Comp_Next := Comp_Next + 1; -- Optimize the simple case where the gcc command line looks like -- gcc -c -I. ... -I- file.adb --into-> gcc -c ... file.adb if Args (Args'First).all = "-I" & Normalized_CWD and then Args (Args'Last).all = "-I-" and then S = Strip_Directory (S) then Comp_Last := Comp_Next + Args'Length - 3; Comp_Args (Comp_Next .. Comp_Last) := Args (Args'First + 1 .. Args'Last - 1); else Comp_Last := Comp_Next + Args'Length - 1; Comp_Args (Comp_Next .. Comp_Last) := Args; end if; -- Set -gnatpg for predefined files (for this purpose the renamings -- such as Text_IO do not count as predefined). Note that we strip -- the directory name from the source file name becase the call to -- Fname.Is_Predefined_File_Name cannot deal with directory prefixes. declare Fname : constant File_Name_Type := Strip_Directory (S); begin if Is_Predefined_File_Name (Fname, False) then if Check_Readonly_Files then Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := GNAT_Flag; else Fail ("not allowed to compile """ & Get_Name_String (Fname) & """; use -a switch."); end if; end if; end; -- Now check if the file name has one of the suffixes familiar to -- the gcc driver. If this is not the case then add the ada flag -- "-x ada". if not Ada_File_Name (S) then Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := Ada_Flag_1; Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := Ada_Flag_2; end if; if L /= Strip_Directory (L) then -- Build -o argument. Get_Name_String (L); for J in reverse 1 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Len := J + Object_Suffix'Length - 1; Name_Buffer (J .. Name_Len) := Object_Suffix; exit; end if; end loop; Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := Output_Flag; Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len)); end if; Get_Name_String (S); Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len)); Display (Gcc.all, Comp_Args (Args'First .. Comp_Last)); if Gcc_Path = null then Osint.Fail ("error, unable to locate " & Gcc.all); end if; return GNAT.OS_Lib.Non_Blocking_Spawn (Gcc_Path.all, Comp_Args (Args'First .. Comp_Last)); end Compile; ---------------------------------- -- Configuration_Pragmas_Switch -- ---------------------------------- function Configuration_Pragmas_Switch (For_Project : Project_Id) return Argument_List is begin Prj.Env.Create_Config_Pragmas_File (For_Project, Main_Project); if Projects.Table (For_Project).Config_File_Name /= No_Name then return (1 => new String'("-gnatec" & Get_Name_String (Projects.Table (For_Project).Config_File_Name))); else return (1 .. 0 => null); end if; end Configuration_Pragmas_Switch; --------------- -- Debug_Msg -- --------------- procedure Debug_Msg (S : String; N : Name_Id) is begin if Debug.Debug_Flag_W then Write_Str (" ... "); Write_Str (S); Write_Str (" "); Write_Name (N); Write_Eol; end if; end Debug_Msg; ----------------------- -- Get_Next_Good_ALI -- ----------------------- function Get_Next_Good_ALI return ALI_Id is ALI : ALI_Id; begin pragma Assert (Good_ALI_Present); ALI := Good_ALI.Table (Good_ALI.Last); Good_ALI.Decrement_Last; return ALI; end Get_Next_Good_ALI; ---------------------- -- Good_ALI_Present -- ---------------------- function Good_ALI_Present return Boolean is begin return Good_ALI.First <= Good_ALI.Last; end Good_ALI_Present; -------------------- -- Record_Failure -- -------------------- procedure Record_Failure (File : File_Name_Type; Unit : Unit_Name_Type; Found : Boolean := True) is begin Bad_Compilation.Increment_Last; Bad_Compilation.Table (Bad_Compilation.Last) := (File, Unit, Found); end Record_Failure; --------------------- -- Record_Good_ALI -- --------------------- procedure Record_Good_ALI (A : ALI_Id) is begin Good_ALI.Increment_Last; Good_ALI.Table (Good_ALI.Last) := A; end Record_Good_ALI; -- Start of processing for Compile_Sources begin pragma Assert (Args'First = 1); -- Package and Queue initializations. Good_ALI.Init; Bad_Compilation.Init; Output.Set_Standard_Error; Init_Q; if Initialize_ALI_Data then Initialize_ALI; Initialize_ALI_Source; end if; -- The following two flags affect the behavior of ALI.Set_Source_Table. -- We set Opt.Check_Source_Files to True to ensure that source file -- time stamps are checked, and we set Opt.All_Sources to False to -- avoid checking the presence of the source files listed in the -- source dependency section of an ali file (which would be a mistake -- since the ali file may be obsolete). Opt.Check_Source_Files := True; Opt.All_Sources := False; -- If the main source is marked, there is nothing to compile. -- This can happen when we have several main subprograms. -- For the first main, we always insert in the Q. if not Is_Marked (Main_Source) then Insert_Q (Main_Source); Mark (Main_Source); end if; First_Compiled_File := No_File; Most_Recent_Obj_File := No_File; Main_Unit := False; -- Keep looping until there is no more work to do (the Q is empty) -- and all the outstanding compilations have terminated Make_Loop : while not Empty_Q or else Outstanding_Compiles > 0 loop -- If the user does not want to keep going in case of errors then -- wait for the remaining outstanding compiles and then exit. if Bad_Compilation_Count > 0 and then not Keep_Going then while Outstanding_Compiles > 0 loop Await_Compile (Full_Source_File, Lib_File, Source_Unit, Compilation_OK); if not Compilation_OK then Record_Failure (Full_Source_File, Source_Unit); end if; end loop; exit Make_Loop; end if; -- PHASE 1: Check if there is more work that we can do (ie the Q -- is non empty). If there is, do it only if we have not yet used -- up all the available processes. if not Empty_Q and then Outstanding_Compiles < Max_Process then Extract_From_Q (Source_File, Source_Unit); Full_Source_File := Osint.Full_Source_Name (Source_File); Lib_File := Osint.Lib_File_Name (Source_File); Full_Lib_File := Osint.Full_Lib_File_Name (Lib_File); -- If the library file is an Ada library skip it if Full_Lib_File /= No_File and then In_Ada_Lib_Dir (Full_Lib_File) then Verbose_Msg (Lib_File, "is in an Ada library", Prefix => " "); -- If the library file is a read-only library skip it elsif Full_Lib_File /= No_File and then not Check_Readonly_Files and then Is_Readonly_Library (Full_Lib_File) then Verbose_Msg (Lib_File, "is a read-only library", Prefix => " "); -- The source file that we are checking cannot be located elsif Full_Source_File = No_File then Record_Failure (Source_File, Source_Unit, False); -- Source and library files can be located but are internal -- files elsif not Check_Readonly_Files and then Full_Lib_File /= No_File and then Is_Internal_File_Name (Source_File) then if Force_Compilations then Fail ("not allowed to compile """ & Get_Name_String (Source_File) & """; use -a switch."); end if; Verbose_Msg (Lib_File, "is an internal library", Prefix => " "); -- The source file that we are checking can be located else -- Don't waste any time if we have to recompile anyway Obj_Stamp := Empty_Time_Stamp; Need_To_Compile := Force_Compilations; if not Force_Compilations then Check (Lib_File, ALI, Obj_File, Obj_Stamp); Need_To_Compile := (ALI = No_ALI_Id); end if; if not Need_To_Compile then -- The ALI file is up-to-date. Record its Id. Record_Good_ALI (ALI); -- Record the time stamp of the most recent object file -- as long as no (re)compilations are needed. if First_Compiled_File = No_File and then (Most_Recent_Obj_File = No_File or else Obj_Stamp > Most_Recent_Obj_Stamp) then Most_Recent_Obj_File := Obj_File; Most_Recent_Obj_Stamp := Obj_Stamp; end if; else -- Is this the first file we have to compile? if First_Compiled_File = No_File then First_Compiled_File := Full_Source_File; Most_Recent_Obj_File := No_File; if Do_Not_Execute then exit Make_Loop; end if; end if; if In_Place_Mode then -- If the library file was not found, then save the -- library file near the source file. if Full_Lib_File = No_File then Get_Name_String (Full_Source_File); for J in reverse 1 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Buffer (J + 1 .. J + 3) := "ali"; Name_Len := J + 3; exit; end if; end loop; Lib_File := Name_Find; -- If the library file was found, then save the -- library file in the same place. else Lib_File := Full_Lib_File; end if; end if; -- Check for special compilation flags Arg_Index := 0; Get_Name_String (Source_File); -- Start the compilation and record it. We can do this -- because there is at least one free process. Collect_Arguments_And_Compile; -- Make sure we could successfully start the compilation if Pid = Invalid_Pid then Record_Failure (Full_Source_File, Source_Unit); else Add_Process (Pid, Full_Source_File, Lib_File, Source_Unit); end if; end if; end if; end if; -- PHASE 2: Now check if we should wait for a compilation to -- finish. This is the case if all the available processes are -- busy compiling sources or there is nothing else to do -- (that is the Q is empty and there are no good ALIs to process). if Outstanding_Compiles = Max_Process or else (Empty_Q and then not Good_ALI_Present and then Outstanding_Compiles > 0) then Await_Compile (Full_Source_File, Lib_File, Source_Unit, Compilation_OK); if not Compilation_OK then Record_Failure (Full_Source_File, Source_Unit); else -- Re-read the updated library file Text := Read_Library_Info (Lib_File); -- If no ALI file was generated by this compilation nothing -- more to do, otherwise scan the ali file and record it. -- If the scan fails, a previous ali file is inconsistent with -- the unit just compiled. if Text /= null then ALI := Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True); if ALI = No_ALI_Id then Inform (Lib_File, "incompatible ALI file, please recompile"); Record_Failure (Full_Source_File, Source_Unit); else Free (Text); Record_Good_ALI (ALI); end if; -- If we could not read the ALI file that was just generated -- then there could be a problem reading either the ALI or the -- corresponding object file (if Opt.Check_Object_Consistency -- is set Read_Library_Info checks that the time stamp of the -- object file is more recent than that of the ALI). For an -- example of problems caught by this test see [6625-009]. else Inform (Lib_File, "WARNING: ALI or object file not found after compile"); Record_Failure (Full_Source_File, Source_Unit); end if; end if; end if; exit Make_Loop when Unique_Compile; -- PHASE 3: Check if we recorded good ALI files. If yes process -- them now in the order in which they have been recorded. There -- are two occasions in which we record good ali files. The first is -- in phase 1 when, after scanning an existing ALI file we realise -- it is up-to-date, the second instance is after a successful -- compilation. while Good_ALI_Present loop ALI := Get_Next_Good_ALI; -- If we are processing the library file corresponding to the -- main source file check if this source can be a main unit. if ALIs.Table (ALI).Sfile = Main_Source then Main_Unit := ALIs.Table (ALI).Main_Program /= None; end if; -- The following adds the standard library (s-stalib) to the -- list of files to be handled by gnatmake: this file and any -- files it depends on are always included in every bind, -- except in No_Run_Time mode, even if they are not -- in the explicit dependency list. -- However, to avoid annoying output about s-stalib.ali being -- read only, when "-v" is used, we add the standard library -- only when "-a" is used. if Need_To_Check_Standard_Library then Need_To_Check_Standard_Library := False; if not ALIs.Table (ALI).No_Run_Time then declare Sfile : Name_Id; begin Name_Len := Standard_Library_Package_Body_Name'Length; Name_Buffer (1 .. Name_Len) := Standard_Library_Package_Body_Name; Sfile := Name_Enter; if not Is_Marked (Sfile) then Insert_Q (Sfile); Mark (Sfile); end if; end; end if; end if; -- Now insert in the Q the unmarked source files (i.e. those -- which have neever been inserted in the Q and hence never -- considered). for J in ALIs.Table (ALI).First_Unit .. ALIs.Table (ALI).Last_Unit loop for K in Units.Table (J).First_With .. Units.Table (J).Last_With loop Sfile := Withs.Table (K).Sfile; if Sfile = No_File then Debug_Msg ("Skipping generic:", Withs.Table (K).Uname); elsif Is_Marked (Sfile) then Debug_Msg ("Skipping marked file:", Sfile); elsif not Check_Readonly_Files and then Is_Internal_File_Name (Sfile) then Debug_Msg ("Skipping internal file:", Sfile); else Insert_Q (Sfile, Withs.Table (K).Uname); Mark (Sfile); end if; end loop; end loop; end loop; if Opt.Display_Compilation_Progress then Write_Str ("completed "); Write_Int (Int (Q_Front)); Write_Str (" out of "); Write_Int (Int (Q.Last)); Write_Str (" ("); Write_Int (Int ((Q_Front * 100) / (Q.Last - Q.First))); Write_Str ("%)..."); Write_Eol; end if; end loop Make_Loop; Compilation_Failures := Bad_Compilation_Count; -- Compilation is finished -- Delete any temporary configuration pragma file if Main_Project /= No_Project then declare Success : Boolean; begin for Project in 1 .. Projects.Last loop if Projects.Table (Project).Config_File_Temp then if Opt.Verbose_Mode then Write_Str ("Deleting temp configuration file """); Write_Str (Get_Name_String (Projects.Table (Project).Config_File_Name)); Write_Line (""""); end if; Delete_File (Name => Get_Name_String (Projects.Table (Project).Config_File_Name), Success => Success); -- Make sure that we don't have a config file for this -- project, in case when there are several mains. -- In this case, we will recreate another config file: -- we cannot reuse the one that we just deleted! Projects.Table (Project).Config_Checked := False; Projects.Table (Project).Config_File_Name := No_Name; Projects.Table (Project).Config_File_Temp := False; end if; end loop; end; end if; end Compile_Sources; ------------- -- Display -- ------------- procedure Display (Program : String; Args : Argument_List) is begin pragma Assert (Args'First = 1); if Display_Executed_Programs then Write_Str (Program); for J in Args'Range loop Write_Str (" "); Write_Str (Args (J).all); end loop; Write_Eol; end if; end Display; ---------------------- -- Display_Commands -- ---------------------- procedure Display_Commands (Display : Boolean := True) is begin Display_Executed_Programs := Display; end Display_Commands; ------------- -- Empty_Q -- ------------- function Empty_Q return Boolean is begin if Debug.Debug_Flag_P then Write_Str (" Q := ["); for J in Q_Front .. Q.Last - 1 loop Write_Str (" "); Write_Name (Q.Table (J).File); Write_Eol; Write_Str (" "); end loop; Write_Str ("]"); Write_Eol; end if; return Q_Front >= Q.Last; end Empty_Q; --------------------- -- Extract_Failure -- --------------------- procedure Extract_Failure (File : out File_Name_Type; Unit : out Unit_Name_Type; Found : out Boolean) is begin File := Bad_Compilation.Table (Bad_Compilation.Last).File; Unit := Bad_Compilation.Table (Bad_Compilation.Last).Unit; Found := Bad_Compilation.Table (Bad_Compilation.Last).Found; Bad_Compilation.Decrement_Last; end Extract_Failure; -------------------- -- Extract_From_Q -- -------------------- procedure Extract_From_Q (Source_File : out File_Name_Type; Source_Unit : out Unit_Name_Type) is File : constant File_Name_Type := Q.Table (Q_Front).File; Unit : constant Unit_Name_Type := Q.Table (Q_Front).Unit; begin if Debug.Debug_Flag_Q then Write_Str (" Q := Q - [ "); Write_Name (File); Write_Str (" ]"); Write_Eol; end if; Q_Front := Q_Front + 1; Source_File := File; Source_Unit := Unit; end Extract_From_Q; -------------- -- Gnatmake -- -------------- procedure Gnatmake is Main_Source_File : File_Name_Type; -- The source file containing the main compilation unit Compilation_Failures : Natural; Is_Main_Unit : Boolean; -- Set to True by Compile_Sources if the Main_Source_File can be a -- main unit. Main_ALI_File : File_Name_Type; -- The ali file corresponding to Main_Source_File Executable : File_Name_Type := No_File; -- The file name of an executable Non_Std_Executable : Boolean := False; -- Non_Std_Executable is set to True when there is a possibility -- that the linker will not choose the correct executable file name. Executable_Obsolete : Boolean := False; -- Executable_Obsolete is set to True for the first obsolete main -- and is never reset to False. Any subsequent main will always -- be rebuild (if we rebuild mains), even in the case when it is not -- really necessary, because it is too hard to decide. Mapping_File_Name : Temp_File_Name; -- The name of the temporary mapping file that is copmmunicated -- to the compiler through a -gnatem switch, when using project files. begin Do_Compile_Step := True; Do_Bind_Step := True; Do_Link_Step := True; Make.Initialize; if Hostparm.Java_VM then Gcc := new String'("jgnat"); Gnatbind := new String'("jgnatbind"); Gnatlink := new String '("jgnatlink"); -- Do not check for an object file (".o") when compiling to -- Java bytecode since ".class" files are generated instead. Opt.Check_Object_Consistency := False; end if; if Opt.Verbose_Mode then Write_Eol; Write_Str ("GNATMAKE "); Write_Str (Gnatvsn.Gnat_Version_String); Write_Str (" Copyright 1995-2001 Free Software Foundation, Inc."); Write_Eol; end if; -- If no mains have been specified on the command line, -- and we are using a project file, we either find the main(s) -- in the attribute Main of the main project, or we put all -- the sources of the project file as mains. if Main_Project /= No_Project and then Osint.Number_Of_Files = 0 then Name_Len := 4; Name_Buffer (1 .. 4) := "main"; declare Main_Id : constant Name_Id := Name_Find; Mains : constant Prj.Variable_Value := Prj.Util.Value_Of (Variable_Name => Main_Id, In_Variables => Projects.Table (Main_Project).Decl.Attributes); Value : String_List_Id := Mains.Values; begin -- The attribute Main is an empty list or not specified, -- or else gnatmake was invoked with the switch "-u". if Value = Prj.Nil_String or else Unique_Compile then -- First make sure that the binder and the linker -- will not be invoked. Do_Bind_Step := False; Do_Link_Step := False; -- Put all the sources in the queue Insert_Project_Sources (The_Project => Main_Project, Into_Q => False); else -- The attribute Main is not an empty list. -- Put all the main subprograms in the list as if there were -- specified on the command line. while Value /= Prj.Nil_String loop String_To_Name_Buffer (String_Elements.Table (Value).Value); Osint.Add_File (Name_Buffer (1 .. Name_Len)); Value := String_Elements.Table (Value).Next; end loop; end if; end; end if; -- Output usage information if no files. Note that this can happen -- in the case of a project file that contains only subunits. if Osint.Number_Of_Files = 0 then Makeusg; Exit_Program (E_Fatal); end if; -- If -l was specified behave as if -n was specified if Opt.List_Dependencies then Opt.Do_Not_Execute := True; end if; -- Note that Osint.Next_Main_Source will always return the (possibly -- abbreviated file) without any directory information. Main_Source_File := Next_Main_Source; if Project_File_Name = null then Add_Switch ("-I-", Compiler, And_Save => True); Add_Switch ("-I-", Binder, And_Save => True); if Opt.Look_In_Primary_Dir then Add_Switch ("-I" & Normalize_Directory_Name (Get_Primary_Src_Search_Directory.all).all, Compiler, Append_Switch => False, And_Save => False); Add_Switch ("-aO" & Normalized_CWD, Binder, Append_Switch => False, And_Save => False); end if; end if; -- If the user wants a program without a main subprogram, add the -- appropriate switch to the binder. if Opt.No_Main_Subprogram then Add_Switch ("-z", Binder, And_Save => True); end if; if Main_Project /= No_Project then Change_Dir (Get_Name_String (Projects.Table (Main_Project).Object_Directory)); -- Find the file name of the main unit declare Main_Source_File_Name : constant String := Get_Name_String (Main_Source_File); Main_Unit_File_Name : constant String := Prj.Env.File_Name_Of_Library_Unit_Body (Name => Main_Source_File_Name, Project => Main_Project); The_Packages : constant Package_Id := Projects.Table (Main_Project).Decl.Packages; Gnatmake : constant Prj.Package_Id := Prj.Util.Value_Of (Name => Name_Builder, In_Packages => The_Packages); Binder_Package : constant Prj.Package_Id := Prj.Util.Value_Of (Name => Name_Binder, In_Packages => The_Packages); Linker_Package : constant Prj.Package_Id := Prj.Util.Value_Of (Name => Name_Linker, In_Packages => The_Packages); begin -- We fail if we cannot find the main source file -- as an immediate source of the main project file. if Main_Unit_File_Name = "" then Fail ('"' & Main_Source_File_Name & """ is not a unit of project " & Project_File_Name.all & "."); else -- Remove any directory information from the main -- source file name. declare Pos : Natural := Main_Unit_File_Name'Last; begin loop exit when Pos < Main_Unit_File_Name'First or else Main_Unit_File_Name (Pos) = Directory_Separator; Pos := Pos - 1; end loop; Name_Len := Main_Unit_File_Name'Last - Pos; Name_Buffer (1 .. Name_Len) := Main_Unit_File_Name (Pos + 1 .. Main_Unit_File_Name'Last); Main_Source_File := Name_Find; -- We only output the main source file if there is only one if Opt.Verbose_Mode and then Osint.Number_Of_Files = 1 then Write_Str ("Main source file: """); Write_Str (Main_Unit_File_Name (Pos + 1 .. Main_Unit_File_Name'Last)); Write_Line ("""."); end if; end; end if; -- If there is a package gnatmake in the main project file, add -- the switches from it. We also add the switches from packages -- gnatbind and gnatlink, if any. if Gnatmake /= No_Package then -- If there is only one main, we attempt to get the gnatmake -- switches for this main (if any). If there are no specific -- switch for this particular main, get the general gnatmake -- switches (if any). if Osint.Number_Of_Files = 1 then if Opt.Verbose_Mode then Write_Str ("Adding gnatmake switches for """); Write_Str (Main_Unit_File_Name); Write_Line ("""."); end if; Add_Switches (File_Name => Main_Unit_File_Name, The_Package => Gnatmake, Program => None); else -- If there are several mains, we always get the general -- gnatmake switches (if any). -- Note: As there is never a source with name " ", -- we are guaranteed to always get the gneneral switches. Add_Switches (File_Name => " ", The_Package => Gnatmake, Program => None); end if; end if; if Binder_Package /= No_Package then -- If there is only one main, we attempt to get the gnatbind -- switches for this main (if any). If there are no specific -- switch for this particular main, get the general gnatbind -- switches (if any). if Osint.Number_Of_Files = 1 then if Opt.Verbose_Mode then Write_Str ("Adding binder switches for """); Write_Str (Main_Unit_File_Name); Write_Line ("""."); end if; Add_Switches (File_Name => Main_Unit_File_Name, The_Package => Binder_Package, Program => Binder); else -- If there are several mains, we always get the general -- gnatbind switches (if any). -- Note: As there is never a source with name " ", -- we are guaranteed to always get the gneneral switches. Add_Switches (File_Name => " ", The_Package => Binder_Package, Program => Binder); end if; end if; if Linker_Package /= No_Package then -- If there is only one main, we attempt to get the -- gnatlink switches for this main (if any). If there are -- no specific switch for this particular main, we get the -- general gnatlink switches (if any). if Osint.Number_Of_Files = 1 then if Opt.Verbose_Mode then Write_Str ("Adding linker switches for"""); Write_Str (Main_Unit_File_Name); Write_Line ("""."); end if; Add_Switches (File_Name => Main_Unit_File_Name, The_Package => Linker_Package, Program => Linker); else -- If there are several mains, we always get the general -- gnatlink switches (if any). -- Note: As there is never a source with name " ", -- we are guaranteed to always get the general switches. Add_Switches (File_Name => " ", The_Package => Linker_Package, Program => Linker); end if; end if; end; end if; Display_Commands (not Opt.Quiet_Output); -- We now put in the Binder_Switches and Linker_Switches tables, -- the binder and linker switches of the command line that have been -- put in the Saved_ tables. If a project file was used, then the -- command line switches will follow the project file switches. for J in 1 .. Saved_Binder_Switches.Last loop Add_Switch (Saved_Binder_Switches.Table (J), Binder, And_Save => False); end loop; for J in 1 .. Saved_Linker_Switches.Last loop Add_Switch (Saved_Linker_Switches.Table (J), Linker, And_Save => False); end loop; -- If no project file is used, we just put the gcc switches -- from the command line in the Gcc_Switches table. if Main_Project = No_Project then for J in 1 .. Saved_Gcc_Switches.Last loop Add_Switch (Saved_Gcc_Switches.Table (J), Compiler, And_Save => False); end loop; else -- And we put the command line gcc switches in the variable -- The_Saved_Gcc_Switches. They are going to be used later -- in procedure Compile_Sources. The_Saved_Gcc_Switches := new Argument_List (1 .. Saved_Gcc_Switches.Last + 2); for J in 1 .. Saved_Gcc_Switches.Last loop The_Saved_Gcc_Switches (J) := Saved_Gcc_Switches.Table (J); Test_If_Relative_Path (The_Saved_Gcc_Switches (J)); end loop; -- We never use gnat.adc when a project file is used The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last - 1) := No_gnat_adc; -- Create a temporary mapping file and add the switch -gnatem -- with its name to the compiler. Prj.Env.Create_Mapping_File (Name => Mapping_File_Name); The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last) := new String'("-gnatem" & Mapping_File_Name); -- Check if there are any relative search paths in the switches. -- Fail if there is one. for J in 1 .. Gcc_Switches.Last loop Test_If_Relative_Path (Gcc_Switches.Table (J)); end loop; for J in 1 .. Binder_Switches.Last loop Test_If_Relative_Path (Binder_Switches.Table (J)); end loop; for J in 1 .. Linker_Switches.Last loop Test_If_Relative_Path (Linker_Switches.Table (J)); end loop; end if; -- If there was a --GCC, --GNATBIND or --GNATLINK switch on -- the command line, then we have to use it, even if there was -- another switch in the project file. if Saved_Gcc /= null then Gcc := Saved_Gcc; end if; if Saved_Gnatbind /= null then Gnatbind := Saved_Gnatbind; end if; if Saved_Gnatlink /= null then Gnatlink := Saved_Gnatlink; end if; Gcc_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all); Gnatbind_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all); Gnatlink_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all); -- If we have specified -j switch both from the project file -- and on the command line, the one from the command line takes -- precedence. if Saved_Maximum_Processes = 0 then Saved_Maximum_Processes := Opt.Maximum_Processes; end if; -- If either -c, -b or -l has been specified, we will not necessarily -- execute all steps. if Compile_Only or else Bind_Only or else Link_Only then Do_Compile_Step := Do_Compile_Step and Compile_Only; Do_Bind_Step := Do_Bind_Step and Bind_Only; Do_Link_Step := Do_Link_Step and Link_Only; -- If -c has been specified, but not -b, ignore any potential -l if Do_Compile_Step and then not Do_Bind_Step then Do_Link_Step := False; end if; end if; -- Here is where the make process is started -- We do the same process for each main Multiple_Main_Loop : for N_File in 1 .. Osint.Number_Of_Files loop if Do_Compile_Step then Recursive_Compilation_Step : declare Args : Argument_List (1 .. Gcc_Switches.Last); First_Compiled_File : Name_Id; Youngest_Obj_File : Name_Id; Youngest_Obj_Stamp : Time_Stamp_Type; Executable_Stamp : Time_Stamp_Type; -- Executable is the final executable program. begin Executable := No_File; Non_Std_Executable := False; for J in 1 .. Gcc_Switches.Last loop Args (J) := Gcc_Switches.Table (J); end loop; -- Look inside the linker switches to see if the name -- of the final executable program was specified. for J in reverse Linker_Switches.First .. Linker_Switches.Last loop if Linker_Switches.Table (J).all = Output_Flag.all then pragma Assert (J < Linker_Switches.Last); -- We cannot specify a single executable for several -- main subprograms! if Osint.Number_Of_Files > 1 then Fail ("cannot specify a single executable " & "for several mains"); end if; Name_Len := Linker_Switches.Table (J + 1)'Length; Name_Buffer (1 .. Name_Len) := Linker_Switches.Table (J + 1).all; -- If target has an executable suffix and it has not been -- specified then it is added here. if Executable_Suffix'Length /= 0 and then Linker_Switches.Table (J + 1) (Name_Len - Executable_Suffix'Length + 1 .. Name_Len) /= Executable_Suffix then Name_Buffer (Name_Len + 1 .. Name_Len + Executable_Suffix'Length) := Executable_Suffix; Name_Len := Name_Len + Executable_Suffix'Length; end if; Executable := Name_Enter; Verbose_Msg (Executable, "final executable"); end if; end loop; -- If the name of the final executable program was not -- specified then construct it from the main input file. if Executable = No_File then if Main_Project = No_Project then Executable := Executable_Name (Strip_Suffix (Main_Source_File)); else -- If we are using a project file, we attempt to -- remove the body (or spec) termination of the main -- subprogram. We find it the the naming scheme of the -- project file. This will avoid to generate an -- executable "main.2" for a main subprogram -- "main.2.ada", when the body termination is ".2.ada". declare Body_Append : constant String := Get_Name_String (Projects.Table (Main_Project). Naming.Current_Impl_Suffix); Spec_Append : constant String := Get_Name_String (Projects.Table (Main_Project). Naming.Current_Spec_Suffix); begin Get_Name_String (Main_Source_File); if Name_Len > Body_Append'Length and then Name_Buffer (Name_Len - Body_Append'Length + 1 .. Name_Len) = Body_Append then -- We have found the body termination. We remove it -- add the executable termination, if any. Name_Len := Name_Len - Body_Append'Length; Executable := Executable_Name (Name_Find); elsif Name_Len > Spec_Append'Length and then Name_Buffer (Name_Len - Spec_Append'Length + 1 .. Name_Len) = Spec_Append then -- We have found the spec termination. We remove -- it, add the executable termination, if any. Name_Len := Name_Len - Spec_Append'Length; Executable := Executable_Name (Name_Find); else Executable := Executable_Name (Strip_Suffix (Main_Source_File)); end if; end; end if; end if; if Main_Project /= No_Project then declare Exec_File_Name : constant String := Get_Name_String (Executable); begin if not Is_Absolute_Path (Exec_File_Name) then for Index in Exec_File_Name'Range loop if Exec_File_Name (Index) = Directory_Separator then Fail ("relative executable (""" & Exec_File_Name & """) with directory part not allowed " & "when using project files"); end if; end loop; Get_Name_String (Projects.Table (Main_Project).Exec_Directory); if Name_Buffer (Name_Len) /= Directory_Separator then Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Directory_Separator; end if; Name_Buffer (Name_Len + 1 .. Name_Len + Exec_File_Name'Length) := Exec_File_Name; Name_Len := Name_Len + Exec_File_Name'Length; Executable := Name_Find; Non_Std_Executable := True; end if; end; end if; -- Now we invoke Compile_Sources for the current main Compile_Sources (Main_Source => Main_Source_File, Args => Args, First_Compiled_File => First_Compiled_File, Most_Recent_Obj_File => Youngest_Obj_File, Most_Recent_Obj_Stamp => Youngest_Obj_Stamp, Main_Unit => Is_Main_Unit, Compilation_Failures => Compilation_Failures, Check_Readonly_Files => Opt.Check_Readonly_Files, Do_Not_Execute => Opt.Do_Not_Execute, Force_Compilations => Opt.Force_Compilations, In_Place_Mode => Opt.In_Place_Mode, Keep_Going => Opt.Keep_Going, Initialize_ALI_Data => True, Max_Process => Saved_Maximum_Processes); if Opt.Verbose_Mode then Write_Str ("End of compilation"); Write_Eol; end if; if Compilation_Failures /= 0 then List_Bad_Compilations; raise Compilation_Failed; end if; -- Regenerate libraries, if any and if object files -- have been regenerated if Main_Project /= No_Project and then MLib.Tgt.Libraries_Are_Supported then for Proj in Projects.First .. Projects.Last loop if Proj /= Main_Project and then Projects.Table (Proj).Flag1 then MLib.Prj.Build_Library (For_Project => Proj); end if; end loop; end if; if Opt.List_Dependencies then if First_Compiled_File /= No_File then Inform (First_Compiled_File, "must be recompiled. Can't generate dependence list."); else List_Depend; end if; elsif First_Compiled_File = No_File and then not Do_Bind_Step and then not Opt.Quiet_Output and then Osint.Number_Of_Files = 1 then if Unique_Compile then Inform (Msg => "object up to date."); else Inform (Msg => "objects up to date."); end if; elsif Opt.Do_Not_Execute and then First_Compiled_File /= No_File then Write_Name (First_Compiled_File); Write_Eol; end if; -- Stop after compile step if any of: -- 1) -n (Do_Not_Execute) specified -- 2) -l (List_Dependencies) specified (also sets -- Do_Not_Execute above, so this is probably superfluous). -- 3) -c (Compile_Only) specified, but not -b (Bind_Only) -- 4) Made unit cannot be a main unit if (Opt.Do_Not_Execute or Opt.List_Dependencies or not Do_Bind_Step or not Is_Main_Unit) and then not No_Main_Subprogram then if Osint.Number_Of_Files = 1 then exit Multiple_Main_Loop; else goto Next_Main; end if; end if; -- If the objects were up-to-date check if the executable file -- is also up-to-date. For now always bind and link on the JVM -- since there is currently no simple way to check the -- up-to-date status of objects if not Hostparm.Java_VM and then First_Compiled_File = No_File then Executable_Stamp := File_Stamp (Executable); -- Once Executable_Obsolete is set to True, it is never -- reset to False, because it is too hard to accurately -- decide if a subsequent main need to be rebuilt or not. Executable_Obsolete := Executable_Obsolete or else Youngest_Obj_Stamp > Executable_Stamp; if not Executable_Obsolete then -- If no Ada object files obsolete the executable, check -- for younger or missing linker files. Check_Linker_Options (Executable_Stamp, Youngest_Obj_File, Youngest_Obj_Stamp); Executable_Obsolete := Youngest_Obj_File /= No_File; end if; -- Return if the executable is up to date -- and otherwise motivate the relink/rebind. if not Executable_Obsolete then if not Opt.Quiet_Output then Inform (Executable, "up to date."); end if; if Osint.Number_Of_Files = 1 then exit Multiple_Main_Loop; else goto Next_Main; end if; end if; if Executable_Stamp (1) = ' ' then Verbose_Msg (Executable, "missing.", Prefix => " "); elsif Youngest_Obj_Stamp (1) = ' ' then Verbose_Msg (Youngest_Obj_File, "missing.", Prefix => " "); elsif Youngest_Obj_Stamp > Executable_Stamp then Verbose_Msg (Youngest_Obj_File, "(" & String (Youngest_Obj_Stamp) & ") newer than", Executable, "(" & String (Executable_Stamp) & ")"); else Verbose_Msg (Executable, "needs to be rebuild.", Prefix => " "); end if; end if; end Recursive_Compilation_Step; end if; -- If we are here, it means that we need to rebuilt the current -- main. So we set Executable_Obsolete to True to make sure that -- the subsequent mains will be rebuilt. Executable_Obsolete := True; Main_ALI_In_Place_Mode_Step : declare ALI_File : File_Name_Type; Src_File : File_Name_Type; begin Src_File := Strip_Directory (Main_Source_File); ALI_File := Lib_File_Name (Src_File); Main_ALI_File := Full_Lib_File_Name (ALI_File); -- When In_Place_Mode, the library file can be located in the -- Main_Source_File directory which may not be present in the -- library path. In this case, use the corresponding library file -- name. if Main_ALI_File = No_File and then Opt.In_Place_Mode then Get_Name_String (Get_Directory (Full_Source_Name (Src_File))); Get_Name_String_And_Append (ALI_File); Main_ALI_File := Name_Find; Main_ALI_File := Full_Lib_File_Name (Main_ALI_File); end if; if Main_ALI_File = No_File then Fail ("could not find the main ALI file"); end if; end Main_ALI_In_Place_Mode_Step; if Do_Bind_Step then Bind_Step : declare Args : Argument_List (Binder_Switches.First .. Binder_Switches.Last); begin -- Get all the binder switches for J in Binder_Switches.First .. Binder_Switches.Last loop Args (J) := Binder_Switches.Table (J); end loop; if Main_Project /= No_Project then -- Put all the source directories in ADA_INCLUDE_PATH, -- and all the object directories in ADA_OBJECTS_PATH Set_Ada_Paths (Main_Project, False); end if; Bind (Main_ALI_File, Args); end Bind_Step; end if; if Do_Link_Step then Link_Step : declare There_Are_Libraries : Boolean := False; Linker_Switches_Last : constant Integer := Linker_Switches.Last; begin if Main_Project /= No_Project then if MLib.Tgt.Libraries_Are_Supported then Set_Libraries (Main_Project, There_Are_Libraries); end if; if There_Are_Libraries then -- Add -L<lib_dir> -lgnarl -lgnat -Wl,-rpath,<lib_dir> Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := new String'("-L" & MLib.Utl.Lib_Directory); Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := new String'("-lgnarl"); Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := new String'("-lgnat"); declare Option : constant String_Access := MLib.Tgt.Linker_Library_Path_Option (MLib.Utl.Lib_Directory); begin if Option /= null then Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := Option; end if; end; end if; -- Put the object directories in ADA_OBJECTS_PATH Set_Ada_Paths (Main_Project, False); end if; declare Args : Argument_List (Linker_Switches.First .. Linker_Switches.Last + 2); Last_Arg : Integer := Linker_Switches.First - 1; Skip : Boolean := False; begin -- Get all the linker switches for J in Linker_Switches.First .. Linker_Switches.Last loop if Skip then Skip := False; elsif Non_Std_Executable and then Linker_Switches.Table (J).all = "-o" then Skip := True; else Last_Arg := Last_Arg + 1; Args (Last_Arg) := Linker_Switches.Table (J); end if; end loop; -- And invoke the linker if Non_Std_Executable then Last_Arg := Last_Arg + 1; Args (Last_Arg) := new String'("-o"); Last_Arg := Last_Arg + 1; Args (Last_Arg) := new String'(Get_Name_String (Executable)); Link (Main_ALI_File, Args (Args'First .. Last_Arg)); else Link (Main_ALI_File, Args (Args'First .. Last_Arg)); end if; end; Linker_Switches.Set_Last (Linker_Switches_Last); end Link_Step; end if; -- We go to here when we skip the bind and link steps. <<Next_Main>> -- We go to the next main, if we did not process the last one if N_File < Osint.Number_Of_Files then Main_Source_File := Next_Main_Source; if Main_Project /= No_Project then -- Find the file name of the main unit declare Main_Source_File_Name : constant String := Get_Name_String (Main_Source_File); Main_Unit_File_Name : constant String := Prj.Env. File_Name_Of_Library_Unit_Body (Name => Main_Source_File_Name, Project => Main_Project); begin -- We fail if we cannot find the main source file -- as an immediate source of the main project file. if Main_Unit_File_Name = "" then Fail ('"' & Main_Source_File_Name & """ is not a unit of project " & Project_File_Name.all & "."); else -- Remove any directory information from the main -- source file name. declare Pos : Natural := Main_Unit_File_Name'Last; begin loop exit when Pos < Main_Unit_File_Name'First or else Main_Unit_File_Name (Pos) = Directory_Separator; Pos := Pos - 1; end loop; Name_Len := Main_Unit_File_Name'Last - Pos; Name_Buffer (1 .. Name_Len) := Main_Unit_File_Name (Pos + 1 .. Main_Unit_File_Name'Last); Main_Source_File := Name_Find; end; end if; end; end if; end if; end loop Multiple_Main_Loop; -- Delete the temporary mapping file that was created if we are -- using project files. if Main_Project /= No_Project then declare Success : Boolean; begin Delete_File (Name => Mapping_File_Name, Success => Success); end; end if; Exit_Program (E_Success); exception when Bind_Failed => Osint.Fail ("*** bind failed."); when Compilation_Failed => Exit_Program (E_Fatal); when Link_Failed => Osint.Fail ("*** link failed."); when X : others => Write_Line (Exception_Information (X)); Osint.Fail ("INTERNAL ERROR. Please report."); end Gnatmake; -------------------- -- In_Ada_Lib_Dir -- -------------------- function In_Ada_Lib_Dir (File : File_Name_Type) return Boolean is D : constant Name_Id := Get_Directory (File); B : constant Byte := Get_Name_Table_Byte (D); begin return (B and Ada_Lib_Dir) /= 0; end In_Ada_Lib_Dir; ------------ -- Inform -- ------------ procedure Inform (N : Name_Id := No_Name; Msg : String) is begin Osint.Write_Program_Name; Write_Str (": "); if N /= No_Name then Write_Str (""""); Write_Name (N); Write_Str (""" "); end if; Write_Str (Msg); Write_Eol; end Inform; ------------ -- Init_Q -- ------------ procedure Init_Q is begin First_Q_Initialization := False; Q_Front := Q.First; Q.Set_Last (Q.First); end Init_Q; ---------------- -- Initialize -- ---------------- procedure Initialize is Next_Arg : Positive; begin -- Override default initialization of Check_Object_Consistency -- since this is normally False for GNATBIND, but is True for -- GNATMAKE since we do not need to check source consistency -- again once GNATMAKE has looked at the sources to check. Opt.Check_Object_Consistency := True; -- Package initializations. The order of calls is important here. Output.Set_Standard_Error; Osint.Initialize (Osint.Make); Gcc_Switches.Init; Binder_Switches.Init; Linker_Switches.Init; Csets.Initialize; Namet.Initialize; Snames.Initialize; Prj.Initialize; Next_Arg := 1; Scan_Args : while Next_Arg <= Argument_Count loop Scan_Make_Arg (Argument (Next_Arg), And_Save => True); Next_Arg := Next_Arg + 1; end loop Scan_Args; if Usage_Requested then Makeusg; end if; -- Test for trailing -o switch if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then Fail ("output file name missing after -o"); end if; if Project_File_Name /= null then -- A project file was specified by a -P switch if Opt.Verbose_Mode then Write_Eol; Write_Str ("Parsing Project File """); Write_Str (Project_File_Name.all); Write_Str ("""."); Write_Eol; end if; -- Avoid looking in the current directory for ALI files -- Opt.Look_In_Primary_Dir := False; -- Set the project parsing verbosity to whatever was specified -- by a possible -vP switch. Prj.Pars.Set_Verbosity (To => Current_Verbosity); -- Parse the project file. -- If there is an error, Main_Project will still be No_Project. Prj.Pars.Parse (Project => Main_Project, Project_File_Name => Project_File_Name.all); if Main_Project = No_Project then Fail ("""" & Project_File_Name.all & """ processing failed"); end if; if Opt.Verbose_Mode then Write_Eol; Write_Str ("Parsing of Project File """); Write_Str (Project_File_Name.all); Write_Str (""" is finished."); Write_Eol; end if; -- We add the source directories and the object directories -- to the search paths. Add_Source_Directories (Main_Project); Add_Object_Directories (Main_Project); end if; Osint.Add_Default_Search_Dirs; -- Mark the GNAT libraries if needed. -- Source file lookups should be cached for efficiency. -- Source files are not supposed to change. Osint.Source_File_Data (Cache => True); -- Read gnat.adc file to initialize Fname.UF Fname.UF.Initialize; begin Fname.SF.Read_Source_File_Name_Pragmas; exception when Err : SFN_Scan.Syntax_Error_In_GNAT_ADC => Osint.Fail (Exception_Message (Err)); end; end Initialize; ----------------------------------- -- Insert_Project_Sources_Into_Q -- ----------------------------------- procedure Insert_Project_Sources (The_Project : Project_Id; Into_Q : Boolean) is Unit : Com.Unit_Data; Sfile : Name_Id; begin -- For all the sources in the project files, for Id in Com.Units.First .. Com.Units.Last loop Unit := Com.Units.Table (Id); Sfile := No_Name; -- If there is a source for the body, if Unit.File_Names (Com.Body_Part).Name /= No_Name then -- And it is a source of the specified project if Unit.File_Names (Com.Body_Part).Project = The_Project then -- If we don't have a spec, we cannot consider the source -- if it is a subunit if Unit.File_Names (Com.Specification).Name = No_Name then declare Src_Ind : Source_File_Index; begin Src_Ind := Sinput.L.Load_Source_File (Unit.File_Names (Com.Body_Part).Name); -- If it is a subunit, discard it if Sinput.L.Source_File_Is_Subunit (Src_Ind) then Sfile := No_Name; else Sfile := Unit.File_Names (Com.Body_Part).Name; end if; end; else Sfile := Unit.File_Names (Com.Body_Part).Name; end if; end if; elsif Unit.File_Names (Com.Specification).Name /= No_Name and then Unit.File_Names (Com.Specification).Project = The_Project then -- If there is no source for the body, but there is a source -- for the spec, then we take this one. Sfile := Unit.File_Names (Com.Specification).Name; end if; -- If Into_Q is True, we insert into the Q if Into_Q then -- For the first source inserted into the Q, we need -- to initialize the Q, but not for the subsequent sources. if First_Q_Initialization then Init_Q; end if; -- And of course, we only insert in the Q if the source -- is not marked. if Sfile /= No_Name and then not Is_Marked (Sfile) then Insert_Q (Sfile); Mark (Sfile); end if; elsif Sfile /= No_Name then -- If Into_Q is False, we add the source as it it were -- specified on the command line. Osint.Add_File (Get_Name_String (Sfile)); end if; end loop; end Insert_Project_Sources; -------------- -- Insert_Q -- -------------- procedure Insert_Q (Source_File : File_Name_Type; Source_Unit : Unit_Name_Type := No_Name) is begin if Debug.Debug_Flag_Q then Write_Str (" Q := Q + [ "); Write_Name (Source_File); Write_Str (" ] "); Write_Eol; end if; Q.Table (Q.Last).File := Source_File; Q.Table (Q.Last).Unit := Source_Unit; Q.Increment_Last; end Insert_Q; ---------------------------- -- Is_External_Assignment -- ---------------------------- function Is_External_Assignment (Argv : String) return Boolean is Start : Positive := 3; Finish : Natural := Argv'Last; Equal_Pos : Natural; begin if Argv'Last < 5 then return False; elsif Argv (3) = '"' then if Argv (Argv'Last) /= '"' or else Argv'Last < 7 then return False; else Start := 4; Finish := Argv'Last - 1; end if; end if; Equal_Pos := Start; while Equal_Pos <= Finish and then Argv (Equal_Pos) /= '=' loop Equal_Pos := Equal_Pos + 1; end loop; if Equal_Pos = Start or else Equal_Pos >= Finish then return False; else Prj.Ext.Add (External_Name => Argv (Start .. Equal_Pos - 1), Value => Argv (Equal_Pos + 1 .. Finish)); return True; end if; end Is_External_Assignment; --------------- -- Is_Marked -- --------------- function Is_Marked (Source_File : File_Name_Type) return Boolean is begin return Get_Name_Table_Byte (Source_File) /= 0; end Is_Marked; ---------- -- Link -- ---------- procedure Link (ALI_File : File_Name_Type; Args : Argument_List) is Link_Args : Argument_List (Args'First .. Args'Last + 1); Success : Boolean; begin Link_Args (Args'Range) := Args; Get_Name_String (ALI_File); Link_Args (Args'Last + 1) := new String'(Name_Buffer (1 .. Name_Len)); Display (Gnatlink.all, Link_Args); if Gnatlink_Path = null then Osint.Fail ("error, unable to locate " & Gnatlink.all); end if; GNAT.OS_Lib.Spawn (Gnatlink_Path.all, Link_Args, Success); if not Success then raise Link_Failed; end if; end Link; --------------------------- -- List_Bad_Compilations -- --------------------------- procedure List_Bad_Compilations is begin for J in Bad_Compilation.First .. Bad_Compilation.Last loop if Bad_Compilation.Table (J).File = No_File then null; elsif not Bad_Compilation.Table (J).Found then Inform (Bad_Compilation.Table (J).File, "not found"); else Inform (Bad_Compilation.Table (J).File, "compilation error"); end if; end loop; end List_Bad_Compilations; ----------------- -- List_Depend -- ----------------- procedure List_Depend is Lib_Name : Name_Id; Obj_Name : Name_Id; Src_Name : Name_Id; Len : Natural; Line_Pos : Natural; Line_Size : constant := 77; begin Set_Standard_Output; for A in ALIs.First .. ALIs.Last loop Lib_Name := ALIs.Table (A).Afile; -- We have to provide the full library file name in In_Place_Mode if Opt.In_Place_Mode then Lib_Name := Full_Lib_File_Name (Lib_Name); end if; Obj_Name := Object_File_Name (Lib_Name); Write_Name (Obj_Name); Write_Str (" :"); Get_Name_String (Obj_Name); Len := Name_Len; Line_Pos := Len + 2; for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop Src_Name := Sdep.Table (D).Sfile; if Is_Internal_File_Name (Src_Name) and then not Check_Readonly_Files then null; else if not Opt.Quiet_Output then Src_Name := Full_Source_Name (Src_Name); end if; Get_Name_String (Src_Name); Len := Name_Len; if Line_Pos + Len + 1 > Line_Size then Write_Str (" \"); Write_Eol; Line_Pos := 0; end if; Line_Pos := Line_Pos + Len + 1; Write_Str (" "); Write_Name (Src_Name); end if; end loop; Write_Eol; end loop; Set_Standard_Error; end List_Depend; ---------- -- Mark -- ---------- procedure Mark (Source_File : File_Name_Type) is begin Set_Name_Table_Byte (Source_File, 1); end Mark; ------------------- -- Mark_Dir_Path -- ------------------- procedure Mark_Dir_Path (Path : String_Access; Mark : Lib_Mark_Type) is Dir : String_Access; begin if Path /= null then Osint.Get_Next_Dir_In_Path_Init (Path); loop Dir := Osint.Get_Next_Dir_In_Path (Path); exit when Dir = null; Mark_Directory (Dir.all, Mark); end loop; end if; end Mark_Dir_Path; -------------------- -- Mark_Directory -- -------------------- procedure Mark_Directory (Dir : String; Mark : Lib_Mark_Type) is N : Name_Id; B : Byte; begin -- Dir last character is supposed to be a directory separator. Name_Len := Dir'Length; Name_Buffer (1 .. Name_Len) := Dir; if not Is_Directory_Separator (Name_Buffer (Name_Len)) then Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Directory_Separator; end if; -- Add flags to the already existing flags N := Name_Find; B := Get_Name_Table_Byte (N); Set_Name_Table_Byte (N, B or Mark); end Mark_Directory; ---------------------- -- Object_File_Name -- ---------------------- function Object_File_Name (Source : String) return String is Pos : Natural := Source'Last; begin while Pos >= Source'First and then Source (Pos) /= '.' loop Pos := Pos - 1; end loop; if Pos >= Source'First then Pos := Pos - 1; end if; return Source (Source'First .. Pos) & Object_Suffix; end Object_File_Name; ------------------- -- Scan_Make_Arg -- ------------------- procedure Scan_Make_Arg (Argv : String; And_Save : Boolean) is begin pragma Assert (Argv'First = 1); if Argv'Length = 0 then return; end if; -- If the previous switch has set the Output_File_Name_Present -- flag (that is we have seen a -o), then the next argument is -- the name of the output executable. if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then Output_File_Name_Seen := True; if Argv (1) = Switch_Character or else Argv (1) = '-' then Fail ("output file name missing after -o"); else Add_Switch ("-o", Linker, And_Save => And_Save); -- Automatically add the executable suffix if it has not been -- specified explicitly. if Executable_Suffix'Length /= 0 and then Argv (Argv'Last - Executable_Suffix'Length + 1 .. Argv'Last) /= Executable_Suffix then Add_Switch (Argv & Executable_Suffix, Linker, And_Save => And_Save); else Add_Switch (Argv, Linker, And_Save => And_Save); end if; end if; -- Then check if we are dealing with a -cargs, -bargs or -largs elsif (Argv (1) = Switch_Character or else Argv (1) = '-') and then (Argv (2 .. Argv'Last) = "cargs" or else Argv (2 .. Argv'Last) = "bargs" or else Argv (2 .. Argv'Last) = "largs" or else Argv (2 .. Argv'Last) = "margs") then case Argv (2) is when 'c' => Program_Args := Compiler; when 'b' => Program_Args := Binder; when 'l' => Program_Args := Linker; when 'm' => Program_Args := None; when others => raise Program_Error; end case; -- A special test is needed for the -o switch within a -largs -- since that is another way to specify the name of the final -- executable. elsif Program_Args = Linker and then (Argv (1) = Switch_Character or else Argv (1) = '-') and then Argv (2 .. Argv'Last) = "o" then Fail ("switch -o not allowed within a -largs. Use -o directly."); -- Check to see if we are reading switches after a -cargs, -- -bargs or -largs switch. If yes save it. elsif Program_Args /= None then -- Check to see if we are reading -I switches in order -- to take into account in the src & lib search directories. if Argv'Length > 2 and then Argv (1 .. 2) = "-I" then if Argv (3 .. Argv'Last) = "-" then Opt.Look_In_Primary_Dir := False; elsif Program_Args = Compiler then if Argv (3 .. Argv'Last) /= "-" then Add_Src_Search_Dir (Argv (3 .. Argv'Last)); end if; elsif Program_Args = Binder then Add_Lib_Search_Dir (Argv (3 .. Argv'Last)); end if; end if; Add_Switch (Argv, Program_Args, And_Save => And_Save); -- Handle non-default compiler, binder, linker elsif Argv'Length > 2 and then Argv (1 .. 2) = "--" then if Argv'Length > 6 and then Argv (1 .. 6) = "--GCC=" then declare Program_Args : Argument_List_Access := Argument_String_To_List (Argv (7 .. Argv'Last)); begin if And_Save then Saved_Gcc := new String'(Program_Args.all (1).all); else Gcc := new String'(Program_Args.all (1).all); end if; for J in 2 .. Program_Args.all'Last loop Add_Switch (Program_Args.all (J).all, Compiler, And_Save => And_Save); end loop; end; elsif Argv'Length > 11 and then Argv (1 .. 11) = "--GNATBIND=" then declare Program_Args : Argument_List_Access := Argument_String_To_List (Argv (12 .. Argv'Last)); begin if And_Save then Saved_Gnatbind := new String'(Program_Args.all (1).all); else Gnatbind := new String'(Program_Args.all (1).all); end if; for J in 2 .. Program_Args.all'Last loop Add_Switch (Program_Args.all (J).all, Binder, And_Save => And_Save); end loop; end; elsif Argv'Length > 11 and then Argv (1 .. 11) = "--GNATLINK=" then declare Program_Args : Argument_List_Access := Argument_String_To_List (Argv (12 .. Argv'Last)); begin if And_Save then Saved_Gnatlink := new String'(Program_Args.all (1).all); else Gnatlink := new String'(Program_Args.all (1).all); end if; for J in 2 .. Program_Args.all'Last loop Add_Switch (Program_Args.all (J).all, Linker); end loop; end; else Fail ("unknown switch: ", Argv); end if; -- If we have seen a regular switch process it elsif Argv (1) = Switch_Character or else Argv (1) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); -- -I- elsif Argv (2 .. Argv'Last) = "I-" then Opt.Look_In_Primary_Dir := False; -- Forbid -?- or -??- where ? is any character elsif (Argv'Length = 3 and then Argv (3) = '-') or else (Argv'Length = 4 and then Argv (4) = '-') then Fail ("trailing ""-"" at the end of ", Argv, " forbidden."); -- -Idir elsif Argv (2) = 'I' then Add_Src_Search_Dir (Argv (3 .. Argv'Last)); Add_Lib_Search_Dir (Argv (3 .. Argv'Last)); Add_Switch (Argv, Compiler, And_Save => And_Save); Add_Switch ("-aO" & Argv (3 .. Argv'Last), Binder, And_Save => And_Save); -- No need to pass any source dir to the binder -- since gnatmake call it with the -x flag -- (ie do not check source time stamp) -- -aIdir (to gcc this is like a -I switch) elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aI" then Add_Src_Search_Dir (Argv (4 .. Argv'Last)); Add_Switch ("-I" & Argv (4 .. Argv'Last), Compiler, And_Save => And_Save); -- -aOdir elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aO" then Add_Lib_Search_Dir (Argv (4 .. Argv'Last)); Add_Switch (Argv, Binder, And_Save => And_Save); -- -aLdir (to gnatbind this is like a -aO switch) elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aL" then Mark_Directory (Argv (4 .. Argv'Last), Ada_Lib_Dir); Add_Lib_Search_Dir (Argv (4 .. Argv'Last)); Add_Switch ("-aO" & Argv (4 .. Argv'Last), Binder, And_Save => And_Save); -- -Adir (to gnatbind this is like a -aO switch, to gcc like a -I) elsif Argv (2) = 'A' then Mark_Directory (Argv (3 .. Argv'Last), Ada_Lib_Dir); Add_Src_Search_Dir (Argv (3 .. Argv'Last)); Add_Lib_Search_Dir (Argv (3 .. Argv'Last)); Add_Switch ("-I" & Argv (3 .. Argv'Last), Compiler, And_Save => And_Save); Add_Switch ("-aO" & Argv (3 .. Argv'Last), Binder, And_Save => And_Save); -- -Ldir elsif Argv (2) = 'L' then Add_Switch (Argv, Linker, And_Save => And_Save); -- For -gxxxxx,-pg : give the switch to both the compiler and the -- linker (except for -gnatxxx which is only for the compiler) elsif (Argv (2) = 'g' and then (Argv'Last < 5 or else Argv (2 .. 5) /= "gnat")) or else Argv (2 .. Argv'Last) = "pg" then Add_Switch (Argv, Compiler, And_Save => And_Save); Add_Switch (Argv, Linker, And_Save => And_Save); -- -d elsif Argv (2) = 'd' and then Argv'Last = 2 then Opt.Display_Compilation_Progress := True; -- -j (need to save the result) elsif Argv (2) = 'j' then Scan_Make_Switches (Argv); if And_Save then Saved_Maximum_Processes := Maximum_Processes; end if; -- -m elsif Argv (2) = 'm' and then Argv'Last = 2 then Opt.Minimal_Recompilation := True; -- -u elsif Argv (2) = 'u' and then Argv'Last = 2 then Unique_Compile := True; Opt.Compile_Only := True; Do_Bind_Step := False; Do_Link_Step := False; -- -Pprj (only once, and only on the command line) elsif Argv'Last > 2 and then Argv (2) = 'P' then if Project_File_Name /= null then Fail ("cannot have several project files specified"); elsif not And_Save then -- It could be a tool other than gnatmake (i.e, gnatdist) -- or a -P switch inside a project file. Fail ("either the tool is not ""project-aware"" or " & "a project file is specified inside a project file"); else Project_File_Name := new String' (Argv (3 .. Argv'Last)); end if; -- -S (Assemble) -- Since no object file is created, don't check object -- consistency. elsif Argv (2) = 'S' and then Argv'Last = 2 then Opt.Check_Object_Consistency := False; Add_Switch (Argv, Compiler, And_Save => And_Save); -- -vPx (verbosity of the parsing of the project files) elsif Argv'Last = 4 and then Argv (2 .. 3) = "vP" and then Argv (4) in '0' .. '2' then if And_Save then case Argv (4) is when '0' => Current_Verbosity := Prj.Default; when '1' => Current_Verbosity := Prj.Medium; when '2' => Current_Verbosity := Prj.High; when others => null; end case; end if; -- -Wx (need to save the result) elsif Argv (2) = 'W' then Scan_Make_Switches (Argv); if And_Save then Saved_WC_Encoding_Method := Wide_Character_Encoding_Method; Saved_WC_Encoding_Method_Set := True; end if; -- -Xext=val (External assignment) elsif Argv (2) = 'X' and then Is_External_Assignment (Argv) then -- Is_External_Assignment has side effects -- when it returns True; null; -- If -gnath is present, then generate the usage information -- right now for the compiler, and do not pass this option -- on to the compiler calls. elsif Argv = "-gnath" then null; -- If -gnatc is specified, make sure the bind step and the link -- step are not executed. elsif Argv'Length >= 6 and then Argv (2 .. 6) = "gnatc" then -- If -gnatc is specified, make sure the bind step and the link -- step are not executed. Add_Switch (Argv, Compiler, And_Save => And_Save); Opt.Operating_Mode := Opt.Check_Semantics; Opt.Check_Object_Consistency := False; Opt.Compile_Only := True; Do_Bind_Step := False; Do_Link_Step := False; elsif Argv (2 .. Argv'Last) = "nostdlib" then -- Don't pass -nostdlib to gnatlink, it will disable -- linking with all standard library files. Opt.No_Stdlib := True; Add_Switch (Argv, Binder, And_Save => And_Save); elsif Argv (2 .. Argv'Last) = "nostdinc" then -- Pass -nostdinv to the Compiler and to gnatbind Opt.No_Stdinc := True; Add_Switch (Argv, Compiler, And_Save => And_Save); Add_Switch (Argv, Binder, And_Save => And_Save); -- By default all switches with more than one character -- or one character switches which are not in 'a' .. 'z' -- (except 'M') are passed to the compiler, unless we are dealing -- with a debug switch (starts with 'd') elsif Argv (2) /= 'd' and then Argv (2 .. Argv'Last) /= "M" and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z') then Add_Switch (Argv, Compiler, And_Save => And_Save); -- All other options are handled by Scan_Make_Switches else Scan_Make_Switches (Argv); end if; -- If not a switch it must be a file name else Set_Main_File_Name (Argv); end if; end Scan_Make_Arg; ------------------- -- Set_Ada_Paths -- ------------------- procedure Set_Ada_Paths (For_Project : Prj.Project_Id; Including_Libraries : Boolean) is New_Ada_Include_Path : constant String_Access := Prj.Env.Ada_Include_Path (For_Project); New_Ada_Objects_Path : constant String_Access := Prj.Env.Ada_Objects_Path (For_Project, Including_Libraries); begin -- If ADA_INCLUDE_PATH needs to be changed (we are not using the same -- project file), set the new ADA_INCLUDE_PATH if New_Ada_Include_Path /= Current_Ada_Include_Path then Current_Ada_Include_Path := New_Ada_Include_Path; if Original_Ada_Include_Path'Length = 0 then Setenv ("ADA_INCLUDE_PATH", New_Ada_Include_Path.all); else -- If there existed an ADA_INCLUDE_PATH at the invocation of -- gnatmake, concatenate new ADA_INCLUDE_PATH with the original. Setenv ("ADA_INCLUDE_PATH", Original_Ada_Include_Path.all & Path_Separator & New_Ada_Include_Path.all); end if; if Opt.Verbose_Mode then declare Include_Path : constant String_Access := Getenv ("ADA_INCLUDE_PATH"); begin -- Display the new ADA_INCLUDE_PATH Write_Str ("ADA_INCLUDE_PATH = """); Prj.Util.Write_Str (S => Include_Path.all, Max_Length => Max_Line_Length, Separator => Path_Separator); Write_Str (""""); Write_Eol; end; end if; end if; -- If ADA_OBJECTS_PATH needs to be changed (we are not using the same -- project file), set the new ADA_OBJECTS_PATH if New_Ada_Objects_Path /= Current_Ada_Objects_Path then Current_Ada_Objects_Path := New_Ada_Objects_Path; if Original_Ada_Objects_Path'Length = 0 then Setenv ("ADA_OBJECTS_PATH", New_Ada_Objects_Path.all); else -- If there existed an ADA_OBJECTS_PATH at the invocation of -- gnatmake, concatenate new ADA_OBJECTS_PATH with the original. Setenv ("ADA_OBJECTS_PATH", Original_Ada_Objects_Path.all & Path_Separator & New_Ada_Objects_Path.all); end if; if Opt.Verbose_Mode then declare Objects_Path : constant String_Access := Getenv ("ADA_OBJECTS_PATH"); begin -- Display the new ADA_OBJECTS_PATH Write_Str ("ADA_OBJECTS_PATH = """); Prj.Util.Write_Str (S => Objects_Path.all, Max_Length => Max_Line_Length, Separator => Path_Separator); Write_Str (""""); Write_Eol; end; end if; end if; end Set_Ada_Paths; --------------------- -- Set_Library_For -- --------------------- procedure Set_Library_For (Project : Project_Id; There_Are_Libraries : in out Boolean) is begin -- Case of library project if Projects.Table (Project).Library then There_Are_Libraries := True; -- Add the -L switch Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := new String'("-L" & Get_Name_String (Projects.Table (Project).Library_Dir)); -- Add the -l switch Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := new String'("-l" & Get_Name_String (Projects.Table (Project).Library_Name)); -- Add the Wl,-rpath switch if library non static if Projects.Table (Project).Library_Kind /= Static then declare Option : constant String_Access := MLib.Tgt.Linker_Library_Path_Option (Get_Name_String (Projects.Table (Project).Library_Dir)); begin if Option /= null then Linker_Switches.Increment_Last; Linker_Switches.Table (Linker_Switches.Last) := Option; end if; end; end if; end if; end Set_Library_For; ----------------- -- Switches_Of -- ----------------- function Switches_Of (Source_File : Name_Id; Source_File_Name : String; Naming : Naming_Data; In_Package : Package_Id; Allow_ALI : Boolean) return Variable_Value is Switches : Variable_Value; Defaults : constant Array_Element_Id := Prj.Util.Value_Of (Name => Name_Default_Switches, In_Arrays => Packages.Table (In_Package).Decl.Arrays); Switches_Array : constant Array_Element_Id := Prj.Util.Value_Of (Name => Name_Switches, In_Arrays => Packages.Table (In_Package).Decl.Arrays); begin Switches := Prj.Util.Value_Of (Index => Source_File, In_Array => Switches_Array); if Switches = Nil_Variable_Value then declare Name : String (1 .. Source_File_Name'Length + 3); Last : Positive := Source_File_Name'Length; Spec_Suffix : constant String := Get_Name_String (Naming.Current_Spec_Suffix); Impl_Suffix : constant String := Get_Name_String (Naming.Current_Impl_Suffix); Truncated : Boolean := False; begin Name (1 .. Last) := Source_File_Name; if Last > Impl_Suffix'Length and then Name (Last - Impl_Suffix'Length + 1 .. Last) = Impl_Suffix then Truncated := True; Last := Last - Impl_Suffix'Length; end if; if not Truncated and then Last > Spec_Suffix'Length and then Name (Last - Spec_Suffix'Length + 1 .. Last) = Spec_Suffix then Truncated := True; Last := Last - Spec_Suffix'Length; end if; if Truncated then Name_Len := Last; Name_Buffer (1 .. Name_Len) := Name (1 .. Last); Switches := Prj.Util.Value_Of (Index => Name_Find, In_Array => Switches_Array); if Switches = Nil_Variable_Value then Last := Source_File_Name'Length; while Name (Last) /= '.' loop Last := Last - 1; end loop; Name (Last + 1 .. Last + 3) := "ali"; Name_Len := Last + 3; Name_Buffer (1 .. Name_Len) := Name (1 .. Name_Len); Switches := Prj.Util.Value_Of (Index => Name_Find, In_Array => Switches_Array); end if; end if; end; end if; if Switches = Nil_Variable_Value then Switches := Prj.Util.Value_Of (Index => Name_Ada, In_Array => Defaults); end if; return Switches; end Switches_Of; --------------------------- -- Test_If_Relative_Path -- --------------------------- procedure Test_If_Relative_Path (Switch : String_Access) is begin if Switch /= null then declare Sw : String (1 .. Switch'Length); Start : Positive; begin Sw := Switch.all; if Sw (1) = '-' then if Sw'Length >= 3 and then (Sw (2) = 'A' or else Sw (2) = 'I' or else Sw (2) = 'L') then Start := 3; if Sw = "-I-" then return; end if; elsif Sw'Length >= 4 and then (Sw (2 .. 3) = "aL" or else Sw (2 .. 3) = "aO" or else Sw (2 .. 3) = "aI") then Start := 4; else return; end if; if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then Fail ("relative search path switches (""" & Sw & """) are not allowed when using project files"); end if; end if; end; end if; end Test_If_Relative_Path; ------------ -- Unmark -- ------------ procedure Unmark (Source_File : File_Name_Type) is begin Set_Name_Table_Byte (Source_File, 0); end Unmark; ----------------- -- Verbose_Msg -- ----------------- procedure Verbose_Msg (N1 : Name_Id; S1 : String; N2 : Name_Id := No_Name; S2 : String := ""; Prefix : String := " -> ") is begin if not Opt.Verbose_Mode then return; end if; Write_Str (Prefix); Write_Str (""""); Write_Name (N1); Write_Str (""" "); Write_Str (S1); if N2 /= No_Name then Write_Str (" """); Write_Name (N2); Write_Str (""" "); end if; Write_Str (S2); Write_Eol; end Verbose_Msg; end Make;
with Hide.Value; procedure Hide.Encode_Generic is use all type Posix.C_String; Source_File : constant String := Posix.Get_Line; Offset : constant Natural := Value (Posix.Get_Line); Text : constant String := Posix.Get_Line; Output_File : constant String := Posix.Get_Line; begin Encode ((+Source_File), (+Output_File), Offset , Text); end Hide.Encode_Generic;
with Tkmrpc.Types; package Tkmrpc.Contexts.nc is type nc_State_Type is (clean, -- No nonce present. invalid, -- Error state. created -- Nonce available. ); function Get_State (Id : Types.nc_id_type) return nc_State_Type with Pre => Is_Valid (Id); function Is_Valid (Id : Types.nc_id_type) return Boolean; -- Returns True if the given id has a valid value. function Has_nonce (Id : Types.nc_id_type; nonce : Types.nonce_type) return Boolean with Pre => Is_Valid (Id); -- Returns True if the context specified by id has the given -- nonce value. function Has_State (Id : Types.nc_id_type; State : nc_State_Type) return Boolean with Pre => Is_Valid (Id); -- Returns True if the context specified by id has the given -- State value. procedure consume (Id : Types.nc_id_type; nonce : out Types.nonce_type) with Pre => Is_Valid (Id) and then (Has_State (Id, created)), Post => Has_State (Id, clean); procedure create (Id : Types.nc_id_type; nonce : Types.nonce_type) with Pre => Is_Valid (Id) and then (Has_State (Id, clean)), Post => Has_State (Id, created) and Has_nonce (Id, nonce); procedure invalidate (Id : Types.nc_id_type) with Pre => Is_Valid (Id), Post => Has_State (Id, invalid); procedure reset (Id : Types.nc_id_type) with Pre => Is_Valid (Id), Post => Has_State (Id, clean); end Tkmrpc.Contexts.nc;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This program demonstrates reading the analog voltage value on a GPIO -- pin with an ADC unit, using polling. The pin is continously polled in an -- infinite loop, displaying the current sample on each iteration. Connect the -- pin to an appropriate external input voltage to drive the displayed value. -- Absent an input, the sensed (and displayed) value will be meaningless. The -- green LED will toggle on each iteration, as an additional indication of -- execution. -- -- NB: The input voltage must not exceed the maximum allowed for the board's -- circuitry! A value between zero and three volts (inclusive) is safe. -- -- The displayed value is the raw sample quantity in the range 0 .. 4095, -- representing an input voltage of 0.0 to 3.0 volts. Thus, for an -- incoming voltage of 1.5 volts, the sample would be approximately half of -- 4095, i.e., 2048. -- Note that you will likely need to reset the board manually after loading. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with STM32.Board; use STM32.Board; with STM32.Device; use STM32.Device; with HAL; use HAL; with STM32.ADC; use STM32.ADC; with STM32.GPIO; use STM32.GPIO; with LCD_Std_Out; with Ada.Real_Time; use Ada.Real_Time; procedure Demo_ADC_GPIO_Polling is Converter : Analog_To_Digital_Converter renames ADC_1; Input_Channel : constant Analog_Input_Channel := 5; Input : constant GPIO_Point := PA5; -- See the mapping of channels to GPIO pins at the top of the ADC package. -- Also see the board's User Manual for which GPIO pins are available. -- For example, on the F429 Discovery board, PA5 is not used by some -- other device, and maps to ADC channel 5. All_Regular_Conversions : constant Regular_Channel_Conversions := (1 => (Channel => Input_Channel, Sample_Time => Sample_144_Cycles)); Raw : UInt32 := 0; Successful : Boolean; Timed_Out : exception; procedure Print (X, Y : Natural; Value : String); procedure Configure_Analog_Input; ----------- -- Print -- ----------- procedure Print (X, Y : Natural; Value : String) is Trailing_Blanks : constant String := " "; -- to clear the rest of line begin LCD_Std_Out.Put (X, Y, Value & " / 4095" & Trailing_Blanks); end Print; ---------------------------- -- Configure_Analog_Input -- ---------------------------- procedure Configure_Analog_Input is begin Enable_Clock (Input); Configure_IO (Input, (Mode => Mode_Analog, others => <>)); end Configure_Analog_Input; begin Initialize_LEDs; Configure_Analog_Input; Enable_Clock (Converter); Reset_All_ADC_Units; Configure_Common_Properties (Mode => Independent, Prescalar => PCLK2_Div_2, DMA_Mode => Disabled, Sampling_Delay => Sampling_Delay_5_Cycles); Configure_Unit (Converter, Resolution => ADC_Resolution_12_Bits, Alignment => Right_Aligned); Configure_Regular_Conversions (Converter, Continuous => False, Trigger => Software_Triggered, Enable_EOC => True, Conversions => All_Regular_Conversions); Enable (Converter); loop Start_Conversion (Converter); Poll_For_Status (Converter, Regular_Channel_Conversion_Complete, Successful); if not Successful then raise Timed_Out; end if; Raw := UInt32 (Conversion_Value (Converter)); Print (0, 0, Raw'Img); Green_LED.Toggle; delay until Clock + Milliseconds (200); -- slow it down to ease reading end loop; end Demo_ADC_GPIO_Polling;
package Default_Value is function My_Function (X : Integer; Y : Integer := 2) return Integer; private function My_Function (X : Integer; Y : Integer := 2) return Integer is (X + Y); end Default_Value;
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. (gh+owm@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); with Ada.Characters.Latin_1; with Ada.Text_IO; with AWS.Client; with AWS.Messages; with AWS.Response; with GNATCOLL.JSON; package body Open_Weather_Map.API.Service is My_Debug : constant not null GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create (Unit_Name => "OWM.API.SERVICE"); use type Ada.Real_Time.Time; ----------------------------------------------------------------------------- -- Initialize ----------------------------------------------------------------------------- procedure Initialize (Self : out T; Configuration : in GNATCOLL.JSON.JSON_Value; Connection : not null Client.T_Access; Max_Cache_Interval : in Ada.Real_Time.Time_Span := Default_Cache_Interval; For_API_Service : in API_Services) is begin My_Debug.all.Trace (Message => "Initialize"); -- inherited initialization Query.T (Self).Initialize; -- initialization of added fields Self.Server_Connection := Connection; Self.Cache_Interval := Max_Cache_Interval; -- initialization of added fields. Get_API_Key : declare pragma Assertion_Policy (Dynamic_Predicate => Check); -- Force type predicate check on API key type. begin My_Debug.all.Trace (Message => "Initialize: Loading API key..."); Self.Key := Configuration.Get (Field => Config_Names.Field_API_Key); My_Debug.all.Trace (Message => "Initialize: API key loaded."); exception when E : others => My_Debug.all.Trace (E => E, Msg => "Initialize: Error parsing configuration data: "); Ada.Text_IO.Put_Line (File => Ada.Text_IO.Standard_Error, Item => "Warning: Missing or invalid JSON data, " & "API key configuration is invalid."); Self.Key := Invalid_API_Key; -- Force API key to invalid, yet satisfy the type predicate. end Get_API_Key; Self.Service := For_API_Service; end Initialize; ----------------------------------------------------------------------------- -- Perform_Query ----------------------------------------------------------------------------- overriding procedure Perform_Query (Self : in out T; Current : in out Data_Set) is Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; URI : constant String := T'Class (Self).Service_URI; begin My_Debug.all.Trace (Message => "Query"); if T'Class (Self).Last_Query + T'Class (Self).Cache_Interval < Now then My_Debug.all.Trace (Message => "Query: Firing query: """ & API_Host & URI & """"); Do_HTTP_Query : declare Response : AWS.Response.Data; begin AWS.Client.Get (Connection => Self.Server_Connection.all.Connection.all, URI => URI & "&appid=" & T'Class (Self).Key, Result => Response); declare Status_Code : constant AWS.Messages.Status_Code := AWS.Response.Status_Code (D => Response); begin if Status_Code in AWS.Messages.Success then My_Debug.all.Trace (Message => "Query: Succeeded (" & AWS.Messages.Image (S => Status_Code) & "/" & AWS.Messages.Reason_Phrase (S => Status_Code) & ")"); T'Class (Self).Set_Last_Query (Value => Now); -- Mark retrieval of data. -- Decode retrieved JSON data. declare Content : constant String := AWS.Response.Message_Body (D => Response); begin My_Debug.all.Trace (Message => "Query: Received response: " & Ada.Characters.Latin_1.LF & """" & Content & """"); declare Read_Result : constant GNATCOLL.JSON.Read_Result := GNATCOLL.JSON.Read (Strm => Content); begin if Read_Result.Success then Current := T'Class (Self).Decode_Response (Root => Read_Result.Value); else Report_Error : declare Error_Msg : constant String := GNATCOLL.JSON.Format_Parsing_Error (Error => Read_Result.Error); begin My_Debug.all.Trace (Message => "Query: " & Error_Msg); Ada.Text_IO.Put_Line (File => Ada.Text_IO.Standard_Error, Item => "Error parsing response: " & Error_Msg); end Report_Error; end if; end; end; else -- Error retrieving network data. My_Debug.all.Trace (Message => "Query: Failed (" & AWS.Messages.Image (Status_Code) & "/" & AWS.Messages.Reason_Phrase (Status_Code) & ")"); Ada.Text_IO.Put_Line (File => Ada.Text_IO.Standard_Error, Item => "API query failed: " & AWS.Messages.Image (Status_Code) & "/" & AWS.Messages.Reason_Phrase (S => Status_Code) & "."); end if; end; end Do_HTTP_Query; else My_Debug.all.Trace (Message => "Query: Within cache interval, nothing to do."); end if; end Perform_Query; ----------------------------------------------------------------------------- -- Service_URI ----------------------------------------------------------------------------- function Service_URI (This : in T) return String is Result : constant String := API_Path & To_Service_Name (This.Service) & This.Parameters.URI_Format; begin My_Debug.all.Trace (Message => "Service_URI: " & Result); return Result; end Service_URI; ----------------------------------------------------------------------------- -- Set_Cache_Interval ----------------------------------------------------------------------------- procedure Set_Cache_Interval (Self : in out T; Max_Cache_Interval : in Ada.Real_Time.Time_Span) is begin My_Debug.all.Trace (Message => "Set_Cache_Interval"); Self.Cache_Interval := Max_Cache_Interval; end Set_Cache_Interval; end Open_Weather_Map.API.Service;
-- NORX_Load_Store -- A collection of functions to load and store words of different sizes from -- Storage_Array in Little Endian format. This version assumes that the machine -- is Little Endian and does unchecked conversions to convert the types. -- Copyright (c) 2016, James Humphry - see LICENSE file for details -- Note that all the Unsigned_xx types count as Implementation_Identifiers pragma Restrictions(No_Implementation_Attributes, No_Implementation_Units, No_Obsolescent_Features); with System.Storage_Elements; use System.Storage_Elements; with Interfaces; use Interfaces; package NORX_Load_Store with Pure, SPARK_Mode => On is function Storage_Array_To_Unsigned_8 (S : in Storage_Array) return Unsigned_8 with Inline, Pre => (S'Length = 1); function Unsigned_8_To_Storage_Array (W : in Unsigned_8) return Storage_Array with Inline, Post => (Unsigned_8_To_Storage_Array'Result'Length = 1); function Storage_Array_To_Unsigned_16 (S : in Storage_Array) return Unsigned_16 with Inline, Pre => (S'Length = 2); function Unsigned_16_To_Storage_Array (W : in Unsigned_16) return Storage_Array with Inline, Post => (Unsigned_16_To_Storage_Array'Result'Length = 2); function Storage_Array_To_Unsigned_32 (S : in Storage_Array) return Unsigned_32 with Inline, Pre => (S'Length = 4); function Unsigned_32_To_Storage_Array (W : in Unsigned_32) return Storage_Array with Inline, Post => (Unsigned_32_To_Storage_Array'Result'Length = 4); function Storage_Array_To_Unsigned_64 (S : in Storage_Array) return Unsigned_64 with Inline, Pre => (S'Length = 8); function Unsigned_64_To_Storage_Array (W : in Unsigned_64) return Storage_Array with Inline, Post => (Unsigned_64_To_Storage_Array'Result'Length = 8); end NORX_Load_Store;
with Ada.Containers.Generic_Array_Sort; with Ada.Containers.Hashed_Maps; with Ada.Containers.Vectors; with Ada.Strings.Unbounded.Hash; with Ada.Unchecked_Deallocation; with TOML.Generic_Dump; with TOML.Generic_Parse; package body TOML is use Ada.Strings.Unbounded; procedure Dump_To_String is new TOML.Generic_Dump (Output_Stream => Unbounded_UTF8_String, Put => Append); procedure Sort_Keys is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Unbounded_UTF8_String, Array_Type => Key_Array); package TOML_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => TOML_Value, Hash => Hash, Equivalent_Keys => "="); package TOML_Vectors is new Ada.Containers.Vectors (Positive, TOML_Value); type TOML_Value_Record (Kind : Any_Value_Kind) is limited record Ref_Count : Natural; case Kind is when TOML_Table => Map_Value : TOML_Maps.Map; Table_Implicitly_Created : Boolean; -- Helper for parsing: true iff this table was created implictly -- when parsing a sub-table. For instance, this is true for the -- table "a" if we read "[a.b]" but not yet "[a]". when TOML_Array => Array_Value : TOML_Vectors.Vector; -- List of values for all items Array_Implicitly_Created : Boolean; -- Same as Table_Implicitly_Created when TOML_String => String_Value : Unbounded_String; when TOML_Integer => Integer_Value : Any_Integer; when TOML_Float => Float_Value : Any_Float; when TOML_Boolean => Boolean_Value : Boolean; when TOML_Offset_Datetime => Offset_Datetime_Value : Any_Offset_Datetime; when TOML_Local_Datetime => Local_Datetime_Value : Any_Local_Datetime; when TOML_Local_Date => Local_Date_Value : Any_Local_Date; when TOML_Local_Time => Local_Time_Value : Any_Local_Time; end case; end record; procedure Free is new Ada.Unchecked_Deallocation (TOML_Value_Record, TOML_Value_Record_Access); function Create_Value (Rec : TOML_Value_Record_Access) return TOML_Value; -- Wrap a value record in a value. This resets its ref-count to 1. ------------------ -- Create_Value -- ------------------ function Create_Value (Rec : TOML_Value_Record_Access) return TOML_Value is begin return Result : TOML_Value do Rec.Ref_Count := 1; Result.Value := Rec; end return; end Create_Value; ------------------ -- Create_Error -- ------------------ function Create_Error (Message : String; Location : Source_Location) return Read_Result is begin return (Success => False, Message => To_Unbounded_String (Message), Location => Location); end Create_Error; ------------- -- Is_Null -- ------------- function Is_Null (Value : TOML_Value) return Boolean is begin return Value.Value = null; end Is_Null; ---------- -- Kind -- ---------- function Kind (Value : TOML_Value) return Any_Value_Kind is begin return Value.Value.Kind; end Kind; ------------ -- Equals -- ------------ function Equals (Left, Right : TOML_Value) return Boolean is begin -- If Left and Right refer to the same document, they are obviously -- equivalent (X is equivalent to X). If they don't have the same kind, -- they are obviously not equivalent. if Left = Right then return True; elsif Left.Kind /= Right.Kind then return False; end if; case Left.Kind is when TOML_Table => declare Left_Keys : constant Key_Array := Left.Keys; Right_Keys : constant Key_Array := Right.Keys; begin if Left_Keys /= Right_Keys then return False; end if; for K of Left_Keys loop if not Equals (Left.Get (K), Right.Get (K)) then return False; end if; end loop; end; when TOML_Array => if Left.Length /= Right.Length then return False; end if; for I in 1 .. Left.Length loop if not Equals (Left.Item (I), Right.Item (I)) then return False; end if; end loop; when TOML_String => return Left.Value.String_Value = Right.Value.String_Value; when TOML_Integer => return Left.Value.Integer_Value = Right.Value.Integer_Value; when TOML_Boolean => return Left.Value.Boolean_Value = Right.Value.Boolean_Value; when TOML_Offset_Datetime => return Left.Value.Offset_Datetime_Value = Right.Value.Offset_Datetime_Value; when TOML_Local_Datetime => return Left.Value.Local_Datetime_Value = Right.Value.Local_Datetime_Value; when TOML_Local_Date => return Left.Value.Local_Date_Value = Right.Value.Local_Date_Value; when TOML_Local_Time => return Left.Value.Local_Time_Value = Right.Value.Local_Time_Value; when TOML_Float => return Left.Value.Float_Value = Right.Value.Float_Value; end case; return True; end Equals; ----------- -- Clone -- ----------- function Clone (Value : TOML_Value) return TOML_Value is Result : TOML_Value; begin case Value.Kind is when TOML_Table => Result := Create_Table; for Key of Value.Keys loop Result.Set (Key, Value.Get (Key).Clone); end loop; when TOML_Array => Result := Create_Array; for I in 1 .. Value.Length loop Result.Append (Value.Item (I)); end loop; when TOML_String => Result := Create_String (Value.Value.String_Value); when TOML_Integer => Result := Create_Integer (Value.Value.Integer_Value); when TOML_Boolean => Result := Create_Boolean (Value.Value.Boolean_Value); when TOML_Offset_Datetime => Result := Create_Offset_Datetime (Value.Value.Offset_Datetime_Value); when TOML_Local_Datetime => Result := Create_Local_Datetime (Value.Value.Local_Datetime_Value); when TOML_Local_Date => Result := Create_Local_Date (Value.Value.Local_Date_Value); when TOML_Local_Time => Result := Create_Local_Time (Value.Value.Local_Time_Value); when TOML_Float => Result := Create_Float (Value.Value.Float_Value); end case; return Result; end Clone; ---------------- -- As_Boolean -- ---------------- function As_Boolean (Value : TOML_Value) return Boolean is begin return Value.Value.Boolean_Value; end As_Boolean; ---------------- -- As_Integer -- ---------------- function As_Integer (Value : TOML_Value) return Any_Integer is begin return Value.Value.Integer_Value; end As_Integer; -------------- -- As_Float -- -------------- function As_Float (Value : TOML_Value) return Any_Float is begin return Value.Value.Float_Value; end As_Float; --------------- -- As_String -- --------------- function As_String (Value : TOML_Value) return String is begin return To_String (Value.As_Unbounded_String); end As_String; ------------------------- -- As_Unbounded_String -- ------------------------- function As_Unbounded_String (Value : TOML_Value) return Ada.Strings.Unbounded.Unbounded_String is begin return Value.Value.String_Value; end As_Unbounded_String; ------------------------ -- As_Offset_Datetime -- ------------------------ function As_Offset_Datetime (Value : TOML_Value) return Any_Offset_Datetime is begin return Value.Value.Offset_Datetime_Value; end As_Offset_Datetime; ----------------------- -- As_Local_Datetime -- ----------------------- function As_Local_Datetime (Value : TOML_Value) return Any_Local_Datetime is begin return Value.Value.Local_Datetime_Value; end As_Local_Datetime; ------------------- -- As_Local_Date -- ------------------- function As_Local_Date (Value : TOML_Value) return Any_Local_Date is begin return Value.Value.Local_Date_Value; end As_Local_Date; ------------------- -- As_Local_Time -- ------------------- function As_Local_Time (Value : TOML_Value) return Any_Local_Time is begin return Value.Value.Local_Time_Value; end As_Local_Time; --------- -- Has -- --------- function Has (Value : TOML_Value; Key : String) return Boolean is begin return Value.Has (To_Unbounded_String (Key)); end Has; --------- -- Has -- --------- function Has (Value : TOML_Value; Key : Unbounded_UTF8_String) return Boolean is begin return Value.Value.Map_Value.Contains (Key); end Has; ---------- -- Keys -- ---------- function Keys (Value : TOML_Value) return Key_Array is use TOML_Maps; Map : TOML_Maps.Map renames Value.Value.Map_Value; I : Positive := 1; begin return Result : Key_Array (1 .. Natural (Map.Length)) do for Position in Map.Iterate loop Result (I) := Key (Position); I := I + 1; end loop; Sort_Keys (Result); end return; end Keys; --------- -- Get -- --------- function Get (Value : TOML_Value; Key : String) return TOML_Value is begin return Value.Get (To_Unbounded_String (Key)); end Get; --------- -- Get -- --------- function Get (Value : TOML_Value; Key : Unbounded_UTF8_String) return TOML_Value is begin return Value.Value.Map_Value.Element (Key); end Get; ----------------- -- Get_Or_Null -- ----------------- function Get_Or_Null (Value : TOML_Value; Key : String) return TOML_Value is begin return Value.Get_Or_Null (To_Unbounded_String (Key)); end Get_Or_Null; ----------------- -- Get_Or_Null -- ----------------- function Get_Or_Null (Value : TOML_Value; Key : Unbounded_UTF8_String) return TOML_Value is use TOML_Maps; Position : constant Cursor := Value.Value.Map_Value.Find (Key); begin return (if Has_Element (Position) then Element (Position) else No_TOML_Value); end Get_Or_Null; ---------------------- -- Iterate_On_Table -- ---------------------- function Iterate_On_Table (Value : TOML_Value) return Table_Entry_Array is Keys : constant Key_Array := Value.Keys; begin return Result : Table_Entry_Array (Keys'Range) do for I In Keys'Range loop Result (I) := (Keys (I), Value.Get (Keys (I))); end loop; end return; end Iterate_On_Table; ------------ -- Length -- ------------ function Length (Value : TOML_Value) return Natural is begin return Natural (Value.Value.Array_Value.Length); end Length; ---------- -- Item -- ---------- function Item (Value : TOML_Value; Index : Positive) return TOML_Value is begin return Value.Value.Array_Value.Element (Index); end Item; -------------------- -- Create_Boolean -- -------------------- function Create_Boolean (Value : Boolean) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Boolean, Ref_Count => 1, Boolean_Value => Value)); end Create_Boolean; -------------------- -- Create_Integer -- -------------------- function Create_Integer (Value : Any_Integer) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Integer, Ref_Count => 1, Integer_Value => Value)); end Create_Integer; ------------------ -- Create_Float -- ------------------ function Create_Float (Value : Any_Float) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Float, Ref_Count => 1, Float_Value => Value)); end Create_Float; ------------------- -- Create_String -- ------------------- function Create_String (Value : String) return TOML_Value is begin return Create_String (To_Unbounded_String (Value)); end Create_String; ------------------- -- Create_String -- ------------------- function Create_String (Value : Unbounded_UTF8_String) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_String, Ref_Count => 1, String_Value => Value)); end Create_String; ---------------------------- -- Create_Offset_Datetime -- ---------------------------- function Create_Offset_Datetime (Value : Any_Offset_Datetime) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Offset_Datetime, Ref_Count => 1, Offset_Datetime_Value => Value)); end Create_Offset_Datetime; --------------------------- -- Create_Local_Datetime -- --------------------------- function Create_Local_Datetime (Value : Any_Local_Datetime) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Local_Datetime, Ref_Count => 1, Local_Datetime_Value => Value)); end Create_Local_Datetime; ----------------------- -- Create_Local_Date -- ----------------------- function Create_Local_Date (Value : Any_Local_Date) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Local_Date, Ref_Count => 1, Local_Date_Value => Value)); end Create_Local_Date; ----------------------- -- Create_Local_Time -- ----------------------- function Create_Local_Time (Value : Any_Local_Time) return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Local_Time, Ref_Count => 1, Local_Time_Value => Value)); end Create_Local_Time; ------------------ -- Create_Table -- ------------------ function Create_Table return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Table, Ref_Count => 1, Map_Value => <>, Table_Implicitly_Created => False)); end Create_Table; --------- -- Set -- --------- procedure Set (Value : TOML_Value; Key : String; Entry_Value : TOML_Value) is begin Value.Set (To_Unbounded_String (Key), Entry_Value); end Set; --------- -- Set -- --------- procedure Set (Value : TOML_Value; Key : Unbounded_UTF8_String; Entry_Value : TOML_Value) is begin Value.Value.Map_Value.Include (Key, Entry_Value); end Set; ----------------- -- Set_Default -- ----------------- procedure Set_Default (Value : TOML_Value; Key : String; Entry_Value : TOML_Value) is begin Value.Set_Default (To_Unbounded_String (Key), Entry_Value); end Set_Default; ----------------- -- Set_Default -- ----------------- procedure Set_Default (Value : TOML_Value; Key : Unbounded_UTF8_String; Entry_Value : TOML_Value) is use TOML_Maps; Dummy_Position : Cursor; Dummy_Inserted : Boolean; begin Value.Value.Map_Value.Insert (Key, Entry_Value, Dummy_Position, Dummy_Inserted); end Set_Default; ----------- -- Unset -- ----------- procedure Unset (Value : TOML_Value; Key : String) is begin Value.Unset (To_Unbounded_String (Key)); end Unset; ----------- -- Unset -- ----------- procedure Unset (Value : TOML_Value; Key : Unbounded_UTF8_String) is begin Value.Value.Map_Value.Delete (Key); end Unset; ----------- -- Merge -- ----------- function Merge (L, R : TOML_Value) return TOML_Value is function Merge_Entries (Key : Unbounded_UTF8_String; Dummy_L, Dummy_R : TOML_Value) return TOML_Value is (raise Constraint_Error with "duplicate key: " & To_String (Key)); begin return Merge (L, R, Merge_Entries'Access); end Merge; ----------- -- Merge -- ----------- function Merge (L, R : TOML_Value; Merge_Entries : not null access function (Key : Unbounded_UTF8_String; L, R : TOML_Value) return TOML_Value) return TOML_Value is Table : constant TOML_Value := Create_Table; begin for Key of L.Keys loop Table.Set (Key, L.Get (Key)); end loop; for Key of R.Keys loop declare Value : TOML_Value := R.Get (Key); begin if Table.Has (Key) then Value := Merge_Entries (Key, Table.Get (Key), Value); end if; Table.Set (Key, Value); end; end loop; return Table; end Merge; ------------------ -- Create_Array -- ------------------ function Create_Array return TOML_Value is begin return Create_Value (new TOML_Value_Record' (Kind => TOML_Array, Ref_Count => 1, Array_Value => <>, Array_Implicitly_Created => False)); end Create_Array; --------- -- Set -- --------- procedure Set (Value : TOML_Value; Index : Positive; Item : TOML_Value) is begin Value.Value.Array_Value (Index) := Item; end Set; ------------ -- Append -- ------------ procedure Append (Value, Item : TOML_Value) is begin Value.Value.Array_Value.Append (Item); end Append; ------------------- -- Insert_Before -- ------------------- procedure Insert_Before (Value : TOML_Value; Index : Positive; Item : TOML_Value) is begin Value.Value.Array_Value.Insert (Index, Item); end Insert_Before; ----------------- -- Load_String -- ----------------- function Load_String (Content : String) return Read_Result is type Input_Stream is record Next_Character : Positive; -- Index of the next character in Content that Get must return end record; procedure Get (Stream : in out Input_Stream; EOF : out Boolean; Byte : out Character); -- Callback for Parse_String --------- -- Get -- --------- procedure Get (Stream : in out Input_Stream; EOF : out Boolean; Byte : out Character) is begin if Stream.Next_Character > Content'Length then EOF := True; else EOF := False; Byte := Content (Stream.Next_Character); Stream.Next_Character := Stream.Next_Character + 1; end if; end Get; function Parse_String is new TOML.Generic_Parse (Input_Stream, Get); Stream : Input_Stream := (Next_Character => Content'First); begin return Parse_String (Stream); end Load_String; -------------------- -- Dump_As_String -- -------------------- function Dump_As_String (Value : TOML_Value) return String is begin return To_String (Dump_As_Unbounded (Value)); end Dump_As_String; ----------------------- -- Dump_As_Unbounded -- ----------------------- function Dump_As_Unbounded (Value : TOML_Value) return Unbounded_UTF8_String is begin return Result : Unbounded_UTF8_String do Dump_To_String (Result, Value); end return; end Dump_As_Unbounded; ------------------ -- Format_Error -- ------------------ function Format_Error (Result : Read_Result) return String is Formatted : Unbounded_UTF8_String; begin if Result.Location.Line /= 0 then declare L : constant String := Result.Location.Line'Image; C : constant String := Result.Location.Column'Image; begin Append (Formatted, L (L'First + 1 .. L'Last)); Append (Formatted, ":"); Append (Formatted, C (C'First + 1 .. C'Last)); Append (Formatted, ": "); end; end if; Append (Formatted, Result.Message); return To_String (Formatted); end Format_Error; ------------ -- Adjust -- ------------ overriding procedure Adjust (Self : in out TOML_Value) is begin if Self.Value = null then return; end if; Self.Value.Ref_Count := Self.Value.Ref_Count + 1; end Adjust; -------------- -- Finalize -- -------------- overriding procedure Finalize (Self : in out TOML_Value) is begin if Self.Value = null then return; end if; declare V : TOML_Value_Record renames Self.Value.all; begin -- Decrement the ref-count. If no-one references V anymore, -- deallocate it. V.Ref_Count := V.Ref_Count - 1; if V.Ref_Count > 0 then return; end if; end; Free (Self.Value); end Finalize; ------------------------ -- Implicitly_Created -- ------------------------ function Implicitly_Created (Self : TOML_Value'Class) return Boolean is begin if Self.Kind = TOML_Table then return Self.Value.Table_Implicitly_Created; else return Self.Value.Array_Implicitly_Created; end if; end Implicitly_Created; ---------------------------- -- Set_Implicitly_Created -- ---------------------------- procedure Set_Implicitly_Created (Self : TOML_Value'Class) is begin if Self.Kind = TOML_Table then Self.Value.Table_Implicitly_Created := True; else Self.Value.Array_Implicitly_Created := True; end if; end Set_Implicitly_Created; ---------------------------- -- Set_Explicitly_Created -- ---------------------------- procedure Set_Explicitly_Created (Self : TOML_Value'Class) is begin if Self.Kind = TOML_Table then Self.Value.Table_Implicitly_Created := False; else Self.Value.Array_Implicitly_Created := False; end if; end Set_Explicitly_Created; end TOML;
with bullet_c.Binding, bullet_c.Pointers, bullet_physics.Shape, c_math_c.Conversion, c_math_c.Vector_3, c_math_c.Matrix_3x3, c_math_c.Matrix_4x4, float_Math.Algebra.linear.D3, Swig, interfaces.C, ada.unchecked_Deallocation, ada.Unchecked_Conversion, ada.Text_IO; package body bullet_Physics.Object is use bullet_c.Binding, c_math_c.Conversion, ada.Text_IO; type Any_limited_view is access all lace.Any.limited_item'Class; function new_Object (Shape : in physics.Shape.view; Mass : in Real; Friction : in Real; Restitution : in Real; at_Site : in Vector_3) return View -- is_Kinematic : in Boolean) return View is Self : constant View := new Item; begin Self.define (Shape => Shape, Mass => Mass, Friction => Friction, Restitution => Restitution, at_Site => at_Site); return Self; end new_Object; overriding procedure define (Self : access Item; Shape : in physics.Shape.view; Mass : in Real; Friction : in Real; Restitution : in Real; at_Site : in Vector_3) is use interfaces.C; function to_void_ptr is new ada.unchecked_Conversion (Any_limited_view, Swig.void_ptr); begin Self.C := b3d_new_Object (c_math_c.Real (Mass), bullet_physics.Shape.view (Shape).C, is_Kinematic => Boolean'Pos (False)); -- Boolean'Pos (is_Kinematic)); b3d_Object_Friction_is (Self.C, c_float (Friction)); b3d_Object_Restitution_is (Self.C, c_float (Restitution)); b3d_Object_user_Data_is (Self => Self.C.all'Access, Now => to_void_ptr (Self.all'Access)); Self.user_Data_is (Self); Self.Site_is (at_Site); end define; overriding procedure destruct (Self : in out Item) is begin null; end destruct; procedure free (the_Object : in out physics.Object.view) is procedure deallocate is new ada.unchecked_Deallocation (physics.Object.item'Class, physics.Object.view); begin the_Object.destruct; deallocate (the_Object); end free; function C (Self : in Item) return access bullet_C.Object is begin return Self.C; end C; overriding function Model (Self : in Item) return physics.Model.view is begin return Self.Model; end Model; overriding procedure Model_is (Self : in out Item; Now : in physics.Model.view) is begin Self.Model := Now; end Model_is; overriding function Shape (Self : in Item) return physics.Shape.view is c_Shape : constant bullet_c.Pointers.Shape_pointer := b3d_Object_Shape (Self.C); function to_Any_view is new ada.unchecked_Conversion (Swig.void_ptr, Any_limited_view); begin return physics.Shape.view (to_Any_view (b3d_Shape_user_Data (c_Shape))); end Shape; overriding function Scale (Self : in Item) return Vector_3 is begin raise Error with "TODO"; return math.Origin_3D; end Scale; overriding procedure Scale_is (Self : in out Item; Now : in Vector_3) is begin put_Line ("Scale_is not implemented for bullet_Physics.Object"); raise Error with "TODO"; end Scale_is; overriding procedure update_Dynamics (Self : in out Item) is Dynamics : constant Matrix_4x4 := Self.Transform; begin Self.Dynamics.set (Dynamics); end update_Dynamics; overriding function get_Dynamics (Self : in Item) return Matrix_4x4 is use float_Math.Algebra.linear.D3; my_Site : Vector_3 := Self.Site; my_Spin : Matrix_3x3 := Self.Spin; my_Transform : Matrix_4x4 := to_transform_Matrix (Translation => my_Site, Rotation => my_Spin); begin RETURN my_Transform; put_Line (Self.Site (2)'Image); return Self.Dynamics.get; end get_Dynamics; overriding function is_Active (Self : in Item) return Boolean is begin return True; end is_Active; overriding procedure activate (Self : in out Item; forceActivation : in Boolean := False) is pragma unreferenced (forceActivation); begin null; end activate; overriding function Mass (Self : in Item) return Real is begin return Real (b3d_Object_Mass (Self.C)); end Mass; overriding function Site (Self : in Item) return Vector_3 is the_Site : constant c_math_c.Vector_3.item := b3d_Object_Site (Self.C); begin return +the_Site; end Site; overriding procedure Site_is (Self : in out Item; Now : in Vector_3) is c_Now : aliased c_math_c.Vector_3.item := +Now; begin b3d_Object_Site_is (Self.C, c_Now'unchecked_Access); end Site_is; overriding function Spin (Self : in Item) return math.Matrix_3x3 is begin if Self.C /= null then declare the_Spin : constant c_math_c.Matrix_3x3.item := b3d_Object_Spin (Self.C); begin return +the_Spin; end; else return Self.Dynamics.get_Spin; end if; end Spin; overriding procedure Spin_is (Self : in out Item; Now : in Matrix_3x3) is begin Self.Dynamics.set_Spin (Now); if Self.C /= null then declare c_Now : aliased c_math_c.Matrix_3x3.item := +Now; begin b3d_Object_Spin_is (Self.C, c_Now'unchecked_Access); end; end if; end Spin_is; overriding function xy_Spin (Self : in Item) return Radians is begin raise Error with "TODO"; return 0.0; end xy_Spin; overriding procedure xy_Spin_is (Self : in out Item; Now : in Radians) is begin raise Error with "TODO"; end xy_Spin_is; overriding function Transform (Self : in Item) return Matrix_4x4 is the_Transform : constant c_math_c.Matrix_4x4.item := b3d_Object_Transform (Self.C); begin return +the_Transform; end Transform; overriding procedure Transform_is (Self : in out Item; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Object_Transform_is (Self.C, c_Now'unchecked_Access); end Transform_is; overriding function Speed (Self : in Item) return math.Vector_3 is the_Speed : constant c_math_c.Vector_3.item := b3d_Object_Speed (Self.C); begin return +the_Speed; end Speed; overriding procedure Speed_is (Self : in out Item; Now : in Vector_3) is c_Now : aliased c_math_c.Vector_3.item := +Now; begin b3d_Object_Speed_is (Self.C, c_Now'unchecked_Access); end Speed_is; overriding function Gyre (Self : in Item) return math.Vector_3 is the_Gyre : constant c_math_c.Vector_3.item := b3d_Object_Gyre (Self.C); begin return +the_Gyre; end Gyre; overriding procedure Gyre_is (Self : in out Item; Now : in Vector_3) is c_Now : aliased c_math_c.Vector_3.item := +Now; begin b3d_Object_Gyre_is (Self.C, c_Now'unchecked_Access); end Gyre_is; overriding procedure Friction_is (Self : in out Item; Now : in Real) is begin b3d_Object_Friction_is (Self.C, +Now); end Friction_is; overriding procedure Restitution_is (Self : in out Item; Now : in Real) is begin b3d_Object_Restitution_is (Self.C, +Now); end Restitution_is; --- Forces -- overriding procedure apply_Torque (Self : in out Item; Torque : in Vector_3) is c_Torque : aliased c_math_c.Vector_3.item := +Torque; begin b3d_Object_apply_Torque (Self.C, c_Torque'unchecked_Access); end apply_Torque; overriding procedure apply_Torque_impulse (Self : in out Item; Torque : in Vector_3) is c_Torque : aliased c_math_c.Vector_3.item := +Torque; begin b3d_Object_apply_Torque_impulse (Self.C, c_Torque'unchecked_Access); end apply_Torque_impulse; overriding procedure apply_Force (Self : in out Item; Force : in Vector_3) is c_Force : aliased c_math_c.Vector_3.item := +Force; begin b3d_Object_apply_Force (Self.C, c_Force'unchecked_Access); end apply_Force; --- User data -- overriding procedure user_Data_is (Self : in out Item; Now : access lace.Any.limited_item'Class) is begin Self.user_Data := Now.all'unchecked_Access; end user_Data_is; overriding function user_Data (Self : in Item) return access lace.Any.limited_item'Class is begin return Self.user_Data; end user_Data; end bullet_Physics.Object;
-- Copyright 2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "Robtex" type = "api" function start() setratelimit(1) end function vertical(ctx, domain) local cfg = datasrc_config() if (cfg == nil) then return end local url = "https://freeapi.robtex.com/pdns/forward/" .. domain local resp, err = request(ctx, { ['url']=url, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return end local j = json.decode("{\"results\": [" .. resp .. "]}") if (j == nil or #(j.results) == 0) then return end for _, rr in pairs(j.results) do if (rr.rrtype == "A") then local d = ipinfo(ctx, rr.rrdata, cfg.ttl) if (d == nil) then return end extractnames(ctx, d) elseif (rr.rrtype == "NS" or rr.rrtype == "MX") then sendnames(ctx, rr.rrdata) end end end function asn(ctx, addr, asn) local cfg = datasrc_config() if (cfg == nil) then return end local d local prefix if (asn == 0) then if (addr == "") then return end d = ipinfo(ctx, addr, cfg.ttl) if (d == nil) then return end asn = d.as prefix = d.bgproute end local cidrs = netblocks(ctx, asn, cfg.ttl) if (cidrs == nil or #cidrs == 0) then return end if (prefix == "") then prefix = cidrs[1] parts = split(prefix, "/") addr = parts[1] d = ipinfo(ctx, addr, cfg.ttl) if (d == nil) then return end end extractnames(ctx, d) local desc = d.asname if (desc == nil) then desc = "" end if (string.len(desc) < string.len(d.whoisdesc)) then desc = d.whoisdesc end if (d.asdesc ~= nil and string.len(d.asdesc) > 0) then desc = desc .. " - " .. d.asdesc elseif (d.routedesc ~= nil and string.len(d.routedesc) > 0) then desc = desc .. " - " .. d.routedesc end newasn(ctx, { ['addr']=addr, ['asn']=asn, ['prefix']=prefix, ['desc']=desc, ['netblocks']=cidrs, }) end function ipinfo(ctx, addr, ttl) local url = "https://freeapi.robtex.com/ipquery/" .. addr local resp, err = request(ctx, { ['url']=url, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return nil end local j = json.decode(resp) if (j == nil or j.status ~= "ok") then return nil end return j end function extractnames(ctx, djson) local sections = {"act", "acth", "pas", "pash"} for _, s in pairs(sections) do if (djson[s] ~= nil and #(djson[s]) > 0) then for _, name in pairs(djson[s]) do if inscope(ctx, name.o) then newname(ctx, name.o) end end end end end function netblocks(ctx, asn, ttl) local url = "https://freeapi.robtex.com/asquery/" .. tostring(asn) local resp, err = request(ctx, { ['url']=url, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return nil end local j = json.decode(resp) if (j == nil or j.status ~= "ok") then return nil end local netblocks = {} for _, net in pairs(j.nets) do table.insert(netblocks, net.n) end if (#netblocks == 0) then return nil end return netblocks end function sendnames(ctx, content) local names = find(content, subdomainre) if (names == nil) then return end local found = {} for i, v in pairs(names) do if (found[v] == nil) then newname(ctx, v) found[v] = true end end end function split(str, delim) local result = {} local pattern = "[^%" .. delim .. "]+" local matches = find(str, pattern) if (matches == nil or #matches == 0) then return result end for i, match in pairs(matches) do table.insert(result, match) end return result end
------------------------------------------------------------------------ -- Copyright (C) 2010-2020 by Heisenbug Ltd. (github@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); ------------------------------------------------------------------------ -- Mailbox_Sharing -- -- Supports import and export of mailboxes from any instantiation of -- the generic Local_Message_Passing package. -- -- This package should be viewed and used like a private child of -- Local_Message_Passing, meaning it should not be used by user code at -- all! -- ------------------------------------------------------------------------ with Ada.Real_Time; with System.Storage_Elements; package Mailbox_Sharing is package SSE renames System.Storage_Elements; -- -- Package configuration. May be adapted for different purposes. -- -- Configured maximum number of mailboxes to handle. MAX_MAILBOXES : constant Positive := 100; -- Number of significant characters in mailbox names. MAX_NAME_LENGTH : constant Positive := 31; -- -- Several exception objects to indicate erroneous situations. -- -- A mailbox with this name has already been exported. Already_Exported : exception; -- There are no more slots in the static list to export a mailbox. -- MAX_MAILBOXES should be increased. Too_Many_Mailboxes : exception; -- Raised when the maximum timeout for a connection attempt is gone -- by and the requested mailbox has not been exported yet. No_Such_Mailbox : exception; --------------------------------------------------------------------- -- Add_Mailbox -- -- Adds a mailbox to the global pool. Each mailbox name can be -- exported once only. --------------------------------------------------------------------- procedure Add_Mailbox (Mbx_Address : in System.Address; Name : in String; Msg_Size : in SSE.Storage_Count); --------------------------------------------------------------------- -- Find_Mailbox -- -- Finds a mailbox in the global pool up until the time specified. -- For a successful connection both name and message size of the -- mailbox must match. --------------------------------------------------------------------- function Find_Mailbox (Name : in String; Msg_Size : in SSE.Storage_Count; Latest : in Ada.Real_Time.Time) return System.Address; end Mailbox_Sharing;
with Liste_Generique; package Vecteurs is type Vecteur is array(Positive range<>) of Float; subtype Point2D is Vecteur(1..2); subtype Point3D is Vecteur(1..3); package Liste_Points is new Liste_Generique(Point2D); type Facette is record P1, P2, P3 : Point3D; end record; package Liste_Facettes is new Liste_Generique(Facette); -- addition de 2 vecteurs -- Requiert A, B de taille identique function "+" (A : Vecteur ; B : Vecteur) return Vecteur; -- soustraction de 2 vecteurs -- Requiert A, B de taille identique function "-" (A : Vecteur ; B : Vecteur) return Vecteur; -- multiplication scalaire vecteur function "*" (Facteur : Float ; V : Vecteur) return Vecteur; -- expo scalaire vecteur function "**" (V : Vecteur; Facteur : Positive) return Vecteur; -- division scalaire vecteur function "/" (V : Vecteur; Facteur : Float) return Vecteur; -- Renvoie une réprésentation chainée d'un point function To_String (P : Point2D) return String; function To_String_3D (P : Point3D) return String; end Vecteurs;
----------------------------------------------------------------------- -- awa-images-tests -- Unit tests for images module -- Copyright (C) 2018, 2019, 2020, 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Util.Test_Caller; with Util.Strings; with ADO; with Servlet.Requests.Mockup; with Servlet.Responses.Mockup; with ASF.Tests; with AWA.Tests.Helpers.Users; package body AWA.Images.Tests is use Ada.Strings.Unbounded; use ADO; package Caller is new Util.Test_Caller (Test, "Images.Beans"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Images.Beans.Create", Test_Create_Image'Access); Caller.Add_Test (Suite, "Test AWA.Images.Servlets (missing)", Test_Missing_Image'Access); end Add_Tests; -- ------------------------------ -- Get some access on the wiki as anonymous users. -- ------------------------------ procedure Verify_Anonymous (T : in out Test; Page : in String; Title : in String) is pragma Unreferenced (Page, Title); Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/images.html", "images-anonymous-list.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list recent page is invalid"); end Verify_Anonymous; -- ------------------------------ -- Verify that the wiki lists contain the given page. -- ------------------------------ procedure Verify_List_Contains (T : in out Test; Name : in String) is pragma Unreferenced (Name); Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/documents.html", "storage-list.html"); ASF.Tests.Assert_Contains (T, "Documents of the workspace", Reply, "List of documents is invalid"); end Verify_List_Contains; -- ------------------------------ -- Test access to the blog as anonymous user. -- ------------------------------ procedure Test_Anonymous_Access (T : in out Test) is begin T.Verify_Anonymous ("", ""); end Test_Anonymous_Access; -- ------------------------------ -- Test creation of image by simulating web requests. -- ------------------------------ procedure Test_Create_Image (T : in out Test) is Request : Servlet.Requests.Mockup.Part_Request (1); Reply : Servlet.Responses.Mockup.Response; Content : Ada.Strings.Unbounded.Unbounded_String; Folder_Id : ADO.Identifier; Image_Id : ADO.Identifier; Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/upload.jpg"); begin AWA.Tests.Helpers.Users.Login ("test-image@test.com", Request); -- Create the folder. Request.Set_Parameter ("folder-name", "Image Folder Name"); Request.Set_Parameter ("storage-folder-create-form", "1"); Request.Set_Parameter ("storage-folder-create-button", "1"); ASF.Tests.Do_Post (Request, Reply, "/storages/forms/folder-create.html", "folder-create-form.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after folder creation"); Reply.Read_Content (Content); Folder_Id := AWA.Tests.Helpers.Extract_Identifier (To_String (Content), "#folder"); T.Assert (Folder_Id > 0, "Invalid folder id returned"); -- Check the list page. ASF.Tests.Do_Get (Request, Reply, "/storages/images.html", "image-list.html"); ASF.Tests.Assert_Contains (T, "Documents of the workspace", Reply, "List of documents is invalid (title)"); ASF.Tests.Assert_Contains (T, "Image Folder Name", Reply, "List of documents is invalid (content)"); -- Upload an image to the folder. if Ada.Directories.Exists (Path) then Ada.Directories.Delete_File (Path); end if; Ada.Directories.Copy_File (Source_Name => "regtests/files/images/Ada-Lovelace.jpg", Target_Name => Path, Form => "all"); Request.Set_Parameter ("folder", ADO.Identifier'Image (Folder_Id)); Request.Set_Parameter ("uploadForm", "1"); Request.Set_Parameter ("id", "-1"); Request.Set_Parameter ("upload-button", "1"); Request.Set_Part (Position => 1, Name => "upload-file", Path => Path, Content_Type => "image/jpg"); ASF.Tests.Do_Post (Request, Reply, "/storages/forms/upload-form.html", "upload-image-form.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after image upload"); T.Assert_Equals ("application/json", Reply.Get_Content_Type, "Invalid response after upload"); Reply.Read_Content (Content); Image_Id := AWA.Tests.Helpers.Extract_Identifier (To_String (Content), "store"); T.Assert (Image_Id > 0, "Invalid image id returned after upload"); -- Look at the image content. ASF.Tests.Do_Get (Request, Reply, "/storages/images/" & Util.Strings.Image (Natural (Image_Id)) & "/view/upload.jpg", "image-file-data.jpg"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after image get"); T.Assert_Equals ("image/jpg", Reply.Get_Content_Type, "Invalid response after upload"); -- Look at the image description page. ASF.Tests.Do_Get (Request, Reply, "/storages/image-info/" & Util.Strings.Image (Natural (Image_Id)), "image-file-info.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response for image-info page"); T.Assert_Equals ("text/html; charset=UTF-8", Reply.Get_Content_Type, "Invalid response for image-info"); ASF.Tests.Assert_Contains (T, "/storages/files/" & Util.Strings.Image (Natural (Image_Id)) & "/", Reply, "Image info page is invalid (missing link)"); end Test_Create_Image; -- ------------------------------ -- Test getting an image which does not exist. -- ------------------------------ procedure Test_Missing_Image (T : in out Test) is Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/images/12345345/view/missing.jpg", "image-file-missing.html"); ASF.Tests.Assert_Redirect (T, "/auth/login.html", Reply, "Invalid redirection for protected page"); AWA.Tests.Helpers.Users.Login ("test-image@test.com", Request); ASF.Tests.Do_Get (Request, Reply, "/storages/images/12345345/view/missing.jpg", "image-file-missing.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_NOT_FOUND, "Invalid response after image get"); end Test_Missing_Image; end AWA.Images.Tests;
------------------------------------------------------------------------------ -- -- -- Ada binding for OpenGL/WebGL -- -- -- -- Examples Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2018, 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. -- -- -- ------------------------------------------------------------------------------ with League.Strings; with WebAPI.HTML.Globals; with WebAPI.HTML.Canvas_Elements; with OpenGL.Contexts; with OpenGL.Textures; with Pyramid.Programs; procedure Pyramid.Driver is use type OpenGL.GLfloat; Points : constant Pyramid.Programs.Vertex_Data_Array := (((0.0, 0.5, 0.0), (0.5, 1.0)), ((0.5, -0.5, 0.0), (1.0, 0.0)), ((-0.5, -0.5, 0.0), (0.0, 0.0))); -- Img : constant array (1 .. 9, 1 .. 3) of OpenGL.GLubyte := -- ((255, 0, 0), (127, 0, 0), (0, 0, 127), -- (127, 255, 0), (0, 127, 0), (0, 0, 127), -- (32, 0, 255), (0, 0, 127), (0,0, 127)); Unit : constant OpenGL.Texture_Unit := 0; Context : OpenGL.Contexts.OpenGL_Context; Buffer : Pyramid.Programs.Vertex_Data_Buffers.OpenGL_Buffer (OpenGL.Vertex); Program : Pyramid.Programs.Pyramid_Program; Texture : OpenGL.Textures.OpenGL_Texture (OpenGL.Texture_2D); begin Context.Create (WebAPI.HTML.Canvas_Elements.HTML_Canvas_Element_Access (WebAPI.HTML.Globals.Window.Get_Document.Get_Element_By_Id (League.Strings.To_Universal_String ("canvas")))); Context.Make_Current; Context.Functions.Enable (OpenGL.GL_DEPTH_TEST); Buffer.Create; Buffer.Bind; Buffer.Allocate (Points); Texture.Create; Texture.Bind (Unit); -- Texture.Set_Image_2D -- (0, OpenGL.GL_RGB, 3, 3, OpenGL.GL_UNSIGNED_BYTE, Img'Address); Texture.Set_Parameter (OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR); Texture.Set_Parameter (OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR); Program.Initialize; Program.Bind; Program.Set_Vertex_Data_Buffer (Buffer); Program.Set_Texture_Unit (Unit); declare use type OpenGL.GLbitfield; Clear_Flag : OpenGL.Clear_Buffer_Mask := OpenGL.GL_DEPTH_BUFFER_BIT + OpenGL.GL_COLOR_BUFFER_BIT; begin Context.Functions.Clear (Clear_Flag); Context.Functions.Draw_Arrays (OpenGL.GL_TRIANGLES, 0, Points'Length); end; end Pyramid.Driver;
with Ada.Text_Io; use Ada.Text_Io; procedure Mutual_Recursion is function M(N : Integer) return Integer; function F(N : Integer) return Integer is begin if N = 0 then return 1; else return N - M(F(N - 1)); end if; end F; function M(N : Integer) return Integer is begin if N = 0 then return 0; else return N - F(M(N-1)); end if; end M; begin for I in 0..19 loop Put_Line(Integer'Image(F(I))); end loop; New_Line; for I in 0..19 loop Put_Line(Integer'Image(M(I))); end loop; end Mutual_recursion;
-- MIT License -- Copyright (c) 2021 Stephen Merrony -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. with Ada.Text_IO; use Ada.Text_IO; with Debug_Logs; use Debug_Logs; with Resolver; use Resolver; package body Processor.Eclipse_FPU_P is procedure Debug_FPACs (CPU : in CPU_T) is begin Loggers.Debug_Print (Debug_Log, "FPAC0: " & CPU.FPAC(0)'Image & " FPAC1: " & CPU.FPAC(1)'Image & " FPAC2: " & CPU.FPAC(2)'Image & " FPAC3: " & CPU.FPAC(3)'Image); -- Ada.Text_IO.Put_Line("FPAC0: " & CPU.FPAC(0)'Image & -- " FPAC1: " & CPU.FPAC(1)'Image & -- " FPAC2: " & CPU.FPAC(2)'Image & -- " FPAC3: " & CPU.FPAC(3)'Image); end Debug_FPACs; procedure Do_Eclipse_FPU (I : in Decoded_Instr_T; CPU : in out CPU_T) is QW : Qword_T; --LF : Long_Float; DG_Dbl : Double_Overlay; begin Debug_FPACs (CPU); case I.Instruction is when I_FAD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) + CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FCLE => CPU.FPSR := 0; -- TODO verify - PoP contradicts itself when I_FCMP => if CPU.FPAC(I.Acs) = CPU.FPAC(I.Acd) then Set_N (CPU, false); Set_Z (CPU, true); elsif CPU.FPAC(I.Acs) > CPU.FPAC(I.Acd) then Set_N (CPU, true); Set_Z (CPU, false); else Set_N (CPU, false); Set_Z (CPU, false); end if; when I_FDD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) / CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FMS => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) * CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSGT => if (not Get_Z(CPU)) and (not Get_N(CPU)) then CPU.PC := CPU.PC + 1; end if; when I_FINT => CPU.FPAC(I.Ac) := Long_Float'Truncation(CPU.FPAC(I.Ac)); Set_N (CPU, (CPU.FPAC(I.Ac) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Ac) = 0.0)); when I_FMD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) * CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSEQ => if Get_Z(CPU) then CPU.PC := CPU.PC + 1; end if; when I_FSGE => if not Get_N(CPU) then CPU.PC := CPU.PC + 1; end if; when I_FSLT => if Get_N(CPU) then CPU.PC := CPU.PC + 1; end if; when I_FTD => Clear_QW_Bit (CPU.FPSR, FPSR_Te); when I_FTE => Set_QW_Bit (CPU.FPSR, FPSR_Te); when I_FRDS => QW := Long_Float_To_DG_Double(CPU.FPAC(I.Acs)); if Test_QW_Bit (CPU.FPSR, FPSR_Rnd) then -- FIXME - should round not truncate DG_Dbl.Double_QW := QW and 16#ffff_ffff_0000_0000#; CPU.FPAC(I.Acd) := DG_Double_To_Long_Float(DG_Dbl); else DG_Dbl.Double_QW := QW and 16#ffff_ffff_0000_0000#; CPU.FPAC(I.Acd) := DG_Double_To_Long_Float(DG_Dbl); end if; Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSD => CPU.FPAC(I.Acd) := CPU.FPAC(I.Acd) - CPU.FPAC(I.Acs); Set_N (CPU, (CPU.FPAC(I.Acd) < 0.0)); Set_Z (CPU, (CPU.FPAC(I.Acd) = 0.0)); when I_FSNE => if Get_Z(CPU) then CPU.PC := CPU.PC + 1; end if; when others => Put_Line ("ERROR: ECLIPSE_FPU instruction " & To_String(I.Mnemonic) & " not yet implemented"); raise Execution_Failure with "ERROR: ECLIPSE_FPU instruction " & To_String(I.Mnemonic) & " not yet implemented"; end case; Debug_FPACs (CPU); CPU.PC := CPU.PC + Phys_Addr_T(I.Instr_Len); end Do_Eclipse_FPU; end Processor.Eclipse_FPU_P;
pragma SPARK_Mode; with Types; use Types; with Interfaces; use Interfaces; -- @summary -- Interface to Arduino Wire library -- -- @description -- Provides an interface to the Arudino Wire library. This is used for -- I2C busses. -- package Wire is -- Return result of a transmission -- @value Success success -- @value Data_Too_Long data too long to fit in transmit buffer -- @value Rx_NACK_Addr received NACK on transmit of address -- @value Rx_NACK_Data received NACK on transmit of data -- @value Other_Err other error type Transmission_Status_Index is (Success, Data_Too_Long, Rx_NACK_Addr, Rx_NACK_Data, Other_Err); Transmission_Status : array (Transmission_Status_Index) of Byte := (Success => 0, Data_Too_Long => 1, Rx_NACK_Addr => 2, Rx_NACK_Data => 3, Other_Err => 4); -- Translates a Byte to Transmission_Status_Index -- @param BB the byte to cast -- @return the Transmission_Status_Index corresponding to the value in BB function Byte2TSI (BB : Byte) return Transmission_Status_Index; -- Initiate the Wire library and join the I2C bus as a master. procedure Init_Master with Global => null; pragma Import (C, Init_Master, "Wire_Begin_Master"); -- Initiate the Wire library and join the I2C bus as a slave -- @param Addr the 7-bit slave address procedure Init_Slave (Addr : Byte) with Global => null; pragma Import (C, Init_Slave, "Wire_Begin_Slave"); -- This function modifies the clock frequency for I2C communication. -- @param Freq the value (in Hertz) of desired communication clock procedure SetClock (Freq : Unsigned_32) with Global => null; pragma Import (C, SetClock, "Wire_SetClock"); -- Read a byte from the Reg register on the device at Addr -- @param Addr the address of the device to access -- @param Reg the register to access on the device -- @return the Byte read from the device function Read_Byte (Addr : Byte; Reg : Byte) return Byte; -- Read multiple bytes from the device at Addr start at register Reg -- @param Addr the address of the device to access -- @param Reg the starting register to access on the device -- @param Data an array of Bytes read from the registers procedure Read_Bytes (Addr : Byte; Reg : Byte; Data : out Byte_Array) with Global => Transmission_Status, Pre => (Data'Length > 0); pragma Annotate (GNATprove, False_Positive, """Data"" might not be initialized", String'("Data is properly initialized by this loop")); -- Write a byte to the register Reg on the device at Addr -- @param Addr the address of the device to write to -- @param Reg the register to write to on the device -- @param Data the data to write to the device -- @return the status of the write transaction function Write_Byte (Addr : Byte; Reg : Byte; Data : Byte) return Transmission_Status_Index; private -- Used by the master to request bytes from a slave device. -- Ada wrapper around imported RequestFrom_C -- @param Addr the 7-bit address of the device to request bytes from -- @param Quant the number of bytes to request -- @param Stop true will send a stop message after the request, releasing -- the bus. false will continually send a restart after the request, -- keeping the connection active. -- @return the number of bytes returned from the slave device function RequestFrom (Addr : Byte; Quant : Byte; Stop : Boolean) return Byte; -- See documentation for RequestFrom function RequestFrom_C (Addr : Byte; Quant : Byte; Stop : Byte) return Byte with Global => null; pragma Import (C, RequestFrom_C, "Wire_RequestFrom"); -- Begin a transmission to the I2C slave device with the given address -- @param Addr the 7-bit address of the device to transmit to procedure BeginTransmission (Addr : Byte) with Global => null; pragma Import (C, BeginTransmission, "Wire_BeginTransmission"); -- Ends a transmission to a slave device that was begun by -- BeginTransmission () and transmits the bytes that were queued -- by write (). Ada wrapper around EndTransmission_C -- @param Stop true will send a stop message, releasing the bus after -- transmission. false will send a restart, keeping the connection active -- @return byte, which indicates the status of the transmission function EndTransmission (Stop : Boolean) return Byte; -- See documentation for EndTransmission function EndTransmission_C (Stop : Byte) return Byte with Global => null; pragma Import (C, EndTransmission_C, "Wire_EndTransmission"); -- Queues bytes for transmission from a master to slave device -- @param Val a value to send as a single byte -- @return will return the number of bytes written function Write_Value (Val : Byte) return Byte with Global => null; pragma Import (C, Write_Value, "Wire_Write_Value"); -- Returns the number of bytes available for retrieval with read() -- @return The number of bytes available for reading. function Available return Integer with Global => null; pragma Import (C, Available, "Wire_Available"); -- Reads a byte that was transmitted from a slave device to a master -- @return The next byte received function Read return Byte with Global => null; pragma Import (C, Read, "Wire_Read"); end Wire;
with Ada.Real_Time; use Ada.Real_Time; package System_Function_Package is function System_A(X : Integer) return Integer; function System_B(Y : Integer) return Integer; function System_C(X, Y : Integer) return Integer; end System_Function_Package ;
With Ada.Containers.Indefinite_Holders, Ada.IO_Exceptions, Ada.Strings.Fixed; Package Body INI is use type Ada.Containers.Count_Type; Package String_Holder is new Ada.Containers.Indefinite_Holders( String ); Function "=" (Left, Right : String) return Boolean renames Ada.Strings.Equal_Case_Insensitive; Function "="(Left, Right : KEY_VALUE_MAP.Map) return Boolean is (if Left.Length /= Right.Length then False else (for all Item in Left.Iterate => Right.Contains(KEY_VALUE_MAP.Key(Item)) and then KEY_VALUE_MAP.Element( Item ) = Right(KEY_VALUE_MAP.Key( Item )) )); Generic Target : Character; Stream : not null access Ada.Streams.Root_Stream_Type'Class; Function Read_Until return String; Function Read_until return String is Begin Declare C : Character renames Character'Input( Stream ); Begin Return (if C = Target then "" else C & Read_until); End; exception when Ada.IO_Exceptions.End_Error => Return ""; End Read_until; Function "="(Left, Right : Value_Object) return Boolean is (if Left.Kind /= Right.Kind then False else (case Left.Kind is when vt_String => Left.String_Value = Right.String_Value, when vt_Float => Left.Float_Value = Right.Float_Value, when vt_Integer => Left.Integer_Value = Right.Integer_Value, when vt_Boolean => Left.Boolean_Value = Right.Boolean_Value ) ); Function "ABS"( Object : Value_Object ) return String is (case Object.Kind is when vt_String => (if (for some C of Object.String_Value => C = '"') then raise Program_Error with "Qoute cannot be embedded at this time." else Object.String_Value), when vt_Float => Float'Image ( Object.Float_Value ), when vt_Integer => Integer'Image( Object.Integer_Value), when vt_Boolean => Boolean'Image( Object.Boolean_Value) ); package body Object_Package is function Value_Input( Stream : not null access Ada.Streams.Root_Stream_Type'Class ) return Value_Object is Subtype Integer_Characters is Character with Static_Predicate => Integer_Characters in '0'..'9'; Subtype Float_Characters is Character with Static_Predicate => Float_Characters in '.'|Integer_Characters; Function Dequote ( Input : String ) Return String is Function Delimit( Input, Working : String := "" ) return String is Search: constant String:= """"""; Index : Natural renames Ada.Strings.Fixed.Index( Source => Input, Pattern => Search, From => 1 ); Subtype Head is Natural range Input'First..Positive'Pred(Index); Subtype Tail is Natural range Input'First+Search'Length..Input'Last; Begin If Index not in Positive then Return Working & Input; else Return Delimit( Input(Tail), Working & Input(Head) & '"'); end if; End; Subtype Inner_Range is Natural range Positive'Succ(Input'First) .. Positive'Pred(Input'Last); Temp : String( Input'Range ) := Input; Index_Input, Index_Temp : Natural := Input'First; Begin if Input'Length not in Positive then return ""; elsif Input(Input'Last) = '"' and Input(Input'First) = '=' then Return Delimit( Inner_Range ); else Return Input; end if; End Dequote; Function Trim(Input : String) return String is Function Trim_Left(Input : String) return String is Index : Positive := Input'First; Begin If Input'Length not in Positive then Return ""; Else while Index <= Input'Last and Input(Index) not in ' '..'~' loop Index:= Positive'Succ( Index ); end loop; Return Input(Index..Input'Last); end if; End; Function Trim_Right( Input : String ) return String is Index : Natural := Input'Last; Begin If Input'Length not in Positive then Return ""; Else while Index >= Input'First and Input(Index) not in ' '..'~' loop Index:= Positive'Pred( Index ); end loop; Return Input(Input'First..Index); End if; End; Begin Return Trim_Right( Trim_Left( Input ) ); end Trim; Function Get_Value is new Read_until( ASCII.CR, STREAM ); Value : String renames Get_Value; Begin --Return (vt_Boolean, 0, Boolean_Value => Value = "T" or Value = "TRUE"); if Value = "T" or Value = "TRUE" or Value = "F" or Value = "FALSE" then Return (vt_Boolean, 0, Boolean_Value => Value = "T" or Value = "TRUE"); -- elsif (for all C of Value => C in Integer_Characters) then -- Return ( vt_Integer, 0, Integer_Value => Integer'Value(Value) ); -- elsif (for all C of Value => C in Float_Characters) then -- Return ( vt_Float, 0, Float_Value => Float'Value(Value) ); else Declare Text : String renames Dequote( Trim( Value ) ); Begin Return ( vt_String, Text'Length, String_Value => Text ); End; end if; End Value_Input; End Object_Package; Generic Item : Value_Object; Procedure Assignment( Object : in out Instance; Key : in String; Section: in String); Procedure Assignment( Object : in out Instance; Key : in String; Section: in String ) is Begin Declare -- This RENAME raises CONSTRAINT_ERROR if the section does not exist. Sec : KEY_VALUE_MAP.Map renames Object(Section); Begin -- This indexing raises CONSTRAINT_ERROR when the key does not exist. Sec(Key):= Item; exception when Constraint_Error => -- Create a new key, with the item associated. Sec.Include(Key => Key, New_Item => Item); End; exception when Constraint_Error => -- Create a new section, with a new key that has item associated. Declare New_Section : KEY_VALUE_MAP.Map := KEY_VALUE_MAP.Empty_Map; Begin New_Section.Include(Key => Key, New_Item => Item); Object.Include(Key => Section, New_Item => New_Section); End; End Assignment; Function Exists( Object : in Instance; Key : in String; Section: in String:= "" ) return Boolean is ( Object.Contains(Section) and then Object(Section).Contains(Key) ); -- Return the type of the associated value. Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Value_Type is (Object(Section)(Key).Kind); -- Return the value associated with the key in the indicated section. Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return String is (Object(Section)(Key).String_Value); Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Float is (Object(Section)(Key).Float_Value); Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Integer is (Object(Section)(Key).Integer_Value); Function Value( Object : in Instance; Key : in String; Section: in String:= "" ) return Boolean is (Object(Section)(Key).Boolean_Value); -- Associates a value with the given key in the indicated section. Procedure Value( Object : in out Instance; Key : in String; Value : in String; Section: in String:= "" ) is Item : Constant Value_Object := (Kind => vt_String, Length => Value'Length, String_Value => Value); Procedure Assign is new Assignment(Item); begin Assign(Object, Key, Section); end Value; Procedure Value( Object : in out Instance; Key : in String; Value : in Float; Section: in String:= "" ) is Item : Constant Value_Object := (Kind => vt_Float, Length => 0, Float_Value => Value); Procedure Assign is new Assignment(Item); begin Assign( Object, Key, Section ); end Value; Procedure Value( Object : in out Instance; Key : in String; Value : in Integer; Section: in String:= "" ) is item : Constant Value_Object := (Kind => vt_Integer, Length => 0, Integer_Value => Value); Procedure Assign is new Assignment(Item); begin Assign( Object, Key, Section ); end Value; Procedure Value( Object : in out Instance; Key : in String; Value : in Boolean; Section: in String:= "" ) is Item : Constant Value_Object := (Kind => vt_Boolean, Length => 0, Boolean_Value => Value); Procedure Assign is new Assignment(Item); begin Assign( Object, Key, Section ); end Value; Procedure INI_Output( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in Instance ) is Begin for Section in Item.Iterate loop Declare Key : String renames KEY_SECTION_MAP.Key( Section ); Val : KEY_VALUE_MAP.Map renames KEY_SECTION_MAP.Element(Section); Begin if Key /= "" then String'Write( Stream, '[' & Key & ']' ); String'Write(Stream, ASCII.CR & ASCII.LF); end if; for KVP in Val.Iterate loop Declare K : String renames KEY_VALUE_MAP.Key( KVP ); V : Value_Object renames KEY_VALUE_MAP.Element( KVP ); Begin String'Write (Stream, K); Character'Write (Stream, '='); Value_Object'Write (Stream, V); String'Write (Stream, ASCII.CR & ASCII.LF); End; end loop; String'Write (Stream, ASCII.CR & ASCII.LF); End; end loop; End INI_Output; Function INI_Input( Stream : not null access Ada.Streams.Root_Stream_Type'Class ) return Instance is Section_Name : String_Holder.Holder:= String_Holder.To_Holder(""); Finished : Boolean := False; Function Get_Name is new Read_until( ']', Stream ); Function Get_Key is new Read_until( '=', Stream ); Function Get_Value is new Read_until( ASCII.CR, Stream ); -- Gets the next graphic character in the stream, discarding all the -- non-graphic characters; sets FINISHED to true on END_ERROR. Function Get_Non_Blank return Character is Begin Return Result : Character do loop Character'Read(Stream, Result); exit when Result in ' '..'~'; end loop; exception when Ada.IO_Exceptions.End_Error => Finished:= True; end return; End Get_Non_Blank; Begin Return Result : Instance(Convert => Default_Conversion) do Result.Include(Section_Name.Element, KEY_VALUE_MAP.Empty_Map); Loop Declare Procedure Set_Name is Name : String renames Get_Name; Default : KEY_VALUE_MAP.Map; Begin Section_Name.Replace_Element( Name ); Result.Include(Section_Name.Element, Default); End Set_Name; C : Constant Character := Get_Non_Blank; begin exit when Finished; case C is when '[' => Set_Name; when others => Declare Key : String renames "&"(C, Get_Key); Value : Constant Value_Object:= Object_Package.Value_Input(Stream); Begin Result(Section_Name.Element).Include(Key, Value); End; end case; end; end loop; end return; End INI_Input; End INI;
with Ada.Real_Time; with Keyboard; with Levels; with Player; with Render; with GESTE; with GESTE.Maths_Types; use GESTE.Maths_Types; with GESTE.Text; package body Game is package RT renames Ada.Real_Time; use type RT.Time; use type RT.Time_Span; Period : constant RT.Time_Span := RT.Seconds (1) / 60; Next_Release : RT.Time := RT.Clock + Period; --------------- -- Game_Loop -- --------------- procedure Game_Loop is begin loop Keyboard.Update; if Keyboard.Pressed (Keyboard.Up) then Player.Throttle; end if; if Keyboard.Pressed (Keyboard.Down) then Player.Brake; end if; if Keyboard.Pressed (Keyboard.Left) then Player.Move_Left; end if; if Keyboard.Pressed (Keyboard.Right) then Player.Move_Right; end if; if Keyboard.Pressed (Keyboard.Esc) then return; end if; Player.Update (Value (1.0 / 60.0)); Render.Render_Dirty (Render.Black); delay until Next_Release; Next_Release := RT.Clock + Period; end loop; end Game_Loop; begin Levels.Enter (Levels.Lvl_1); Render.Render_All (Render.Black); end Game;
-- MIT License -- -- Copyright (c) 2021 Glen Cornell <glen.m.cornell@gmail.com> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. package Sockets.Can.Broadcast_Manager is type Broadcast_Manager_Type is tagged private; procedure Create (This : out Broadcast_Manager_Type; Interface_Name : in String); -- Object initialization. function Get_Socket (This : in Broadcast_Manager_Type) return Sockets.Can.Socket_Type; -- Socket type accessor procedure Send_Periodic (This : in Broadcast_Manager_Type; Item : in Sockets.Can_Frame.Can_Frame; Interval : in Duration); -- Periodically send the CAN frame at the specified interval. procedure Send_Once (This : in Broadcast_Manager_Type; Item : in Sockets.Can_Frame.Can_Frame); -- Send the CAN frame only once. procedure Update_Periodic (This : in Broadcast_Manager_Type; Item : in Sockets.Can_Frame.Can_Frame); -- Change the contents of the CAN frame that is periodically sent. procedure Stop_Periodic (This : in Broadcast_Manager_Type; Can_Id : in Sockets.Can_Frame.Can_Id_Type); -- Delete the cyclic send job of the CAN frame with the specified -- CAN ID. procedure Add_Receive_Filter (This : in Broadcast_Manager_Type; Item : in Sockets.Can_Frame.Can_Frame; Interval : in Duration := 0.0); -- Setup the receive filter for the given CAN ID. Mask is the -- content filter - if data changes on the specified mask, the -- broadcast manager will send the CAN frame to your socket. If -- the mask is empty, content filtering is disabled and any change -- will be forwarded to the receiving socket. Interval is the -- down-sampling inteval. Down-sampling will reduce the CPU -- burden on the application at the expense of dropping all -- packets in between intervals. procedure Remove_Receive_Filter (This : in Broadcast_Manager_Type; Can_Id : in Sockets.Can_Frame.Can_Id_Type); -- Remove the receive filter. procedure Receive_Can_Frame (This : in Broadcast_Manager_Type; Frame : out Sockets.Can_Frame.Can_Frame); private type Broadcast_Manager_Type is tagged record Socket : Sockets.Can.Socket_Type; Address : Sockets.Can.Sock_Addr_Type; end record; end Sockets.Can.Broadcast_Manager;
private with Libadalang.Analysis; with A_Nodes; with Dot; private with Lal_Adapter.Node; -- with Lal_Adapter.Unit; package Lal_Adapter.Context is type Class is tagged limited private; procedure Process (This : in out Class; Input_File_Name : in String; Project_File_Name : in String; -- Unit_Options : in Unit.Options_Record; Outputs : in Output_Accesses_Record); private package LAL renames Libadalang.Analysis; -- For debuggng: Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Context"; type Class is tagged limited -- Initialized record Lal_Context : LAL.Analysis_Context := LAL.No_Analysis_Context; Top_Unit : LAL.Analysis_Unit := LAL.No_Analysis_Unit; Top_Compilation_Unit : LAL.Compilation_Unit := LAL.No_Compilation_Unit; Nodes : Lal_Adapter.Node.Class; -- Initialized end record; end Lal_Adapter.Context;
-- SPDX-FileCopyrightText: 2019-2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Unit_Naming; private with Ada.Strings.Wide_Wide_Maps; package Program.GNAT_Unit_Naming is pragma Preelaborate; type GNAT_Unit_Naming is new Program.Unit_Naming.Unit_Naming_Schema with private; -- This object returns file base name for GNAT naming (except predefined). private type GNAT_Unit_Naming is new Program.Unit_Naming.Unit_Naming_Schema with record Map : Ada.Strings.Wide_Wide_Maps.Wide_Wide_Character_Mapping := Ada.Strings.Wide_Wide_Maps.To_Mapping (".", "-"); end record; overriding function Standard_Text_Name (Self : GNAT_Unit_Naming) return Text; -- Get compilation Text_Name for Standard library package. overriding function Declaration_Text_Name (Self : GNAT_Unit_Naming; Name : Program.Text) return Program.Text; -- Get compilation Text_Name for given library declaration unit. overriding function Body_Text_Name (Self : GNAT_Unit_Naming; Name : Program.Text) return Program.Text; -- Get compilation Text_Name for given body. overriding function Subunit_Text_Name (Self : GNAT_Unit_Naming; Name : Program.Text) return Program.Text; end Program.GNAT_Unit_Naming;
Name: declare -- a local declaration block has an optional name A : constant Integer := 42; -- Create a constant X : String := "Hello"; -- Create and initialize a local variable Y : Integer; -- Create an uninitialized variable Z : Integer renames Y: -- Rename Y (creates a view) function F (X: Integer) return Integer is -- Inside, all declarations outside are visible when not hidden: X, Y, Z are global with respect to F. X: Integer := Z; -- hides the outer X which however can be refered to by Name.X begin ... end F; -- locally declared variables stop to exist here begin Y := 1; -- Assign variable declare X: Float := -42.0E-10; -- hides the outer X (can be referred to Name.X like in F) begin ... end; end Name; -- End of the scope
-- -- Copyright (C) 2022 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- with Ada.Text_IO; use Ada.Text_IO; package body App is use GNAT.Sockets; use Ada.Streams; function To_String (SEA : Stream_Element_Array) return String is Offset : Stream_Element_Offset := SEA'First; S : String (1 .. SEA'Length); begin for I in S'Range loop S (I) := Character'Val (SEA (Offset)); Offset := Offset + 1; end loop; return S; end To_String; function On_Connect (Socket : Socket_Type) return Server.Socket_Action is begin Put_Line ("On_Connect"); return Server.No_Action; end On_Connect; function On_Readable (Socket : Socket_Type) return Server.Socket_Action is Buffer : Stream_Element_Array (1 .. 1024); Last : Stream_Element_Offset; begin Receive_Socket (Socket, Buffer, Last); if Last = Buffer'First - 1 then Put_Line ("Client closed connection"); return Server.Should_Close; else Put_Line ("Received: " & To_String (Buffer (1 .. Last))); return Server.No_Action; end if; end On_Readable; function On_Writable (Socket : Socket_Type) return Server.Socket_Action is Channel : constant GNAT.Sockets.Stream_Access := Stream (Socket); begin String'Write (Channel, "hello world" & ASCII.CR & ASCII.LF); return Server.Should_Close; end On_Writable; end App;
with ada.Strings.unbounded; package XML.Reader is use ada.Strings.unbounded; type Parser is private; function Create_Parser return Parser; type Start_Element_Handler is access procedure (Name : in unbounded_String; Atts : in XML.Attributes_view); type End_Element_Handler is access procedure (Name : in unbounded_String); procedure Set_Element_Handler (The_Parser : in Parser; Start_Handler : in Start_Element_Handler; End_Handler : in End_Element_Handler); type Character_Data_Handler is access procedure (Data: in unbounded_String); procedure Set_Character_Data_Handler (The_Parser : in Parser; CD_Handler : in Character_Data_Handler); procedure Parse (The_Parser : in Parser; XML : in String; Is_Final : in Boolean); XML_Parse_Error : exception; private type XML_Parser_Ptr is access all Character; -- Essentially, C's "void *". type Parser_Rec is record XML_Parser : XML_Parser_Ptr; Start_Handler : Start_Element_Handler; End_Handler : End_Element_Handler; CD_Handler : Character_Data_Handler; end record; type Parser is access Parser_Rec; -- pragma Linker_Options ("-lexpat"); end XML.Reader;
-- C72002A.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 THE DECLARATIVE ITEMS IN A PACKAGE SPECIFICATION ARE -- ELABORATED IN THE ORDER DECLARED. -- HISTORY: -- DHH 03/09/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C72002A IS A : INTEGER := 0; TYPE ORDER_ARRAY IS ARRAY(1 .. 14) OF INTEGER; OBJECT_ARRAY : ORDER_ARRAY; TYPE REAL IS DIGITS 4; TYPE ENUM IS (RED,YELLOW,BLUE); TYPE ARR IS ARRAY(1 ..2) OF BOOLEAN; D : ARR := (TRUE, TRUE); E : ARR := (FALSE, FALSE); TYPE REC IS RECORD I : INTEGER; END RECORD; B : REC := (I => IDENT_INT(1)); C : REC := (I => IDENT_INT(2)); FUNCTION GIVEN_ORDER(X : INTEGER) RETURN INTEGER IS Y : INTEGER; BEGIN Y := X + 1; RETURN Y; END GIVEN_ORDER; FUNCTION BOOL(X : INTEGER) RETURN BOOLEAN IS BEGIN IF X = IDENT_INT(1) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN TRUE; ELSIF X = IDENT_INT(8) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN FALSE; END IF; END BOOL; FUNCTION INT(X : INTEGER) RETURN INTEGER IS BEGIN IF X = IDENT_INT(2) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN IDENT_INT(1); ELSIF X = IDENT_INT(9) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN IDENT_INT(2); END IF; END INT; FUNCTION FLOAT(X : INTEGER) RETURN REAL IS BEGIN IF X = IDENT_INT(3) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN 1.0; ELSIF X = IDENT_INT(10) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN 2.0; END IF; END FLOAT; FUNCTION CHAR(X : INTEGER) RETURN CHARACTER IS BEGIN IF X = IDENT_INT(4) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN 'A'; ELSIF X = IDENT_INT(11) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN 'Z'; END IF; END CHAR; FUNCTION ENUMR(X : INTEGER) RETURN ENUM IS BEGIN IF X = IDENT_INT(5) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN RED; ELSIF X = IDENT_INT(12) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN YELLOW; END IF; END ENUMR; FUNCTION ARRY(X : INTEGER) RETURN ARR IS BEGIN IF X = IDENT_INT(6) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN D; ELSIF X = IDENT_INT(13) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN E; END IF; END ARRY; FUNCTION RECOR(X : INTEGER) RETURN REC IS BEGIN IF X = IDENT_INT(7) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN B; ELSIF X = IDENT_INT(14) THEN A := GIVEN_ORDER(A); OBJECT_ARRAY(X) := A; RETURN C; END IF; END RECOR; PACKAGE PACK IS A : BOOLEAN := BOOL(1); B : INTEGER := INT(2); C : REAL := FLOAT(3); D : CHARACTER := CHAR(4); E : ENUM := ENUMR(5); F : ARR := ARRY(6); G : REC := RECOR(7); H : BOOLEAN := BOOL(8); I : INTEGER := INT(9); J : REAL := FLOAT(10); K : CHARACTER := CHAR(11); L : ENUM := ENUMR(12); M : ARR := ARRY(13); N : REC := RECOR(14); END PACK; BEGIN TEST("C72002A", "CHECK THAT THE DECLARATIVE ITEMS IN A PACKAGE " & "SPECIFICATION ARE ELABORATED IN THE ORDER " & "DECLARED"); IF OBJECT_ARRAY(1) /= IDENT_INT(1) THEN FAILED("BOOLEAN 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(2) /= IDENT_INT(2) THEN FAILED("INTEGER 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(3) /= IDENT_INT(3) THEN FAILED("REAL 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(4) /= IDENT_INT(4) THEN FAILED("CHARACTER 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(5) /= IDENT_INT(5) THEN FAILED("ENUMERATION 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(6) /= IDENT_INT(6) THEN FAILED("ARRAY 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(7) /= IDENT_INT(7) THEN FAILED("RECORD 1 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(8) /= IDENT_INT(8) THEN FAILED("BOOLEAN 2 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(9) /= IDENT_INT(9) THEN FAILED("INTEGER 2 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(10) /= IDENT_INT(10) THEN FAILED("REAL 2 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(11) /= IDENT_INT(11) THEN FAILED("CHARACTER 2 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(12) /= IDENT_INT(12) THEN FAILED("ENUMERATION 2 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(13) /= IDENT_INT(13) THEN FAILED("ARRAY 2 ELABORATED OUT OF ORDER"); END IF; IF OBJECT_ARRAY(14) /= IDENT_INT(14) THEN FAILED("RECORD 2 ELABORATED OUT OF ORDER"); END IF; RESULT; END C72002A;
with Interfaces.C; use Interfaces.C; with SDL_SDL_h; use SDL_SDL_h; with SDL_SDL_video_h; use SDL_SDL_video_h; package body SDL_Display is Display : access SDL_Surface; Screen_Offset : GESTE.Pix_Point := (0, 0); XS, XE, YS, YE : Natural := 0; X, Y : Natural := 0; ---------------- -- Initialize -- ---------------- procedure Initialize is begin if SDL_Init (SDL_INIT_VIDEO) < 0 then raise Program_Error with "SDL Video init failed"; return; end if; Display := SDL_SetVideoMode (800 * int (Pixel_Scale), 600 * int (Pixel_Scale), SDL_Pixel'Size, SDL_SWSURFACE); if Display = null then raise Program_Error with "Cannot create SDL display"; end if; end Initialize; ---------------------- -- Set_Drawing_Area -- ---------------------- procedure Set_Drawing_Area (Area : GESTE.Pix_Rect) is begin XS := Area.TL.X - Screen_Offset.X; YS := Area.TL.Y - Screen_Offset.Y; XE := Area.BR.X - Screen_Offset.X; YE := Area.BR.Y - Screen_Offset.Y; X := XS; Y := YS; if XS < 0 then raise Program_Error; end if; if YS < 0 then raise Program_Error; end if; if XE >= Width then raise Program_Error; end if; if YE >= Height then raise Program_Error; end if; end Set_Drawing_Area; ----------------------- -- Set_Screen_Offset -- ----------------------- procedure Set_Screen_Offset (Pt : GESTE.Pix_Point) is begin Screen_Offset := Pt; end Set_Screen_Offset; ------------ -- Update -- ------------ procedure Update is begin SDL_UpdateRect (Display, 0, 0, 0, 0); end Update; ------------------ -- To_SDL_Color -- ------------------ function To_SDL_Color (R, G, B : Unsigned_8) return SDL_Pixel is begin return SDL_Pixel (SDL_MapRGB (Display.format, unsigned_char (R), unsigned_char (G), unsigned_char (B))); end To_SDL_Color; ----------------- -- Push_Pixels -- ----------------- procedure Push_Pixels (Pixels : GESTE.Output_Buffer) is Buffer : array (0 .. Natural (Display.w * Display.h - 1)) of SDL_Pixel with Address => Display.pixels; begin for Pix of Pixels loop for XP in X * Pixel_Scale .. X * Pixel_Scale + Pixel_Scale loop for YP in Y * Pixel_Scale .. Y * Pixel_Scale + Pixel_Scale loop Buffer (XP + YP * Natural (Display.w)) := Pix; end loop; end loop; if X = XE then X := XS; if Y = YE then Y := YS; else Y := Y + 1; end if; else X := X + 1; end if; end loop; SDL_UpdateRect (Display, int (XS * Pixel_Scale), int (YS * Pixel_Scale), unsigned ((XE - XS + 1) * Pixel_Scale), unsigned ((YE - YS + 1) * Pixel_Scale)); end Push_Pixels; --------------- -- Set_Pixel -- --------------- procedure Set_Pixel (X, Y : Natural; Pix : SDL_Pixel) is Buffer : array (0 .. Natural (Display.w * Display.h - 1)) of SDL_Pixel with Address => Display.pixels; begin Buffer (X + Y * Natural (Display.w)) := Pix; end Set_Pixel; begin Initialize; end SDL_Display;
with Ada.Unchecked_Deallocation; package body kv.avm.Messages is type Message_Data_Type is record Source_Actor : kv.avm.Actor_References.Actor_Reference_Type; Reply_To : kv.avm.Actor_References.Actor_Reference_Type; Destination_Actor : kv.avm.Actor_References.Actor_Reference_Type; Message_Name : kv.avm.Registers.String_Type; Data : kv.avm.Tuples.Tuple_Type; Future : Interfaces.Unsigned_32; end record; type Message_Data_Access is access Message_Data_Type; type Reference_Counted_Message_Type is record Count : Natural := 0; Data : Message_Data_Access; end record; ----------------------------------------------------------------------------- procedure Free is new Ada.Unchecked_Deallocation(Reference_Counted_Message_Type, Reference_Counted_Message_Access); ----------------------------------------------------------------------------- procedure Free is new Ada.Unchecked_Deallocation(Message_Data_Type, Message_Data_Access); ----------------------------------------------------------------------------- function Debug(Data : Message_Data_Access) return String is begin return "N: '" & (+Data.Message_Name) & "'" & " S:" & Data.Source_Actor.Image & " R:" & Data.Reply_To.Image & " D:" & Data.Destination_Actor.Image & " T: " & Data.Data.To_String & " F:" & Interfaces.Unsigned_32'IMAGE(Data.Future); end Debug; ----------------------------------------------------------------------------- procedure Initialize (Self : in out Message_Type) is begin null; end Initialize; ---------------------------------------------------------------------------- procedure Adjust (Self : in out Message_Type) is begin if Self.Ref /= null then Self.Ref.Count := Self.Ref.Count + 1; end if; end Adjust; ---------------------------------------------------------------------------- procedure Finalize (Self : in out Message_Type) is Ref : Reference_Counted_Message_Access := Self.Ref; begin Self.Ref := null; if Ref /= null then Ref.Count := Ref.Count - 1; if Ref.Count = 0 then Free(Ref.Data); Free(Ref); end if; end if; end Finalize; ----------------------------------------------------------------------------- procedure Initialize (Self : in out Message_Type; Source : in kv.avm.Actor_References.Actor_Reference_Type; Reply_To : in kv.avm.Actor_References.Actor_Reference_Type; Destination : in kv.avm.Actor_References.Actor_Reference_Type; Message_Name : in String; Data : in kv.avm.Tuples.Tuple_Type; Future : in Interfaces.Unsigned_32) is use kv.avm.Registers; begin Self.Ref := new Reference_Counted_Message_Type; Self.Ref.Count := 1; Self.Ref.Data := new Message_Data_Type; Self.Ref.Data.Source_Actor := Source; Self.Ref.Data.Reply_To := Reply_To; Self.Ref.Data.Destination_Actor := Destination; Self.Ref.Data.Message_Name := +Message_Name; Self.Ref.Data.Data := Data; Self.Ref.Data.Future := Future; end Initialize; ----------------------------------------------------------------------------- function Get_Name(Self : Message_Type) return String is use kv.avm.Registers; begin return +Self.Ref.Data.Message_Name; end Get_Name; ----------------------------------------------------------------------------- function Get_Source(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type is begin return Self.Ref.Data.Source_Actor; end Get_Source; ----------------------------------------------------------------------------- function Get_Reply_To(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type is begin return Self.Ref.Data.Reply_To; end Get_Reply_To; ----------------------------------------------------------------------------- function Get_Destination(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type is begin return Self.Ref.Data.Destination_Actor; end Get_Destination; ----------------------------------------------------------------------------- function Get_Data(Self : Message_Type) return kv.avm.Tuples.Tuple_Type is begin return Self.Ref.Data.Data; end Get_Data; ----------------------------------------------------------------------------- function Get_Future(Self : Message_Type) return Interfaces.Unsigned_32 is begin return Self.Ref.Data.Future; end Get_Future; ----------------------------------------------------------------------------- function Image(Self : Message_Type) return String is begin return "Message<" & Self.Get_Name & ">"; end Image; ----------------------------------------------------------------------------- function Debug(Ref : Reference_Counted_Message_Access) return String is Count : constant String := Natural'IMAGE(Ref.Count); begin if Ref.Data = null then return "null data"&Count; else return Debug(Ref.Data); end if; end Debug; ----------------------------------------------------------------------------- function Debug(Self : Message_Type) return String is begin if Self.Ref = null then return "null ref"; else return Debug(Self.Ref); end if; end Debug; ----------------------------------------------------------------------------- function Reachable(Self : Message_Type) return kv.avm.Actor_References.Sets.Set is begin return Self.Ref.Data.Data.Reachable; end Reachable; ---------------------------------------------------------------------------- function "="(L, R: Message_Type) return Boolean is begin if L.Ref = Null or R.Ref = Null then return False; end if; if L.Ref.Data = Null or R.Ref.Data = Null then return False; end if; return (L.Ref.Data.all = R.Ref.Data.all); end "="; ---------------------------------------------------------------------------- procedure Message_Write(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : in Message_Type) is begin kv.avm.Actor_References.Actor_Reference_Type'OUTPUT(Stream, Item.Ref.Data.Source_Actor); kv.avm.Actor_References.Actor_Reference_Type'OUTPUT(Stream, Item.Ref.Data.Reply_To); kv.avm.Actor_References.Actor_Reference_Type'OUTPUT(Stream, Item.Ref.Data.Destination_Actor); kv.avm.Registers.String_Type'OUTPUT (Stream, Item.Ref.Data.Message_Name); kv.avm.Tuples.Tuple_Type'OUTPUT (Stream, Item.Ref.Data.Data); Interfaces.Unsigned_32'OUTPUT (Stream, Item.Ref.Data.Future); end Message_Write; ---------------------------------------------------------------------------- procedure Message_Read(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : out Message_Type) is Source : kv.avm.Actor_References.Actor_Reference_Type; Reply_To : kv.avm.Actor_References.Actor_Reference_Type; Destination : kv.avm.Actor_References.Actor_Reference_Type; Message_Name : kv.avm.Registers.String_Type; Data : kv.avm.Tuples.Tuple_Type; Future : Interfaces.Unsigned_32; use kv.avm.Registers; begin Item.Finalize; -- Clear out the old one, if there was something there. -- Even though the parameters to a message's Initialize routine are -- in this order, reading the values as parameters to the routine -- resulted in an out-of-order read from the Stream. Source := kv.avm.Actor_References.Actor_Reference_Type'INPUT(Stream); Reply_To := kv.avm.Actor_References.Actor_Reference_Type'INPUT(Stream); Destination := kv.avm.Actor_References.Actor_Reference_Type'INPUT(Stream); Message_Name := kv.avm.Registers.String_Type'INPUT(Stream); Data := kv.avm.Tuples.Tuple_Type'INPUT(Stream); Future := Interfaces.Unsigned_32'INPUT(Stream); Item.Initialize (Source => Source, Reply_To => Reply_To, Destination => Destination, Message_Name => +Message_Name, Data => Data, Future => Future); end Message_Read; end kv.avm.Messages;
with Pck; use Pck; procedure Foo is Some_Local_Variable : Integer := 1; External_Identical_Two : Integer := 74; begin My_Global_Variable := Some_Local_Variable + 1; -- START Proc (External_Identical_Two); end Foo;
package Card_Dir is type Cardinal_Direction is (N, NE, E, SE, S, SW, W, NW); --enumerator for cardinal directions end Card_Dir;
with Ada.Text_IO; with kv.avm.vole_tree; use kv.avm.vole_tree; with kv.avm.Tree_Visitors; use kv.avm.Tree_Visitors; package kv.avm.Tree_Rewrite is type Rewriter_Class is limited new Visitor_Class with record Temp : Natural := 0; Block : Natural := 0; end record; procedure Init (Self : in out Rewriter_Class); procedure Finalize (Self : in out Rewriter_Class); function Next_Temp(Self : access Rewriter_Class; Src_Line : Positive) return String; function Next_Block(Self : access Rewriter_Class) return String; overriding procedure Visit_Id (Self : in out Rewriter_Class; Target : in out Id_Node_Class'CLASS; Depth : in Natural); overriding procedure Visit_Actor_Definition (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Attribute_Definition (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Message_Definition (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Kind_Node (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Argument (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Constructor_Send_Node (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Expression_List (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Expression_Op (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Expression_Var (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Expression_Literal (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Expression_Send (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Expression_Fold (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_List (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_Assign (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_Var_Def (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_Emit (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_Return (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_If (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_Assert (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_Send (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Statement_While (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Program (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); overriding procedure Visit_Unimp (Self : in out Rewriter_Class; Target : in out Node_Base_Class'CLASS; Depth : in Natural); end kv.avm.Tree_Rewrite;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2014, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ pragma Ada_2012; private package XML.SAX.Simple_Readers.Scanner.Actions is function On_Attribute_Name_In_Attribute_List_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles name of the attribute in the attribute list declaration. function On_Attribute_Type (Self : in out Simple_Reader'Class; Type_Token : Token) return Token; -- Handles attribute type in attribute type declaration. Checks whether -- whitespace is present before type keyword and resets whitespace flag. -- Returns Type_Token on success, otherwise return Error. function On_Open_Parenthesis_In_Notation_Attribute (Self : in out Simple_Reader'Class) return Token; -- Handles open parenthesis in notation attribute delaration. Checks -- whether whitespace is present before open parenthesis. Returns -- Token_Open_Parenthesis on success and reports error and returns Error -- othewise. function On_Close_Parenthesis_In_Notation_Attribute (Self : in out Simple_Reader'Class) return Token; -- Handles close parenthesis in notation attribute delaration. Resets -- whitespace matching flag. Returns Token_Close_Parenthesis. procedure On_Attribute_Value_Character_Data (Self : in out Simple_Reader'Class); -- Handles character data in the attribute value. function On_Attribute_Value_Close_Delimiter (Self : in out Simple_Reader'Class) return Boolean; -- Process close delimiter of attribute value. Returns True when -- attribute's value is closed. function On_Attribute_Value_Open_Delimiter (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32) return Boolean; -- Process open delimiter of attribute value. Returns True on success, -- otherwise returns False. procedure On_Attribute_Value_Open_Delimiter (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32); -- Process open delimiter of attribute value. Same as before, but doesn't -- check presence of whitespace before delimiter. function On_Character_Data (Self : in out Simple_Reader'Class) return Token; -- Handles character data in as well as apperance of forbidden ']]>' string -- in the character data. function On_Character_Reference (Self : in out Simple_Reader'Class; Hex : Boolean) return Token; -- Processes character reference, except character reference in attribute -- value. function On_Character_Reference_In_Attribute_Value (Self : in out Simple_Reader'Class; Hex : Boolean) return Boolean; -- Processes character reference in attribute value. Returns False when -- error was detected and reported to application. function On_Close_Of_Conditional_Section (Self : in out Simple_Reader'Class) return Token; -- Handles close of conditional section. function On_Close_Of_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles close of entity declaration. function On_Close_Of_Document_Type_Declaration (Self : in out Simple_Reader'Class) return Boolean; -- Handles close of document type declaration. Returns True when -- close token must be returned to parser, otherwise scanning must be -- continued because it pushes external subset entity into the scanner's -- stack. function On_Close_Of_Empty_Element_Tag (Self : in out Simple_Reader'Class) return Token; -- Handles close of empty element tag. function On_Close_Of_Processing_Instruction (Self : in out Simple_Reader'Class; Is_Empty : Boolean) return Token; -- Handles close of processing instructio. When Is_Empty is True it means -- that processing instruction doesn't have data. function On_Close_Of_Tag (Self : in out Simple_Reader'Class) return Token; -- Handles close of element tag and of document type declaration, function On_Close_Of_XML_Or_Text_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles close of XML declaration and text declaration. procedure On_Conditional_Section_Directive (Self : in out Simple_Reader'Class; Include : Boolean); -- Handles directive of conditional section. procedure On_Content_Of_Ignore_Conditional_Section (Self : in out Simple_Reader'Class); -- Handles content of ignore conditional section. function On_Default_Declaration (Self : in out Simple_Reader'Class; State : Interfaces.Unsigned_32; Default_Token : Token) return Token; -- Handles default declaration of attribute definition. Checks for -- whitespace before the token and returns Error when this check fail, -- otherwise returns Default_Token. Resets whitespace detection flag and -- enter specified start condition. function On_Element_Name_In_Attribute_List_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles element's name in attribute list declaration. function On_Entity_Value_Close_Delimiter (Self : in out Simple_Reader'Class) return Token; -- Process entity value close delimiter, rule [9]. It is also handle -- "Include In Literal" (4.4.5) mode for parameter entities, when quotation -- and apostrophe characters are not recognized as delimiters. function On_Entity_Value_Open_Delimiter (Self : in out Simple_Reader'Class) return Token; -- Handles open delimiter of entity value. function On_General_Entity_Reference_In_Attribute_Value (Self : in out Simple_Reader'Class) return Boolean; -- Handles general entity reference in attribute value. function On_General_Entity_Reference_In_Document_Content (Self : in out Simple_Reader'Class) return Token; -- Handles general entity reference in document content. Do several checks -- and push entity contents into the scanner's stack. Returns -- Token_Entity_Start on success when replacement text is pushed in stack; -- End_Of_Input when replacement text is empty and doesn't pushed into the -- stack; and returns Error on any error. function On_General_Entity_Reference_In_Entity_Value (Self : in out Simple_Reader'Class) return Token; -- Handles general entity reference in entity value. function On_Parameter_Entity_Reference_In_Entity_Value (Self : in out Simple_Reader'Class) return Boolean; -- Handles parameter entity reference in entity value. function On_Parameter_Entity_Reference_In_Markup_Declaration (Self : in out Simple_Reader'Class) return Boolean; -- Handles parameter entity reference inside markup declaration in the -- document type declaration. function On_Parameter_Entity_Reference_In_Document_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles parameter entity reference outside of markup declaration in the -- document type declaration. function On_Less_Than_Sign_In_Attribute_Value (Self : in out Simple_Reader'Class) return Token; -- Handling of less-than sign in attribute value. function On_Name_In_Attribute_List_Declaration_Notation (Self : in out Simple_Reader'Class) return Token; -- Handles name of the notation in the attribute list declaration. function On_Name_In_Element_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles name of the element declaration. function On_Name_In_Element_Declaration_Children (Self : in out Simple_Reader'Class) return Token; -- Handles name of the children element in element declaration. function On_Name_In_Element_Start_Tag (Self : in out Simple_Reader'Class) return Token; -- Handles name of the attribute in element start tag or empty element tag. function On_Name_In_Entity_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles name of the entity in the entity declaration. function On_Name_In_Entity_Declaration_Notation (Self : in out Simple_Reader'Class) return Token; -- Handles name of the notation in the entity declaration. function On_NDATA (Self : in out Simple_Reader'Class) return Token; -- Handles NDATA keyword in entity declaration. procedure On_No_XML_Declaration (Self : in out Simple_Reader'Class); -- Handles start of document and external parsed entities which doesn't -- starts from XML declaration. function On_Open_Of_Attribute_List_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles open of attribute list declaration. function On_Open_Of_Conditional_Section (Self : in out Simple_Reader'Class) return Token; -- Handles open of conditional section. Returns Token_Conditional_Open on -- success, Error otherwise. function On_Open_Of_Conditional_Section_Content (Self : in out Simple_Reader'Class) return Boolean; -- Handles open of content of conditional section. function On_Open_Of_Document_Type_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles open of document type declaration. function On_Open_Of_Element_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles open of element declaration. function On_Open_Of_End_Tag (Self : in out Simple_Reader'Class) return Token; -- Handles open of end tag. function On_Open_Of_Internal_Subset (Self : in out Simple_Reader'Class) return Token; -- Handles open of internal subset of document type declaration. function On_Open_Of_Notation_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles open of notation declaration. function On_Open_Of_Processing_Instruction (Self : in out Simple_Reader'Class) return Token; -- Handles open of processing instruction. function On_Open_Of_Start_Tag (Self : in out Simple_Reader'Class) return Token; -- Handles open of start tag or empty element tag. function On_Open_Of_XML_Or_Text_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles open of XML declaration in document or text declaration in -- external entity or external subset. function On_Public_Literal (Self : in out Simple_Reader'Class) return Token; -- Handles public literal. function On_System_Literal (Self : in out Simple_Reader'Class) return Token; -- Handles system literal. function On_Unexpected_Character (Self : in out Simple_Reader'Class) return Token; -- General handling of unexpected character. function On_Whitespace_In_Document (Self : in out Simple_Reader'Class) return Boolean; -- Handles whitespaces outside of markup. Returns True and sets YYLVal when -- document content analysis started, and return False otherwise. procedure On_Whitespace_In_Processing_Instruction (Self : in out Simple_Reader'Class); -- Handles sequence of whitespaces between processing instruction's target -- and data. function On_Version_Keyword (Self : in out Simple_Reader'Class) return Token; -- Handles 'version' keyword in XML declaration or text declaration. function On_Encoding_Keyword (Self : in out Simple_Reader'Class) return Token; -- Handles 'encoding' keyword in XML declaration or text declaration. function On_Standalone_Keyword (Self : in out Simple_Reader'Class) return Token; -- Handles 'standalone' keyword in XML declaration. function On_Percent_Sign (Self : in out Simple_Reader'Class) return Token; -- Handles percent sign in parameter entity declaration. function On_CDATA (Self : in out Simple_Reader'Class) return Token; -- Handles CDATA section. function On_Close_Parenthesis_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles close parenthesis in element content model and mixed content -- declaration, productions [49], [50], [51]. function On_Open_Parenthesis_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles open parenthesis in element content model and mixed content -- declaration, productions [49], [50], [51]. function On_Question_Mark_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles question mark in element content model, productions [47], [48]. function On_Plus_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles plus in element content model, productions [47], [48]. function On_Asterisk_In_Content_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles asterisk in element content model and mixed content declaration, -- productions [47], [48], [51]. function On_Open_Of_CDATA (Self : in out Simple_Reader'Class) return Token; -- Handles open of CDATA section. function On_Close_Of_CDATA (Self : in out Simple_Reader'Class) return Token; -- Handles close of CDATA section. function On_Attribute_Value_In_XML_Declaration (Self : in out Simple_Reader'Class) return Token; -- Handles value of attribute in the XML declaration. function On_System_Keyword_In_Document_Type (Self : in out Simple_Reader'Class) return Token; -- Handles SYSTEM keyword in document type declaration. function On_System_Keyword_In_Entity_Or_Notation (Self : in out Simple_Reader'Class) return Token; -- Handles SYSTEM keyword in entity definition or notation declaration. end XML.SAX.Simple_Readers.Scanner.Actions;
-- -- Copyright (C) 2017 Nico Huber <nico.h@gmx.de> -- -- 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 Ada.Text_IO; with Ada.Strings.Fixed; with HW.File; with HW.PCI.MMConf; with HW.MMIO_Range; pragma Elaborate_All (HW.MMIO_Range); use Ada.Strings.Fixed; package body HW.PCI.Dev with Refined_State => (Address_State => MM.Address_State, PCI_State => MM.PCI_State) is -- We map each device's config space individually, hence Address'(0, 0, 0). package MM is new HW.PCI.MMConf (Address'(0, 0, 0)); procedure Read8 (Value : out Word8; Offset : Index) renames MM.Read8; procedure Read16 (Value : out Word16; Offset : Index) renames MM.Read16; procedure Read32 (Value : out Word32; Offset : Index) renames MM.Read32; procedure Write8 (Offset : Index; Value : Word8) renames MM.Write8; procedure Write16 (Offset : Index; Value : Word16) renames MM.Write16; procedure Write32 (Offset : Index; Value : Word32) renames MM.Write32; -- No-op PCI config update to share contracts -- with implementations that do actual updates. procedure Dummy_PCI_Update with Global => (In_Out => MM.PCI_State); procedure Dummy_PCI_Update is null with SPARK_Mode => Off; function Hex (Val : Natural) return Character with Pre => Val < 16 is begin if Val < 10 then return Character'Val (Character'Pos ('0') + Val); else return Character'Val (Character'Pos ('a') + Val - 10); end if; end Hex; subtype String2 is String (1 .. 2); function Hex2 (Val : Natural) return String2 with Pre => Val < 256 is Res : constant String (1 .. 2) := (Hex (Val / 16), Hex (Val mod 16)); begin return Res; end Hex2; procedure Patch_Sysfs_Path (Path : in out String) with Pre => Path'Length >= 36 is begin Path (Path'First + 21 .. Path'First + 22) := Hex2 (Natural (Dev.Bus)); Path (Path'First + 29 .. Path'First + 30) := Hex2 (Natural (Dev.Bus)); Path (Path'First + 32 .. Path'First + 33) := Hex2 (Natural (Dev.Slot)); Path (Path'First + 35) := Hex (Natural (Dev.Func)); end Patch_Sysfs_Path; procedure Map (Addr : out Word64; Res : in Resource; Length : in Natural := 0; Offset : in Natural := 0; WC : in Boolean := False) is Success : Boolean; Path : String (1 .. 49) := "/sys/devices/pci0000:xx/0000:xx:xx.x/resourcex_wc"; begin Dummy_PCI_Update; Patch_Sysfs_Path (Path); Path (46) := Character'Val (Character'Pos ('0') + Resource'Pos (Res)); if not WC then Path (47) := Character'Val (0); end if; File.Map (Addr => Addr, Path => Path, Len => Length, Offset => Offset, Readable => True, Writable => True, Success => Success); if not Success and WC then -- try again without write-combining Path (47) := Character'Val (0); File.Map (Addr => Addr, Path => Path, Len => Length, Offset => Offset, Readable => True, Writable => True, Success => Success); end if; if not Success then Addr := 0; end if; end Map; procedure Resource_Size (Length : out Natural; Res : Resource) is Path : String (1 .. 46) := "/sys/devices/pci0000:xx/0000:xx:xx.x/resourcex"; begin Dummy_PCI_Update; Patch_Sysfs_Path (Path); Path (46) := Character'Val (Character'Pos ('0') + Resource'Pos (Res)); File.Size (Length, Path); end Resource_Size; procedure Initialize (Success : out Boolean; MMConf_Base : Word64 := 0) is Addr : Word64; Path : String (1 .. 43) := "/sys/devices/pci0000:xx/0000:xx:xx.x/config"; begin Patch_Sysfs_Path (Path); File.Map (Addr => Addr, Path => Path, Readable => True, Map_Copy => True, Success => Success); MM.Set_Base_Address (Addr); end Initialize; end HW.PCI.Dev;
procedure numtriangular (n1: in Integer; resultado: out Integer) is indice:integer:=0; begin resultado:=0; indice:=n1; while indice/=0 loop resultado:=resultado+indice; indice:=indice-1; end loop; end numtriangular;
with Screen_Interface; use Screen_Interface; package Fonts is type BMP_Font is (Font8x8, Font12x12, Font16x24); procedure Draw_Char (X, Y : Integer; Char : Character; Font : BMP_Font; FG, BG : Color); procedure Draw_Char (X, Y : Integer; Char : Character; Font : BMP_Font; FG : Color); procedure Draw_String (X, Y : Integer; Str : String; Font : BMP_Font; FG, BG : Color; Wrap : Boolean := False); procedure Draw_String (X, Y : Integer; Str : String; Font : BMP_Font; FG : Color; Wrap : Boolean := False); function Char_Size (Font : BMP_Font) return Point; function String_Size (Font : BMP_Font; Text : String) return Point; end Fonts;
-- This package has been generated automatically by GNATtest. -- Do not edit any part of it, see GNATtest documentation for more details. -- begin read only with GNATtest_Generated; package Crew.Member_Data_Test_Data.Member_Data_Tests is type Test_Member_Data is new GNATtest_Generated.GNATtest_Standard.Crew .Member_Data_Test_Data .Test_Member_Data with null record; end Crew.Member_Data_Test_Data.Member_Data_Tests; -- end read only
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with System.Storage_Pools.Subpools; private with Program.Compilation_Units; private with Program.Element_Factories; private with Program.Elements; private package Program.Parsers.Nodes is pragma Preelaborate; type Node is private; type Node_Array is array (Positive range <>) of Node; None : constant Node; No_Token : constant Node; type Node_Factory (Comp : not null Program.Compilations.Compilation_Access; Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle) is tagged limited private; function Token (Self : Node_Factory'Class; Value : not null Program.Lexical_Elements.Lexical_Element_Access) return Node; procedure Get_Compilation_Units (Value : Node; Units : out Program.Parsers.Unit_Vectors.Vector; Pragmas : out Program.Parsers.Element_Vectors.Vector); function Compilation (Self : Node_Factory'Class; Units : Node; Compilation_Pragmas : Node) return Node; function Abort_Statement (Self : Node_Factory'Class; Abort_Token : Node; Aborted_Tasks : Node; Semicolon_Token : Node) return Node; function Accept_Statement (Self : Node_Factory'Class; Accept_Token : Node; Accept_Entry_Direct_Name : Node; Left_Parenthesis_Token : Node; Accept_Entry_Index : Node; Right_Parenthesis_Token : Node; Lp_Token : Node; Accept_Parameters : Node; Rp_Token : Node; Do_Token : Node; Accept_Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Access_To_Function_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Function_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Access_To_Function_Result_Subtype : Node) return Node; function Access_To_Object_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Constant_Token : Node; Subtype_Indication : Node) return Node; function Access_To_Procedure_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Procedure_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node) return Node; function Allocator (Self : Node_Factory'Class; New_Token : Node; Left_Parenthesis_Token : Node; Subpool_Name : Node; Right_Parenthesis_Token : Node; Subtype_Or_Expression : Node) return Node; function Anonymous_Access_To_Function_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Function_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Access_To_Function_Result_Subtype : Node) return Node; function Anonymous_Access_To_Object_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Constant_Token : Node; Anonymous_Access_To_Object_Subtype_Mark : Node) return Node; function Anonymous_Access_To_Procedure_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Procedure_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node) return Node; function Aspect_Specification (Self : Node_Factory'Class; Aspect_Mark : Node; Arrow_Token : Node; Aspect_Definition : Node) return Node; function Assignment_Statement (Self : Node_Factory'Class; Assignment_Variable_Name : Node; Assignment_Token : Node; Assignment_Expression : Node; Semicolon_Token : Node) return Node; function Association (Self : Node_Factory'Class; Array_Component_Choices : Node; Arrow_Token : Node; Component_Expression : Node) return Node; function Association_List (Self : Node_Factory'Class; Left_Token : Node; Record_Component_Associations : Node; Right_Token : Node) return Node; function Asynchronous_Select (Self : Node_Factory'Class; Select_Token : Node; Asynchronous_Statement_Paths : Node; End_Token : Node; End_Select : Node; Semicolon_Token : Node) return Node; function At_Clause (Self : Node_Factory'Class; For_Token : Node; Representation_Clause_Name : Node; Use_Token : Node; At_Token : Node; Representation_Clause_Expression : Node; Semicolon_Token : Node) return Node; function Attribute_Definition_Clause (Self : Node_Factory'Class; For_Token : Node; Representation_Clause_Name : Node; Use_Token : Node; Representation_Clause_Expression : Node; Semicolon_Token : Node) return Node; function Attribute_Reference (Self : Node_Factory'Class; Prefix : Node; Apostrophe_Token : Node; Attribute_Designator_Identifier : Node; Attribute_Designator_Expressions : Node) return Node; function Block_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; Declare_Token : Node; Block_Declarative_Items : Node; Begin_Token : Node; Block_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Box (Self : Node_Factory'Class; Box_Token : Node) return Node; function Case_Expression (Self : Node_Factory'Class; Case_Token : Node; Expression : Node; Is_Token : Node; Case_Expression_Paths : Node) return Node; function Case_Expression_Path (Self : Node_Factory'Class; When_Token : Node; Case_Path_Alternative_Choices : Node; Arrow_Token : Node; Dependent_Expression : Node) return Node; function Case_Path (Self : Node_Factory'Class; When_Token : Node; Variant_Choices : Node; Arrow_Token : Node; Sequence_Of_Statements : Node) return Node; function Case_Statement (Self : Node_Factory'Class; Case_Token : Node; Case_Expression : Node; Is_Token : Node; Case_Statement_Paths : Node; End_Token : Node; Endcase : Node; Semicolon_Token : Node) return Node; function Character_Literal (Self : Node_Factory'Class; Character_Literal_Token : Node) return Node; function Choice_Parameter_Specification (Self : Node_Factory'Class; Names : Node) return Node; function Compilation_Unit_Body (Self : Node_Factory'Class; Context_Clause_Elements : Node; Unit_Declaration : Node) return Node; function Compilation_Unit_Declaration (Self : Node_Factory'Class; Context_Clause_Elements : Node; Private_Token : Node; Unit_Declaration : Node) return Node; function Component_Clause (Self : Node_Factory'Class; Representation_Clause_Name : Node; At_Token : Node; Component_Clause_Position : Node; Range_Token : Node; Component_Clause_Range : Node; Semicolon_Token : Node) return Node; function Component_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Component_Definition (Self : Node_Factory'Class; Aliased_Token : Node; Subtype_Indication : Node) return Node; -- function Composite_Constraint -- (Self : Node_Factory'Class; -- Left_Token : Node; -- Associations : Node; -- Right_Token : Node) return Node; -- We call Function_Call instead -- function Composite_Subtype_Indication -- (Self : Node_Factory'Class; -- Not_Token : Node; -- Null_Token : Node; -- Subtype_Mark : Node; -- Composite_Constraint : Node) return Node; function Constrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Discrete_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node; function Decimal_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Delta_Expression : Node; Digits_Token : Node; Digits_Expression : Node; Real_Range_Constraint : Node) return Node; function Defining_Character_Literal (Self : Node_Factory'Class; Character_Literal : Node) return Node; function Defining_Enumeration_Literal (Self : Node_Factory'Class; Identifier : Node) return Node; -- function Defining_Expanded_Unit_Name -- (Self : Node_Factory'Class; -- Defining_Prefix : Node; -- Dot_Token : Node; -- Defining_Selector : Node) return Node; function Defining_Identifier (Self : Node_Factory'Class; Identifier_Token : Node) return Node; function Defining_Operator_Symbol (Self : Node_Factory'Class; Operator_Symbol_Token : Node) return Node; function Delay_Statement (Self : Node_Factory'Class; Delay_Token : Node; Until_Token : Node; Delay_Expression : Node; Semicolon_Token : Node) return Node; function Delta_Constraint (Self : Node_Factory'Class; Delta_Token : Node; Delta_Expression : Node; Real_Range_Constraint : Node) return Node; function Derived_Record_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; New_Token : Node; Parent_Subtype_Indication : Node; Progenitor_List : Node; With_Token : Node; Record_Definition : Node) return Node; function Derived_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; New_Token : Node; Parent_Subtype_Indication : Node) return Node; function Digits_Constraint (Self : Node_Factory'Class; Digits_Token : Node; Digits_Expression : Node; Real_Range_Constraint : Node) return Node; function Discrete_Range_Attribute_Reference (Self : Node_Factory'Class; Range_Attribute : Node) return Node; function Discrete_Simple_Expression_Range (Self : Node_Factory'Class; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node; function Discrete_Subtype_Indication (Self : Node_Factory'Class; Subtype_Mark : Node; Subtype_Constraint : Node) return Node; function Discrete_Subtype_Indication_Dr (Self : Node_Factory'Class; Subtype_Mark : Node; Subtype_Constraint : Node) return Node; function Discriminant_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node) return Node; function Element_Iterator_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Subtype_Indication : Node; Of_Token : Node; Reverse_Token : Node; Iteration_Scheme_Name : Node) return Node; function Else_Expression_Path (Self : Node_Factory'Class; Else_Token : Node; Dependent_Expression : Node) return Node; function Else_Path (Self : Node_Factory'Class; Else_Token : Node; Sequence_Of_Statements : Node) return Node; function Elsif_Expression_Path (Self : Node_Factory'Class; Elsif_Token : Node; Condition_Expression : Node; Then_Token : Node; Dependent_Expression : Node) return Node; function Elsif_Path (Self : Node_Factory'Class; Elsif_Token : Node; Condition_Expression : Node; Then_Token : Node; Sequence_Of_Statements : Node) return Node; function Entry_Body (Self : Node_Factory'Class; Entry_Token : Node; Names : Node; Left_Parenthesis_Token : Node; Entry_Index_Specification : Node; Right_Parenthesis_Token : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; When_Token : Node; Entry_Barrier : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Entry_Declaration (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Entry_Token : Node; Names : Node; Left_Parenthesis_Token : Node; Entry_Family_Definition : Node; Right_Parenthesis_Token : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Entry_Index_Specification (Self : Node_Factory'Class; For_Token : Node; Names : Node; In_Token : Node; Specification_Subtype_Definition : Node) return Node; function Enumeration_Literal_Specification (Self : Node_Factory'Class; Names : Node) return Node; function Enumeration_Type_Definition (Self : Node_Factory'Class; Left_Token : Node; Literals : Node; Right_Token : Node) return Node; function Exception_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Exception_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Exception_Handler (Self : Node_Factory'Class; When_Token : Node; Choice_Parameter_Specification : Node; Colon_Token : Node; Exception_Choices : Node; Arrow_Token : Node; Handler_Statements : Node) return Node; function Exception_Renaming_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Exception_Token : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Exit_Statement (Self : Node_Factory'Class; Exit_Token : Node; Exit_Loop_Name : Node; When_Token : Node; Exit_Condition : Node; Semicolon_Token : Node) return Node; function Explicit_Dereference (Self : Node_Factory'Class; Prefix : Node; Dot_Token : Node; All_Token : Node) return Node; function Extended_Return_Statement (Self : Node_Factory'Class; Return_Token : Node; Return_Object_Specification : Node; Do_Token : Node; Extended_Return_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Return : Node; Semicolon_Token : Node) return Node; function Extension_Aggregate (Self : Node_Factory'Class; Left_Token : Node; Extension_Aggregate_Expression : Node; With_Token : Node; Record_Component_Associations : Node; Right_Token : Node) return Node; function Floating_Point_Definition (Self : Node_Factory'Class; Digits_Token : Node; Digits_Expression : Node; Real_Range_Constraint : Node) return Node; function For_Loop_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; For_Token : Node; Loop_Parameter_Specification : Node; Loop_Token : Node; Loop_Statements : Node; End_Token : Node; End_Loop : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Formal_Access_To_Function_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Function_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Access_To_Function_Result_Subtype : Node) return Node; function Formal_Access_To_Object_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Constant_Token : Node; Subtype_Indication : Node) return Node; function Formal_Access_To_Procedure_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Procedure_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node) return Node; function Formal_Constrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Discrete_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node; function Formal_Decimal_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Delta_Box : Node; Digits_Token : Node; Digits_Box : Node) return Node; function Formal_Derived_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; Synchronized_Token : Node; New_Token : Node; Subtype_Mark : Node; And_Token : Node; Progenitor_List : Node; With_Token : Node; Private_Token : Node; Aspect_Specifications : Node) return Node; function Formal_Discrete_Type_Definition (Self : Node_Factory'Class; Left_Parenthesis_Token : Node; Box_Token : Node; Right_Parenthesis_Token : Node) return Node; function Formal_Floating_Point_Definition (Self : Node_Factory'Class; Digits_Token : Node; Box_Token : Node) return Node; function Formal_Function_Declaration (Self : Node_Factory'Class; With_Token : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Is_Token : Node; Abstract_Token : Node; Formal_Subprogram_Default : Node; Box_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Formal_Incomplete_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Tagged_Token : Node; Semicolon_Token : Node) return Node; function Formal_Interface_Type_Definition (Self : Node_Factory'Class; Kind_Token : Node; Interface_Token : Node; Progenitor_List : Node) return Node; function Formal_Modular_Type_Definition (Self : Node_Factory'Class; Mod_Token : Node; Box_Token : Node) return Node; function Formal_Object_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; In_Token : Node; Out_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Formal_Ordinary_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Box_Token : Node) return Node; function Formal_Package_Declaration (Self : Node_Factory'Class; With_Token : Node; Package_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Formal_Private_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Tagged_Token : Node; Limited_Token : Node; Private_Token : Node) return Node; function Formal_Procedure_Declaration (Self : Node_Factory'Class; With_Token : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Is_Token : Node; Abstract_Token : Node; Box_Token : Node; Null_Token : Node; Formal_Subprogram_Default : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Formal_Signed_Integer_Type_Definition (Self : Node_Factory'Class; Range_Token : Node; Box_Token : Node) return Node; function Formal_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Formal_Unconstrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Index_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node; function Full_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Function_Body (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node; function Function_Call (Self : Node_Factory'Class; Prefix : Node; Function_Call_Parameters : Node) return Node; function Function_Declaration (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Is_Token : Node; Abstract_Token : Node; Result_Expression : Node; Renames_Token : Node; Renamed_Entity : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Function_Instantiation (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Function_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; -- function Generalized_Iterator_Specification -- (Self : Node_Factory'Class; -- Names : Node; -- In_Token : Node; -- Reverse_Token : Node; -- Iteration_Scheme_Name : Node) return Node; function Generic_Association (Self : Node_Factory'Class; Formal_Parameter : Node; Arrow_Token : Node; Actual_Parameter : Node; Box_Token : Node) return Node; function Generic_Function_Declaration (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Generic_Function_Renaming (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Function_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Generic_Package_Declaration (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Package_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Visible_Part_Declarative_Items : Node; Private_Token : Node; Private_Part_Declarative_Items : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node; function Generic_Package_Renaming (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Package_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Generic_Procedure_Declaration (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Generic_Procedure_Renaming (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Procedure_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Goto_Statement (Self : Node_Factory'Class; Exit_Token : Node; Goto_Label : Node; Semicolon_Token : Node) return Node; function Identifier (Self : Node_Factory'Class; Identifier_Token : Node) return Node; function If_Expression (Self : Node_Factory'Class; Expression_Paths : Node) return Node; function If_Expression_Path (Self : Node_Factory'Class; If_Token : Node; Condition_Expression : Node; Then_Token : Node; Dependent_Expression : Node) return Node; function If_Path (Self : Node_Factory'Class; If_Token : Node; Condition_Expression : Node; Then_Token : Node; Sequence_Of_Statements : Node) return Node; function If_Statement (Self : Node_Factory'Class; Statement_Paths : Node; End_Token : Node; If_Token : Node; Semicolon_Token : Node) return Node; function Incomplete_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Semicolon_Token : Node) return Node; function Incomplete_Type_Definition (Self : Node_Factory'Class; Tagged_Token : Node) return Node; function Interface_Type_Definition (Self : Node_Factory'Class; Kind_Token : Node; Interface_Token : Node; Progenitor_List : Node) return Node; function Known_Discriminant_Part (Self : Node_Factory'Class; Left_Parenthesis_Token : Node; Discriminants : Node; Right_Parenthesis_Token : Node) return Node; function Label_Decorator (Self : Node_Factory'Class; Label_Names : Node; Unlabeled_Statement : Node) return Node; function Loop_Parameter_Specification (Self : Node_Factory'Class; Names : Node; In_Token : Node; Reverse_Token : Node; Specification_Subtype_Definition : Node) return Node; function Loop_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; Loop_Token : Node; Loop_Statements : Node; End_Token : Node; End_Loop : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Membership_Test (Self : Node_Factory'Class; Membership_Test_Expression : Node; Not_Token : Node; In_Token : Node; Membership_Test_Choices : Node) return Node; function Modular_Type_Definition (Self : Node_Factory'Class; Mod_Token : Node; Mod_Static_Expression : Node) return Node; function Null_Component (Self : Node_Factory'Class; Null_Token : Node; Semicolon_Token : Node) return Node; function Null_Literal (Self : Node_Factory'Class; Null_Literal_Token : Node) return Node; function Null_Record_Definition (Self : Node_Factory'Class; Null_Token : Node; Record_Token : Node) return Node; function Null_Statement (Self : Node_Factory'Class; Null_Token : Node; Semicolon_Token : Node) return Node; function Number_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Constant_Token : Node; Assignment_Token : Node; Initialization_Expression : Node; Semicolon_Token : Node) return Node; function Numeric_Literal (Self : Node_Factory'Class; Numeric_Literal_Token : Node) return Node; function Object_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Aliased_Token : Node; Constant_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Object_Renaming_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Operator_Symbol (Self : Node_Factory'Class; Operator_Symbol_Token : Node) return Node; function Ordinary_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Delta_Expression : Node; Real_Range_Constraint : Node) return Node; function Others_Choice (Self : Node_Factory'Class; Others_Token : Node) return Node; function Package_Body (Self : Node_Factory'Class; Package_Token : Node; Body_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node; function Package_Body_Stub (Self : Node_Factory'Class; Package_Token : Node; Body_Token : Node; Names : Node; Is_Token : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Package_Declaration (Self : Node_Factory'Class; Package_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Visible_Part_Declarative_Items : Node; Private_Token : Node; Private_Part_Declarative_Items : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node; function Package_Instantiation (Self : Node_Factory'Class; Package_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Package_Renaming_Declaration (Self : Node_Factory'Class; Package_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; -- function Parameter_Association -- (Self : Node_Factory'Class; -- Formal_Parameter : Node; -- Actual_Parameter : Node) return Node; function Parameter_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Aliased_Token : Node; In_Token : Node; Out_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node) return Node; -- function Parenthesized_Expression -- (Self : Node_Factory'Class; -- Left_Token : Node; -- Expression_Parenthesized : Node; -- Right_Token : Node) return Node; function Pragma_Argument_Association (Self : Node_Factory'Class; Formal_Parameter : Node; Arrow_Token : Node; Actual_Parameter : Node) return Node; function Pragma_Node (Self : Node_Factory'Class; Pragma_Token : Node; Formal_Parameter : Node; Left_Token : Node; Pragma_Argument_Associations : Node; Right_Token : Node; Semicolon_Token : Node) return Node; function Private_Extension_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Private_Extension_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; Synchronized_Token : Node; New_Token : Node; Ancestor_Subtype_Indication : Node; Progenitor_List : Node; With_Token : Node; Private_Token : Node) return Node; function Private_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Private_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Tagged_Token : Node; Limited_Token : Node; Private_Token : Node) return Node; function Procedure_Body (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node; function Procedure_Call_Statement (Self : Node_Factory'Class; Function_Call : Node; Semicolon_Token : Node) return Node; function Procedure_Declaration (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Is_Token : Node; Abstract_Token : Node; Renames_Token : Node; Renamed_Entity : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Procedure_Instantiation (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Procedure_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Protected_Body (Self : Node_Factory'Class; Protected_Token : Node; Body_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Protected_Operation_Items : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Protected_Body_Stub (Self : Node_Factory'Class; Protected_Token : Node; Body_Token : Node; Names : Node; Is_Token : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Protected_Definition (Self : Node_Factory'Class; Visible_Protected_Items : Node; Private_Token : Node; Private_Protected_Items : Node; End_Token : Node; Identifier_Token : Node) return Node; function Protected_Type_Declaration (Self : Node_Factory'Class; Protected_Token : Node; Type_Token : Node; Names : Node; Discriminant_Part : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Type_Declaration_View : Node; Semicolon_Token : Node) return Node; function Qualified_Expression (Self : Node_Factory'Class; Converted_Or_Qualified_Subtype_Mark : Node; Apostrophe_Token : Node; Left_Parenthesis_Token : Node; Converted_Or_Qualified_Expression : Node; Right_Parenthesis_Token : Node) return Node; function Quantified_Expression (Self : Node_Factory'Class; For_Token : Node; Quantifier_Token : Node; Iterator_Specification : Node; Arrow_Token : Node; Predicate : Node) return Node; function Raise_Statement (Self : Node_Factory'Class; Raise_Token : Node; Raised_Exception : Node; With_Token : Node; Raise_Statement_Message : Node; Semicolon_Token : Node) return Node; function Range_Attribute_Reference (Self : Node_Factory'Class; Range_Attribute : Node) return Node; function Range_Attribute_Reference_Dr (Self : Node_Factory'Class; Range_Attribute : Node) return Node; -- function Record_Aggregate -- (Self : Node_Factory'Class; Associations : Node) return Node; function Real_Range_Specification (Self : Node_Factory'Class; Range_Token : Node; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node; function Record_Definition (Self : Node_Factory'Class; Record_Token : Node; Record_Components : Node; End_Token : Node; End_Record_Token : Node) return Node; function Record_Representation_Clause (Self : Node_Factory'Class; For_Token : Node; Representation_Clause_Name : Node; Use_Token : Node; Record_Token : Node; At_Token : Node; Mod_Token : Node; Mod_Clause_Expression : Node; Mod_Semicolon : Node; Component_Clauses : Node; End_Token : Node; End_Record : Node; Semicolon_Token : Node) return Node; function Record_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Tagged_Token : Node; Limited_Token : Node; Record_Definition : Node) return Node; function Requeue_Statement (Self : Node_Factory'Class; Requeue_Token : Node; Requeue_Entry_Name : Node; With_Token : Node; Abort_Token : Node; Semicolon_Token : Node) return Node; function Return_Object_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Aliased_Token : Node; Constant_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node) return Node; -- function Root_Type_Definition -- (Self : Node_Factory'Class; Dummy_Token : Node) return Node; -- function Scalar_Subtype_Indication -- (Self : Node_Factory'Class; -- Subtype_Mark : Node; -- Scalar_Constraint : Node) -- return Node; function Select_Or_Path (Self : Node_Factory'Class; Or_Token : Node; When_Token : Node; Guard : Node; Arrow_Token : Node; Sequence_Of_Statements : Node) return Node; function Selected_Component (Self : Node_Factory'Class; Prefix : Node; Dot_Token : Node; Selector : Node) return Node; function Selected_Identifier (Self : Node_Factory'Class; Prefix : Node; Dot_Token : Node; Selector : Node) return Node; function Selective_Accept (Self : Node_Factory'Class; Select_Token : Node; Selective_Statement_Paths : Node; End_Token : Node; End_Select : Node; Semicolon_Token : Node) return Node; function Short_Circuit (Self : Node_Factory'Class; Short_Circuit_Operation_Left_Expression : Node; And_Token : Node; Then_Token : Node; Short_Circuit_Operation_Right_Expression : Node) return Node; function Signed_Integer_Type_Definition (Self : Node_Factory'Class; Range_Token : Node; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node; function Simple_Expression_Range (Self : Node_Factory'Class; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node; function Simple_Expression_Range_Dr (Self : Node_Factory'Class; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node; function Simple_Return_Statement (Self : Node_Factory'Class; Return_Token : Node; Return_Expression : Node; Semicolon_Token : Node) return Node; function Single_Protected_Declaration (Self : Node_Factory'Class; Protected_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Object_Declaration_Subtype : Node; Semicolon_Token : Node) return Node; function Single_Task_Declaration (Self : Node_Factory'Class; Task_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Object_Declaration_Subtype : Node; Semicolon_Token : Node) return Node; -- function String_Literal -- (Self : Node_Factory'Class; -- String_Literal_Token : Node) return Node; function Subtype_Declaration (Self : Node_Factory'Class; Subtype_Token : Node; Names : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Subunit (Self : Node_Factory'Class; Context_Clause_Elements : Node; Separate_Token : Node; Left_Parenthesis_Token : Node; Parent_Unit_Name : Node; Right_Parenthesis_Token : Node; Unit_Declaration : Node) return Node; function Task_Body (Self : Node_Factory'Class; Task_Token : Node; Body_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function Task_Body_Stub (Self : Node_Factory'Class; Task_Token : Node; Body_Token : Node; Names : Node; Is_Token : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node; function Task_Definition (Self : Node_Factory'Class; Visible_Task_Items : Node; Private_Token : Node; Private_Task_Items : Node; End_Token : Node; Identifier_Token : Node) return Node; function Task_Type_Declaration (Self : Node_Factory'Class; Task_Token : Node; Type_Token : Node; Names : Node; Discriminant_Part : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Type_Declaration_View : Node; Semicolon_Token : Node) return Node; function Terminate_Alternative_Statement (Self : Node_Factory'Class; Terminate_Token : Node; Semicolon_Token : Node) return Node; function Then_Abort_Path (Self : Node_Factory'Class; Then_Token : Node; Abort_Token : Node; Sequence_Of_Statements : Node) return Node; function Unconstrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Index_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node; function Unknown_Discriminant_Part (Self : Node_Factory'Class; Left_Token : Node; Box_Token : Node; Right_Token : Node) return Node; function Use_Package_Clause (Self : Node_Factory'Class; Use_Token : Node; Clause_Names : Node; Semicolon_Token : Node) return Node; function Use_Type_Clause (Self : Node_Factory'Class; Use_Token : Node; All_Token : Node; Type_Token : Node; Type_Clause_Names : Node; Semicolon_Token : Node) return Node; function Variant (Self : Node_Factory'Class; When_Token : Node; Variant_Choices : Node; Arrow_Token : Node; Record_Components : Node) return Node; function Variant_Part (Self : Node_Factory'Class; Case_Token : Node; Discriminant_Direct_Name : Node; Is_Token : Node; Variants : Node; End_Token : Node; End_Case_Token : Node; Semicolon_Token : Node) return Node; function While_Loop_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; While_Token : Node; While_Condition : Node; Loop_Token : Node; Loop_Statements : Node; End_Token : Node; End_Loop : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node; function With_Clause (Self : Node_Factory'Class; Limited_Token : Node; Private_Token : Node; With_Token : Node; With_Clause_Names : Node; Semicolon_Token : Node) return Node; --------------------- -- Node sequences -- --------------------- function Aspect_Specification_Sequence (Self : Node_Factory'Class) return Node; function Association_Sequence (Self : Node_Factory'Class) return Node; function Basic_Declarative_Item_Sequence (Self : Node_Factory'Class) return Node; function Case_Expression_Path_Sequence (Self : Node_Factory'Class) return Node; function Case_Path_Sequence (Self : Node_Factory'Class) return Node; function Clause_Or_Pragma_Sequence (Self : Node_Factory'Class) return Node; function Compilation_Unit_Sequence (Self : Node_Factory'Class) return Node; function Component_Item_Sequence (Self : Node_Factory'Class) return Node; function Context_Item_Sequence (Self : Node_Factory'Class) return Node; function Declarative_Item_Sequence (Self : Node_Factory'Class) return Node; function Defining_Identifier_Sequence (Self : Node_Factory'Class) return Node; function Discrete_Choice_Sequence (Self : Node_Factory'Class) return Node; function Discrete_Subtype_Definition_Sequence (Self : Node_Factory'Class) return Node; function Discriminant_Specification_Sequence (Self : Node_Factory'Class) return Node; function Enumeration_Literal_Specification_Sequence (Self : Node_Factory'Class) return Node; function Exception_Choice_Sequence (Self : Node_Factory'Class) return Node; function Exception_Handler_Sequence (Self : Node_Factory'Class) return Node; function Generic_Association_Sequence (Self : Node_Factory'Class) return Node; function Generic_Formal_Sequence (Self : Node_Factory'Class) return Node; function If_Else_Expression_Path_Sequence (Self : Node_Factory'Class) return Node; function If_Elsif_Else_Path_Sequence (Self : Node_Factory'Class) return Node; function Membership_Choice_Sequence (Self : Node_Factory'Class) return Node; function Name_Sequence (Self : Node_Factory'Class) return Node; function Parameter_Specification_Sequence (Self : Node_Factory'Class) return Node; function Pragma_Argument_Association_Sequence (Self : Node_Factory'Class) return Node; function Program_Unit_Name_Sequence (Self : Node_Factory'Class) return Node; function Protected_Element_Declaration_Sequence (Self : Node_Factory'Class) return Node; function Protected_Operation_Declaration_Sequence (Self : Node_Factory'Class) return Node; function Protected_Operation_Item_Sequence (Self : Node_Factory'Class) return Node; function Select_Or_Else_Path_Sequence (Self : Node_Factory'Class) return Node; function Select_Then_Abort_Path_Sequence (Self : Node_Factory'Class) return Node; function Statement_Sequence (Self : Node_Factory'Class) return Node; function Subtype_Mark_Sequence (Self : Node_Factory'Class) return Node; function Task_Item_Sequence (Self : Node_Factory'Class) return Node; function Variant_Sequence (Self : Node_Factory'Class) return Node; ------------ -- Append -- ------------ procedure Append_Aspect_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Association (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Basic_Declarative_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Case_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Case_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Clause_Or_Pragma (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Compilation_Unit (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Component_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Context_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Declarative_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Defining_Identifier (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Discrete_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Discrete_Subtype_Definition (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Discriminant_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Enumeration_Literal_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Exception_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Exception_Handler (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Generic_Association (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Generic_Formal (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_If_Else_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_If_Elsif_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Membership_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Name (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Parameter_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Pragma_Argument_Association (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Program_Unit_Name (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Protected_Element_Declaration (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Protected_Operation_Declaration (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Protected_Operation_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Select_Or_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Select_Then_Abort_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Statement (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Subtype_Mark (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append_Variant (Self : Node_Factory'Class; List : in out Node; Item : Node); ------------- -- Prepend -- ------------- procedure Prepend_Aspect_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Case_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Case_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Compilation_Unit (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Component_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Declarative_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Defining_Identifier (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Discrete_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Discrete_Subtype_Definition (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Discriminant_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Enumeration_Literal_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Exception_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Generic_Association (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_If_Else_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_If_Elsif_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Membership_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Name (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Parameter_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Pragma_Argument_Association (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Statement (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Subtype_Mark (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Association (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Select_Or_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Exception_Handler (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Task_Item (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Program_Unit_Name (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Prepend_Variant (Self : Node_Factory'Class; List : in out Node; Item : Node); ------------------- -- Special cases -- ------------------- function To_Defining_Program_Unit_Name (Self : Node_Factory'Class; Selected_Identifier : Node) return Node; -- Convert selected_identifier to defining_program_unit_name function Infix_Call (Self : Node_Factory'Class; Prefix, Left, Right : Node) return Node; function To_Aggregate_Or_Expression (Self : Node_Factory'Class; Association_List : Node) return Node; -- If Value is (X) return Parenthesized_Expression else -- return Record_Aggregate function To_Subtype_Indication (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Mark : Node; Constraint : Node) return Node; private type Node_Kind is (Token_Node, Element_Node, Element_Sequence_Node, Unit_Node, Unit_Sequence_Node, Compilation_Node); type Node (Kind : Node_Kind := Node_Kind'First) is record case Kind is when Token_Node => Token : Program.Lexical_Elements.Lexical_Element_Access; when Element_Node => Element : Program.Elements.Element_Access; when Element_Sequence_Node => Vector : aliased Element_Vectors.Vector; when Unit_Node => Unit : Program.Compilation_Units.Compilation_Unit_Access; when Unit_Sequence_Node => Units : aliased Unit_Vectors.Vector; when Compilation_Node => Root_Units : Unit_Vectors.Vector; Pragmas : Element_Vectors.Vector; end case; end record; type Node_Factory (Comp : not null Program.Compilations.Compilation_Access; Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle) is tagged limited record EF : Program.Element_Factories.Element_Factory (Subpool); end record; None : constant Node := (Element_Node, null); No_Token : constant Node := (Token_Node, null); end Program.Parsers.Nodes;
with SAX.Readers; with DOM.Readers; with Input_Sources.Strings; with Unicode.CES.Utf8; with Dom.Core.Elements; with DOM.Core.Nodes; with Ada.Strings.Maps; with Ada.Strings.Fixed; package body XML_Utilities is procedure Remove_White_Space (Doc : Dom.Core.Node) is use Dom.Core; use Dom.Core.Nodes; Children : constant Dom.Core.Node_List := Dom.Core.Nodes.Child_Nodes (Doc); N : Dom.Core.Node; begin for I in 1 .. Dom.Core.Nodes.Length (Children) loop N := Dom.Core.Nodes.Item (Children, I); if Node_Type (N) /= Text_Node then Remove_White_Space (N); else declare X : constant String := Node_Value (N); Q : Node; begin if (for all I in X'Range => X (I) = ' ' or X (I) = Character'Val (10)) then Q := Remove_Child (Doc, N); Free (Q); end if; end; end if; end loop; end Remove_White_Space; ------------------ -- Parse_String -- ------------------ function Parse_String (Item : String) return DOM.Core.Document is use SAX.Readers; use Ada.Strings.Fixed; use Ada.Strings.Maps; In_Source : Input_Sources.Strings.String_Input; Reader : DOM.Readers.Tree_Reader; Result : Dom.Core.Document; Eol_To_Space : constant Character_Mapping := To_Mapping (From => "" & Character'Val (10), To => " "); begin Input_Sources.Strings.Open (Str => Translate (Item, Eol_To_Space), Encoding => Unicode.CES.Utf8.Utf8_Encoding, Input => In_Source); SAX.Readers.Set_Feature (Parser => Sax_Reader (Reader), Name => SAX.Readers.Validation_Feature, Value => False); SAX.Readers.Set_Feature (Parser => Sax_Reader (Reader), Name => SAX.Readers.Namespace_Feature, Value => False); Sax.Readers.Parse (Parser => Sax_Reader (Reader), Input => In_Source); Result := DOM.Readers.Get_Tree (Reader); Remove_White_Space (Result); return Result; end Parse_String; function Expect_Attribute (N : DOM.Core.Node; Name : String) return String is use type DOM.Core.Node; Attr : constant DOM.Core.Node := DOM.Core.Elements.Get_Attribute_Node (N, Name); begin if Attr = null then raise No_Such_Attribute; else return DOM.Core.Nodes.Node_Value (Attr); end if; end Expect_Attribute; function Get_Attribute (N : DOM.Core.Node; Name : String; Default : String := "") return String is use type DOM.Core.Node; Attr : constant DOM.Core.Node := DOM.Core.Elements.Get_Attribute_Node (N, Name); begin if Attr = null then return Default; else return DOM.Core.Nodes.Node_Value (Attr); end if; end Get_Attribute; function Has_Attribute (N : DOM.Core.Node; Name : String) return Boolean is use DOM.Core; begin return Elements.Get_Attribute_Node (N, Name) /= null; end Has_Attribute; end XML_Utilities;
----------------------------------------------------------------------- -- security-openid-servlets - Servlets for OpenID 2.0 Authentication -- Copyright (C) 2010, 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Servlet.Sessions; with Util.Beans.Objects; with Util.Beans.Objects.Records; with Util.Log.Loggers; package body Servlet.Security.Servlets is -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.Servlets"); -- Make a package to store the Association in the session. package Association_Bean is new Util.Beans.Objects.Records (Auth.Association); subtype Association_Access is Association_Bean.Element_Type_Access; -- ------------------------------ -- Called by the servlet container to indicate to a servlet that the servlet -- is being placed into service. -- ------------------------------ procedure Initialize (Server : in out Openid_Servlet; Context : in Servlet.Core.Servlet_Registry'Class) is begin null; end Initialize; -- Name of the session attribute which holds information about the active authentication. OPENID_ASSOC_ATTRIBUTE : constant String := "openid-assoc"; procedure Initialize (Server : in Openid_Servlet; Provider : in String; Manager : in out Auth.Manager) is begin Manager.Initialize (Params => Server, Name => Provider); end Initialize; -- Get a configuration parameter from the servlet context for the security Auth provider. overriding function Get_Parameter (Server : in Openid_Servlet; Name : in String) return String is Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; begin return Ctx.Get_Init_Parameter (Name); end Get_Parameter; function Get_Provider_URL (Server : in Request_Auth_Servlet; Request : in Servlet.Requests.Request'Class) return String is pragma Unreferenced (Server); URI : constant String := Request.Get_Path_Info; begin if URI'Length = 0 then return ""; end if; Log.Info ("OpenID authentication with {0}", URI); return URI (URI'First + 1 .. URI'Last); end Get_Provider_URL; -- ------------------------------ -- Proceed to the OpenID authentication with an OpenID provider. -- Find the OpenID provider URL and starts the discovery, association phases -- during which a private key is obtained from the OpenID provider. -- After OpenID discovery and association, the user will be redirected to -- the OpenID provider. -- ------------------------------ procedure Do_Get (Server : in Request_Auth_Servlet; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class) is Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; Name : constant String := Server.Get_Provider_URL (Request); URL : constant String := Ctx.Get_Init_Parameter ("auth.url." & Name); begin Log.Info ("Request OpenId authentication to {0} - {1}", Name, URL); if Name'Length = 0 or URL'Length = 0 then Response.Set_Status (Servlet.Responses.SC_NOT_FOUND); return; end if; declare Mgr : Auth.Manager; OP : Auth.End_Point; Bean : constant Util.Beans.Objects.Object := Association_Bean.Create; Assoc : constant Association_Access := Association_Bean.To_Element_Access (Bean); begin Server.Initialize (Name, Mgr); -- Yadis discovery (get the XRDS file). This step does nothing for OAuth. Mgr.Discover (URL, OP); -- Associate to the OpenID provider and get an end-point with a key. Mgr.Associate (OP, Assoc.all); -- Save the association in the HTTP session and -- redirect the user to the OpenID provider. declare Auth_URL : constant String := Mgr.Get_Authentication_URL (OP, Assoc.all); Session : Servlet.Sessions.Session := Request.Get_Session (Create => True); begin Log.Info ("Redirect to auth URL: {0}", Auth_URL); Response.Send_Redirect (Location => Auth_URL); Session.Set_Attribute (Name => OPENID_ASSOC_ATTRIBUTE, Value => Bean); end; end; end Do_Get; -- ------------------------------ -- Verify the authentication result that was returned by the OpenID provider. -- If the authentication succeeded and the signature was correct, sets a -- user principals on the session. -- ------------------------------ procedure Do_Get (Server : in Verify_Auth_Servlet; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class) is use type Auth.Auth_Result; type Auth_Params is new Auth.Parameters with null record; overriding function Get_Parameter (Params : in Auth_Params; Name : in String) return String; overriding function Get_Parameter (Params : in Auth_Params; Name : in String) return String is pragma Unreferenced (Params); begin return Request.Get_Parameter (Name); end Get_Parameter; Session : Servlet.Sessions.Session := Request.Get_Session (Create => False); Bean : Util.Beans.Objects.Object; Mgr : Auth.Manager; Assoc : Association_Access; Credential : Auth.Authentication; Params : Auth_Params; Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; begin Log.Info ("Verify openid authentication"); if not Session.Is_Valid then Log.Warn ("Session has expired during OpenID authentication process"); Response.Set_Status (Servlet.Responses.SC_FORBIDDEN); return; end if; Bean := Session.Get_Attribute (OPENID_ASSOC_ATTRIBUTE); -- Cleanup the session and drop the association end point. Session.Remove_Attribute (OPENID_ASSOC_ATTRIBUTE); if Util.Beans.Objects.Is_Null (Bean) then Log.Warn ("Verify openid request without active session"); Response.Set_Status (Servlet.Responses.SC_FORBIDDEN); return; end if; Assoc := Association_Bean.To_Element_Access (Bean); Server.Initialize (Auth.Get_Provider (Assoc.all), Mgr); -- Verify that what we receive through the callback matches the association key. Mgr.Verify (Assoc.all, Params, Credential); if Auth.Get_Status (Credential) /= Auth.AUTHENTICATED then Log.Info ("Authentication has failed"); Response.Set_Status (Servlet.Responses.SC_FORBIDDEN); return; end if; Log.Info ("Authentication succeeded for {0}", Auth.Get_Email (Credential)); -- Get a user principal and set it on the session. declare User : Servlet.Principals.Principal_Access; URL : constant String := Ctx.Get_Init_Parameter ("openid.success_url"); begin Verify_Auth_Servlet'Class (Server).Create_Principal (Credential, User); Session.Set_Principal (User); Log.Info ("Redirect user to success URL: {0}", URL); Response.Send_Redirect (Location => URL); end; end Do_Get; -- ------------------------------ -- Create a principal object that correspond to the authenticated user identified -- by the <b>Credential</b> information. The principal will be attached to the session -- and will be destroyed when the session is closed. -- ------------------------------ procedure Create_Principal (Server : in Verify_Auth_Servlet; Credential : in Auth.Authentication; Result : out Servlet.Principals.Principal_Access) is pragma Unreferenced (Server); P : constant Auth.Principal_Access := Auth.Create_Principal (Credential); begin Result := P.all'Access; end Create_Principal; end Servlet.Security.Servlets;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with GBA.Memory; use GBA.Memory; with GBA.Memory.IO_Registers; package GBA.DMA is type Dest_Address_Adjustment is ( Increment , Decrement , Fixed , Increment_And_Reset ); for Dest_Address_Adjustment use ( Increment => 0 , Decrement => 1 , Fixed => 2 , Increment_And_Reset => 3 ); type Source_Address_Adjustment is ( Increment , Decrement , Fixed ); for Source_Address_Adjustment use ( Increment => 0 , Decrement => 1 , Fixed => 2 ); type Unit_Size is ( Half_Word -- 16 bits , Word -- 32 bits ); for Unit_Size use ( Half_Word => 0 , Word => 1 ); type Timing_Mode is ( Start_Immediately , Start_At_VBlank , Start_At_HBlank ); for Timing_Mode use ( Start_Immediately => 0 , Start_At_VBlank => 1 , Start_At_HBlank => 2 ); type Transfer_Count_Type is mod 2**15; type Transfer_Info is record Transfer_Count : Transfer_Count_Type; Dest_Adjustment : Dest_Address_Adjustment; Source_Adjustment : Source_Address_Adjustment; Repeat : Boolean; Copy_Unit_Size : Unit_Size; Timing : Timing_Mode; Enable_Interrupt : Boolean; Enabled : Boolean; end record with Size => 32; for Transfer_Info use record Transfer_Count at 0 range 16#00# .. 16#0F#; Dest_Adjustment at 0 range 16#15# .. 16#16#; Source_Adjustment at 0 range 16#17# .. 16#18#; Repeat at 0 range 16#19# .. 16#19#; Copy_Unit_Size at 0 range 16#1A# .. 16#1A#; Timing at 0 range 16#1C# .. 16#1D#; Enable_Interrupt at 0 range 16#1E# .. 16#1E#; Enabled at 0 range 16#1F# .. 16#1F#; end record; type Channel_Info is limited record Source : Address with Volatile; Dest : Address with Volatile; DMA_Info : Transfer_Info with Volatile; end record with Size => 96; for Channel_Info use record Source at 0 range 0 .. 31; Dest at 4 range 0 .. 31; DMA_Info at 8 range 0 .. 31; end record; type Channel_ID is range 0 .. 3; -- Basic access to structured DMA info -- use GBA.Memory.IO_Registers; Channel_Addresses : constant array (Channel_ID) of Address := ( 0 => DMA0SAD , 1 => DMA1SAD , 2 => DMA2SAD , 3 => DMA3SAD ); DMA_Channel_0 : Channel_Info with Import, Address => Channel_Addresses (0); DMA_Channel_1 : Channel_Info with Import, Address => Channel_Addresses (1); DMA_Channel_2 : Channel_Info with Import, Address => Channel_Addresses (2); DMA_Channel_3 : Channel_Info with Import, Address => Channel_Addresses (3); Channel_Array_View : array (Channel_ID) of Channel_Info with Import, Address => DMA0SAD; -- Most basic DMA interface routines -- procedure Setup_DMA_Transfer ( Channel : Channel_ID; Source, Dest : Address; Info : Transfer_Info ) with Inline_Always; function Is_Transfer_Ongoing ( Channel : Channel_ID ) return Boolean with Inline_Always; procedure Stop_Ongoing_Transfer ( Channel : Channel_ID ) with Inline_Always; end GBA.DMA;
with Ada.Streams.Stream_IO; with League.Text_Codecs; with League.Stream_Element_Vectors; with XML.SAX.Pretty_Writers; with XML.SAX.String_Output_Destinations; with Incr.Debug; package body Ada_LSP.Documents.Debug is ---------- -- Dump -- ---------- procedure Dump (Self : Document; Name : String; Data : P.Parser_Data_Provider'Class) is Output : Ada.Streams.Stream_IO.File_Type; Dest : aliased XML.SAX.String_Output_Destinations. String_Output_Destination; Writer : XML.SAX.Pretty_Writers.XML_Pretty_Writer; Image : League.Stream_Element_Vectors.Stream_Element_Vector; begin Writer.Set_Output_Destination (Dest'Unchecked_Access); Writer.Set_Offset (2); Incr.Debug.Dump (Self, Data, Writer); Image := League.Text_Codecs.Codec_For_Application_Locale.Encode (Dest.Get_Text); Ada.Streams.Stream_IO.Create (Output, Name => "/tmp/" & Name); Ada.Streams.Stream_IO.Write (Output, Image.To_Stream_Element_Array); Ada.Streams.Stream_IO.Close (Output); end Dump; end Ada_LSP.Documents.Debug;